via_drm.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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/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. #include "via_drmclient.h"
  33. #define VIA_NR_SAREA_CLIPRECTS 8
  34. #define VIA_NR_XVMC_PORTS 10
  35. #define VIA_NR_XVMC_LOCKS 5
  36. #define VIA_MAX_CACHELINE_SIZE 64
  37. #define XVMCLOCKPTR(saPriv,lockNo) \
  38. ((__volatile__ struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
  39. (VIA_MAX_CACHELINE_SIZE - 1)) & \
  40. ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
  41. VIA_MAX_CACHELINE_SIZE*(lockNo)))
  42. /* Each region is a minimum of 64k, and there are at most 64 of them.
  43. */
  44. #define VIA_NR_TEX_REGIONS 64
  45. #define VIA_LOG_MIN_TEX_REGION_SIZE 16
  46. #endif
  47. #define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
  48. #define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
  49. #define VIA_UPLOAD_CTX 0x4
  50. #define VIA_UPLOAD_BUFFERS 0x8
  51. #define VIA_UPLOAD_TEX0 0x10
  52. #define VIA_UPLOAD_TEX1 0x20
  53. #define VIA_UPLOAD_CLIPRECTS 0x40
  54. #define VIA_UPLOAD_ALL 0xff
  55. /* VIA specific ioctls */
  56. #define DRM_VIA_ALLOCMEM 0x00
  57. #define DRM_VIA_FREEMEM 0x01
  58. #define DRM_VIA_AGP_INIT 0x02
  59. #define DRM_VIA_FB_INIT 0x03
  60. #define DRM_VIA_MAP_INIT 0x04
  61. #define DRM_VIA_DEC_FUTEX 0x05
  62. #define NOT_USED
  63. #define DRM_VIA_DMA_INIT 0x07
  64. #define DRM_VIA_CMDBUFFER 0x08
  65. #define DRM_VIA_FLUSH 0x09
  66. #define DRM_VIA_PCICMD 0x0a
  67. #define DRM_VIA_CMDBUF_SIZE 0x0b
  68. #define NOT_USED
  69. #define DRM_VIA_WAIT_IRQ 0x0d
  70. #define DRM_VIA_DMA_BLIT 0x0e
  71. #define DRM_VIA_BLIT_SYNC 0x0f
  72. #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
  73. #define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
  74. #define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
  75. #define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
  76. #define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
  77. #define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
  78. #define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
  79. #define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
  80. #define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
  81. #define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
  82. #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
  83. drm_via_cmdbuf_size_t)
  84. #define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
  85. #define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
  86. #define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
  87. /* Indices into buf.Setup where various bits of state are mirrored per
  88. * context and per buffer. These can be fired at the card as a unit,
  89. * or in a piecewise fashion as required.
  90. */
  91. #define VIA_TEX_SETUP_SIZE 8
  92. /* Flags for clear ioctl
  93. */
  94. #define VIA_FRONT 0x1
  95. #define VIA_BACK 0x2
  96. #define VIA_DEPTH 0x4
  97. #define VIA_STENCIL 0x8
  98. #define VIA_MEM_VIDEO 0 /* matches drm constant */
  99. #define VIA_MEM_AGP 1 /* matches drm constant */
  100. #define VIA_MEM_SYSTEM 2
  101. #define VIA_MEM_MIXED 3
  102. #define VIA_MEM_UNKNOWN 4
  103. typedef struct {
  104. __u32 offset;
  105. __u32 size;
  106. } drm_via_agp_t;
  107. typedef struct {
  108. __u32 offset;
  109. __u32 size;
  110. } drm_via_fb_t;
  111. typedef struct {
  112. __u32 context;
  113. __u32 type;
  114. __u32 size;
  115. unsigned long index;
  116. unsigned long offset;
  117. } drm_via_mem_t;
  118. typedef struct _drm_via_init {
  119. enum {
  120. VIA_INIT_MAP = 0x01,
  121. VIA_CLEANUP_MAP = 0x02
  122. } func;
  123. unsigned long sarea_priv_offset;
  124. unsigned long fb_offset;
  125. unsigned long mmio_offset;
  126. unsigned long agpAddr;
  127. } drm_via_init_t;
  128. typedef struct _drm_via_futex {
  129. enum {
  130. VIA_FUTEX_WAIT = 0x00,
  131. VIA_FUTEX_WAKE = 0X01
  132. } func;
  133. __u32 ms;
  134. __u32 lock;
  135. __u32 val;
  136. } drm_via_futex_t;
  137. typedef struct _drm_via_dma_init {
  138. enum {
  139. VIA_INIT_DMA = 0x01,
  140. VIA_CLEANUP_DMA = 0x02,
  141. VIA_DMA_INITIALIZED = 0x03
  142. } func;
  143. unsigned long offset;
  144. unsigned long size;
  145. unsigned long reg_pause_addr;
  146. } drm_via_dma_init_t;
  147. typedef struct _drm_via_cmdbuffer {
  148. char *buf;
  149. unsigned long size;
  150. } drm_via_cmdbuffer_t;
  151. /* Warning: If you change the SAREA structure you must change the Xserver
  152. * structure as well */
  153. typedef struct _drm_via_tex_region {
  154. unsigned char next, prev; /* indices to form a circular LRU */
  155. unsigned char inUse; /* owned by a client, or free? */
  156. int age; /* tracked by clients to update local LRU's */
  157. } drm_via_tex_region_t;
  158. typedef struct _drm_via_sarea {
  159. unsigned int dirty;
  160. unsigned int nbox;
  161. struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
  162. drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
  163. int texAge; /* last time texture was uploaded */
  164. int ctxOwner; /* last context to upload state */
  165. int vertexPrim;
  166. /*
  167. * Below is for XvMC.
  168. * We want the lock integers alone on, and aligned to, a cache line.
  169. * Therefore this somewhat strange construct.
  170. */
  171. char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
  172. unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
  173. unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
  174. unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
  175. /* Used by the 3d driver only at this point, for pageflipping:
  176. */
  177. unsigned int pfCurrentOffset;
  178. } drm_via_sarea_t;
  179. typedef struct _drm_via_cmdbuf_size {
  180. enum {
  181. VIA_CMDBUF_SPACE = 0x01,
  182. VIA_CMDBUF_LAG = 0x02
  183. } func;
  184. int wait;
  185. __u32 size;
  186. } drm_via_cmdbuf_size_t;
  187. typedef enum {
  188. VIA_IRQ_ABSOLUTE = 0x0,
  189. VIA_IRQ_RELATIVE = 0x1,
  190. VIA_IRQ_SIGNAL = 0x10000000,
  191. VIA_IRQ_FORCE_SEQUENCE = 0x20000000
  192. } via_irq_seq_type_t;
  193. #define VIA_IRQ_FLAGS_MASK 0xF0000000
  194. enum drm_via_irqs {
  195. drm_via_irq_hqv0 = 0,
  196. drm_via_irq_hqv1,
  197. drm_via_irq_dma0_dd,
  198. drm_via_irq_dma0_td,
  199. drm_via_irq_dma1_dd,
  200. drm_via_irq_dma1_td,
  201. drm_via_irq_num
  202. };
  203. struct drm_via_wait_irq_request {
  204. unsigned irq;
  205. via_irq_seq_type_t type;
  206. __u32 sequence;
  207. __u32 signal;
  208. };
  209. typedef union drm_via_irqwait {
  210. struct drm_via_wait_irq_request request;
  211. struct drm_wait_vblank_reply reply;
  212. } drm_via_irqwait_t;
  213. typedef struct drm_via_blitsync {
  214. __u32 sync_handle;
  215. unsigned engine;
  216. } drm_via_blitsync_t;
  217. /* - * Below,"flags" is currently unused but will be used for possible future
  218. * extensions like kernel space bounce buffers for bad alignments and
  219. * blit engine busy-wait polling for better latency in the absence of
  220. * interrupts.
  221. */
  222. typedef struct drm_via_dmablit {
  223. __u32 num_lines;
  224. __u32 line_length;
  225. __u32 fb_addr;
  226. __u32 fb_stride;
  227. unsigned char *mem_addr;
  228. __u32 mem_stride;
  229. __u32 flags;
  230. int to_fb;
  231. drm_via_blitsync_t sync;
  232. } drm_via_dmablit_t;
  233. #endif /* _VIA_DRM_H_ */