radeon_drm.h 37 KB

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