i830_drm.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:8k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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. #ifndef _I830_DEFINES_
  7. #define _I830_DEFINES_
  8. #define I830_DMA_BUF_ORDER 12
  9. #define I830_DMA_BUF_SZ  (1<<I830_DMA_BUF_ORDER)
  10. #define I830_DMA_BUF_NR  256
  11. #define I830_NR_SAREA_CLIPRECTS  8
  12. /* Each region is a minimum of 64k, and there are at most 64 of them.
  13.  */
  14. #define I830_NR_TEX_REGIONS 64
  15. #define I830_LOG_MIN_TEX_REGION_SIZE 16
  16. /* if defining I830_ENABLE_4_TEXTURES, do it in i830_3d_reg.h, too */
  17. #if !defined(I830_ENABLE_4_TEXTURES)
  18. #define I830_TEXTURE_COUNT 2
  19. #define I830_TEXBLEND_COUNT 2 /* always same as TEXTURE_COUNT? */
  20. #else /* defined(I830_ENABLE_4_TEXTURES) */
  21. #define I830_TEXTURE_COUNT 4
  22. #define I830_TEXBLEND_COUNT 4 /* always same as TEXTURE_COUNT? */
  23. #endif /* I830_ENABLE_4_TEXTURES */
  24. #define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
  25. #define I830_UPLOAD_CTX 0x1
  26. #define I830_UPLOAD_BUFFERS 0x2
  27. #define I830_UPLOAD_CLIPRECTS 0x4
  28. #define I830_UPLOAD_TEX0_IMAGE 0x100 /* handled clientside */
  29. #define I830_UPLOAD_TEX0_CUBE 0x200 /* handled clientside */
  30. #define I830_UPLOAD_TEX1_IMAGE 0x400 /* handled clientside */
  31. #define I830_UPLOAD_TEX1_CUBE 0x800 /* handled clientside */
  32. #define I830_UPLOAD_TEX2_IMAGE 0x1000 /* handled clientside */
  33. #define I830_UPLOAD_TEX2_CUBE 0x2000 /* handled clientside */
  34. #define I830_UPLOAD_TEX3_IMAGE 0x4000 /* handled clientside */
  35. #define I830_UPLOAD_TEX3_CUBE 0x8000 /* handled clientside */
  36. #define I830_UPLOAD_TEX_N_IMAGE(n) (0x100 << (n * 2))
  37. #define I830_UPLOAD_TEX_N_CUBE(n) (0x200 << (n * 2))
  38. #define I830_UPLOAD_TEXIMAGE_MASK 0xff00
  39. #define I830_UPLOAD_TEX0 0x10000
  40. #define I830_UPLOAD_TEX1 0x20000
  41. #define I830_UPLOAD_TEX2 0x40000
  42. #define I830_UPLOAD_TEX3 0x80000
  43. #define I830_UPLOAD_TEX_N(n) (0x10000 << (n))
  44. #define I830_UPLOAD_TEX_MASK 0xf0000
  45. #define I830_UPLOAD_TEXBLEND0 0x100000
  46. #define I830_UPLOAD_TEXBLEND1 0x200000
  47. #define I830_UPLOAD_TEXBLEND2 0x400000
  48. #define I830_UPLOAD_TEXBLEND3 0x800000
  49. #define I830_UPLOAD_TEXBLEND_N(n) (0x100000 << (n))
  50. #define I830_UPLOAD_TEXBLEND_MASK 0xf00000
  51. #define I830_UPLOAD_TEX_PALETTE_N(n)    (0x1000000 << (n))
  52. #define I830_UPLOAD_TEX_PALETTE_SHARED 0x4000000
  53. /* Indices into buf.Setup where various bits of state are mirrored per
  54.  * context and per buffer.  These can be fired at the card as a unit,
  55.  * or in a piecewise fashion as required.
  56.  */
  57. /* Destbuffer state 
  58.  *    - backbuffer linear offset and pitch -- invarient in the current dri
  59.  *    - zbuffer linear offset and pitch -- also invarient
  60.  *    - drawing origin in back and depth buffers.
  61.  *
  62.  * Keep the depth/back buffer state here to acommodate private buffers
  63.  * in the future.
  64.  */
  65. #define I830_DESTREG_CBUFADDR 0
  66. /* Invarient */
  67. #define I830_DESTREG_DBUFADDR 1
  68. #define I830_DESTREG_DV0 2
  69. #define I830_DESTREG_DV1 3
  70. #define I830_DESTREG_SENABLE 4
  71. #define I830_DESTREG_SR0 5
  72. #define I830_DESTREG_SR1 6
  73. #define I830_DESTREG_SR2 7
  74. #define I830_DESTREG_DR0 8
  75. #define I830_DESTREG_DR1 9
  76. #define I830_DESTREG_DR2 10
  77. #define I830_DESTREG_DR3 11
  78. #define I830_DESTREG_DR4 12
  79. #define I830_DEST_SETUP_SIZE 13
  80. /* Context state
  81.  */
  82. #define I830_CTXREG_STATE1 0
  83. #define I830_CTXREG_STATE2 1
  84. #define I830_CTXREG_STATE3 2
  85. #define I830_CTXREG_STATE4 3
  86. #define I830_CTXREG_STATE5 4
  87. #define I830_CTXREG_IALPHAB 5
  88. #define I830_CTXREG_STENCILTST 6
  89. #define I830_CTXREG_ENABLES_1 7
  90. #define I830_CTXREG_ENABLES_2 8
  91. #define I830_CTXREG_AA 9
  92. #define I830_CTXREG_FOGCOLOR 10
  93. #define I830_CTXREG_BLENDCOLR0 11
  94. #define I830_CTXREG_BLENDCOLR 12 /* Dword 1 of 2 dword command */
  95. #define I830_CTXREG_VF 13
  96. #define I830_CTXREG_VF2 14
  97. #define I830_CTXREG_MCSB0 15
  98. #define I830_CTXREG_MCSB1 16
  99. #define I830_CTX_SETUP_SIZE 17
  100. /* Texture state (per tex unit)
  101.  */
  102. #define I830_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (6 dwords) */
  103. #define I830_TEXREG_MI1 1
  104. #define I830_TEXREG_MI2 2
  105. #define I830_TEXREG_MI3 3
  106. #define I830_TEXREG_MI4 4
  107. #define I830_TEXREG_MI5 5
  108. #define I830_TEXREG_MF 6 /* GFX_OP_MAP_FILTER */
  109. #define I830_TEXREG_MLC 7 /* GFX_OP_MAP_LOD_CTL */
  110. #define I830_TEXREG_MLL 8 /* GFX_OP_MAP_LOD_LIMITS */
  111. #define I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS */
  112. #define I830_TEX_SETUP_SIZE 10
  113. #define I830_FRONT   0x1
  114. #define I830_BACK    0x2
  115. #define I830_DEPTH   0x4
  116. #endif /* _I830_DEFINES_ */
  117. typedef struct _drm_i830_init {
  118. enum {
  119. I830_INIT_DMA = 0x01,
  120. I830_CLEANUP_DMA = 0x02
  121. } func;
  122. unsigned int mmio_offset;
  123. unsigned int buffers_offset;
  124. int sarea_priv_offset;
  125. unsigned int ring_start;
  126. unsigned int ring_end;
  127. unsigned int ring_size;
  128. unsigned int front_offset;
  129. unsigned int back_offset;
  130. unsigned int depth_offset;
  131. unsigned int w;
  132. unsigned int h;
  133. unsigned int pitch;
  134. unsigned int pitch_bits;
  135. unsigned int back_pitch;
  136. unsigned int depth_pitch;
  137. unsigned int cpp;
  138. } drm_i830_init_t;
  139. /* Warning: If you change the SAREA structure you must change the Xserver
  140.  * structure as well */
  141. typedef struct _drm_i830_tex_region {
  142. unsigned char next, prev; /* indices to form a circular LRU  */
  143. unsigned char in_use; /* owned by a client, or free? */
  144. int age; /* tracked by clients to update local LRU's */
  145. } drm_i830_tex_region_t;
  146. typedef struct _drm_i830_sarea {
  147. unsigned int ContextState[I830_CTX_SETUP_SIZE];
  148.     unsigned int BufferState[I830_DEST_SETUP_SIZE];
  149. unsigned int TexState[I830_TEXTURE_COUNT][I830_TEX_SETUP_SIZE];
  150. unsigned int TexBlendState[I830_TEXBLEND_COUNT][I830_TEXBLEND_SIZE];
  151. unsigned int TexBlendStateWordsUsed[I830_TEXBLEND_COUNT];
  152. unsigned int Palette[2][256];
  153.     unsigned int dirty;
  154. unsigned int nbox;
  155. drm_clip_rect_t boxes[I830_NR_SAREA_CLIPRECTS];
  156. /* Maintain an LRU of contiguous regions of texture space.  If
  157.  * you think you own a region of texture memory, and it has an
  158.  * age different to the one you set, then you are mistaken and
  159.  * it has been stolen by another client.  If global texAge
  160.  * hasn't changed, there is no need to walk the list.
  161.  *
  162.  * These regions can be used as a proxy for the fine-grained
  163.  * texture information of other clients - by maintaining them
  164.  * in the same lru which is used to age their own textures,
  165.  * clients have an approximate lru for the whole of global
  166.  * texture space, and can make informed decisions as to which
  167.  * areas to kick out.  There is no need to choose whether to
  168.  * kick out your own texture or someone else's - simply eject
  169.  * them all in LRU order.  
  170.  */
  171. drm_i830_tex_region_t texList[I830_NR_TEX_REGIONS+1]; 
  172. /* Last elt is sentinal */
  173.         int texAge; /* last time texture was uploaded */
  174.         int last_enqueue; /* last time a buffer was enqueued */
  175. int last_dispatch; /* age of the most recently dispatched buffer */
  176. int last_quiescent;     /*  */
  177. int ctxOwner; /* last context to upload state */
  178. int vertex_prim;
  179. } drm_i830_sarea_t;
  180. typedef struct _drm_i830_clear {
  181. int clear_color;
  182. int clear_depth;
  183. int flags;
  184. unsigned int clear_colormask;
  185. unsigned int clear_depthmask;
  186. } drm_i830_clear_t;
  187. /* These may be placeholders if we have more cliprects than
  188.  * I830_NR_SAREA_CLIPRECTS.  In that case, the client sets discard to
  189.  * false, indicating that the buffer will be dispatched again with a
  190.  * new set of cliprects.
  191.  */
  192. typedef struct _drm_i830_vertex {
  193.     int idx; /* buffer index */
  194. int used; /* nr bytes in use */
  195. int discard; /* client is finished with the buffer? */
  196. } drm_i830_vertex_t;
  197. typedef struct _drm_i830_copy_t {
  198.     int idx; /* buffer index */
  199. int used; /* nr bytes in use */
  200. void *address; /* Address to copy from */
  201. } drm_i830_copy_t;
  202. typedef struct drm_i830_dma {
  203. void *virtual;
  204. int request_idx;
  205. int request_size;
  206. int granted;
  207. } drm_i830_dma_t;
  208. #endif /* _I830_DRM_H_ */