via_drm.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
  3. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sub license,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the
  13. * next paragraph) shall be included in all copies or substantial portions
  14. * of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  19. * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifndef _VIA_DRM_H_
  25. #define _VIA_DRM_H_
  26. #include "drm.h"
  27. /* WARNING: These defines must be the same as what the Xserver uses.
  28. * if you change them, you must change the defines in the Xserver.
  29. */
  30. #ifndef _VIA_DEFINES_
  31. #define _VIA_DEFINES_
  32. #define VIA_NR_SAREA_CLIPRECTS 8
  33. #define VIA_NR_XVMC_PORTS 10
  34. #define VIA_NR_XVMC_LOCKS 5
  35. #define VIA_MAX_CACHELINE_SIZE 64
  36. #define XVMCLOCKPTR(saPriv,lockNo) \
  37. ((volatile struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
  38. (VIA_MAX_CACHELINE_SIZE - 1)) & \
  39. ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
  40. VIA_MAX_CACHELINE_SIZE*(lockNo)))
  41. /* Each region is a minimum of 64k, and there are at most 64 of them.
  42. */
  43. #define VIA_NR_TEX_REGIONS 64
  44. #define VIA_LOG_MIN_TEX_REGION_SIZE 16
  45. #endif
  46. #define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
  47. #define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
  48. #define VIA_UPLOAD_CTX 0x4
  49. #define VIA_UPLOAD_BUFFERS 0x8
  50. #define VIA_UPLOAD_TEX0 0x10
  51. #define VIA_UPLOAD_TEX1 0x20
  52. #define VIA_UPLOAD_CLIPRECTS 0x40
  53. #define VIA_UPLOAD_ALL 0xff
  54. /* VIA specific ioctls */
  55. #define DRM_VIA_ALLOCMEM 0x00
  56. #define DRM_VIA_FREEMEM 0x01
  57. #define DRM_VIA_AGP_INIT 0x02
  58. #define DRM_VIA_FB_INIT 0x03
  59. #define DRM_VIA_MAP_INIT 0x04
  60. #define DRM_VIA_DEC_FUTEX 0x05
  61. #define NOT_USED
  62. #define DRM_VIA_DMA_INIT 0x07
  63. #define DRM_VIA_CMDBUFFER 0x08
  64. #define DRM_VIA_FLUSH 0x09
  65. #define DRM_VIA_PCICMD 0x0a
  66. #define DRM_VIA_CMDBUF_SIZE 0x0b
  67. #define NOT_USED
  68. #define DRM_VIA_WAIT_IRQ 0x0d
  69. #define DRM_VIA_DMA_BLIT 0x0e
  70. #define DRM_VIA_BLIT_SYNC 0x0f
  71. #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
  72. #define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
  73. #define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
  74. #define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
  75. #define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
  76. #define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
  77. #define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
  78. #define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
  79. #define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
  80. #define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
  81. #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
  82. drm_via_cmdbuf_size_t)
  83. #define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
  84. #define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
  85. #define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
  86. /* Indices into buf.Setup where various bits of state are mirrored per
  87. * context and per buffer. These can be fired at the card as a unit,
  88. * or in a piecewise fashion as required.
  89. */
  90. #define VIA_TEX_SETUP_SIZE 8
  91. /* Flags for clear ioctl
  92. */
  93. #define VIA_FRONT 0x1
  94. #define VIA_BACK 0x2
  95. #define VIA_DEPTH 0x4
  96. #define VIA_STENCIL 0x8
  97. #define VIA_MEM_VIDEO 0 /* matches drm constant */
  98. #define VIA_MEM_AGP 1 /* matches drm constant */
  99. #define VIA_MEM_SYSTEM 2
  100. #define VIA_MEM_MIXED 3
  101. #define VIA_MEM_UNKNOWN 4
  102. typedef struct {
  103. __u32 offset;
  104. __u32 size;
  105. } drm_via_agp_t;
  106. typedef struct {
  107. __u32 offset;
  108. __u32 size;
  109. } drm_via_fb_t;
  110. typedef struct {
  111. __u32 context;
  112. __u32 type;
  113. __u32 size;
  114. unsigned long index;
  115. unsigned long offset;
  116. } drm_via_mem_t;
  117. typedef struct _drm_via_init {
  118. enum {
  119. VIA_INIT_MAP = 0x01,
  120. VIA_CLEANUP_MAP = 0x02
  121. } func;
  122. unsigned long sarea_priv_offset;
  123. unsigned long fb_offset;
  124. unsigned long mmio_offset;
  125. unsigned long agpAddr;
  126. } drm_via_init_t;
  127. typedef struct _drm_via_futex {
  128. enum {
  129. VIA_FUTEX_WAIT = 0x00,
  130. VIA_FUTEX_WAKE = 0X01
  131. } func;
  132. __u32 ms;
  133. __u32 lock;
  134. __u32 val;
  135. } drm_via_futex_t;
  136. typedef struct _drm_via_dma_init {
  137. enum {
  138. VIA_INIT_DMA = 0x01,
  139. VIA_CLEANUP_DMA = 0x02,
  140. VIA_DMA_INITIALIZED = 0x03
  141. } func;
  142. unsigned long offset;
  143. unsigned long size;
  144. unsigned long reg_pause_addr;
  145. } drm_via_dma_init_t;
  146. typedef struct _drm_via_cmdbuffer {
  147. char __user *buf;
  148. unsigned long size;
  149. } drm_via_cmdbuffer_t;
  150. /* Warning: If you change the SAREA structure you must change the Xserver
  151. * structure as well */
  152. typedef struct _drm_via_tex_region {
  153. unsigned char next, prev; /* indices to form a circular LRU */
  154. unsigned char inUse; /* owned by a client, or free? */
  155. int age; /* tracked by clients to update local LRU's */
  156. } drm_via_tex_region_t;
  157. typedef struct _drm_via_sarea {
  158. unsigned int dirty;
  159. unsigned int nbox;
  160. struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
  161. drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
  162. int texAge; /* last time texture was uploaded */
  163. int ctxOwner; /* last context to upload state */
  164. int vertexPrim;
  165. /*
  166. * Below is for XvMC.
  167. * We want the lock integers alone on, and aligned to, a cache line.
  168. * Therefore this somewhat strange construct.
  169. */
  170. char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
  171. unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
  172. unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
  173. unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
  174. /* Used by the 3d driver only at this point, for pageflipping:
  175. */
  176. unsigned int pfCurrentOffset;
  177. } drm_via_sarea_t;
  178. typedef struct _drm_via_cmdbuf_size {
  179. enum {
  180. VIA_CMDBUF_SPACE = 0x01,
  181. VIA_CMDBUF_LAG = 0x02
  182. } func;
  183. int wait;
  184. __u32 size;
  185. } drm_via_cmdbuf_size_t;
  186. typedef enum {
  187. VIA_IRQ_ABSOLUTE = 0x0,
  188. VIA_IRQ_RELATIVE = 0x1,
  189. VIA_IRQ_SIGNAL = 0x10000000,
  190. VIA_IRQ_FORCE_SEQUENCE = 0x20000000
  191. } via_irq_seq_type_t;
  192. #define VIA_IRQ_FLAGS_MASK 0xF0000000
  193. enum drm_via_irqs {
  194. drm_via_irq_hqv0 = 0,
  195. drm_via_irq_hqv1,
  196. drm_via_irq_dma0_dd,
  197. drm_via_irq_dma0_td,
  198. drm_via_irq_dma1_dd,
  199. drm_via_irq_dma1_td,
  200. drm_via_irq_num
  201. };
  202. struct drm_via_wait_irq_request {
  203. unsigned irq;
  204. via_irq_seq_type_t type;
  205. __u32 sequence;
  206. __u32 signal;
  207. };
  208. typedef union drm_via_irqwait {
  209. struct drm_via_wait_irq_request request;
  210. struct drm_wait_vblank_reply reply;
  211. } drm_via_irqwait_t;
  212. typedef struct drm_via_blitsync {
  213. __u32 sync_handle;
  214. unsigned engine;
  215. } drm_via_blitsync_t;
  216. /* - * Below,"flags" is currently unused but will be used for possible future
  217. * extensions like kernel space bounce buffers for bad alignments and
  218. * blit engine busy-wait polling for better latency in the absence of
  219. * interrupts.
  220. */
  221. typedef struct drm_via_dmablit {
  222. __u32 num_lines;
  223. __u32 line_length;
  224. __u32 fb_addr;
  225. __u32 fb_stride;
  226. unsigned char *mem_addr;
  227. __u32 mem_stride;
  228. __u32 flags;
  229. int to_fb;
  230. drm_via_blitsync_t sync;
  231. } drm_via_dmablit_t;
  232. #endif /* _VIA_DRM_H_ */