i810_drm.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. #ifndef _I810_DRM_H_
  2. #define _I810_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. #ifndef _I810_DEFINES_
  7. #define _I810_DEFINES_
  8. #define I810_DMA_BUF_ORDER 12
  9. #define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
  10. #define I810_DMA_BUF_NR 256
  11. #define I810_NR_SAREA_CLIPRECTS 8
  12. /* Each region is a minimum of 64k, and there are at most 64 of them.
  13. */
  14. #define I810_NR_TEX_REGIONS 64
  15. #define I810_LOG_MIN_TEX_REGION_SIZE 16
  16. #endif
  17. #define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
  18. #define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
  19. #define I810_UPLOAD_CTX 0x4
  20. #define I810_UPLOAD_BUFFERS 0x8
  21. #define I810_UPLOAD_TEX0 0x10
  22. #define I810_UPLOAD_TEX1 0x20
  23. #define I810_UPLOAD_CLIPRECTS 0x40
  24. /* Indices into buf.Setup where various bits of state are mirrored per
  25. * context and per buffer. These can be fired at the card as a unit,
  26. * or in a piecewise fashion as required.
  27. */
  28. /* Destbuffer state
  29. * - backbuffer linear offset and pitch -- invarient in the current dri
  30. * - zbuffer linear offset and pitch -- also invarient
  31. * - drawing origin in back and depth buffers.
  32. *
  33. * Keep the depth/back buffer state here to accommodate private buffers
  34. * in the future.
  35. */
  36. #define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
  37. #define I810_DESTREG_DI1 1
  38. #define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
  39. #define I810_DESTREG_DV1 3
  40. #define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
  41. #define I810_DESTREG_DR1 5
  42. #define I810_DESTREG_DR2 6
  43. #define I810_DESTREG_DR3 7
  44. #define I810_DESTREG_DR4 8
  45. #define I810_DEST_SETUP_SIZE 10
  46. /* Context state
  47. */
  48. #define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
  49. #define I810_CTXREG_CF1 1
  50. #define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
  51. #define I810_CTXREG_ST1 3
  52. #define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
  53. #define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
  54. #define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
  55. #define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
  56. #define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
  57. #define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
  58. #define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
  59. #define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
  60. #define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
  61. #define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
  62. #define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
  63. #define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
  64. #define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
  65. #define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
  66. #define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
  67. #define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
  68. #define I810_CTX_SETUP_SIZE 20
  69. /* Texture state (per tex unit)
  70. */
  71. #define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
  72. #define I810_TEXREG_MI1 1
  73. #define I810_TEXREG_MI2 2
  74. #define I810_TEXREG_MI3 3
  75. #define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
  76. #define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
  77. #define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
  78. #define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
  79. #define I810_TEX_SETUP_SIZE 8
  80. /* Flags for clear ioctl
  81. */
  82. #define I810_FRONT 0x1
  83. #define I810_BACK 0x2
  84. #define I810_DEPTH 0x4
  85. typedef enum _drm_i810_init_func {
  86. I810_INIT_DMA = 0x01,
  87. I810_CLEANUP_DMA = 0x02,
  88. I810_INIT_DMA_1_4 = 0x03
  89. } drm_i810_init_func_t;
  90. /* This is the init structure after v1.2 */
  91. typedef struct _drm_i810_init {
  92. drm_i810_init_func_t func;
  93. unsigned int mmio_offset;
  94. unsigned int buffers_offset;
  95. int sarea_priv_offset;
  96. unsigned int ring_start;
  97. unsigned int ring_end;
  98. unsigned int ring_size;
  99. unsigned int front_offset;
  100. unsigned int back_offset;
  101. unsigned int depth_offset;
  102. unsigned int overlay_offset;
  103. unsigned int overlay_physical;
  104. unsigned int w;
  105. unsigned int h;
  106. unsigned int pitch;
  107. unsigned int pitch_bits;
  108. } drm_i810_init_t;
  109. /* This is the init structure prior to v1.2 */
  110. typedef struct _drm_i810_pre12_init {
  111. drm_i810_init_func_t func;
  112. unsigned int mmio_offset;
  113. unsigned int buffers_offset;
  114. int sarea_priv_offset;
  115. unsigned int ring_start;
  116. unsigned int ring_end;
  117. unsigned int ring_size;
  118. unsigned int front_offset;
  119. unsigned int back_offset;
  120. unsigned int depth_offset;
  121. unsigned int w;
  122. unsigned int h;
  123. unsigned int pitch;
  124. unsigned int pitch_bits;
  125. } drm_i810_pre12_init_t;
  126. /* Warning: If you change the SAREA structure you must change the Xserver
  127. * structure as well */
  128. typedef struct _drm_i810_tex_region {
  129. unsigned char next, prev; /* indices to form a circular LRU */
  130. unsigned char in_use; /* owned by a client, or free? */
  131. int age; /* tracked by clients to update local LRU's */
  132. } drm_i810_tex_region_t;
  133. typedef struct _drm_i810_sarea {
  134. unsigned int ContextState[I810_CTX_SETUP_SIZE];
  135. unsigned int BufferState[I810_DEST_SETUP_SIZE];
  136. unsigned int TexState[2][I810_TEX_SETUP_SIZE];
  137. unsigned int dirty;
  138. unsigned int nbox;
  139. struct drm_clip_rect boxes[I810_NR_SAREA_CLIPRECTS];
  140. /* Maintain an LRU of contiguous regions of texture space. If
  141. * you think you own a region of texture memory, and it has an
  142. * age different to the one you set, then you are mistaken and
  143. * it has been stolen by another client. If global texAge
  144. * hasn't changed, there is no need to walk the list.
  145. *
  146. * These regions can be used as a proxy for the fine-grained
  147. * texture information of other clients - by maintaining them
  148. * in the same lru which is used to age their own textures,
  149. * clients have an approximate lru for the whole of global
  150. * texture space, and can make informed decisions as to which
  151. * areas to kick out. There is no need to choose whether to
  152. * kick out your own texture or someone else's - simply eject
  153. * them all in LRU order.
  154. */
  155. drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS + 1];
  156. /* Last elt is sentinal */
  157. int texAge; /* last time texture was uploaded */
  158. int last_enqueue; /* last time a buffer was enqueued */
  159. int last_dispatch; /* age of the most recently dispatched buffer */
  160. int last_quiescent; /* */
  161. int ctxOwner; /* last context to upload state */
  162. int vertex_prim;
  163. int pf_enabled; /* is pageflipping allowed? */
  164. int pf_active;
  165. int pf_current_page; /* which buffer is being displayed? */
  166. } drm_i810_sarea_t;
  167. /* WARNING: If you change any of these defines, make sure to change the
  168. * defines in the Xserver file (xf86drmMga.h)
  169. */
  170. /* i810 specific ioctls
  171. * The device specific ioctl range is 0x40 to 0x79.
  172. */
  173. #define DRM_I810_INIT 0x00
  174. #define DRM_I810_VERTEX 0x01
  175. #define DRM_I810_CLEAR 0x02
  176. #define DRM_I810_FLUSH 0x03
  177. #define DRM_I810_GETAGE 0x04
  178. #define DRM_I810_GETBUF 0x05
  179. #define DRM_I810_SWAP 0x06
  180. #define DRM_I810_COPY 0x07
  181. #define DRM_I810_DOCOPY 0x08
  182. #define DRM_I810_OV0INFO 0x09
  183. #define DRM_I810_FSTATUS 0x0a
  184. #define DRM_I810_OV0FLIP 0x0b
  185. #define DRM_I810_MC 0x0c
  186. #define DRM_I810_RSTATUS 0x0d
  187. #define DRM_I810_FLIP 0x0e
  188. #define DRM_IOCTL_I810_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I810_INIT, drm_i810_init_t)
  189. #define DRM_IOCTL_I810_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_I810_VERTEX, drm_i810_vertex_t)
  190. #define DRM_IOCTL_I810_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_I810_CLEAR, drm_i810_clear_t)
  191. #define DRM_IOCTL_I810_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_I810_FLUSH)
  192. #define DRM_IOCTL_I810_GETAGE DRM_IO( DRM_COMMAND_BASE + DRM_I810_GETAGE)
  193. #define DRM_IOCTL_I810_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_I810_GETBUF, drm_i810_dma_t)
  194. #define DRM_IOCTL_I810_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_I810_SWAP)
  195. #define DRM_IOCTL_I810_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_I810_COPY, drm_i810_copy_t)
  196. #define DRM_IOCTL_I810_DOCOPY DRM_IO( DRM_COMMAND_BASE + DRM_I810_DOCOPY)
  197. #define DRM_IOCTL_I810_OV0INFO DRM_IOR( DRM_COMMAND_BASE + DRM_I810_OV0INFO, drm_i810_overlay_t)
  198. #define DRM_IOCTL_I810_FSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FSTATUS)
  199. #define DRM_IOCTL_I810_OV0FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_OV0FLIP)
  200. #define DRM_IOCTL_I810_MC DRM_IOW( DRM_COMMAND_BASE + DRM_I810_MC, drm_i810_mc_t)
  201. #define DRM_IOCTL_I810_RSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_RSTATUS)
  202. #define DRM_IOCTL_I810_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FLIP)
  203. typedef struct _drm_i810_clear {
  204. int clear_color;
  205. int clear_depth;
  206. int flags;
  207. } drm_i810_clear_t;
  208. /* These may be placeholders if we have more cliprects than
  209. * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
  210. * false, indicating that the buffer will be dispatched again with a
  211. * new set of cliprects.
  212. */
  213. typedef struct _drm_i810_vertex {
  214. int idx; /* buffer index */
  215. int used; /* nr bytes in use */
  216. int discard; /* client is finished with the buffer? */
  217. } drm_i810_vertex_t;
  218. typedef struct _drm_i810_copy_t {
  219. int idx; /* buffer index */
  220. int used; /* nr bytes in use */
  221. void *address; /* Address to copy from */
  222. } drm_i810_copy_t;
  223. #define PR_TRIANGLES (0x0<<18)
  224. #define PR_TRISTRIP_0 (0x1<<18)
  225. #define PR_TRISTRIP_1 (0x2<<18)
  226. #define PR_TRIFAN (0x3<<18)
  227. #define PR_POLYGON (0x4<<18)
  228. #define PR_LINES (0x5<<18)
  229. #define PR_LINESTRIP (0x6<<18)
  230. #define PR_RECTS (0x7<<18)
  231. #define PR_MASK (0x7<<18)
  232. typedef struct drm_i810_dma {
  233. void *virtual;
  234. int request_idx;
  235. int request_size;
  236. int granted;
  237. } drm_i810_dma_t;
  238. typedef struct _drm_i810_overlay_t {
  239. unsigned int offset; /* Address of the Overlay Regs */
  240. unsigned int physical;
  241. } drm_i810_overlay_t;
  242. typedef struct _drm_i810_mc {
  243. int idx; /* buffer index */
  244. int used; /* nr bytes in use */
  245. int num_blocks; /* number of GFXBlocks */
  246. int *length; /* List of lengths for GFXBlocks (FUTURE) */
  247. unsigned int last_render; /* Last Render Request */
  248. } drm_i810_mc_t;
  249. #endif /* _I810_DRM_H_ */