r128_drm.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. /* WARNING: If you change any of these defines, make sure to change the
  35. * defines in the X server file (r128_sarea.h)
  36. */
  37. #ifndef __R128_SAREA_DEFINES__
  38. #define __R128_SAREA_DEFINES__
  39. /* What needs to be changed for the current vertex buffer?
  40. */
  41. #define R128_UPLOAD_CONTEXT 0x001
  42. #define R128_UPLOAD_SETUP 0x002
  43. #define R128_UPLOAD_TEX0 0x004
  44. #define R128_UPLOAD_TEX1 0x008
  45. #define R128_UPLOAD_TEX0IMAGES 0x010
  46. #define R128_UPLOAD_TEX1IMAGES 0x020
  47. #define R128_UPLOAD_CORE 0x040
  48. #define R128_UPLOAD_MASKS 0x080
  49. #define R128_UPLOAD_WINDOW 0x100
  50. #define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
  51. #define R128_REQUIRE_QUIESCENCE 0x400
  52. #define R128_UPLOAD_ALL 0x7ff
  53. #define R128_FRONT 0x1
  54. #define R128_BACK 0x2
  55. #define R128_DEPTH 0x4
  56. /* Primitive types
  57. */
  58. #define R128_POINTS 0x1
  59. #define R128_LINES 0x2
  60. #define R128_LINE_STRIP 0x3
  61. #define R128_TRIANGLES 0x4
  62. #define R128_TRIANGLE_FAN 0x5
  63. #define R128_TRIANGLE_STRIP 0x6
  64. /* Vertex/indirect buffer size
  65. */
  66. #define R128_BUFFER_SIZE 16384
  67. /* Byte offsets for indirect buffer data
  68. */
  69. #define R128_INDEX_PRIM_OFFSET 20
  70. #define R128_HOSTDATA_BLIT_OFFSET 32
  71. /* Keep these small for testing.
  72. */
  73. #define R128_NR_SAREA_CLIPRECTS 12
  74. /* There are 2 heaps (local/AGP). Each region within a heap is a
  75. * minimum of 64k, and there are at most 64 of them per heap.
  76. */
  77. #define R128_LOCAL_TEX_HEAP 0
  78. #define R128_AGP_TEX_HEAP 1
  79. #define R128_NR_TEX_HEAPS 2
  80. #define R128_NR_TEX_REGIONS 64
  81. #define R128_LOG_TEX_GRANULARITY 16
  82. #define R128_NR_CONTEXT_REGS 12
  83. #define R128_MAX_TEXTURE_LEVELS 11
  84. #define R128_MAX_TEXTURE_UNITS 2
  85. #endif /* __R128_SAREA_DEFINES__ */
  86. typedef struct {
  87. /* Context state - can be written in one large chunk */
  88. unsigned int dst_pitch_offset_c;
  89. unsigned int dp_gui_master_cntl_c;
  90. unsigned int sc_top_left_c;
  91. unsigned int sc_bottom_right_c;
  92. unsigned int z_offset_c;
  93. unsigned int z_pitch_c;
  94. unsigned int z_sten_cntl_c;
  95. unsigned int tex_cntl_c;
  96. unsigned int misc_3d_state_cntl_reg;
  97. unsigned int texture_clr_cmp_clr_c;
  98. unsigned int texture_clr_cmp_msk_c;
  99. unsigned int fog_color_c;
  100. /* Texture state */
  101. unsigned int tex_size_pitch_c;
  102. unsigned int constant_color_c;
  103. /* Setup state */
  104. unsigned int pm4_vc_fpu_setup;
  105. unsigned int setup_cntl;
  106. /* Mask state */
  107. unsigned int dp_write_mask;
  108. unsigned int sten_ref_mask_c;
  109. unsigned int plane_3d_mask_c;
  110. /* Window state */
  111. unsigned int window_xy_offset;
  112. /* Core state */
  113. unsigned int scale_3d_cntl;
  114. } drm_r128_context_regs_t;
  115. /* Setup registers for each texture unit
  116. */
  117. typedef struct {
  118. unsigned int tex_cntl;
  119. unsigned int tex_combine_cntl;
  120. unsigned int tex_size_pitch;
  121. unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
  122. unsigned int tex_border_color;
  123. } drm_r128_texture_regs_t;
  124. typedef struct drm_r128_sarea {
  125. /* The channel for communication of state information to the kernel
  126. * on firing a vertex buffer.
  127. */
  128. drm_r128_context_regs_t context_state;
  129. drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
  130. unsigned int dirty;
  131. unsigned int vertsize;
  132. unsigned int vc_format;
  133. /* The current cliprects, or a subset thereof.
  134. */
  135. struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS];
  136. unsigned int nbox;
  137. /* Counters for client-side throttling of rendering clients.
  138. */
  139. unsigned int last_frame;
  140. unsigned int last_dispatch;
  141. struct drm_tex_region tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS + 1];
  142. unsigned int tex_age[R128_NR_TEX_HEAPS];
  143. int ctx_owner;
  144. int pfAllowPageFlip; /* number of 3d windows (0,1,2 or more) */
  145. int pfCurrentPage; /* which buffer is being displayed? */
  146. } drm_r128_sarea_t;
  147. /* WARNING: If you change any of these defines, make sure to change the
  148. * defines in the Xserver file (xf86drmR128.h)
  149. */
  150. /* Rage 128 specific ioctls
  151. * The device specific ioctl range is 0x40 to 0x79.
  152. */
  153. #define DRM_R128_INIT 0x00
  154. #define DRM_R128_CCE_START 0x01
  155. #define DRM_R128_CCE_STOP 0x02
  156. #define DRM_R128_CCE_RESET 0x03
  157. #define DRM_R128_CCE_IDLE 0x04
  158. /* 0x05 not used */
  159. #define DRM_R128_RESET 0x06
  160. #define DRM_R128_SWAP 0x07
  161. #define DRM_R128_CLEAR 0x08
  162. #define DRM_R128_VERTEX 0x09
  163. #define DRM_R128_INDICES 0x0a
  164. #define DRM_R128_BLIT 0x0b
  165. #define DRM_R128_DEPTH 0x0c
  166. #define DRM_R128_STIPPLE 0x0d
  167. /* 0x0e not used */
  168. #define DRM_R128_INDIRECT 0x0f
  169. #define DRM_R128_FULLSCREEN 0x10
  170. #define DRM_R128_CLEAR2 0x11
  171. #define DRM_R128_GETPARAM 0x12
  172. #define DRM_R128_FLIP 0x13
  173. #define DRM_IOCTL_R128_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INIT, drm_r128_init_t)
  174. #define DRM_IOCTL_R128_CCE_START DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_START)
  175. #define DRM_IOCTL_R128_CCE_STOP DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CCE_STOP, drm_r128_cce_stop_t)
  176. #define DRM_IOCTL_R128_CCE_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_RESET)
  177. #define DRM_IOCTL_R128_CCE_IDLE DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_IDLE)
  178. /* 0x05 not used */
  179. #define DRM_IOCTL_R128_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_RESET)
  180. #define DRM_IOCTL_R128_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_R128_SWAP)
  181. #define DRM_IOCTL_R128_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR, drm_r128_clear_t)
  182. #define DRM_IOCTL_R128_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_R128_VERTEX, drm_r128_vertex_t)
  183. #define DRM_IOCTL_R128_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INDICES, drm_r128_indices_t)
  184. #define DRM_IOCTL_R128_BLIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_BLIT, drm_r128_blit_t)
  185. #define DRM_IOCTL_R128_DEPTH DRM_IOW( DRM_COMMAND_BASE + DRM_R128_DEPTH, drm_r128_depth_t)
  186. #define DRM_IOCTL_R128_STIPPLE DRM_IOW( DRM_COMMAND_BASE + DRM_R128_STIPPLE, drm_r128_stipple_t)
  187. /* 0x0e not used */
  188. #define DRM_IOCTL_R128_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_INDIRECT, drm_r128_indirect_t)
  189. #define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_R128_FULLSCREEN, drm_r128_fullscreen_t)
  190. #define DRM_IOCTL_R128_CLEAR2 DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR2, drm_r128_clear2_t)
  191. #define DRM_IOCTL_R128_GETPARAM DRM_IOWR( DRM_COMMAND_BASE + DRM_R128_GETPARAM, drm_r128_getparam_t)
  192. #define DRM_IOCTL_R128_FLIP DRM_IO( DRM_COMMAND_BASE + DRM_R128_FLIP)
  193. typedef struct drm_r128_init {
  194. enum {
  195. R128_INIT_CCE = 0x01,
  196. R128_CLEANUP_CCE = 0x02
  197. } func;
  198. unsigned long sarea_priv_offset;
  199. int is_pci;
  200. int cce_mode;
  201. int cce_secure;
  202. int ring_size;
  203. int usec_timeout;
  204. unsigned int fb_bpp;
  205. unsigned int front_offset, front_pitch;
  206. unsigned int back_offset, back_pitch;
  207. unsigned int depth_bpp;
  208. unsigned int depth_offset, depth_pitch;
  209. unsigned int span_offset;
  210. unsigned long fb_offset;
  211. unsigned long mmio_offset;
  212. unsigned long ring_offset;
  213. unsigned long ring_rptr_offset;
  214. unsigned long buffers_offset;
  215. unsigned long agp_textures_offset;
  216. } drm_r128_init_t;
  217. typedef struct drm_r128_cce_stop {
  218. int flush;
  219. int idle;
  220. } drm_r128_cce_stop_t;
  221. typedef struct drm_r128_clear {
  222. unsigned int flags;
  223. unsigned int clear_color;
  224. unsigned int clear_depth;
  225. unsigned int color_mask;
  226. unsigned int depth_mask;
  227. } drm_r128_clear_t;
  228. typedef struct drm_r128_vertex {
  229. int prim;
  230. int idx; /* Index of vertex buffer */
  231. int count; /* Number of vertices in buffer */
  232. int discard; /* Client finished with buffer? */
  233. } drm_r128_vertex_t;
  234. typedef struct drm_r128_indices {
  235. int prim;
  236. int idx;
  237. int start;
  238. int end;
  239. int discard; /* Client finished with buffer? */
  240. } drm_r128_indices_t;
  241. typedef struct drm_r128_blit {
  242. int idx;
  243. int pitch;
  244. int offset;
  245. int format;
  246. unsigned short x, y;
  247. unsigned short width, height;
  248. } drm_r128_blit_t;
  249. typedef struct drm_r128_depth {
  250. enum {
  251. R128_WRITE_SPAN = 0x01,
  252. R128_WRITE_PIXELS = 0x02,
  253. R128_READ_SPAN = 0x03,
  254. R128_READ_PIXELS = 0x04
  255. } func;
  256. int n;
  257. int __user *x;
  258. int __user *y;
  259. unsigned int __user *buffer;
  260. unsigned char __user *mask;
  261. } drm_r128_depth_t;
  262. typedef struct drm_r128_stipple {
  263. unsigned int __user *mask;
  264. } drm_r128_stipple_t;
  265. typedef struct drm_r128_indirect {
  266. int idx;
  267. int start;
  268. int end;
  269. int discard;
  270. } drm_r128_indirect_t;
  271. typedef struct drm_r128_fullscreen {
  272. enum {
  273. R128_INIT_FULLSCREEN = 0x01,
  274. R128_CLEANUP_FULLSCREEN = 0x02
  275. } func;
  276. } drm_r128_fullscreen_t;
  277. /* 2.3: An ioctl to get parameters that aren't available to the 3d
  278. * client any other way.
  279. */
  280. #define R128_PARAM_IRQ_NR 1
  281. typedef struct drm_r128_getparam {
  282. int param;
  283. void __user *value;
  284. } drm_r128_getparam_t;
  285. #endif