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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
  2.  * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
  3.  *
  4.  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  5.  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  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: Jeff Hartmann <jhartmann@valinux.com>
  28.  *          Keith Whitwell <keithw@valinux.com>
  29.  *
  30.  */
  31. #ifndef _MGA_DRM_H_
  32. #define _MGA_DRM_H_
  33. /* WARNING: If you change any of these defines, make sure to change the
  34.  * defines in the Xserver file (xf86drmMga.h)
  35.  */
  36. #ifndef _MGA_DEFINES_
  37. #define _MGA_DEFINES_
  38. #define MGA_F  0x1 /* fog */
  39. #define MGA_A  0x2 /* alpha */
  40. #define MGA_S  0x4 /* specular */
  41. #define MGA_T2 0x8 /* multitexture */
  42. #define MGA_WARP_TGZ            0
  43. #define MGA_WARP_TGZF           (MGA_F)
  44. #define MGA_WARP_TGZA           (MGA_A)
  45. #define MGA_WARP_TGZAF          (MGA_F|MGA_A)
  46. #define MGA_WARP_TGZS           (MGA_S)
  47. #define MGA_WARP_TGZSF          (MGA_S|MGA_F)
  48. #define MGA_WARP_TGZSA          (MGA_S|MGA_A)
  49. #define MGA_WARP_TGZSAF         (MGA_S|MGA_F|MGA_A)
  50. #define MGA_WARP_T2GZ           (MGA_T2)
  51. #define MGA_WARP_T2GZF          (MGA_T2|MGA_F)
  52. #define MGA_WARP_T2GZA          (MGA_T2|MGA_A)
  53. #define MGA_WARP_T2GZAF         (MGA_T2|MGA_A|MGA_F)
  54. #define MGA_WARP_T2GZS          (MGA_T2|MGA_S)
  55. #define MGA_WARP_T2GZSF         (MGA_T2|MGA_S|MGA_F)
  56. #define MGA_WARP_T2GZSA         (MGA_T2|MGA_S|MGA_A)
  57. #define MGA_WARP_T2GZSAF        (MGA_T2|MGA_S|MGA_F|MGA_A)
  58. #define MGA_MAX_G400_PIPES 16
  59. #define MGA_MAX_G200_PIPES  8 /* no multitex */
  60. #define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
  61. #define MGA_CARD_TYPE_G200 1
  62. #define MGA_CARD_TYPE_G400 2
  63. #define MGA_FRONT   0x1
  64. #define MGA_BACK    0x2
  65. #define MGA_DEPTH   0x4
  66. /* 3d state excluding texture units:
  67.  */
  68. #define MGA_CTXREG_DSTORG     0 /* validated */
  69. #define MGA_CTXREG_MACCESS    1
  70. #define MGA_CTXREG_PLNWT      2 
  71. #define MGA_CTXREG_DWGCTL     3
  72. #define MGA_CTXREG_ALPHACTRL  4
  73. #define MGA_CTXREG_FOGCOLOR   5
  74. #define MGA_CTXREG_WFLAG      6
  75. #define MGA_CTXREG_TDUAL0     7
  76. #define MGA_CTXREG_TDUAL1     8
  77. #define MGA_CTXREG_FCOL       9
  78. #define MGA_CTXREG_STENCIL    10
  79. #define MGA_CTXREG_STENCILCTL 11
  80. #define MGA_CTX_SETUP_SIZE    12
  81. /* 2d state
  82.  */
  83. #define MGA_2DREG_PITCH  0
  84. #define MGA_2D_SETUP_SIZE  1
  85. /* Each texture unit has a state:
  86.  */
  87. #define MGA_TEXREG_CTL        0
  88. #define MGA_TEXREG_CTL2       1
  89. #define MGA_TEXREG_FILTER     2
  90. #define MGA_TEXREG_BORDERCOL  3
  91. #define MGA_TEXREG_ORG        4 /* validated */
  92. #define MGA_TEXREG_ORG1       5
  93. #define MGA_TEXREG_ORG2       6
  94. #define MGA_TEXREG_ORG3       7
  95. #define MGA_TEXREG_ORG4       8
  96. #define MGA_TEXREG_WIDTH      9
  97. #define MGA_TEXREG_HEIGHT     10
  98. #define MGA_TEX_SETUP_SIZE    11
  99. /* What needs to be changed for the current vertex dma buffer?
  100.  */
  101. #define MGA_UPLOAD_CTX        0x1
  102. #define MGA_UPLOAD_TEX0       0x2
  103. #define MGA_UPLOAD_TEX1       0x4
  104. #define MGA_UPLOAD_PIPE       0x8
  105. #define MGA_UPLOAD_TEX0IMAGE  0x10 /* handled client-side */
  106. #define MGA_UPLOAD_TEX1IMAGE  0x20 /* handled client-side */
  107. #define MGA_UPLOAD_2D        0x40
  108. #define MGA_WAIT_AGE          0x80 /* handled client-side */
  109. #define MGA_UPLOAD_CLIPRECTS  0x100 /* handled client-side */
  110. #define MGA_DMA_FLUSH       0x200 /* set when someone gets the lock
  111.                                        quiescent */
  112. /* 32 buffers of 64k each, total 2 meg.
  113.  */
  114. #define MGA_DMA_BUF_ORDER     16
  115. #define MGA_DMA_BUF_SZ        (1<<MGA_DMA_BUF_ORDER)
  116. #define MGA_DMA_BUF_NR        31
  117. /* Keep these small for testing.
  118.  */
  119. #define MGA_NR_SAREA_CLIPRECTS 8
  120. /* 2 heaps (1 for card, 1 for agp), each divided into upto 128
  121.  * regions, subject to a minimum region size of (1<<16) == 64k. 
  122.  *
  123.  * Clients may subdivide regions internally, but when sharing between
  124.  * clients, the region size is the minimum granularity. 
  125.  */
  126. #define MGA_CARD_HEAP 0
  127. #define MGA_AGP_HEAP  1
  128. #define MGA_NR_TEX_HEAPS 2
  129. #define MGA_NR_TEX_REGIONS 16
  130. #define MGA_LOG_MIN_TEX_REGION_SIZE 16
  131. #endif
  132. typedef struct _drm_mga_warp_index {
  133.     int installed;
  134.     unsigned long phys_addr;
  135.     int size;
  136. } drm_mga_warp_index_t;
  137. typedef struct drm_mga_init {
  138.     enum { 
  139.     MGA_INIT_DMA = 0x01,
  140.         MGA_CLEANUP_DMA = 0x02
  141. } func;
  142.     int reserved_map_agpstart;
  143.     int reserved_map_idx;
  144.     int buffer_map_idx;
  145.     int sarea_priv_offset;
  146.     int primary_size;
  147.     int warp_ucode_size;
  148.     unsigned int frontOffset;
  149.     unsigned int backOffset;
  150.     unsigned int depthOffset;
  151.     unsigned int textureOffset;
  152.     unsigned int textureSize;
  153.         unsigned int agpTextureOffset;
  154.         unsigned int agpTextureSize;
  155.     unsigned int cpp;
  156.     unsigned int stride;
  157.     int sgram;
  158. int chipset;
  159.     drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES];
  160. unsigned int mAccess;
  161. } drm_mga_init_t;
  162. /* Warning: if you change the sarea structure, you must change the Xserver
  163.  * structures as well */
  164. typedef struct _drm_mga_tex_region {
  165. unsigned char next, prev;
  166. unsigned char in_use;
  167. unsigned int age;
  168. } drm_mga_tex_region_t;
  169. typedef struct _drm_mga_sarea {
  170. /* The channel for communication of state information to the kernel
  171.  * on firing a vertex dma buffer.
  172.  */
  173.     unsigned int ContextState[MGA_CTX_SETUP_SIZE];
  174.     unsigned int ServerState[MGA_2D_SETUP_SIZE];
  175.     unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
  176.     unsigned int WarpPipe;
  177.     unsigned int dirty;
  178.     unsigned int nbox;
  179.     drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
  180. /* Information about the most recently used 3d drawable.  The
  181.  * client fills in the req_* fields, the server fills in the 
  182.  * exported_ fields and puts the cliprects into boxes, above.
  183.  *
  184.  * The client clears the exported_drawable field before
  185.  * clobbering the boxes data.
  186.  */
  187.         unsigned int req_drawable;  /* the X drawable id */
  188. unsigned int req_draw_buffer;  /* MGA_FRONT or MGA_BACK */
  189.         unsigned int exported_drawable;  
  190. unsigned int exported_index; 
  191.         unsigned int exported_stamp;
  192.         unsigned int exported_buffers;  
  193.         unsigned int exported_nfront;
  194.         unsigned int exported_nback;
  195. int exported_back_x, exported_front_x, exported_w;
  196. int exported_back_y, exported_front_y, exported_h;
  197.     drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
  198.    
  199. /* Counters for aging textures and for client-side throttling.
  200.  */
  201.         unsigned int last_enqueue; /* last time a buffer was enqueued */
  202. unsigned int last_dispatch; /* age of the most recently dispatched buffer */
  203. unsigned int last_quiescent;     /*  */
  204. /* LRU lists for texture memory in agp space and on the card
  205.  */
  206. drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
  207. unsigned int texAge[MGA_NR_TEX_HEAPS];
  208. /* Mechanism to validate card state.
  209.  */
  210.     int ctxOwner;
  211.     int vertexsize;
  212. } drm_mga_sarea_t;
  213. /* Device specific ioctls:
  214.  */
  215. typedef struct _drm_mga_clear {
  216. unsigned int clear_color;
  217. unsigned int clear_depth;
  218. unsigned int flags;
  219. unsigned int clear_depth_mask;
  220. unsigned int clear_color_mask;
  221. } drm_mga_clear_t;
  222. typedef struct _drm_mga_swap {
  223.     int dummy;
  224. } drm_mga_swap_t;
  225. typedef struct _drm_mga_iload {
  226. int idx;
  227. int length;
  228. unsigned int destOrg;
  229. } drm_mga_iload_t;
  230. typedef struct _drm_mga_vertex {
  231.     int idx; /* buffer to queue */
  232. int used; /* bytes in use */
  233. int discard; /* client finished with buffer?  */
  234. } drm_mga_vertex_t;
  235. typedef struct _drm_mga_indices {
  236.     int idx; /* buffer to queue */
  237. unsigned int start;
  238. unsigned int end;
  239. int discard; /* client finished with buffer?  */
  240. } drm_mga_indices_t;
  241. #endif