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. #ifndef __RADEON_DRM_H__
  31. #define __RADEON_DRM_H__
  32. /* WARNING: If you change any of these defines, make sure to change the
  33.  * defines in the X server file (radeon_sarea.h)
  34.  */
  35. #ifndef __RADEON_SAREA_DEFINES__
  36. #define __RADEON_SAREA_DEFINES__
  37. /* What needs to be changed for the current vertex buffer?
  38.  */
  39. #define RADEON_UPLOAD_CONTEXT 0x00000001
  40. #define RADEON_UPLOAD_VERTFMT 0x00000002
  41. #define RADEON_UPLOAD_LINE 0x00000004
  42. #define RADEON_UPLOAD_BUMPMAP 0x00000008
  43. #define RADEON_UPLOAD_MASKS 0x00000010
  44. #define RADEON_UPLOAD_VIEWPORT 0x00000020
  45. #define RADEON_UPLOAD_SETUP 0x00000040
  46. #define RADEON_UPLOAD_TCL 0x00000080
  47. #define RADEON_UPLOAD_MISC 0x00000100
  48. #define RADEON_UPLOAD_TEX0 0x00000200
  49. #define RADEON_UPLOAD_TEX1 0x00000400
  50. #define RADEON_UPLOAD_TEX2 0x00000800
  51. #define RADEON_UPLOAD_TEX0IMAGES 0x00001000
  52. #define RADEON_UPLOAD_TEX1IMAGES 0x00002000
  53. #define RADEON_UPLOAD_TEX2IMAGES 0x00004000
  54. #define RADEON_UPLOAD_CLIPRECTS 0x00008000 /* handled client-side */
  55. #define RADEON_REQUIRE_QUIESCENCE 0x00010000
  56. #define RADEON_UPLOAD_ALL 0x0001ffff
  57. #define RADEON_FRONT 0x1
  58. #define RADEON_BACK 0x2
  59. #define RADEON_DEPTH 0x4
  60. /* Primitive types
  61.  */
  62. #define RADEON_POINTS 0x1
  63. #define RADEON_LINES 0x2
  64. #define RADEON_LINE_STRIP 0x3
  65. #define RADEON_TRIANGLES 0x4
  66. #define RADEON_TRIANGLE_FAN 0x5
  67. #define RADEON_TRIANGLE_STRIP 0x6
  68. /* Vertex/indirect buffer size
  69.  */
  70. #define RADEON_BUFFER_SIZE 65536
  71. /* Byte offsets for indirect buffer data
  72.  */
  73. #define RADEON_INDEX_PRIM_OFFSET 20
  74. #define RADEON_HOSTDATA_BLIT_OFFSET 32
  75. #define RADEON_SCRATCH_REG_OFFSET 32
  76. /* Keep these small for testing
  77.  */
  78. #define RADEON_NR_SAREA_CLIPRECTS 12
  79. /* There are 2 heaps (local/AGP).  Each region within a heap is a
  80.  * minimum of 64k, and there are at most 64 of them per heap.
  81.  */
  82. #define RADEON_LOCAL_TEX_HEAP 0
  83. #define RADEON_AGP_TEX_HEAP 1
  84. #define RADEON_NR_TEX_HEAPS 2
  85. #define RADEON_NR_TEX_REGIONS 64
  86. #define RADEON_LOG_TEX_GRANULARITY 16
  87. #define RADEON_MAX_TEXTURE_LEVELS 11
  88. #define RADEON_MAX_TEXTURE_UNITS 3
  89. #endif /* __RADEON_SAREA_DEFINES__ */
  90. typedef struct {
  91. unsigned int red;
  92. unsigned int green;
  93. unsigned int blue;
  94. unsigned int alpha;
  95. } radeon_color_regs_t;
  96. typedef struct {
  97. /* Context state */
  98. unsigned int pp_misc; /* 0x1c14 */
  99. unsigned int pp_fog_color;
  100. unsigned int re_solid_color;
  101. unsigned int rb3d_blendcntl;
  102. unsigned int rb3d_depthoffset;
  103. unsigned int rb3d_depthpitch;
  104. unsigned int rb3d_zstencilcntl;
  105. unsigned int pp_cntl; /* 0x1c38 */
  106. unsigned int rb3d_cntl;
  107. unsigned int rb3d_coloroffset;
  108. unsigned int re_width_height;
  109. unsigned int rb3d_colorpitch;
  110. unsigned int se_cntl;
  111. /* Vertex format state */
  112. unsigned int se_coord_fmt; /* 0x1c50 */
  113. /* Line state */
  114. unsigned int re_line_pattern; /* 0x1cd0 */
  115. unsigned int re_line_state;
  116. unsigned int se_line_width; /* 0x1db8 */
  117. /* Bumpmap state */
  118. unsigned int pp_lum_matrix; /* 0x1d00 */
  119. unsigned int pp_rot_matrix_0; /* 0x1d58 */
  120. unsigned int pp_rot_matrix_1;
  121. /* Mask state */
  122. unsigned int rb3d_stencilrefmask; /* 0x1d7c */
  123. unsigned int rb3d_ropcntl;
  124. unsigned int rb3d_planemask;
  125. /* Viewport state */
  126. unsigned int se_vport_xscale; /* 0x1d98 */
  127. unsigned int se_vport_xoffset;
  128. unsigned int se_vport_yscale;
  129. unsigned int se_vport_yoffset;
  130. unsigned int se_vport_zscale;
  131. unsigned int se_vport_zoffset;
  132. /* Setup state */
  133. unsigned int se_cntl_status; /* 0x2140 */
  134. #ifdef TCL_ENABLE
  135. /* TCL state */
  136. radeon_color_regs_t se_tcl_material_emmissive; /* 0x2210 */
  137. radeon_color_regs_t se_tcl_material_ambient;
  138. radeon_color_regs_t se_tcl_material_diffuse;
  139. radeon_color_regs_t se_tcl_material_specular;
  140. unsigned int se_tcl_shininess;
  141. unsigned int se_tcl_output_vtx_fmt;
  142. unsigned int se_tcl_output_vtx_sel;
  143. unsigned int se_tcl_matrix_select_0;
  144. unsigned int se_tcl_matrix_select_1;
  145. unsigned int se_tcl_ucp_vert_blend_ctl;
  146. unsigned int se_tcl_texture_proc_ctl;
  147. unsigned int se_tcl_light_model_ctl;
  148. unsigned int se_tcl_per_light_ctl[4];
  149. #endif
  150. /* Misc state */
  151. unsigned int re_top_left; /* 0x26c0 */
  152. unsigned int re_misc;
  153. } drm_radeon_context_regs_t;
  154. /* Setup registers for each texture unit
  155.  */
  156. typedef struct {
  157. unsigned int pp_txfilter;
  158. unsigned int pp_txformat;
  159. unsigned int pp_txoffset;
  160. unsigned int pp_txcblend;
  161. unsigned int pp_txablend;
  162. unsigned int pp_tfactor;
  163. unsigned int pp_border_color;
  164. #ifdef CUBIC_ENABLE
  165. unsigned int pp_cubic_faces;
  166. unsigned int pp_cubic_offset[5];
  167. #endif
  168. } drm_radeon_texture_regs_t;
  169. typedef struct {
  170. unsigned char next, prev;
  171. unsigned char in_use;
  172. int age;
  173. } drm_radeon_tex_region_t;
  174. typedef struct {
  175. /* The channel for communication of state information to the kernel
  176.  * on firing a vertex buffer.
  177.  */
  178. drm_radeon_context_regs_t context_state;
  179. drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS];
  180. unsigned int dirty;
  181. unsigned int vertsize;
  182. unsigned int vc_format;
  183. /* The current cliprects, or a subset thereof.
  184.  */
  185. drm_clip_rect_t boxes[RADEON_NR_SAREA_CLIPRECTS];
  186. unsigned int nbox;
  187. /* Counters for client-side throttling of rendering clients.
  188.  */
  189. unsigned int last_frame;
  190. unsigned int last_dispatch;
  191. unsigned int last_clear;
  192. drm_radeon_tex_region_t tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS+1];
  193. int tex_age[RADEON_NR_TEX_HEAPS];
  194. int ctx_owner;
  195. } drm_radeon_sarea_t;
  196. /* WARNING: If you change any of these defines, make sure to change the
  197.  * defines in the Xserver file (xf86drmRadeon.h)
  198.  */
  199. typedef struct drm_radeon_init {
  200. enum {
  201. RADEON_INIT_CP    = 0x01,
  202. RADEON_CLEANUP_CP = 0x02
  203. } func;
  204. unsigned long sarea_priv_offset;
  205. int is_pci;
  206. int cp_mode;
  207. int agp_size;
  208. int ring_size;
  209. int usec_timeout;
  210. unsigned int fb_bpp;
  211. unsigned int front_offset, front_pitch;
  212. unsigned int back_offset, back_pitch;
  213. unsigned int depth_bpp;
  214. unsigned int depth_offset, depth_pitch;
  215. unsigned long fb_offset;
  216. unsigned long mmio_offset;
  217. unsigned long ring_offset;
  218. unsigned long ring_rptr_offset;
  219. unsigned long buffers_offset;
  220. unsigned long agp_textures_offset;
  221. } drm_radeon_init_t;
  222. typedef struct drm_radeon_cp_stop {
  223. int flush;
  224. int idle;
  225. } drm_radeon_cp_stop_t;
  226. typedef struct drm_radeon_fullscreen {
  227. enum {
  228. RADEON_INIT_FULLSCREEN    = 0x01,
  229. RADEON_CLEANUP_FULLSCREEN = 0x02
  230. } func;
  231. } drm_radeon_fullscreen_t;
  232. #define CLEAR_X1 0
  233. #define CLEAR_Y1 1
  234. #define CLEAR_X2 2
  235. #define CLEAR_Y2 3
  236. #define CLEAR_DEPTH 4
  237. typedef union drm_radeon_clear_rect {
  238. float f[5];
  239. unsigned int ui[5];
  240. } drm_radeon_clear_rect_t;
  241. typedef struct drm_radeon_clear {
  242. unsigned int flags;
  243. unsigned int clear_color;
  244. unsigned int clear_depth;
  245. unsigned int color_mask;
  246. unsigned int depth_mask;
  247. drm_radeon_clear_rect_t *depth_boxes;
  248. } drm_radeon_clear_t;
  249. typedef struct drm_radeon_vertex {
  250. int prim;
  251. int idx; /* Index of vertex buffer */
  252. int count; /* Number of vertices in buffer */
  253. int discard; /* Client finished with buffer? */
  254. } drm_radeon_vertex_t;
  255. typedef struct drm_radeon_indices {
  256. int prim;
  257. int idx;
  258. int start;
  259. int end;
  260. int discard; /* Client finished with buffer? */
  261. } drm_radeon_indices_t;
  262. typedef struct drm_radeon_tex_image {
  263. unsigned int x, y; /* Blit coordinates */
  264. unsigned int width, height;
  265. const void *data;
  266. } drm_radeon_tex_image_t;
  267. typedef struct drm_radeon_texture {
  268. int offset;
  269. int pitch;
  270. int format;
  271. int width; /* Texture image coordinates */
  272. int height;
  273. drm_radeon_tex_image_t *image;
  274. } drm_radeon_texture_t;
  275. typedef struct drm_radeon_stipple {
  276. unsigned int *mask;
  277. } drm_radeon_stipple_t;
  278. typedef struct drm_radeon_indirect {
  279. int idx;
  280. int start;
  281. int end;
  282. int discard;
  283. } drm_radeon_indirect_t;
  284. #endif