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

Linux/Unix编程

开发平台:

Unix_Linux

  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.  * All rights reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the "Software"),
  9.  * to deal in the Software without restriction, including without limitation
  10.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11.  * and/or sell copies of the Software, and to permit persons to whom the
  12.  * Software is furnished to do so, subject to the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the next
  15.  * paragraph) shall be included in all copies or substantial portions of the
  16.  * Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  21.  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  22.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24.  * DEALINGS IN THE SOFTWARE.
  25.  *
  26.  * Authors:
  27.  *    Kevin E. Martin <martin@valinux.com>
  28.  *    Gareth Hughes <gareth@valinux.com>
  29.  *
  30.  */
  31. #ifndef __RADEON_DRM_H__
  32. #define __RADEON_DRM_H__
  33. /* WARNING: If you change any of these defines, make sure to change the
  34.  * defines in the X server file (radeon_sarea.h)
  35.  */
  36. #ifndef __RADEON_SAREA_DEFINES__
  37. #define __RADEON_SAREA_DEFINES__
  38. /* What needs to be changed for the current vertex buffer?
  39.  */
  40. #define RADEON_UPLOAD_CONTEXT 0x00000001
  41. #define RADEON_UPLOAD_VERTFMT 0x00000002
  42. #define RADEON_UPLOAD_LINE 0x00000004
  43. #define RADEON_UPLOAD_BUMPMAP 0x00000008
  44. #define RADEON_UPLOAD_MASKS 0x00000010
  45. #define RADEON_UPLOAD_VIEWPORT 0x00000020
  46. #define RADEON_UPLOAD_SETUP 0x00000040
  47. #define RADEON_UPLOAD_TCL 0x00000080
  48. #define RADEON_UPLOAD_MISC 0x00000100
  49. #define RADEON_UPLOAD_TEX0 0x00000200
  50. #define RADEON_UPLOAD_TEX1 0x00000400
  51. #define RADEON_UPLOAD_TEX2 0x00000800
  52. #define RADEON_UPLOAD_TEX0IMAGES 0x00001000
  53. #define RADEON_UPLOAD_TEX1IMAGES 0x00002000
  54. #define RADEON_UPLOAD_TEX2IMAGES 0x00004000
  55. #define RADEON_UPLOAD_CLIPRECTS 0x00008000 /* handled client-side */
  56. #define RADEON_REQUIRE_QUIESCENCE 0x00010000
  57. #define RADEON_UPLOAD_ALL 0x0001ffff
  58. #define RADEON_FRONT 0x1
  59. #define RADEON_BACK 0x2
  60. #define RADEON_DEPTH 0x4
  61. /* Primitive types
  62.  */
  63. #define RADEON_POINTS 0x1
  64. #define RADEON_LINES 0x2
  65. #define RADEON_LINE_STRIP 0x3
  66. #define RADEON_TRIANGLES 0x4
  67. #define RADEON_TRIANGLE_FAN 0x5
  68. #define RADEON_TRIANGLE_STRIP 0x6
  69. /* Vertex/indirect buffer size
  70.  */
  71. #define RADEON_BUFFER_SIZE 16384
  72. /* Byte offsets for indirect buffer data
  73.  */
  74. #define RADEON_INDEX_PRIM_OFFSET 20
  75. #define RADEON_HOSTDATA_BLIT_OFFSET 32
  76. #define RADEON_SCRATCH_REG_OFFSET 32
  77. /* Keep these small for testing
  78.  */
  79. #define RADEON_NR_SAREA_CLIPRECTS 12
  80. /* There are 2 heaps (local/AGP).  Each region within a heap is a
  81.  * minimum of 64k, and there are at most 64 of them per heap.
  82.  */
  83. #define RADEON_LOCAL_TEX_HEAP 0
  84. #define RADEON_AGP_TEX_HEAP 1
  85. #define RADEON_NR_TEX_HEAPS 2
  86. #define RADEON_NR_TEX_REGIONS 64
  87. #define RADEON_LOG_TEX_GRANULARITY 16
  88. #define RADEON_MAX_TEXTURE_LEVELS 11
  89. #define RADEON_MAX_TEXTURE_UNITS 3
  90. #endif /* __RADEON_SAREA_DEFINES__ */
  91. typedef struct {
  92. unsigned int red;
  93. unsigned int green;
  94. unsigned int blue;
  95. unsigned int alpha;
  96. } radeon_color_regs_t;
  97. typedef struct {
  98. /* Context state */
  99. unsigned int pp_misc; /* 0x1c14 */
  100. unsigned int pp_fog_color;
  101. unsigned int re_solid_color;
  102. unsigned int rb3d_blendcntl;
  103. unsigned int rb3d_depthoffset;
  104. unsigned int rb3d_depthpitch;
  105. unsigned int rb3d_zstencilcntl;
  106. unsigned int pp_cntl; /* 0x1c38 */
  107. unsigned int rb3d_cntl;
  108. unsigned int rb3d_coloroffset;
  109. unsigned int re_width_height;
  110. unsigned int rb3d_colorpitch;
  111. unsigned int se_cntl;
  112. /* Vertex format state */
  113. unsigned int se_coord_fmt; /* 0x1c50 */
  114. /* Line state */
  115. unsigned int re_line_pattern; /* 0x1cd0 */
  116. unsigned int re_line_state;
  117. unsigned int se_line_width; /* 0x1db8 */
  118. /* Bumpmap state */
  119. unsigned int pp_lum_matrix; /* 0x1d00 */
  120. unsigned int pp_rot_matrix_0; /* 0x1d58 */
  121. unsigned int pp_rot_matrix_1;
  122. /* Mask state */
  123. unsigned int rb3d_stencilrefmask; /* 0x1d7c */
  124. unsigned int rb3d_ropcntl;
  125. unsigned int rb3d_planemask;
  126. /* Viewport state */
  127. unsigned int se_vport_xscale; /* 0x1d98 */
  128. unsigned int se_vport_xoffset;
  129. unsigned int se_vport_yscale;
  130. unsigned int se_vport_yoffset;
  131. unsigned int se_vport_zscale;
  132. unsigned int se_vport_zoffset;
  133. /* Setup state */
  134. unsigned int se_cntl_status; /* 0x2140 */
  135. #ifdef TCL_ENABLE
  136. /* TCL state */
  137. radeon_color_regs_t se_tcl_material_emmissive; /* 0x2210 */
  138. radeon_color_regs_t se_tcl_material_ambient;
  139. radeon_color_regs_t se_tcl_material_diffuse;
  140. radeon_color_regs_t se_tcl_material_specular;
  141. unsigned int se_tcl_shininess;
  142. unsigned int se_tcl_output_vtx_fmt;
  143. unsigned int se_tcl_output_vtx_sel;
  144. unsigned int se_tcl_matrix_select_0;
  145. unsigned int se_tcl_matrix_select_1;
  146. unsigned int se_tcl_ucp_vert_blend_ctl;
  147. unsigned int se_tcl_texture_proc_ctl;
  148. unsigned int se_tcl_light_model_ctl;
  149. unsigned int se_tcl_per_light_ctl[4];
  150. #endif
  151. /* Misc state */
  152. unsigned int re_top_left; /* 0x26c0 */
  153. unsigned int re_misc;
  154. } drm_radeon_context_regs_t;
  155. /* Setup registers for each texture unit
  156.  */
  157. typedef struct {
  158. unsigned int pp_txfilter;
  159. unsigned int pp_txformat;
  160. unsigned int pp_txoffset;
  161. unsigned int pp_txcblend;
  162. unsigned int pp_txablend;
  163. unsigned int pp_tfactor;
  164. unsigned int pp_border_color;
  165. #ifdef CUBIC_ENABLE
  166. unsigned int pp_cubic_faces;
  167. unsigned int pp_cubic_offset[5];
  168. #endif
  169. } drm_radeon_texture_regs_t;
  170. typedef struct {
  171. unsigned char next, prev;
  172. unsigned char in_use;
  173. int age;
  174. } drm_radeon_tex_region_t;
  175. typedef struct {
  176. /* The channel for communication of state information to the kernel
  177.  * on firing a vertex buffer.
  178.  */
  179. drm_radeon_context_regs_t context_state;
  180. drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS];
  181. unsigned int dirty;
  182. unsigned int vertsize;
  183. unsigned int vc_format;
  184. /* The current cliprects, or a subset thereof.
  185.  */
  186. drm_clip_rect_t boxes[RADEON_NR_SAREA_CLIPRECTS];
  187. unsigned int nbox;
  188. /* Counters for client-side throttling of rendering clients.
  189.  */
  190. unsigned int last_frame;
  191. unsigned int last_dispatch;
  192. unsigned int last_clear;
  193. drm_radeon_tex_region_t tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS+1];
  194. int tex_age[RADEON_NR_TEX_HEAPS];
  195. int ctx_owner;
  196. } drm_radeon_sarea_t;
  197. /* WARNING: If you change any of these defines, make sure to change the
  198.  * defines in the Xserver file (xf86drmRadeon.h)
  199.  */
  200. typedef struct drm_radeon_init {
  201. enum {
  202. RADEON_INIT_CP    = 0x01,
  203. RADEON_CLEANUP_CP = 0x02
  204. } func;
  205. int sarea_priv_offset;
  206. int is_pci;
  207. int cp_mode;
  208. int agp_size;
  209. int ring_size;
  210. int usec_timeout;
  211. unsigned int fb_bpp;
  212. unsigned int front_offset, front_pitch;
  213. unsigned int back_offset, back_pitch;
  214. unsigned int depth_bpp;
  215. unsigned int depth_offset, depth_pitch;
  216. unsigned int fb_offset;
  217. unsigned int mmio_offset;
  218. unsigned int ring_offset;
  219. unsigned int ring_rptr_offset;
  220. unsigned int buffers_offset;
  221. unsigned int agp_textures_offset;
  222. } drm_radeon_init_t;
  223. typedef struct drm_radeon_cp_stop {
  224. int flush;
  225. int idle;
  226. } drm_radeon_cp_stop_t;
  227. typedef struct drm_radeon_fullscreen {
  228. enum {
  229. RADEON_INIT_FULLSCREEN    = 0x01,
  230. RADEON_CLEANUP_FULLSCREEN = 0x02
  231. } func;
  232. } drm_radeon_fullscreen_t;
  233. #define CLEAR_X1 0
  234. #define CLEAR_Y1 1
  235. #define CLEAR_X2 2
  236. #define CLEAR_Y2 3
  237. #define CLEAR_DEPTH 4
  238. typedef struct drm_radeon_clear {
  239. unsigned int flags;
  240. int x, y, w, h;
  241. unsigned int clear_color;
  242. unsigned int clear_depth;
  243. union {
  244. float f[5];
  245. unsigned int ui[5];
  246. } rect;
  247. } drm_radeon_clear_t;
  248. typedef struct drm_radeon_vertex {
  249. int prim;
  250. int idx; /* Index of vertex buffer */
  251. int count; /* Number of vertices in buffer */
  252. int discard; /* Client finished with buffer? */
  253. } drm_radeon_vertex_t;
  254. typedef struct drm_radeon_indices {
  255. int prim;
  256. int idx;
  257. int start;
  258. int end;
  259. int discard; /* Client finished with buffer? */
  260. } drm_radeon_indices_t;
  261. typedef struct drm_radeon_blit {
  262. int idx;
  263. int pitch;
  264. int offset;
  265. int format;
  266. unsigned short x, y;
  267. unsigned short width, height;
  268. } drm_radeon_blit_t;
  269. typedef struct drm_radeon_stipple {
  270. unsigned int *mask;
  271. } drm_radeon_stipple_t;
  272. typedef struct drm_radeon_indirect {
  273. int idx;
  274. int start;
  275. int end;
  276. int discard;
  277. } drm_radeon_indirect_t;
  278. #endif