r128_drm.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
  2. * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
  3. */
  4. /*
  5. * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
  6. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  7. * All rights reserved.
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a
  10. * copy of this software and associated documentation files (the "Software"),
  11. * to deal in the Software without restriction, including without limitation
  12. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. * and/or sell copies of the Software, and to permit persons to whom the
  14. * Software is furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the next
  17. * paragraph) shall be included in all copies or substantial portions of the
  18. * Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  23. * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  24. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  25. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  26. * DEALINGS IN THE SOFTWARE.
  27. *
  28. * Authors:
  29. * Gareth Hughes <gareth@valinux.com>
  30. * Kevin E. Martin <martin@valinux.com>
  31. */
  32. #ifndef __R128_DRM_H__
  33. #define __R128_DRM_H__
  34. #include "drm.h"
  35. #if defined(__cplusplus)
  36. extern "C" {
  37. #endif
  38. /* WARNING: If you change any of these defines, make sure to change the
  39. * defines in the X server file (r128_sarea.h)
  40. */
  41. #ifndef __R128_SAREA_DEFINES__
  42. #define __R128_SAREA_DEFINES__
  43. /* What needs to be changed for the current vertex buffer?
  44. */
  45. #define R128_UPLOAD_CONTEXT 0x001
  46. #define R128_UPLOAD_SETUP 0x002
  47. #define R128_UPLOAD_TEX0 0x004
  48. #define R128_UPLOAD_TEX1 0x008
  49. #define R128_UPLOAD_TEX0IMAGES 0x010
  50. #define R128_UPLOAD_TEX1IMAGES 0x020
  51. #define R128_UPLOAD_CORE 0x040
  52. #define R128_UPLOAD_MASKS 0x080
  53. #define R128_UPLOAD_WINDOW 0x100
  54. #define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
  55. #define R128_REQUIRE_QUIESCENCE 0x400
  56. #define R128_UPLOAD_ALL 0x7ff
  57. #define R128_FRONT 0x1
  58. #define R128_BACK 0x2
  59. #define R128_DEPTH 0x4
  60. /* Primitive types
  61. */
  62. #define R128_POINTS 0x1
  63. #define R128_LINES 0x2
  64. #define R128_LINE_STRIP 0x3
  65. #define R128_TRIANGLES 0x4
  66. #define R128_TRIANGLE_FAN 0x5
  67. #define R128_TRIANGLE_STRIP 0x6
  68. /* Vertex/indirect buffer size
  69. */
  70. #define R128_BUFFER_SIZE 16384
  71. /* Byte offsets for indirect buffer data
  72. */
  73. #define R128_INDEX_PRIM_OFFSET 20
  74. #define R128_HOSTDATA_BLIT_OFFSET 32
  75. /* Keep these small for testing.
  76. */
  77. #define R128_NR_SAREA_CLIPRECTS 12
  78. /* There are 2 heaps (local/AGP). Each region within a heap is a
  79. * minimum of 64k, and there are at most 64 of them per heap.
  80. */
  81. #define R128_LOCAL_TEX_HEAP 0
  82. #define R128_AGP_TEX_HEAP 1
  83. #define R128_NR_TEX_HEAPS 2
  84. #define R128_NR_TEX_REGIONS 64
  85. #define R128_LOG_TEX_GRANULARITY 16
  86. #define R128_NR_CONTEXT_REGS 12
  87. #define R128_MAX_TEXTURE_LEVELS 11
  88. #define R128_MAX_TEXTURE_UNITS 2
  89. #endif /* __R128_SAREA_DEFINES__ */
  90. typedef struct {
  91. /* Context state - can be written in one large chunk */
  92. unsigned int dst_pitch_offset_c;
  93. unsigned int dp_gui_master_cntl_c;
  94. unsigned int sc_top_left_c;
  95. unsigned int sc_bottom_right_c;
  96. unsigned int z_offset_c;
  97. unsigned int z_pitch_c;
  98. unsigned int z_sten_cntl_c;
  99. unsigned int tex_cntl_c;
  100. unsigned int misc_3d_state_cntl_reg;
  101. unsigned int texture_clr_cmp_clr_c;
  102. unsigned int texture_clr_cmp_msk_c;
  103. unsigned int fog_color_c;
  104. /* Texture state */
  105. unsigned int tex_size_pitch_c;
  106. unsigned int constant_color_c;
  107. /* Setup state */
  108. unsigned int pm4_vc_fpu_setup;
  109. unsigned int setup_cntl;
  110. /* Mask state */
  111. unsigned int dp_write_mask;
  112. unsigned int sten_ref_mask_c;
  113. unsigned int plane_3d_mask_c;
  114. /* Window state */
  115. unsigned int window_xy_offset;
  116. /* Core state */
  117. unsigned int scale_3d_cntl;
  118. } drm_r128_context_regs_t;
  119. /* Setup registers for each texture unit
  120. */
  121. typedef struct {
  122. unsigned int tex_cntl;
  123. unsigned int tex_combine_cntl;
  124. unsigned int tex_size_pitch;
  125. unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
  126. unsigned int tex_border_color;
  127. } drm_r128_texture_regs_t;
  128. typedef struct drm_r128_sarea {
  129. /* The channel for communication of state information to the kernel
  130. * on firing a vertex buffer.
  131. */
  132. drm_r128_context_regs_t context_state;
  133. drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
  134. unsigned int dirty;
  135. unsigned int vertsize;
  136. unsigned int vc_format;
  137. /* The current cliprects, or a subset thereof.
  138. */
  139. struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS];
  140. unsigned int nbox;
  141. /* Counters for client-side throttling of rendering clients.
  142. */
  143. unsigned int last_frame;
  144. unsigned int last_dispatch;
  145. struct drm_tex_region tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS + 1];
  146. unsigned int tex_age[R128_NR_TEX_HEAPS];
  147. int ctx_owner;
  148. int pfAllowPageFlip; /* number of 3d windows (0,1,2 or more) */
  149. int pfCurrentPage; /* which buffer is being displayed? */
  150. } drm_r128_sarea_t;
  151. /* WARNING: If you change any of these defines, make sure to change the
  152. * defines in the Xserver file (xf86drmR128.h)
  153. */
  154. /* Rage 128 specific ioctls
  155. * The device specific ioctl range is 0x40 to 0x79.
  156. */
  157. #define DRM_R128_INIT 0x00
  158. #define DRM_R128_CCE_START 0x01
  159. #define DRM_R128_CCE_STOP 0x02
  160. #define DRM_R128_CCE_RESET 0x03
  161. #define DRM_R128_CCE_IDLE 0x04
  162. /* 0x05 not used */
  163. #define DRM_R128_RESET 0x06
  164. #define DRM_R128_SWAP 0x07
  165. #define DRM_R128_CLEAR 0x08
  166. #define DRM_R128_VERTEX 0x09
  167. #define DRM_R128_INDICES 0x0a
  168. #define DRM_R128_BLIT 0x0b
  169. #define DRM_R128_DEPTH 0x0c
  170. #define DRM_R128_STIPPLE 0x0d
  171. /* 0x0e not used */
  172. #define DRM_R128_INDIRECT 0x0f
  173. #define DRM_R128_FULLSCREEN 0x10
  174. #define DRM_R128_CLEAR2 0x11
  175. #define DRM_R128_GETPARAM 0x12
  176. #define DRM_R128_FLIP 0x13
  177. #define DRM_IOCTL_R128_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INIT, drm_r128_init_t)
  178. #define DRM_IOCTL_R128_CCE_START DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_START)
  179. #define DRM_IOCTL_R128_CCE_STOP DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CCE_STOP, drm_r128_cce_stop_t)
  180. #define DRM_IOCTL_R128_CCE_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_RESET)
  181. #define DRM_IOCTL_R128_CCE_IDLE DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_IDLE)
  182. /* 0x05 not used */
  183. #define DRM_IOCTL_R128_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_RESET)
  184. #define DRM_IOCTL_R128_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_R128_SWAP)
  185. #define DRM_IOCTL_R128_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR, drm_r128_clear_t)
  186. #define DRM_IOCTL_R128_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_R128_VERTEX, drm_r128_vertex_t)
  187. #define DRM_IOCTL_R128_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INDICES, drm_r128_indices_t)
  188. #define DRM_IOCTL_R128_BLIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_BLIT, drm_r128_blit_t)
  189. #define DRM_IOCTL_R128_DEPTH DRM_IOW( DRM_COMMAND_BASE + DRM_R128_DEPTH, drm_r128_depth_t)
  190. #define DRM_IOCTL_R128_STIPPLE DRM_IOW( DRM_COMMAND_BASE + DRM_R128_STIPPLE, drm_r128_stipple_t)
  191. /* 0x0e not used */
  192. #define DRM_IOCTL_R128_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_INDIRECT, drm_r128_indirect_t)
  193. #define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_R128_FULLSCREEN, drm_r128_fullscreen_t)
  194. #define DRM_IOCTL_R128_CLEAR2 DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR2, drm_r128_clear2_t)
  195. #define DRM_IOCTL_R128_GETPARAM DRM_IOWR( DRM_COMMAND_BASE + DRM_R128_GETPARAM, drm_r128_getparam_t)
  196. #define DRM_IOCTL_R128_FLIP DRM_IO( DRM_COMMAND_BASE + DRM_R128_FLIP)
  197. typedef struct drm_r128_init {
  198. enum {
  199. R128_INIT_CCE = 0x01,
  200. R128_CLEANUP_CCE = 0x02
  201. } func;
  202. unsigned long sarea_priv_offset;
  203. int is_pci;
  204. int cce_mode;
  205. int cce_secure;
  206. int ring_size;
  207. int usec_timeout;
  208. unsigned int fb_bpp;
  209. unsigned int front_offset, front_pitch;
  210. unsigned int back_offset, back_pitch;
  211. unsigned int depth_bpp;
  212. unsigned int depth_offset, depth_pitch;
  213. unsigned int span_offset;
  214. unsigned long fb_offset;
  215. unsigned long mmio_offset;
  216. unsigned long ring_offset;
  217. unsigned long ring_rptr_offset;
  218. unsigned long buffers_offset;
  219. unsigned long agp_textures_offset;
  220. } drm_r128_init_t;
  221. typedef struct drm_r128_cce_stop {
  222. int flush;
  223. int idle;
  224. } drm_r128_cce_stop_t;
  225. typedef struct drm_r128_clear {
  226. unsigned int flags;
  227. unsigned int clear_color;
  228. unsigned int clear_depth;
  229. unsigned int color_mask;
  230. unsigned int depth_mask;
  231. } drm_r128_clear_t;
  232. typedef struct drm_r128_vertex {
  233. int prim;
  234. int idx; /* Index of vertex buffer */
  235. int count; /* Number of vertices in buffer */
  236. int discard; /* Client finished with buffer? */
  237. } drm_r128_vertex_t;
  238. typedef struct drm_r128_indices {
  239. int prim;
  240. int idx;
  241. int start;
  242. int end;
  243. int discard; /* Client finished with buffer? */
  244. } drm_r128_indices_t;
  245. typedef struct drm_r128_blit {
  246. int idx;
  247. int pitch;
  248. int offset;
  249. int format;
  250. unsigned short x, y;
  251. unsigned short width, height;
  252. } drm_r128_blit_t;
  253. typedef struct drm_r128_depth {
  254. enum {
  255. R128_WRITE_SPAN = 0x01,
  256. R128_WRITE_PIXELS = 0x02,
  257. R128_READ_SPAN = 0x03,
  258. R128_READ_PIXELS = 0x04
  259. } func;
  260. int n;
  261. int *x;
  262. int *y;
  263. unsigned int *buffer;
  264. unsigned char *mask;
  265. } drm_r128_depth_t;
  266. typedef struct drm_r128_stipple {
  267. unsigned int *mask;
  268. } drm_r128_stipple_t;
  269. typedef struct drm_r128_indirect {
  270. int idx;
  271. int start;
  272. int end;
  273. int discard;
  274. } drm_r128_indirect_t;
  275. typedef struct drm_r128_fullscreen {
  276. enum {
  277. R128_INIT_FULLSCREEN = 0x01,
  278. R128_CLEANUP_FULLSCREEN = 0x02
  279. } func;
  280. } drm_r128_fullscreen_t;
  281. /* 2.3: An ioctl to get parameters that aren't available to the 3d
  282. * client any other way.
  283. */
  284. #define R128_PARAM_IRQ_NR 1
  285. typedef struct drm_r128_getparam {
  286. int param;
  287. void *value;
  288. } drm_r128_getparam_t;
  289. #if defined(__cplusplus)
  290. }
  291. #endif
  292. #endif