savage_drm.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /* savage_drm.h -- Public header for the savage driver
  2. *
  3. * Copyright 2004 Felix Kuehling
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sub license,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial portions
  15. * of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR
  21. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  22. * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef __SAVAGE_DRM_H__
  26. #define __SAVAGE_DRM_H__
  27. #include <drm/drm.h>
  28. #ifndef __SAVAGE_SAREA_DEFINES__
  29. #define __SAVAGE_SAREA_DEFINES__
  30. /* 2 heaps (1 for card, 1 for agp), each divided into up to 128
  31. * regions, subject to a minimum region size of (1<<16) == 64k.
  32. *
  33. * Clients may subdivide regions internally, but when sharing between
  34. * clients, the region size is the minimum granularity.
  35. */
  36. #define SAVAGE_CARD_HEAP 0
  37. #define SAVAGE_AGP_HEAP 1
  38. #define SAVAGE_NR_TEX_HEAPS 2
  39. #define SAVAGE_NR_TEX_REGIONS 16
  40. #define SAVAGE_LOG_MIN_TEX_REGION_SIZE 16
  41. #endif /* __SAVAGE_SAREA_DEFINES__ */
  42. typedef struct _drm_savage_sarea {
  43. /* LRU lists for texture memory in agp space and on the card.
  44. */
  45. struct drm_tex_region texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS +
  46. 1];
  47. unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
  48. /* Mechanism to validate card state.
  49. */
  50. int ctxOwner;
  51. } drm_savage_sarea_t, *drm_savage_sarea_ptr;
  52. /* Savage-specific ioctls
  53. */
  54. #define DRM_SAVAGE_BCI_INIT 0x00
  55. #define DRM_SAVAGE_BCI_CMDBUF 0x01
  56. #define DRM_SAVAGE_BCI_EVENT_EMIT 0x02
  57. #define DRM_SAVAGE_BCI_EVENT_WAIT 0x03
  58. #define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_INIT, drm_savage_init_t)
  59. #define DRM_IOCTL_SAVAGE_BCI_CMDBUF DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_CMDBUF, drm_savage_cmdbuf_t)
  60. #define DRM_IOCTL_SAVAGE_BCI_EVENT_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_EMIT, drm_savage_event_emit_t)
  61. #define DRM_IOCTL_SAVAGE_BCI_EVENT_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_WAIT, drm_savage_event_wait_t)
  62. #define SAVAGE_DMA_PCI 1
  63. #define SAVAGE_DMA_AGP 3
  64. typedef struct drm_savage_init {
  65. enum {
  66. SAVAGE_INIT_BCI = 1,
  67. SAVAGE_CLEANUP_BCI = 2
  68. } func;
  69. unsigned int sarea_priv_offset;
  70. /* some parameters */
  71. unsigned int cob_size;
  72. unsigned int bci_threshold_lo, bci_threshold_hi;
  73. unsigned int dma_type;
  74. /* frame buffer layout */
  75. unsigned int fb_bpp;
  76. unsigned int front_offset, front_pitch;
  77. unsigned int back_offset, back_pitch;
  78. unsigned int depth_bpp;
  79. unsigned int depth_offset, depth_pitch;
  80. /* local textures */
  81. unsigned int texture_offset;
  82. unsigned int texture_size;
  83. /* physical locations of non-permanent maps */
  84. unsigned long status_offset;
  85. unsigned long buffers_offset;
  86. unsigned long agp_textures_offset;
  87. unsigned long cmd_dma_offset;
  88. } drm_savage_init_t;
  89. typedef union drm_savage_cmd_header drm_savage_cmd_header_t;
  90. typedef struct drm_savage_cmdbuf {
  91. /* command buffer in client's address space */
  92. drm_savage_cmd_header_t *cmd_addr;
  93. unsigned int size; /* size of the command buffer in 64bit units */
  94. unsigned int dma_idx; /* DMA buffer index to use */
  95. int discard; /* discard DMA buffer when done */
  96. /* vertex buffer in client's address space */
  97. unsigned int *vb_addr;
  98. unsigned int vb_size; /* size of client vertex buffer in bytes */
  99. unsigned int vb_stride; /* stride of vertices in 32bit words */
  100. /* boxes in client's address space */
  101. struct drm_clip_rect *box_addr;
  102. unsigned int nbox; /* number of clipping boxes */
  103. } drm_savage_cmdbuf_t;
  104. #define SAVAGE_WAIT_2D 0x1 /* wait for 2D idle before updating event tag */
  105. #define SAVAGE_WAIT_3D 0x2 /* wait for 3D idle before updating event tag */
  106. #define SAVAGE_WAIT_IRQ 0x4 /* emit or wait for IRQ, not implemented yet */
  107. typedef struct drm_savage_event {
  108. unsigned int count;
  109. unsigned int flags;
  110. } drm_savage_event_emit_t, drm_savage_event_wait_t;
  111. /* Commands for the cmdbuf ioctl
  112. */
  113. #define SAVAGE_CMD_STATE 0 /* a range of state registers */
  114. #define SAVAGE_CMD_DMA_PRIM 1 /* vertices from DMA buffer */
  115. #define SAVAGE_CMD_VB_PRIM 2 /* vertices from client vertex buffer */
  116. #define SAVAGE_CMD_DMA_IDX 3 /* indexed vertices from DMA buffer */
  117. #define SAVAGE_CMD_VB_IDX 4 /* indexed vertices client vertex buffer */
  118. #define SAVAGE_CMD_CLEAR 5 /* clear buffers */
  119. #define SAVAGE_CMD_SWAP 6 /* swap buffers */
  120. /* Primitive types
  121. */
  122. #define SAVAGE_PRIM_TRILIST 0 /* triangle list */
  123. #define SAVAGE_PRIM_TRISTRIP 1 /* triangle strip */
  124. #define SAVAGE_PRIM_TRIFAN 2 /* triangle fan */
  125. #define SAVAGE_PRIM_TRILIST_201 3 /* reorder verts for correct flat
  126. * shading on s3d */
  127. /* Skip flags (vertex format)
  128. */
  129. #define SAVAGE_SKIP_Z 0x01
  130. #define SAVAGE_SKIP_W 0x02
  131. #define SAVAGE_SKIP_C0 0x04
  132. #define SAVAGE_SKIP_C1 0x08
  133. #define SAVAGE_SKIP_S0 0x10
  134. #define SAVAGE_SKIP_T0 0x20
  135. #define SAVAGE_SKIP_ST0 0x30
  136. #define SAVAGE_SKIP_S1 0x40
  137. #define SAVAGE_SKIP_T1 0x80
  138. #define SAVAGE_SKIP_ST1 0xc0
  139. #define SAVAGE_SKIP_ALL_S3D 0x3f
  140. #define SAVAGE_SKIP_ALL_S4 0xff
  141. /* Buffer names for clear command
  142. */
  143. #define SAVAGE_FRONT 0x1
  144. #define SAVAGE_BACK 0x2
  145. #define SAVAGE_DEPTH 0x4
  146. /* 64-bit command header
  147. */
  148. union drm_savage_cmd_header {
  149. struct {
  150. unsigned char cmd; /* command */
  151. unsigned char pad0;
  152. unsigned short pad1;
  153. unsigned short pad2;
  154. unsigned short pad3;
  155. } cmd; /* generic */
  156. struct {
  157. unsigned char cmd;
  158. unsigned char global; /* need idle engine? */
  159. unsigned short count; /* number of consecutive registers */
  160. unsigned short start; /* first register */
  161. unsigned short pad3;
  162. } state; /* SAVAGE_CMD_STATE */
  163. struct {
  164. unsigned char cmd;
  165. unsigned char prim; /* primitive type */
  166. unsigned short skip; /* vertex format (skip flags) */
  167. unsigned short count; /* number of vertices */
  168. unsigned short start; /* first vertex in DMA/vertex buffer */
  169. } prim; /* SAVAGE_CMD_DMA_PRIM, SAVAGE_CMD_VB_PRIM */
  170. struct {
  171. unsigned char cmd;
  172. unsigned char prim;
  173. unsigned short skip;
  174. unsigned short count; /* number of indices that follow */
  175. unsigned short pad3;
  176. } idx; /* SAVAGE_CMD_DMA_IDX, SAVAGE_CMD_VB_IDX */
  177. struct {
  178. unsigned char cmd;
  179. unsigned char pad0;
  180. unsigned short pad1;
  181. unsigned int flags;
  182. } clear0; /* SAVAGE_CMD_CLEAR */
  183. struct {
  184. unsigned int mask;
  185. unsigned int value;
  186. } clear1; /* SAVAGE_CMD_CLEAR data */
  187. };
  188. #endif