radeon_drm.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. /* radeon_drm.h -- Public header for the radeon driver -*- linux-c -*-
  2. *
  3. * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
  4. * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
  5. * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
  6. * All rights reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice (including the next
  16. * paragraph) shall be included in all copies or substantial portions of the
  17. * Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  22. * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  23. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  24. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. * DEALINGS IN THE SOFTWARE.
  26. *
  27. * Authors:
  28. * Kevin E. Martin <martin@valinux.com>
  29. * Gareth Hughes <gareth@valinux.com>
  30. * Keith Whitwell <keith@tungstengraphics.com>
  31. */
  32. #ifndef __RADEON_DRM_H__
  33. #define __RADEON_DRM_H__
  34. #include "drm.h"
  35. #if defined(__cplusplus)
  36. extern "C" {
  37. #endif
  38. /* WARNING: If you change any of these defines, make sure to change the
  39. * defines in the X server file (radeon_sarea.h)
  40. */
  41. #ifndef __RADEON_SAREA_DEFINES__
  42. #define __RADEON_SAREA_DEFINES__
  43. /* Old style state flags, required for sarea interface (1.1 and 1.2
  44. * clears) and 1.2 drm_vertex2 ioctl.
  45. */
  46. #define RADEON_UPLOAD_CONTEXT 0x00000001
  47. #define RADEON_UPLOAD_VERTFMT 0x00000002
  48. #define RADEON_UPLOAD_LINE 0x00000004
  49. #define RADEON_UPLOAD_BUMPMAP 0x00000008
  50. #define RADEON_UPLOAD_MASKS 0x00000010
  51. #define RADEON_UPLOAD_VIEWPORT 0x00000020
  52. #define RADEON_UPLOAD_SETUP 0x00000040
  53. #define RADEON_UPLOAD_TCL 0x00000080
  54. #define RADEON_UPLOAD_MISC 0x00000100
  55. #define RADEON_UPLOAD_TEX0 0x00000200
  56. #define RADEON_UPLOAD_TEX1 0x00000400
  57. #define RADEON_UPLOAD_TEX2 0x00000800
  58. #define RADEON_UPLOAD_TEX0IMAGES 0x00001000
  59. #define RADEON_UPLOAD_TEX1IMAGES 0x00002000
  60. #define RADEON_UPLOAD_TEX2IMAGES 0x00004000
  61. #define RADEON_UPLOAD_CLIPRECTS 0x00008000 /* handled client-side */
  62. #define RADEON_REQUIRE_QUIESCENCE 0x00010000
  63. #define RADEON_UPLOAD_ZBIAS 0x00020000 /* version 1.2 and newer */
  64. #define RADEON_UPLOAD_ALL 0x003effff
  65. #define RADEON_UPLOAD_CONTEXT_ALL 0x003e01ff
  66. /* New style per-packet identifiers for use in cmd_buffer ioctl with
  67. * the RADEON_EMIT_PACKET command. Comments relate new packets to old
  68. * state bits and the packet size:
  69. */
  70. #define RADEON_EMIT_PP_MISC 0 /* context/7 */
  71. #define RADEON_EMIT_PP_CNTL 1 /* context/3 */
  72. #define RADEON_EMIT_RB3D_COLORPITCH 2 /* context/1 */
  73. #define RADEON_EMIT_RE_LINE_PATTERN 3 /* line/2 */
  74. #define RADEON_EMIT_SE_LINE_WIDTH 4 /* line/1 */
  75. #define RADEON_EMIT_PP_LUM_MATRIX 5 /* bumpmap/1 */
  76. #define RADEON_EMIT_PP_ROT_MATRIX_0 6 /* bumpmap/2 */
  77. #define RADEON_EMIT_RB3D_STENCILREFMASK 7 /* masks/3 */
  78. #define RADEON_EMIT_SE_VPORT_XSCALE 8 /* viewport/6 */
  79. #define RADEON_EMIT_SE_CNTL 9 /* setup/2 */
  80. #define RADEON_EMIT_SE_CNTL_STATUS 10 /* setup/1 */
  81. #define RADEON_EMIT_RE_MISC 11 /* misc/1 */
  82. #define RADEON_EMIT_PP_TXFILTER_0 12 /* tex0/6 */
  83. #define RADEON_EMIT_PP_BORDER_COLOR_0 13 /* tex0/1 */
  84. #define RADEON_EMIT_PP_TXFILTER_1 14 /* tex1/6 */
  85. #define RADEON_EMIT_PP_BORDER_COLOR_1 15 /* tex1/1 */
  86. #define RADEON_EMIT_PP_TXFILTER_2 16 /* tex2/6 */
  87. #define RADEON_EMIT_PP_BORDER_COLOR_2 17 /* tex2/1 */
  88. #define RADEON_EMIT_SE_ZBIAS_FACTOR 18 /* zbias/2 */
  89. #define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT 19 /* tcl/11 */
  90. #define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED 20 /* material/17 */
  91. #define R200_EMIT_PP_TXCBLEND_0 21 /* tex0/4 */
  92. #define R200_EMIT_PP_TXCBLEND_1 22 /* tex1/4 */
  93. #define R200_EMIT_PP_TXCBLEND_2 23 /* tex2/4 */
  94. #define R200_EMIT_PP_TXCBLEND_3 24 /* tex3/4 */
  95. #define R200_EMIT_PP_TXCBLEND_4 25 /* tex4/4 */
  96. #define R200_EMIT_PP_TXCBLEND_5 26 /* tex5/4 */
  97. #define R200_EMIT_PP_TXCBLEND_6 27 /* /4 */
  98. #define R200_EMIT_PP_TXCBLEND_7 28 /* /4 */
  99. #define R200_EMIT_TCL_LIGHT_MODEL_CTL_0 29 /* tcl/7 */
  100. #define R200_EMIT_TFACTOR_0 30 /* tf/7 */
  101. #define R200_EMIT_VTX_FMT_0 31 /* vtx/5 */
  102. #define R200_EMIT_VAP_CTL 32 /* vap/1 */
  103. #define R200_EMIT_MATRIX_SELECT_0 33 /* msl/5 */
  104. #define R200_EMIT_TEX_PROC_CTL_2 34 /* tcg/5 */
  105. #define R200_EMIT_TCL_UCP_VERT_BLEND_CTL 35 /* tcl/1 */
  106. #define R200_EMIT_PP_TXFILTER_0 36 /* tex0/6 */
  107. #define R200_EMIT_PP_TXFILTER_1 37 /* tex1/6 */
  108. #define R200_EMIT_PP_TXFILTER_2 38 /* tex2/6 */
  109. #define R200_EMIT_PP_TXFILTER_3 39 /* tex3/6 */
  110. #define R200_EMIT_PP_TXFILTER_4 40 /* tex4/6 */
  111. #define R200_EMIT_PP_TXFILTER_5 41 /* tex5/6 */
  112. #define R200_EMIT_PP_TXOFFSET_0 42 /* tex0/1 */
  113. #define R200_EMIT_PP_TXOFFSET_1 43 /* tex1/1 */
  114. #define R200_EMIT_PP_TXOFFSET_2 44 /* tex2/1 */
  115. #define R200_EMIT_PP_TXOFFSET_3 45 /* tex3/1 */
  116. #define R200_EMIT_PP_TXOFFSET_4 46 /* tex4/1 */
  117. #define R200_EMIT_PP_TXOFFSET_5 47 /* tex5/1 */
  118. #define R200_EMIT_VTE_CNTL 48 /* vte/1 */
  119. #define R200_EMIT_OUTPUT_VTX_COMP_SEL 49 /* vtx/1 */
  120. #define R200_EMIT_PP_TAM_DEBUG3 50 /* tam/1 */
  121. #define R200_EMIT_PP_CNTL_X 51 /* cst/1 */
  122. #define R200_EMIT_RB3D_DEPTHXY_OFFSET 52 /* cst/1 */
  123. #define R200_EMIT_RE_AUX_SCISSOR_CNTL 53 /* cst/1 */
  124. #define R200_EMIT_RE_SCISSOR_TL_0 54 /* cst/2 */
  125. #define R200_EMIT_RE_SCISSOR_TL_1 55 /* cst/2 */
  126. #define R200_EMIT_RE_SCISSOR_TL_2 56 /* cst/2 */
  127. #define R200_EMIT_SE_VAP_CNTL_STATUS 57 /* cst/1 */
  128. #define R200_EMIT_SE_VTX_STATE_CNTL 58 /* cst/1 */
  129. #define R200_EMIT_RE_POINTSIZE 59 /* cst/1 */
  130. #define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0 60 /* cst/4 */
  131. #define R200_EMIT_PP_CUBIC_FACES_0 61
  132. #define R200_EMIT_PP_CUBIC_OFFSETS_0 62
  133. #define R200_EMIT_PP_CUBIC_FACES_1 63
  134. #define R200_EMIT_PP_CUBIC_OFFSETS_1 64
  135. #define R200_EMIT_PP_CUBIC_FACES_2 65
  136. #define R200_EMIT_PP_CUBIC_OFFSETS_2 66
  137. #define R200_EMIT_PP_CUBIC_FACES_3 67
  138. #define R200_EMIT_PP_CUBIC_OFFSETS_3 68
  139. #define R200_EMIT_PP_CUBIC_FACES_4 69
  140. #define R200_EMIT_PP_CUBIC_OFFSETS_4 70
  141. #define R200_EMIT_PP_CUBIC_FACES_5 71
  142. #define R200_EMIT_PP_CUBIC_OFFSETS_5 72
  143. #define RADEON_EMIT_PP_TEX_SIZE_0 73
  144. #define RADEON_EMIT_PP_TEX_SIZE_1 74
  145. #define RADEON_EMIT_PP_TEX_SIZE_2 75
  146. #define R200_EMIT_RB3D_BLENDCOLOR 76
  147. #define R200_EMIT_TCL_POINT_SPRITE_CNTL 77
  148. #define RADEON_EMIT_PP_CUBIC_FACES_0 78
  149. #define RADEON_EMIT_PP_CUBIC_OFFSETS_T0 79
  150. #define RADEON_EMIT_PP_CUBIC_FACES_1 80
  151. #define RADEON_EMIT_PP_CUBIC_OFFSETS_T1 81
  152. #define RADEON_EMIT_PP_CUBIC_FACES_2 82
  153. #define RADEON_EMIT_PP_CUBIC_OFFSETS_T2 83
  154. #define R200_EMIT_PP_TRI_PERF_CNTL 84
  155. #define R200_EMIT_PP_AFS_0 85
  156. #define R200_EMIT_PP_AFS_1 86
  157. #define R200_EMIT_ATF_TFACTOR 87
  158. #define R200_EMIT_PP_TXCTLALL_0 88
  159. #define R200_EMIT_PP_TXCTLALL_1 89
  160. #define R200_EMIT_PP_TXCTLALL_2 90
  161. #define R200_EMIT_PP_TXCTLALL_3 91
  162. #define R200_EMIT_PP_TXCTLALL_4 92
  163. #define R200_EMIT_PP_TXCTLALL_5 93
  164. #define R200_EMIT_VAP_PVS_CNTL 94
  165. #define RADEON_MAX_STATE_PACKETS 95
  166. /* Commands understood by cmd_buffer ioctl. More can be added but
  167. * obviously these can't be removed or changed:
  168. */
  169. #define RADEON_CMD_PACKET 1 /* emit one of the register packets above */
  170. #define RADEON_CMD_SCALARS 2 /* emit scalar data */
  171. #define RADEON_CMD_VECTORS 3 /* emit vector data */
  172. #define RADEON_CMD_DMA_DISCARD 4 /* discard current dma buf */
  173. #define RADEON_CMD_PACKET3 5 /* emit hw packet */
  174. #define RADEON_CMD_PACKET3_CLIP 6 /* emit hw packet wrapped in cliprects */
  175. #define RADEON_CMD_SCALARS2 7 /* r200 stopgap */
  176. #define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note:
  177. * doesn't make the cpu wait, just
  178. * the graphics hardware */
  179. #define RADEON_CMD_VECLINEAR 9 /* another r200 stopgap */
  180. typedef union {
  181. int i;
  182. struct {
  183. unsigned char cmd_type, pad0, pad1, pad2;
  184. } header;
  185. struct {
  186. unsigned char cmd_type, packet_id, pad0, pad1;
  187. } packet;
  188. struct {
  189. unsigned char cmd_type, offset, stride, count;
  190. } scalars;
  191. struct {
  192. unsigned char cmd_type, offset, stride, count;
  193. } vectors;
  194. struct {
  195. unsigned char cmd_type, addr_lo, addr_hi, count;
  196. } veclinear;
  197. struct {
  198. unsigned char cmd_type, buf_idx, pad0, pad1;
  199. } dma;
  200. struct {
  201. unsigned char cmd_type, flags, pad0, pad1;
  202. } wait;
  203. } drm_radeon_cmd_header_t;
  204. #define RADEON_WAIT_2D 0x1
  205. #define RADEON_WAIT_3D 0x2
  206. /* Allowed parameters for R300_CMD_PACKET3
  207. */
  208. #define R300_CMD_PACKET3_CLEAR 0
  209. #define R300_CMD_PACKET3_RAW 1
  210. /* Commands understood by cmd_buffer ioctl for R300.
  211. * The interface has not been stabilized, so some of these may be removed
  212. * and eventually reordered before stabilization.
  213. */
  214. #define R300_CMD_PACKET0 1
  215. #define R300_CMD_VPU 2 /* emit vertex program upload */
  216. #define R300_CMD_PACKET3 3 /* emit a packet3 */
  217. #define R300_CMD_END3D 4 /* emit sequence ending 3d rendering */
  218. #define R300_CMD_CP_DELAY 5
  219. #define R300_CMD_DMA_DISCARD 6
  220. #define R300_CMD_WAIT 7
  221. # define R300_WAIT_2D 0x1
  222. # define R300_WAIT_3D 0x2
  223. /* these two defines are DOING IT WRONG - however
  224. * we have userspace which relies on using these.
  225. * The wait interface is backwards compat new
  226. * code should use the NEW_WAIT defines below
  227. * THESE ARE NOT BIT FIELDS
  228. */
  229. # define R300_WAIT_2D_CLEAN 0x3
  230. # define R300_WAIT_3D_CLEAN 0x4
  231. # define R300_NEW_WAIT_2D_3D 0x3
  232. # define R300_NEW_WAIT_2D_2D_CLEAN 0x4
  233. # define R300_NEW_WAIT_3D_3D_CLEAN 0x6
  234. # define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8
  235. #define R300_CMD_SCRATCH 8
  236. #define R300_CMD_R500FP 9
  237. typedef union {
  238. unsigned int u;
  239. struct {
  240. unsigned char cmd_type, pad0, pad1, pad2;
  241. } header;
  242. struct {
  243. unsigned char cmd_type, count, reglo, reghi;
  244. } packet0;
  245. struct {
  246. unsigned char cmd_type, count, adrlo, adrhi;
  247. } vpu;
  248. struct {
  249. unsigned char cmd_type, packet, pad0, pad1;
  250. } packet3;
  251. struct {
  252. unsigned char cmd_type, packet;
  253. unsigned short count; /* amount of packet2 to emit */
  254. } delay;
  255. struct {
  256. unsigned char cmd_type, buf_idx, pad0, pad1;
  257. } dma;
  258. struct {
  259. unsigned char cmd_type, flags, pad0, pad1;
  260. } wait;
  261. struct {
  262. unsigned char cmd_type, reg, n_bufs, flags;
  263. } scratch;
  264. struct {
  265. unsigned char cmd_type, count, adrlo, adrhi_flags;
  266. } r500fp;
  267. } drm_r300_cmd_header_t;
  268. #define RADEON_FRONT 0x1
  269. #define RADEON_BACK 0x2
  270. #define RADEON_DEPTH 0x4
  271. #define RADEON_STENCIL 0x8
  272. #define RADEON_CLEAR_FASTZ 0x80000000
  273. #define RADEON_USE_HIERZ 0x40000000
  274. #define RADEON_USE_COMP_ZBUF 0x20000000
  275. #define R500FP_CONSTANT_TYPE (1 << 1)
  276. #define R500FP_CONSTANT_CLAMP (1 << 2)
  277. /* Primitive types
  278. */
  279. #define RADEON_POINTS 0x1
  280. #define RADEON_LINES 0x2
  281. #define RADEON_LINE_STRIP 0x3
  282. #define RADEON_TRIANGLES 0x4
  283. #define RADEON_TRIANGLE_FAN 0x5
  284. #define RADEON_TRIANGLE_STRIP 0x6
  285. /* Vertex/indirect buffer size
  286. */
  287. #define RADEON_BUFFER_SIZE 65536
  288. /* Byte offsets for indirect buffer data
  289. */
  290. #define RADEON_INDEX_PRIM_OFFSET 20
  291. #define RADEON_SCRATCH_REG_OFFSET 32
  292. #define R600_SCRATCH_REG_OFFSET 256
  293. #define RADEON_NR_SAREA_CLIPRECTS 12
  294. /* There are 2 heaps (local/GART). Each region within a heap is a
  295. * minimum of 64k, and there are at most 64 of them per heap.
  296. */
  297. #define RADEON_LOCAL_TEX_HEAP 0
  298. #define RADEON_GART_TEX_HEAP 1
  299. #define RADEON_NR_TEX_HEAPS 2
  300. #define RADEON_NR_TEX_REGIONS 64
  301. #define RADEON_LOG_TEX_GRANULARITY 16
  302. #define RADEON_MAX_TEXTURE_LEVELS 12
  303. #define RADEON_MAX_TEXTURE_UNITS 3
  304. #define RADEON_MAX_SURFACES 8
  305. /* Blits have strict offset rules. All blit offset must be aligned on
  306. * a 1K-byte boundary.
  307. */
  308. #define RADEON_OFFSET_SHIFT 10
  309. #define RADEON_OFFSET_ALIGN (1 << RADEON_OFFSET_SHIFT)
  310. #define RADEON_OFFSET_MASK (RADEON_OFFSET_ALIGN - 1)
  311. #endif /* __RADEON_SAREA_DEFINES__ */
  312. typedef struct {
  313. unsigned int red;
  314. unsigned int green;
  315. unsigned int blue;
  316. unsigned int alpha;
  317. } radeon_color_regs_t;
  318. typedef struct {
  319. /* Context state */
  320. unsigned int pp_misc; /* 0x1c14 */
  321. unsigned int pp_fog_color;
  322. unsigned int re_solid_color;
  323. unsigned int rb3d_blendcntl;
  324. unsigned int rb3d_depthoffset;
  325. unsigned int rb3d_depthpitch;
  326. unsigned int rb3d_zstencilcntl;
  327. unsigned int pp_cntl; /* 0x1c38 */
  328. unsigned int rb3d_cntl;
  329. unsigned int rb3d_coloroffset;
  330. unsigned int re_width_height;
  331. unsigned int rb3d_colorpitch;
  332. unsigned int se_cntl;
  333. /* Vertex format state */
  334. unsigned int se_coord_fmt; /* 0x1c50 */
  335. /* Line state */
  336. unsigned int re_line_pattern; /* 0x1cd0 */
  337. unsigned int re_line_state;
  338. unsigned int se_line_width; /* 0x1db8 */
  339. /* Bumpmap state */
  340. unsigned int pp_lum_matrix; /* 0x1d00 */
  341. unsigned int pp_rot_matrix_0; /* 0x1d58 */
  342. unsigned int pp_rot_matrix_1;
  343. /* Mask state */
  344. unsigned int rb3d_stencilrefmask; /* 0x1d7c */
  345. unsigned int rb3d_ropcntl;
  346. unsigned int rb3d_planemask;
  347. /* Viewport state */
  348. unsigned int se_vport_xscale; /* 0x1d98 */
  349. unsigned int se_vport_xoffset;
  350. unsigned int se_vport_yscale;
  351. unsigned int se_vport_yoffset;
  352. unsigned int se_vport_zscale;
  353. unsigned int se_vport_zoffset;
  354. /* Setup state */
  355. unsigned int se_cntl_status; /* 0x2140 */
  356. /* Misc state */
  357. unsigned int re_top_left; /* 0x26c0 */
  358. unsigned int re_misc;
  359. } drm_radeon_context_regs_t;
  360. typedef struct {
  361. /* Zbias state */
  362. unsigned int se_zbias_factor; /* 0x1dac */
  363. unsigned int se_zbias_constant;
  364. } drm_radeon_context2_regs_t;
  365. /* Setup registers for each texture unit
  366. */
  367. typedef struct {
  368. unsigned int pp_txfilter;
  369. unsigned int pp_txformat;
  370. unsigned int pp_txoffset;
  371. unsigned int pp_txcblend;
  372. unsigned int pp_txablend;
  373. unsigned int pp_tfactor;
  374. unsigned int pp_border_color;
  375. } drm_radeon_texture_regs_t;
  376. typedef struct {
  377. unsigned int start;
  378. unsigned int finish;
  379. unsigned int prim:8;
  380. unsigned int stateidx:8;
  381. unsigned int numverts:16; /* overloaded as offset/64 for elt prims */
  382. unsigned int vc_format; /* vertex format */
  383. } drm_radeon_prim_t;
  384. typedef struct {
  385. drm_radeon_context_regs_t context;
  386. drm_radeon_texture_regs_t tex[RADEON_MAX_TEXTURE_UNITS];
  387. drm_radeon_context2_regs_t context2;
  388. unsigned int dirty;
  389. } drm_radeon_state_t;
  390. typedef struct {
  391. /* The channel for communication of state information to the
  392. * kernel on firing a vertex buffer with either of the
  393. * obsoleted vertex/index ioctls.
  394. */
  395. drm_radeon_context_regs_t context_state;
  396. drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS];
  397. unsigned int dirty;
  398. unsigned int vertsize;
  399. unsigned int vc_format;
  400. /* The current cliprects, or a subset thereof.
  401. */
  402. struct drm_clip_rect boxes[RADEON_NR_SAREA_CLIPRECTS];
  403. unsigned int nbox;
  404. /* Counters for client-side throttling of rendering clients.
  405. */
  406. unsigned int last_frame;
  407. unsigned int last_dispatch;
  408. unsigned int last_clear;
  409. struct drm_tex_region tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS +
  410. 1];
  411. unsigned int tex_age[RADEON_NR_TEX_HEAPS];
  412. int ctx_owner;
  413. int pfState; /* number of 3d windows (0,1,2ormore) */
  414. int pfCurrentPage; /* which buffer is being displayed? */
  415. int crtc2_base; /* CRTC2 frame offset */
  416. int tiling_enabled; /* set by drm, read by 2d + 3d clients */
  417. } drm_radeon_sarea_t;
  418. /* WARNING: If you change any of these defines, make sure to change the
  419. * defines in the Xserver file (xf86drmRadeon.h)
  420. *
  421. * KW: actually it's illegal to change any of this (backwards compatibility).
  422. */
  423. /* Radeon specific ioctls
  424. * The device specific ioctl range is 0x40 to 0x79.
  425. */
  426. #define DRM_RADEON_CP_INIT 0x00
  427. #define DRM_RADEON_CP_START 0x01
  428. #define DRM_RADEON_CP_STOP 0x02
  429. #define DRM_RADEON_CP_RESET 0x03
  430. #define DRM_RADEON_CP_IDLE 0x04
  431. #define DRM_RADEON_RESET 0x05
  432. #define DRM_RADEON_FULLSCREEN 0x06
  433. #define DRM_RADEON_SWAP 0x07
  434. #define DRM_RADEON_CLEAR 0x08
  435. #define DRM_RADEON_VERTEX 0x09
  436. #define DRM_RADEON_INDICES 0x0A
  437. #define DRM_RADEON_NOT_USED
  438. #define DRM_RADEON_STIPPLE 0x0C
  439. #define DRM_RADEON_INDIRECT 0x0D
  440. #define DRM_RADEON_TEXTURE 0x0E
  441. #define DRM_RADEON_VERTEX2 0x0F
  442. #define DRM_RADEON_CMDBUF 0x10
  443. #define DRM_RADEON_GETPARAM 0x11
  444. #define DRM_RADEON_FLIP 0x12
  445. #define DRM_RADEON_ALLOC 0x13
  446. #define DRM_RADEON_FREE 0x14
  447. #define DRM_RADEON_INIT_HEAP 0x15
  448. #define DRM_RADEON_IRQ_EMIT 0x16
  449. #define DRM_RADEON_IRQ_WAIT 0x17
  450. #define DRM_RADEON_CP_RESUME 0x18
  451. #define DRM_RADEON_SETPARAM 0x19
  452. #define DRM_RADEON_SURF_ALLOC 0x1a
  453. #define DRM_RADEON_SURF_FREE 0x1b
  454. /* KMS ioctl */
  455. #define DRM_RADEON_GEM_INFO 0x1c
  456. #define DRM_RADEON_GEM_CREATE 0x1d
  457. #define DRM_RADEON_GEM_MMAP 0x1e
  458. #define DRM_RADEON_GEM_PREAD 0x21
  459. #define DRM_RADEON_GEM_PWRITE 0x22
  460. #define DRM_RADEON_GEM_SET_DOMAIN 0x23
  461. #define DRM_RADEON_GEM_WAIT_IDLE 0x24
  462. #define DRM_RADEON_CS 0x26
  463. #define DRM_RADEON_INFO 0x27
  464. #define DRM_RADEON_GEM_SET_TILING 0x28
  465. #define DRM_RADEON_GEM_GET_TILING 0x29
  466. #define DRM_RADEON_GEM_BUSY 0x2a
  467. #define DRM_RADEON_GEM_VA 0x2b
  468. #define DRM_RADEON_GEM_OP 0x2c
  469. #define DRM_RADEON_GEM_USERPTR 0x2d
  470. #define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
  471. #define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START)
  472. #define DRM_IOCTL_RADEON_CP_STOP DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_STOP, drm_radeon_cp_stop_t)
  473. #define DRM_IOCTL_RADEON_CP_RESET DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_RESET)
  474. #define DRM_IOCTL_RADEON_CP_IDLE DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_IDLE)
  475. #define DRM_IOCTL_RADEON_RESET DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_RESET)
  476. #define DRM_IOCTL_RADEON_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_FULLSCREEN, drm_radeon_fullscreen_t)
  477. #define DRM_IOCTL_RADEON_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_SWAP)
  478. #define DRM_IOCTL_RADEON_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CLEAR, drm_radeon_clear_t)
  479. #define DRM_IOCTL_RADEON_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_VERTEX, drm_radeon_vertex_t)
  480. #define DRM_IOCTL_RADEON_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_INDICES, drm_radeon_indices_t)
  481. #define DRM_IOCTL_RADEON_STIPPLE DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_STIPPLE, drm_radeon_stipple_t)
  482. #define DRM_IOCTL_RADEON_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INDIRECT, drm_radeon_indirect_t)
  483. #define DRM_IOCTL_RADEON_TEXTURE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_TEXTURE, drm_radeon_texture_t)
  484. #define DRM_IOCTL_RADEON_VERTEX2 DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_VERTEX2, drm_radeon_vertex2_t)
  485. #define DRM_IOCTL_RADEON_CMDBUF DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CMDBUF, drm_radeon_cmd_buffer_t)
  486. #define DRM_IOCTL_RADEON_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GETPARAM, drm_radeon_getparam_t)
  487. #define DRM_IOCTL_RADEON_FLIP DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_FLIP)
  488. #define DRM_IOCTL_RADEON_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_ALLOC, drm_radeon_mem_alloc_t)
  489. #define DRM_IOCTL_RADEON_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_FREE, drm_radeon_mem_free_t)
  490. #define DRM_IOCTL_RADEON_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_INIT_HEAP, drm_radeon_mem_init_heap_t)
  491. #define DRM_IOCTL_RADEON_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_IRQ_EMIT, drm_radeon_irq_emit_t)
  492. #define DRM_IOCTL_RADEON_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_IRQ_WAIT, drm_radeon_irq_wait_t)
  493. #define DRM_IOCTL_RADEON_CP_RESUME DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_RESUME)
  494. #define DRM_IOCTL_RADEON_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SETPARAM, drm_radeon_setparam_t)
  495. #define DRM_IOCTL_RADEON_SURF_ALLOC DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_ALLOC, drm_radeon_surface_alloc_t)
  496. #define DRM_IOCTL_RADEON_SURF_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_FREE, drm_radeon_surface_free_t)
  497. /* KMS */
  498. #define DRM_IOCTL_RADEON_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_INFO, struct drm_radeon_gem_info)
  499. #define DRM_IOCTL_RADEON_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_CREATE, struct drm_radeon_gem_create)
  500. #define DRM_IOCTL_RADEON_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_MMAP, struct drm_radeon_gem_mmap)
  501. #define DRM_IOCTL_RADEON_GEM_PREAD DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PREAD, struct drm_radeon_gem_pread)
  502. #define DRM_IOCTL_RADEON_GEM_PWRITE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PWRITE, struct drm_radeon_gem_pwrite)
  503. #define DRM_IOCTL_RADEON_GEM_SET_DOMAIN DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_DOMAIN, struct drm_radeon_gem_set_domain)
  504. #define DRM_IOCTL_RADEON_GEM_WAIT_IDLE DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_GEM_WAIT_IDLE, struct drm_radeon_gem_wait_idle)
  505. #define DRM_IOCTL_RADEON_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_CS, struct drm_radeon_cs)
  506. #define DRM_IOCTL_RADEON_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INFO, struct drm_radeon_info)
  507. #define DRM_IOCTL_RADEON_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling)
  508. #define DRM_IOCTL_RADEON_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling)
  509. #define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy)
  510. #define DRM_IOCTL_RADEON_GEM_VA DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_VA, struct drm_radeon_gem_va)
  511. #define DRM_IOCTL_RADEON_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_OP, struct drm_radeon_gem_op)
  512. #define DRM_IOCTL_RADEON_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_USERPTR, struct drm_radeon_gem_userptr)
  513. typedef struct drm_radeon_init {
  514. enum {
  515. RADEON_INIT_CP = 0x01,
  516. RADEON_CLEANUP_CP = 0x02,
  517. RADEON_INIT_R200_CP = 0x03,
  518. RADEON_INIT_R300_CP = 0x04,
  519. RADEON_INIT_R600_CP = 0x05
  520. } func;
  521. unsigned long sarea_priv_offset;
  522. int is_pci;
  523. int cp_mode;
  524. int gart_size;
  525. int ring_size;
  526. int usec_timeout;
  527. unsigned int fb_bpp;
  528. unsigned int front_offset, front_pitch;
  529. unsigned int back_offset, back_pitch;
  530. unsigned int depth_bpp;
  531. unsigned int depth_offset, depth_pitch;
  532. unsigned long fb_offset;
  533. unsigned long mmio_offset;
  534. unsigned long ring_offset;
  535. unsigned long ring_rptr_offset;
  536. unsigned long buffers_offset;
  537. unsigned long gart_textures_offset;
  538. } drm_radeon_init_t;
  539. typedef struct drm_radeon_cp_stop {
  540. int flush;
  541. int idle;
  542. } drm_radeon_cp_stop_t;
  543. typedef struct drm_radeon_fullscreen {
  544. enum {
  545. RADEON_INIT_FULLSCREEN = 0x01,
  546. RADEON_CLEANUP_FULLSCREEN = 0x02
  547. } func;
  548. } drm_radeon_fullscreen_t;
  549. #define CLEAR_X1 0
  550. #define CLEAR_Y1 1
  551. #define CLEAR_X2 2
  552. #define CLEAR_Y2 3
  553. #define CLEAR_DEPTH 4
  554. typedef union drm_radeon_clear_rect {
  555. float f[5];
  556. unsigned int ui[5];
  557. } drm_radeon_clear_rect_t;
  558. typedef struct drm_radeon_clear {
  559. unsigned int flags;
  560. unsigned int clear_color;
  561. unsigned int clear_depth;
  562. unsigned int color_mask;
  563. unsigned int depth_mask; /* misnamed field: should be stencil */
  564. drm_radeon_clear_rect_t *depth_boxes;
  565. } drm_radeon_clear_t;
  566. typedef struct drm_radeon_vertex {
  567. int prim;
  568. int idx; /* Index of vertex buffer */
  569. int count; /* Number of vertices in buffer */
  570. int discard; /* Client finished with buffer? */
  571. } drm_radeon_vertex_t;
  572. typedef struct drm_radeon_indices {
  573. int prim;
  574. int idx;
  575. int start;
  576. int end;
  577. int discard; /* Client finished with buffer? */
  578. } drm_radeon_indices_t;
  579. /* v1.2 - obsoletes drm_radeon_vertex and drm_radeon_indices
  580. * - allows multiple primitives and state changes in a single ioctl
  581. * - supports driver change to emit native primitives
  582. */
  583. typedef struct drm_radeon_vertex2 {
  584. int idx; /* Index of vertex buffer */
  585. int discard; /* Client finished with buffer? */
  586. int nr_states;
  587. drm_radeon_state_t *state;
  588. int nr_prims;
  589. drm_radeon_prim_t *prim;
  590. } drm_radeon_vertex2_t;
  591. /* v1.3 - obsoletes drm_radeon_vertex2
  592. * - allows arbitrarily large cliprect list
  593. * - allows updating of tcl packet, vector and scalar state
  594. * - allows memory-efficient description of state updates
  595. * - allows state to be emitted without a primitive
  596. * (for clears, ctx switches)
  597. * - allows more than one dma buffer to be referenced per ioctl
  598. * - supports tcl driver
  599. * - may be extended in future versions with new cmd types, packets
  600. */
  601. typedef struct drm_radeon_cmd_buffer {
  602. int bufsz;
  603. char *buf;
  604. int nbox;
  605. struct drm_clip_rect *boxes;
  606. } drm_radeon_cmd_buffer_t;
  607. typedef struct drm_radeon_tex_image {
  608. unsigned int x, y; /* Blit coordinates */
  609. unsigned int width, height;
  610. const void *data;
  611. } drm_radeon_tex_image_t;
  612. typedef struct drm_radeon_texture {
  613. unsigned int offset;
  614. int pitch;
  615. int format;
  616. int width; /* Texture image coordinates */
  617. int height;
  618. drm_radeon_tex_image_t *image;
  619. } drm_radeon_texture_t;
  620. typedef struct drm_radeon_stipple {
  621. unsigned int *mask;
  622. } drm_radeon_stipple_t;
  623. typedef struct drm_radeon_indirect {
  624. int idx;
  625. int start;
  626. int end;
  627. int discard;
  628. } drm_radeon_indirect_t;
  629. /* enum for card type parameters */
  630. #define RADEON_CARD_PCI 0
  631. #define RADEON_CARD_AGP 1
  632. #define RADEON_CARD_PCIE 2
  633. /* 1.3: An ioctl to get parameters that aren't available to the 3d
  634. * client any other way.
  635. */
  636. #define RADEON_PARAM_GART_BUFFER_OFFSET 1 /* card offset of 1st GART buffer */
  637. #define RADEON_PARAM_LAST_FRAME 2
  638. #define RADEON_PARAM_LAST_DISPATCH 3
  639. #define RADEON_PARAM_LAST_CLEAR 4
  640. /* Added with DRM version 1.6. */
  641. #define RADEON_PARAM_IRQ_NR 5
  642. #define RADEON_PARAM_GART_BASE 6 /* card offset of GART base */
  643. /* Added with DRM version 1.8. */
  644. #define RADEON_PARAM_REGISTER_HANDLE 7 /* for drmMap() */
  645. #define RADEON_PARAM_STATUS_HANDLE 8
  646. #define RADEON_PARAM_SAREA_HANDLE 9
  647. #define RADEON_PARAM_GART_TEX_HANDLE 10
  648. #define RADEON_PARAM_SCRATCH_OFFSET 11
  649. #define RADEON_PARAM_CARD_TYPE 12
  650. #define RADEON_PARAM_VBLANK_CRTC 13 /* VBLANK CRTC */
  651. #define RADEON_PARAM_FB_LOCATION 14 /* FB location */
  652. #define RADEON_PARAM_NUM_GB_PIPES 15 /* num GB pipes */
  653. #define RADEON_PARAM_DEVICE_ID 16
  654. #define RADEON_PARAM_NUM_Z_PIPES 17 /* num Z pipes */
  655. typedef struct drm_radeon_getparam {
  656. int param;
  657. void *value;
  658. } drm_radeon_getparam_t;
  659. /* 1.6: Set up a memory manager for regions of shared memory:
  660. */
  661. #define RADEON_MEM_REGION_GART 1
  662. #define RADEON_MEM_REGION_FB 2
  663. typedef struct drm_radeon_mem_alloc {
  664. int region;
  665. int alignment;
  666. int size;
  667. int *region_offset; /* offset from start of fb or GART */
  668. } drm_radeon_mem_alloc_t;
  669. typedef struct drm_radeon_mem_free {
  670. int region;
  671. int region_offset;
  672. } drm_radeon_mem_free_t;
  673. typedef struct drm_radeon_mem_init_heap {
  674. int region;
  675. int size;
  676. int start;
  677. } drm_radeon_mem_init_heap_t;
  678. /* 1.6: Userspace can request & wait on irq's:
  679. */
  680. typedef struct drm_radeon_irq_emit {
  681. int *irq_seq;
  682. } drm_radeon_irq_emit_t;
  683. typedef struct drm_radeon_irq_wait {
  684. int irq_seq;
  685. } drm_radeon_irq_wait_t;
  686. /* 1.10: Clients tell the DRM where they think the framebuffer is located in
  687. * the card's address space, via a new generic ioctl to set parameters
  688. */
  689. typedef struct drm_radeon_setparam {
  690. unsigned int param;
  691. __s64 value;
  692. } drm_radeon_setparam_t;
  693. #define RADEON_SETPARAM_FB_LOCATION 1 /* determined framebuffer location */
  694. #define RADEON_SETPARAM_SWITCH_TILING 2 /* enable/disable color tiling */
  695. #define RADEON_SETPARAM_PCIGART_LOCATION 3 /* PCI Gart Location */
  696. #define RADEON_SETPARAM_NEW_MEMMAP 4 /* Use new memory map */
  697. #define RADEON_SETPARAM_PCIGART_TABLE_SIZE 5 /* PCI GART Table Size */
  698. #define RADEON_SETPARAM_VBLANK_CRTC 6 /* VBLANK CRTC */
  699. /* 1.14: Clients can allocate/free a surface
  700. */
  701. typedef struct drm_radeon_surface_alloc {
  702. unsigned int address;
  703. unsigned int size;
  704. unsigned int flags;
  705. } drm_radeon_surface_alloc_t;
  706. typedef struct drm_radeon_surface_free {
  707. unsigned int address;
  708. } drm_radeon_surface_free_t;
  709. #define DRM_RADEON_VBLANK_CRTC1 1
  710. #define DRM_RADEON_VBLANK_CRTC2 2
  711. /*
  712. * Kernel modesetting world below.
  713. */
  714. #define RADEON_GEM_DOMAIN_CPU 0x1
  715. #define RADEON_GEM_DOMAIN_GTT 0x2
  716. #define RADEON_GEM_DOMAIN_VRAM 0x4
  717. struct drm_radeon_gem_info {
  718. __u64 gart_size;
  719. __u64 vram_size;
  720. __u64 vram_visible;
  721. };
  722. #define RADEON_GEM_NO_BACKING_STORE (1 << 0)
  723. #define RADEON_GEM_GTT_UC (1 << 1)
  724. #define RADEON_GEM_GTT_WC (1 << 2)
  725. /* BO is expected to be accessed by the CPU */
  726. #define RADEON_GEM_CPU_ACCESS (1 << 3)
  727. /* CPU access is not expected to work for this BO */
  728. #define RADEON_GEM_NO_CPU_ACCESS (1 << 4)
  729. struct drm_radeon_gem_create {
  730. __u64 size;
  731. __u64 alignment;
  732. __u32 handle;
  733. __u32 initial_domain;
  734. __u32 flags;
  735. };
  736. /*
  737. * This is not a reliable API and you should expect it to fail for any
  738. * number of reasons and have fallback path that do not use userptr to
  739. * perform any operation.
  740. */
  741. #define RADEON_GEM_USERPTR_READONLY (1 << 0)
  742. #define RADEON_GEM_USERPTR_ANONONLY (1 << 1)
  743. #define RADEON_GEM_USERPTR_VALIDATE (1 << 2)
  744. #define RADEON_GEM_USERPTR_REGISTER (1 << 3)
  745. struct drm_radeon_gem_userptr {
  746. __u64 addr;
  747. __u64 size;
  748. __u32 flags;
  749. __u32 handle;
  750. };
  751. #define RADEON_TILING_MACRO 0x1
  752. #define RADEON_TILING_MICRO 0x2
  753. #define RADEON_TILING_SWAP_16BIT 0x4
  754. #define RADEON_TILING_SWAP_32BIT 0x8
  755. /* this object requires a surface when mapped - i.e. front buffer */
  756. #define RADEON_TILING_SURFACE 0x10
  757. #define RADEON_TILING_MICRO_SQUARE 0x20
  758. #define RADEON_TILING_EG_BANKW_SHIFT 8
  759. #define RADEON_TILING_EG_BANKW_MASK 0xf
  760. #define RADEON_TILING_EG_BANKH_SHIFT 12
  761. #define RADEON_TILING_EG_BANKH_MASK 0xf
  762. #define RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT 16
  763. #define RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK 0xf
  764. #define RADEON_TILING_EG_TILE_SPLIT_SHIFT 24
  765. #define RADEON_TILING_EG_TILE_SPLIT_MASK 0xf
  766. #define RADEON_TILING_EG_STENCIL_TILE_SPLIT_SHIFT 28
  767. #define RADEON_TILING_EG_STENCIL_TILE_SPLIT_MASK 0xf
  768. struct drm_radeon_gem_set_tiling {
  769. __u32 handle;
  770. __u32 tiling_flags;
  771. __u32 pitch;
  772. };
  773. struct drm_radeon_gem_get_tiling {
  774. __u32 handle;
  775. __u32 tiling_flags;
  776. __u32 pitch;
  777. };
  778. struct drm_radeon_gem_mmap {
  779. __u32 handle;
  780. __u32 pad;
  781. __u64 offset;
  782. __u64 size;
  783. __u64 addr_ptr;
  784. };
  785. struct drm_radeon_gem_set_domain {
  786. __u32 handle;
  787. __u32 read_domains;
  788. __u32 write_domain;
  789. };
  790. struct drm_radeon_gem_wait_idle {
  791. __u32 handle;
  792. __u32 pad;
  793. };
  794. struct drm_radeon_gem_busy {
  795. __u32 handle;
  796. __u32 domain;
  797. };
  798. struct drm_radeon_gem_pread {
  799. /** Handle for the object being read. */
  800. __u32 handle;
  801. __u32 pad;
  802. /** Offset into the object to read from */
  803. __u64 offset;
  804. /** Length of data to read */
  805. __u64 size;
  806. /** Pointer to write the data into. */
  807. /* void *, but pointers are not 32/64 compatible */
  808. __u64 data_ptr;
  809. };
  810. struct drm_radeon_gem_pwrite {
  811. /** Handle for the object being written to. */
  812. __u32 handle;
  813. __u32 pad;
  814. /** Offset into the object to write to */
  815. __u64 offset;
  816. /** Length of data to write */
  817. __u64 size;
  818. /** Pointer to read the data from. */
  819. /* void *, but pointers are not 32/64 compatible */
  820. __u64 data_ptr;
  821. };
  822. /* Sets or returns a value associated with a buffer. */
  823. struct drm_radeon_gem_op {
  824. __u32 handle; /* buffer */
  825. __u32 op; /* RADEON_GEM_OP_* */
  826. __u64 value; /* input or return value */
  827. };
  828. #define RADEON_GEM_OP_GET_INITIAL_DOMAIN 0
  829. #define RADEON_GEM_OP_SET_INITIAL_DOMAIN 1
  830. #define RADEON_VA_MAP 1
  831. #define RADEON_VA_UNMAP 2
  832. #define RADEON_VA_RESULT_OK 0
  833. #define RADEON_VA_RESULT_ERROR 1
  834. #define RADEON_VA_RESULT_VA_EXIST 2
  835. #define RADEON_VM_PAGE_VALID (1 << 0)
  836. #define RADEON_VM_PAGE_READABLE (1 << 1)
  837. #define RADEON_VM_PAGE_WRITEABLE (1 << 2)
  838. #define RADEON_VM_PAGE_SYSTEM (1 << 3)
  839. #define RADEON_VM_PAGE_SNOOPED (1 << 4)
  840. struct drm_radeon_gem_va {
  841. __u32 handle;
  842. __u32 operation;
  843. __u32 vm_id;
  844. __u32 flags;
  845. __u64 offset;
  846. };
  847. #define RADEON_CHUNK_ID_RELOCS 0x01
  848. #define RADEON_CHUNK_ID_IB 0x02
  849. #define RADEON_CHUNK_ID_FLAGS 0x03
  850. #define RADEON_CHUNK_ID_CONST_IB 0x04
  851. /* The first dword of RADEON_CHUNK_ID_FLAGS is a uint32 of these flags: */
  852. #define RADEON_CS_KEEP_TILING_FLAGS 0x01
  853. #define RADEON_CS_USE_VM 0x02
  854. #define RADEON_CS_END_OF_FRAME 0x04 /* a hint from userspace which CS is the last one */
  855. /* The second dword of RADEON_CHUNK_ID_FLAGS is a uint32 that sets the ring type */
  856. #define RADEON_CS_RING_GFX 0
  857. #define RADEON_CS_RING_COMPUTE 1
  858. #define RADEON_CS_RING_DMA 2
  859. #define RADEON_CS_RING_UVD 3
  860. #define RADEON_CS_RING_VCE 4
  861. /* The third dword of RADEON_CHUNK_ID_FLAGS is a sint32 that sets the priority */
  862. /* 0 = normal, + = higher priority, - = lower priority */
  863. struct drm_radeon_cs_chunk {
  864. __u32 chunk_id;
  865. __u32 length_dw;
  866. __u64 chunk_data;
  867. };
  868. /* drm_radeon_cs_reloc.flags */
  869. #define RADEON_RELOC_PRIO_MASK (0xf << 0)
  870. struct drm_radeon_cs_reloc {
  871. __u32 handle;
  872. __u32 read_domains;
  873. __u32 write_domain;
  874. __u32 flags;
  875. };
  876. struct drm_radeon_cs {
  877. __u32 num_chunks;
  878. __u32 cs_id;
  879. /* this points to __u64 * which point to cs chunks */
  880. __u64 chunks;
  881. /* updates to the limits after this CS ioctl */
  882. __u64 gart_limit;
  883. __u64 vram_limit;
  884. };
  885. #define RADEON_INFO_DEVICE_ID 0x00
  886. #define RADEON_INFO_NUM_GB_PIPES 0x01
  887. #define RADEON_INFO_NUM_Z_PIPES 0x02
  888. #define RADEON_INFO_ACCEL_WORKING 0x03
  889. #define RADEON_INFO_CRTC_FROM_ID 0x04
  890. #define RADEON_INFO_ACCEL_WORKING2 0x05
  891. #define RADEON_INFO_TILING_CONFIG 0x06
  892. #define RADEON_INFO_WANT_HYPERZ 0x07
  893. #define RADEON_INFO_WANT_CMASK 0x08 /* get access to CMASK on r300 */
  894. #define RADEON_INFO_CLOCK_CRYSTAL_FREQ 0x09 /* clock crystal frequency */
  895. #define RADEON_INFO_NUM_BACKENDS 0x0a /* DB/backends for r600+ - need for OQ */
  896. #define RADEON_INFO_NUM_TILE_PIPES 0x0b /* tile pipes for r600+ */
  897. #define RADEON_INFO_FUSION_GART_WORKING 0x0c /* fusion writes to GTT were broken before this */
  898. #define RADEON_INFO_BACKEND_MAP 0x0d /* pipe to backend map, needed by mesa */
  899. /* virtual address start, va < start are reserved by the kernel */
  900. #define RADEON_INFO_VA_START 0x0e
  901. /* maximum size of ib using the virtual memory cs */
  902. #define RADEON_INFO_IB_VM_MAX_SIZE 0x0f
  903. /* max pipes - needed for compute shaders */
  904. #define RADEON_INFO_MAX_PIPES 0x10
  905. /* timestamp for GL_ARB_timer_query (OpenGL), returns the current GPU clock */
  906. #define RADEON_INFO_TIMESTAMP 0x11
  907. /* max shader engines (SE) - needed for geometry shaders, etc. */
  908. #define RADEON_INFO_MAX_SE 0x12
  909. /* max SH per SE */
  910. #define RADEON_INFO_MAX_SH_PER_SE 0x13
  911. /* fast fb access is enabled */
  912. #define RADEON_INFO_FASTFB_WORKING 0x14
  913. /* query if a RADEON_CS_RING_* submission is supported */
  914. #define RADEON_INFO_RING_WORKING 0x15
  915. /* SI tile mode array */
  916. #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16
  917. /* query if CP DMA is supported on the compute ring */
  918. #define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17
  919. /* CIK macrotile mode array */
  920. #define RADEON_INFO_CIK_MACROTILE_MODE_ARRAY 0x18
  921. /* query the number of render backends */
  922. #define RADEON_INFO_SI_BACKEND_ENABLED_MASK 0x19
  923. /* max engine clock - needed for OpenCL */
  924. #define RADEON_INFO_MAX_SCLK 0x1a
  925. /* version of VCE firmware */
  926. #define RADEON_INFO_VCE_FW_VERSION 0x1b
  927. /* version of VCE feedback */
  928. #define RADEON_INFO_VCE_FB_VERSION 0x1c
  929. #define RADEON_INFO_NUM_BYTES_MOVED 0x1d
  930. #define RADEON_INFO_VRAM_USAGE 0x1e
  931. #define RADEON_INFO_GTT_USAGE 0x1f
  932. #define RADEON_INFO_ACTIVE_CU_COUNT 0x20
  933. #define RADEON_INFO_CURRENT_GPU_TEMP 0x21
  934. #define RADEON_INFO_CURRENT_GPU_SCLK 0x22
  935. #define RADEON_INFO_CURRENT_GPU_MCLK 0x23
  936. #define RADEON_INFO_READ_REG 0x24
  937. #define RADEON_INFO_VA_UNMAP_WORKING 0x25
  938. #define RADEON_INFO_GPU_RESET_COUNTER 0x26
  939. struct drm_radeon_info {
  940. __u32 request;
  941. __u32 pad;
  942. __u64 value;
  943. };
  944. /* Those correspond to the tile index to use, this is to explicitly state
  945. * the API that is implicitly defined by the tile mode array.
  946. */
  947. #define SI_TILE_MODE_COLOR_LINEAR_ALIGNED 8
  948. #define SI_TILE_MODE_COLOR_1D 13
  949. #define SI_TILE_MODE_COLOR_1D_SCANOUT 9
  950. #define SI_TILE_MODE_COLOR_2D_8BPP 14
  951. #define SI_TILE_MODE_COLOR_2D_16BPP 15
  952. #define SI_TILE_MODE_COLOR_2D_32BPP 16
  953. #define SI_TILE_MODE_COLOR_2D_64BPP 17
  954. #define SI_TILE_MODE_COLOR_2D_SCANOUT_16BPP 11
  955. #define SI_TILE_MODE_COLOR_2D_SCANOUT_32BPP 12
  956. #define SI_TILE_MODE_DEPTH_STENCIL_1D 4
  957. #define SI_TILE_MODE_DEPTH_STENCIL_2D 0
  958. #define SI_TILE_MODE_DEPTH_STENCIL_2D_2AA 3
  959. #define SI_TILE_MODE_DEPTH_STENCIL_2D_4AA 3
  960. #define SI_TILE_MODE_DEPTH_STENCIL_2D_8AA 2
  961. #define CIK_TILE_MODE_DEPTH_STENCIL_1D 5
  962. #if defined(__cplusplus)
  963. }
  964. #endif
  965. #endif