i830_drm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. #ifndef _I830_DRM_H_
  2. #define _I830_DRM_H_
  3. /* WARNING: These defines must be the same as what the Xserver uses.
  4. * if you change them, you must change the defines in the Xserver.
  5. *
  6. * KW: Actually, you can't ever change them because doing so would
  7. * break backwards compatibility.
  8. */
  9. #ifndef _I830_DEFINES_
  10. #define _I830_DEFINES_
  11. #define I830_DMA_BUF_ORDER 12
  12. #define I830_DMA_BUF_SZ (1<<I830_DMA_BUF_ORDER)
  13. #define I830_DMA_BUF_NR 256
  14. #define I830_NR_SAREA_CLIPRECTS 8
  15. /* Each region is a minimum of 64k, and there are at most 64 of them.
  16. */
  17. #define I830_NR_TEX_REGIONS 64
  18. #define I830_LOG_MIN_TEX_REGION_SIZE 16
  19. /* KW: These aren't correct but someone set them to two and then
  20. * released the module. Now we can't change them as doing so would
  21. * break backwards compatibility.
  22. */
  23. #define I830_TEXTURE_COUNT 2
  24. #define I830_TEXBLEND_COUNT I830_TEXTURE_COUNT
  25. #define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
  26. #define I830_UPLOAD_CTX 0x1
  27. #define I830_UPLOAD_BUFFERS 0x2
  28. #define I830_UPLOAD_CLIPRECTS 0x4
  29. #define I830_UPLOAD_TEX0_IMAGE 0x100 /* handled clientside */
  30. #define I830_UPLOAD_TEX0_CUBE 0x200 /* handled clientside */
  31. #define I830_UPLOAD_TEX1_IMAGE 0x400 /* handled clientside */
  32. #define I830_UPLOAD_TEX1_CUBE 0x800 /* handled clientside */
  33. #define I830_UPLOAD_TEX2_IMAGE 0x1000 /* handled clientside */
  34. #define I830_UPLOAD_TEX2_CUBE 0x2000 /* handled clientside */
  35. #define I830_UPLOAD_TEX3_IMAGE 0x4000 /* handled clientside */
  36. #define I830_UPLOAD_TEX3_CUBE 0x8000 /* handled clientside */
  37. #define I830_UPLOAD_TEX_N_IMAGE(n) (0x100 << (n * 2))
  38. #define I830_UPLOAD_TEX_N_CUBE(n) (0x200 << (n * 2))
  39. #define I830_UPLOAD_TEXIMAGE_MASK 0xff00
  40. #define I830_UPLOAD_TEX0 0x10000
  41. #define I830_UPLOAD_TEX1 0x20000
  42. #define I830_UPLOAD_TEX2 0x40000
  43. #define I830_UPLOAD_TEX3 0x80000
  44. #define I830_UPLOAD_TEX_N(n) (0x10000 << (n))
  45. #define I830_UPLOAD_TEX_MASK 0xf0000
  46. #define I830_UPLOAD_TEXBLEND0 0x100000
  47. #define I830_UPLOAD_TEXBLEND1 0x200000
  48. #define I830_UPLOAD_TEXBLEND2 0x400000
  49. #define I830_UPLOAD_TEXBLEND3 0x800000
  50. #define I830_UPLOAD_TEXBLEND_N(n) (0x100000 << (n))
  51. #define I830_UPLOAD_TEXBLEND_MASK 0xf00000
  52. #define I830_UPLOAD_TEX_PALETTE_N(n) (0x1000000 << (n))
  53. #define I830_UPLOAD_TEX_PALETTE_SHARED 0x4000000
  54. #define I830_UPLOAD_STIPPLE 0x8000000
  55. /* Indices into buf.Setup where various bits of state are mirrored per
  56. * context and per buffer. These can be fired at the card as a unit,
  57. * or in a piecewise fashion as required.
  58. */
  59. /* Destbuffer state
  60. * - backbuffer linear offset and pitch -- invarient in the current dri
  61. * - zbuffer linear offset and pitch -- also invarient
  62. * - drawing origin in back and depth buffers.
  63. *
  64. * Keep the depth/back buffer state here to accommodate private buffers
  65. * in the future.
  66. */
  67. #define I830_DESTREG_CBUFADDR 0
  68. #define I830_DESTREG_DBUFADDR 1
  69. #define I830_DESTREG_DV0 2
  70. #define I830_DESTREG_DV1 3
  71. #define I830_DESTREG_SENABLE 4
  72. #define I830_DESTREG_SR0 5
  73. #define I830_DESTREG_SR1 6
  74. #define I830_DESTREG_SR2 7
  75. #define I830_DESTREG_DR0 8
  76. #define I830_DESTREG_DR1 9
  77. #define I830_DESTREG_DR2 10
  78. #define I830_DESTREG_DR3 11
  79. #define I830_DESTREG_DR4 12
  80. #define I830_DEST_SETUP_SIZE 13
  81. /* Context state
  82. */
  83. #define I830_CTXREG_STATE1 0
  84. #define I830_CTXREG_STATE2 1
  85. #define I830_CTXREG_STATE3 2
  86. #define I830_CTXREG_STATE4 3
  87. #define I830_CTXREG_STATE5 4
  88. #define I830_CTXREG_IALPHAB 5
  89. #define I830_CTXREG_STENCILTST 6
  90. #define I830_CTXREG_ENABLES_1 7
  91. #define I830_CTXREG_ENABLES_2 8
  92. #define I830_CTXREG_AA 9
  93. #define I830_CTXREG_FOGCOLOR 10
  94. #define I830_CTXREG_BLENDCOLR0 11
  95. #define I830_CTXREG_BLENDCOLR 12 /* Dword 1 of 2 dword command */
  96. #define I830_CTXREG_VF 13
  97. #define I830_CTXREG_VF2 14
  98. #define I830_CTXREG_MCSB0 15
  99. #define I830_CTXREG_MCSB1 16
  100. #define I830_CTX_SETUP_SIZE 17
  101. /* 1.3: Stipple state
  102. */
  103. #define I830_STPREG_ST0 0
  104. #define I830_STPREG_ST1 1
  105. #define I830_STP_SETUP_SIZE 2
  106. /* Texture state (per tex unit)
  107. */
  108. #define I830_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (6 dwords) */
  109. #define I830_TEXREG_MI1 1
  110. #define I830_TEXREG_MI2 2
  111. #define I830_TEXREG_MI3 3
  112. #define I830_TEXREG_MI4 4
  113. #define I830_TEXREG_MI5 5
  114. #define I830_TEXREG_MF 6 /* GFX_OP_MAP_FILTER */
  115. #define I830_TEXREG_MLC 7 /* GFX_OP_MAP_LOD_CTL */
  116. #define I830_TEXREG_MLL 8 /* GFX_OP_MAP_LOD_LIMITS */
  117. #define I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS */
  118. #define I830_TEX_SETUP_SIZE 10
  119. #define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
  120. #define I830_TEXREG_TM0S0 1
  121. #define I830_TEXREG_TM0S1 2
  122. #define I830_TEXREG_TM0S2 3
  123. #define I830_TEXREG_TM0S3 4
  124. #define I830_TEXREG_TM0S4 5
  125. #define I830_TEXREG_NOP0 6 /* noop */
  126. #define I830_TEXREG_NOP1 7 /* noop */
  127. #define I830_TEXREG_NOP2 8 /* noop */
  128. #define __I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS -- shared */
  129. #define __I830_TEX_SETUP_SIZE 10
  130. #define I830_FRONT 0x1
  131. #define I830_BACK 0x2
  132. #define I830_DEPTH 0x4
  133. #endif /* _I830_DEFINES_ */
  134. typedef struct _drm_i830_init {
  135. enum {
  136. I830_INIT_DMA = 0x01,
  137. I830_CLEANUP_DMA = 0x02
  138. } func;
  139. unsigned int mmio_offset;
  140. unsigned int buffers_offset;
  141. int sarea_priv_offset;
  142. unsigned int ring_start;
  143. unsigned int ring_end;
  144. unsigned int ring_size;
  145. unsigned int front_offset;
  146. unsigned int back_offset;
  147. unsigned int depth_offset;
  148. unsigned int w;
  149. unsigned int h;
  150. unsigned int pitch;
  151. unsigned int pitch_bits;
  152. unsigned int back_pitch;
  153. unsigned int depth_pitch;
  154. unsigned int cpp;
  155. } drm_i830_init_t;
  156. /* Warning: If you change the SAREA structure you must change the Xserver
  157. * structure as well */
  158. typedef struct _drm_i830_tex_region {
  159. unsigned char next, prev; /* indices to form a circular LRU */
  160. unsigned char in_use; /* owned by a client, or free? */
  161. int age; /* tracked by clients to update local LRU's */
  162. } drm_i830_tex_region_t;
  163. typedef struct _drm_i830_sarea {
  164. unsigned int ContextState[I830_CTX_SETUP_SIZE];
  165. unsigned int BufferState[I830_DEST_SETUP_SIZE];
  166. unsigned int TexState[I830_TEXTURE_COUNT][I830_TEX_SETUP_SIZE];
  167. unsigned int TexBlendState[I830_TEXBLEND_COUNT][I830_TEXBLEND_SIZE];
  168. unsigned int TexBlendStateWordsUsed[I830_TEXBLEND_COUNT];
  169. unsigned int Palette[2][256];
  170. unsigned int dirty;
  171. unsigned int nbox;
  172. struct drm_clip_rect boxes[I830_NR_SAREA_CLIPRECTS];
  173. /* Maintain an LRU of contiguous regions of texture space. If
  174. * you think you own a region of texture memory, and it has an
  175. * age different to the one you set, then you are mistaken and
  176. * it has been stolen by another client. If global texAge
  177. * hasn't changed, there is no need to walk the list.
  178. *
  179. * These regions can be used as a proxy for the fine-grained
  180. * texture information of other clients - by maintaining them
  181. * in the same lru which is used to age their own textures,
  182. * clients have an approximate lru for the whole of global
  183. * texture space, and can make informed decisions as to which
  184. * areas to kick out. There is no need to choose whether to
  185. * kick out your own texture or someone else's - simply eject
  186. * them all in LRU order.
  187. */
  188. drm_i830_tex_region_t texList[I830_NR_TEX_REGIONS + 1];
  189. /* Last elt is sentinal */
  190. int texAge; /* last time texture was uploaded */
  191. int last_enqueue; /* last time a buffer was enqueued */
  192. int last_dispatch; /* age of the most recently dispatched buffer */
  193. int last_quiescent; /* */
  194. int ctxOwner; /* last context to upload state */
  195. int vertex_prim;
  196. int pf_enabled; /* is pageflipping allowed? */
  197. int pf_active;
  198. int pf_current_page; /* which buffer is being displayed? */
  199. int perf_boxes; /* performance boxes to be displayed */
  200. /* Here's the state for texunits 2,3:
  201. */
  202. unsigned int TexState2[I830_TEX_SETUP_SIZE];
  203. unsigned int TexBlendState2[I830_TEXBLEND_SIZE];
  204. unsigned int TexBlendStateWordsUsed2;
  205. unsigned int TexState3[I830_TEX_SETUP_SIZE];
  206. unsigned int TexBlendState3[I830_TEXBLEND_SIZE];
  207. unsigned int TexBlendStateWordsUsed3;
  208. unsigned int StippleState[I830_STP_SETUP_SIZE];
  209. } drm_i830_sarea_t;
  210. /* Flags for perf_boxes
  211. */
  212. #define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
  213. #define I830_BOX_FLIP 0x2 /* populated by kernel */
  214. #define I830_BOX_WAIT 0x4 /* populated by kernel & client */
  215. #define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
  216. #define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
  217. /* I830 specific ioctls
  218. * The device specific ioctl range is 0x40 to 0x79.
  219. */
  220. #define DRM_I830_INIT 0x00
  221. #define DRM_I830_VERTEX 0x01
  222. #define DRM_I830_CLEAR 0x02
  223. #define DRM_I830_FLUSH 0x03
  224. #define DRM_I830_GETAGE 0x04
  225. #define DRM_I830_GETBUF 0x05
  226. #define DRM_I830_SWAP 0x06
  227. #define DRM_I830_COPY 0x07
  228. #define DRM_I830_DOCOPY 0x08
  229. #define DRM_I830_FLIP 0x09
  230. #define DRM_I830_IRQ_EMIT 0x0a
  231. #define DRM_I830_IRQ_WAIT 0x0b
  232. #define DRM_I830_GETPARAM 0x0c
  233. #define DRM_I830_SETPARAM 0x0d
  234. #define DRM_IOCTL_I830_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_INIT, drm_i830_init_t)
  235. #define DRM_IOCTL_I830_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_VERTEX, drm_i830_vertex_t)
  236. #define DRM_IOCTL_I830_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_CLEAR, drm_i830_clear_t)
  237. #define DRM_IOCTL_I830_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_FLUSH)
  238. #define DRM_IOCTL_I830_GETAGE DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_GETAGE)
  239. #define DRM_IOCTL_I830_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_GETBUF, drm_i830_dma_t)
  240. #define DRM_IOCTL_I830_SWAP DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_SWAP)
  241. #define DRM_IOCTL_I830_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_COPY, drm_i830_copy_t)
  242. #define DRM_IOCTL_I830_DOCOPY DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_DOCOPY)
  243. #define DRM_IOCTL_I830_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_FLIP)
  244. #define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_IRQ_EMIT, drm_i830_irq_emit_t)
  245. #define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_IRQ_WAIT, drm_i830_irq_wait_t)
  246. #define DRM_IOCTL_I830_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_GETPARAM, drm_i830_getparam_t)
  247. #define DRM_IOCTL_I830_SETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_SETPARAM, drm_i830_setparam_t)
  248. typedef struct _drm_i830_clear {
  249. int clear_color;
  250. int clear_depth;
  251. int flags;
  252. unsigned int clear_colormask;
  253. unsigned int clear_depthmask;
  254. } drm_i830_clear_t;
  255. /* These may be placeholders if we have more cliprects than
  256. * I830_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
  257. * false, indicating that the buffer will be dispatched again with a
  258. * new set of cliprects.
  259. */
  260. typedef struct _drm_i830_vertex {
  261. int idx; /* buffer index */
  262. int used; /* nr bytes in use */
  263. int discard; /* client is finished with the buffer? */
  264. } drm_i830_vertex_t;
  265. typedef struct _drm_i830_copy_t {
  266. int idx; /* buffer index */
  267. int used; /* nr bytes in use */
  268. void __user *address; /* Address to copy from */
  269. } drm_i830_copy_t;
  270. typedef struct drm_i830_dma {
  271. void __user *virtual;
  272. int request_idx;
  273. int request_size;
  274. int granted;
  275. } drm_i830_dma_t;
  276. /* 1.3: Userspace can request & wait on irq's:
  277. */
  278. typedef struct drm_i830_irq_emit {
  279. int __user *irq_seq;
  280. } drm_i830_irq_emit_t;
  281. typedef struct drm_i830_irq_wait {
  282. int irq_seq;
  283. } drm_i830_irq_wait_t;
  284. /* 1.3: New ioctl to query kernel params:
  285. */
  286. #define I830_PARAM_IRQ_ACTIVE 1
  287. typedef struct drm_i830_getparam {
  288. int param;
  289. int __user *value;
  290. } drm_i830_getparam_t;
  291. /* 1.3: New ioctl to set kernel params:
  292. */
  293. #define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
  294. typedef struct drm_i830_setparam {
  295. int param;
  296. int value;
  297. } drm_i830_setparam_t;
  298. #endif /* _I830_DRM_H_ */