via_drm.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. /* WARNING: These defines must be the same as what the Xserver uses.
  27. * if you change them, you must change the defines in the Xserver.
  28. */
  29. #ifndef _VIA_DEFINES_
  30. #define _VIA_DEFINES_
  31. #ifndef __KERNEL__
  32. #include "via_drmclient.h"
  33. #endif
  34. #define VIA_NR_SAREA_CLIPRECTS 8
  35. #define VIA_NR_XVMC_PORTS 10
  36. #define VIA_NR_XVMC_LOCKS 5
  37. #define VIA_MAX_CACHELINE_SIZE 64
  38. #define XVMCLOCKPTR(saPriv,lockNo) \
  39. ((volatile drm_hw_lock_t *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
  40. (VIA_MAX_CACHELINE_SIZE - 1)) & \
  41. ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
  42. VIA_MAX_CACHELINE_SIZE*(lockNo)))
  43. /* Each region is a minimum of 64k, and there are at most 64 of them.
  44. */
  45. #define VIA_NR_TEX_REGIONS 64
  46. #define VIA_LOG_MIN_TEX_REGION_SIZE 16
  47. #endif
  48. #define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
  49. #define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
  50. #define VIA_UPLOAD_CTX 0x4
  51. #define VIA_UPLOAD_BUFFERS 0x8
  52. #define VIA_UPLOAD_TEX0 0x10
  53. #define VIA_UPLOAD_TEX1 0x20
  54. #define VIA_UPLOAD_CLIPRECTS 0x40
  55. #define VIA_UPLOAD_ALL 0xff
  56. /* VIA specific ioctls */
  57. #define DRM_VIA_ALLOCMEM 0x00
  58. #define DRM_VIA_FREEMEM 0x01
  59. #define DRM_VIA_AGP_INIT 0x02
  60. #define DRM_VIA_FB_INIT 0x03
  61. #define DRM_VIA_MAP_INIT 0x04
  62. #define DRM_VIA_DEC_FUTEX 0x05
  63. #define NOT_USED
  64. #define DRM_VIA_DMA_INIT 0x07
  65. #define DRM_VIA_CMDBUFFER 0x08
  66. #define DRM_VIA_FLUSH 0x09
  67. #define DRM_VIA_PCICMD 0x0a
  68. #define DRM_VIA_CMDBUF_SIZE 0x0b
  69. #define NOT_USED
  70. #define DRM_VIA_WAIT_IRQ 0x0d
  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. /* Indices into buf.Setup where various bits of state are mirrored per
  85. * context and per buffer. These can be fired at the card as a unit,
  86. * or in a piecewise fashion as required.
  87. */
  88. #define VIA_TEX_SETUP_SIZE 8
  89. /* Flags for clear ioctl
  90. */
  91. #define VIA_FRONT 0x1
  92. #define VIA_BACK 0x2
  93. #define VIA_DEPTH 0x4
  94. #define VIA_STENCIL 0x8
  95. #define VIDEO 0
  96. #define AGP 1
  97. typedef struct {
  98. uint32_t offset;
  99. uint32_t size;
  100. } drm_via_agp_t;
  101. typedef struct {
  102. uint32_t offset;
  103. uint32_t size;
  104. } drm_via_fb_t;
  105. typedef struct {
  106. uint32_t context;
  107. uint32_t type;
  108. uint32_t size;
  109. unsigned long index;
  110. unsigned long offset;
  111. } drm_via_mem_t;
  112. typedef struct _drm_via_init {
  113. enum {
  114. VIA_INIT_MAP = 0x01,
  115. VIA_CLEANUP_MAP = 0x02
  116. } func;
  117. unsigned long sarea_priv_offset;
  118. unsigned long fb_offset;
  119. unsigned long mmio_offset;
  120. unsigned long agpAddr;
  121. } drm_via_init_t;
  122. typedef struct _drm_via_futex {
  123. enum {
  124. VIA_FUTEX_WAIT = 0x00,
  125. VIA_FUTEX_WAKE = 0X01
  126. } func;
  127. uint32_t ms;
  128. uint32_t lock;
  129. uint32_t val;
  130. } drm_via_futex_t;
  131. typedef struct _drm_via_dma_init {
  132. enum {
  133. VIA_INIT_DMA = 0x01,
  134. VIA_CLEANUP_DMA = 0x02,
  135. VIA_DMA_INITIALIZED = 0x03
  136. } func;
  137. unsigned long offset;
  138. unsigned long size;
  139. unsigned long reg_pause_addr;
  140. } drm_via_dma_init_t;
  141. typedef struct _drm_via_cmdbuffer {
  142. char __user *buf;
  143. unsigned long size;
  144. } drm_via_cmdbuffer_t;
  145. /* Warning: If you change the SAREA structure you must change the Xserver
  146. * structure as well */
  147. typedef struct _drm_via_tex_region {
  148. unsigned char next, prev; /* indices to form a circular LRU */
  149. unsigned char inUse; /* owned by a client, or free? */
  150. int age; /* tracked by clients to update local LRU's */
  151. } drm_via_tex_region_t;
  152. typedef struct _drm_via_sarea {
  153. unsigned int dirty;
  154. unsigned int nbox;
  155. drm_clip_rect_t boxes[VIA_NR_SAREA_CLIPRECTS];
  156. drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
  157. int texAge; /* last time texture was uploaded */
  158. int ctxOwner; /* last context to upload state */
  159. int vertexPrim;
  160. /*
  161. * Below is for XvMC.
  162. * We want the lock integers alone on, and aligned to, a cache line.
  163. * Therefore this somewhat strange construct.
  164. */
  165. char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
  166. unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
  167. unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
  168. unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
  169. } drm_via_sarea_t;
  170. typedef struct _drm_via_cmdbuf_size {
  171. enum {
  172. VIA_CMDBUF_SPACE = 0x01,
  173. VIA_CMDBUF_LAG = 0x02
  174. } func;
  175. int wait;
  176. uint32_t size;
  177. } drm_via_cmdbuf_size_t;
  178. typedef enum {
  179. VIA_IRQ_ABSOLUTE = 0x0,
  180. VIA_IRQ_RELATIVE = 0x1,
  181. VIA_IRQ_SIGNAL = 0x10000000,
  182. VIA_IRQ_FORCE_SEQUENCE = 0x20000000
  183. } via_irq_seq_type_t;
  184. #define VIA_IRQ_FLAGS_MASK 0xF0000000
  185. struct drm_via_wait_irq_request{
  186. unsigned irq;
  187. via_irq_seq_type_t type;
  188. uint32_t sequence;
  189. uint32_t signal;
  190. };
  191. typedef union drm_via_irqwait {
  192. struct drm_via_wait_irq_request request;
  193. struct drm_wait_vblank_reply reply;
  194. } drm_via_irqwait_t;
  195. #ifdef __KERNEL__
  196. int via_fb_init(DRM_IOCTL_ARGS);
  197. int via_mem_alloc(DRM_IOCTL_ARGS);
  198. int via_mem_free(DRM_IOCTL_ARGS);
  199. int via_agp_init(DRM_IOCTL_ARGS);
  200. int via_map_init(DRM_IOCTL_ARGS);
  201. int via_decoder_futex(DRM_IOCTL_ARGS);
  202. int via_dma_init(DRM_IOCTL_ARGS);
  203. int via_cmdbuffer(DRM_IOCTL_ARGS);
  204. int via_flush_ioctl(DRM_IOCTL_ARGS);
  205. int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
  206. int via_cmdbuf_size(DRM_IOCTL_ARGS);
  207. int via_wait_irq(DRM_IOCTL_ARGS);
  208. #endif
  209. #endif /* _VIA_DRM_H_ */