i915_drv.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
  2. */
  3. /*
  4. *
  5. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  6. * All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the
  10. * "Software"), to deal in the Software without restriction, including
  11. * without limitation the rights to use, copy, modify, merge, publish,
  12. * distribute, sub license, and/or sell copies of the Software, and to
  13. * permit persons to whom the Software is furnished to do so, subject to
  14. * the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the
  17. * next paragraph) shall be included in all copies or substantial portions
  18. * of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  24. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. *
  28. */
  29. #ifndef _I915_DRV_H_
  30. #define _I915_DRV_H_
  31. /* General customization:
  32. */
  33. #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
  34. #define DRIVER_NAME "i915"
  35. #define DRIVER_DESC "Intel Graphics"
  36. #define DRIVER_DATE "20051209"
  37. /* Interface history:
  38. *
  39. * 1.1: Original.
  40. * 1.2: Add Power Management
  41. * 1.3: Add vblank support
  42. */
  43. #define DRIVER_MAJOR 1
  44. #define DRIVER_MINOR 3
  45. #define DRIVER_PATCHLEVEL 0
  46. typedef struct _drm_i915_ring_buffer {
  47. int tail_mask;
  48. unsigned long Start;
  49. unsigned long End;
  50. unsigned long Size;
  51. u8 *virtual_start;
  52. int head;
  53. int tail;
  54. int space;
  55. drm_local_map_t map;
  56. } drm_i915_ring_buffer_t;
  57. struct mem_block {
  58. struct mem_block *next;
  59. struct mem_block *prev;
  60. int start;
  61. int size;
  62. DRMFILE filp; /* 0: free, -1: heap, other: real files */
  63. };
  64. typedef struct drm_i915_private {
  65. drm_local_map_t *sarea;
  66. drm_local_map_t *mmio_map;
  67. drm_i915_sarea_t *sarea_priv;
  68. drm_i915_ring_buffer_t ring;
  69. drm_dma_handle_t *status_page_dmah;
  70. void *hw_status_page;
  71. dma_addr_t dma_status_page;
  72. unsigned long counter;
  73. int back_offset;
  74. int front_offset;
  75. int current_page;
  76. int page_flipping;
  77. int use_mi_batchbuffer_start;
  78. wait_queue_head_t irq_queue;
  79. atomic_t irq_received;
  80. atomic_t irq_emitted;
  81. int tex_lru_log_granularity;
  82. int allow_batchbuffer;
  83. struct mem_block *agp_heap;
  84. unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
  85. } drm_i915_private_t;
  86. extern drm_ioctl_desc_t i915_ioctls[];
  87. extern int i915_max_ioctl;
  88. /* i915_dma.c */
  89. extern void i915_kernel_lost_context(drm_device_t * dev);
  90. extern int i915_driver_load(struct drm_device *, unsigned long flags);
  91. extern void i915_driver_lastclose(drm_device_t * dev);
  92. extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp);
  93. extern int i915_driver_device_is_agp(drm_device_t * dev);
  94. extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  95. unsigned long arg);
  96. /* i915_irq.c */
  97. extern int i915_irq_emit(DRM_IOCTL_ARGS);
  98. extern int i915_irq_wait(DRM_IOCTL_ARGS);
  99. extern int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
  100. extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
  101. extern void i915_driver_irq_preinstall(drm_device_t * dev);
  102. extern void i915_driver_irq_postinstall(drm_device_t * dev);
  103. extern void i915_driver_irq_uninstall(drm_device_t * dev);
  104. /* i915_mem.c */
  105. extern int i915_mem_alloc(DRM_IOCTL_ARGS);
  106. extern int i915_mem_free(DRM_IOCTL_ARGS);
  107. extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
  108. extern void i915_mem_takedown(struct mem_block **heap);
  109. extern void i915_mem_release(drm_device_t * dev,
  110. DRMFILE filp, struct mem_block *heap);
  111. #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
  112. #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
  113. #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
  114. #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
  115. #define I915_VERBOSE 0
  116. #define RING_LOCALS unsigned int outring, ringmask, outcount; \
  117. volatile char *virt;
  118. #define BEGIN_LP_RING(n) do { \
  119. if (I915_VERBOSE) \
  120. DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", \
  121. n, __FUNCTION__); \
  122. if (dev_priv->ring.space < n*4) \
  123. i915_wait_ring(dev, n*4, __FUNCTION__); \
  124. outcount = 0; \
  125. outring = dev_priv->ring.tail; \
  126. ringmask = dev_priv->ring.tail_mask; \
  127. virt = dev_priv->ring.virtual_start; \
  128. } while (0)
  129. #define OUT_RING(n) do { \
  130. if (I915_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
  131. *(volatile unsigned int *)(virt + outring) = n; \
  132. outcount++; \
  133. outring += 4; \
  134. outring &= ringmask; \
  135. } while (0)
  136. #define ADVANCE_LP_RING() do { \
  137. if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring); \
  138. dev_priv->ring.tail = outring; \
  139. dev_priv->ring.space -= outcount * 4; \
  140. I915_WRITE(LP_RING + RING_TAIL, outring); \
  141. } while(0)
  142. extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
  143. #define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
  144. #define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
  145. #define CMD_REPORT_HEAD (7<<23)
  146. #define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
  147. #define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
  148. #define INST_PARSER_CLIENT 0x00000000
  149. #define INST_OP_FLUSH 0x02000000
  150. #define INST_FLUSH_MAP_CACHE 0x00000001
  151. #define BB1_START_ADDR_MASK (~0x7)
  152. #define BB1_PROTECTED (1<<0)
  153. #define BB1_UNPROTECTED (0<<0)
  154. #define BB2_END_ADDR_MASK (~0x7)
  155. #define I915REG_HWSTAM 0x02098
  156. #define I915REG_INT_IDENTITY_R 0x020a4
  157. #define I915REG_INT_MASK_R 0x020a8
  158. #define I915REG_INT_ENABLE_R 0x020a0
  159. #define SRX_INDEX 0x3c4
  160. #define SRX_DATA 0x3c5
  161. #define SR01 1
  162. #define SR01_SCREEN_OFF (1<<5)
  163. #define PPCR 0x61204
  164. #define PPCR_ON (1<<0)
  165. #define DVOB 0x61140
  166. #define DVOB_ON (1<<31)
  167. #define DVOC 0x61160
  168. #define DVOC_ON (1<<31)
  169. #define LVDS 0x61180
  170. #define LVDS_ON (1<<31)
  171. #define ADPA 0x61100
  172. #define ADPA_DPMS_MASK (~(3<<10))
  173. #define ADPA_DPMS_ON (0<<10)
  174. #define ADPA_DPMS_SUSPEND (1<<10)
  175. #define ADPA_DPMS_STANDBY (2<<10)
  176. #define ADPA_DPMS_OFF (3<<10)
  177. #define NOPID 0x2094
  178. #define LP_RING 0x2030
  179. #define HP_RING 0x2040
  180. #define RING_TAIL 0x00
  181. #define TAIL_ADDR 0x001FFFF8
  182. #define RING_HEAD 0x04
  183. #define HEAD_WRAP_COUNT 0xFFE00000
  184. #define HEAD_WRAP_ONE 0x00200000
  185. #define HEAD_ADDR 0x001FFFFC
  186. #define RING_START 0x08
  187. #define START_ADDR 0x0xFFFFF000
  188. #define RING_LEN 0x0C
  189. #define RING_NR_PAGES 0x001FF000
  190. #define RING_REPORT_MASK 0x00000006
  191. #define RING_REPORT_64K 0x00000002
  192. #define RING_REPORT_128K 0x00000004
  193. #define RING_NO_REPORT 0x00000000
  194. #define RING_VALID_MASK 0x00000001
  195. #define RING_VALID 0x00000001
  196. #define RING_INVALID 0x00000000
  197. #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
  198. #define SC_UPDATE_SCISSOR (0x1<<1)
  199. #define SC_ENABLE_MASK (0x1<<0)
  200. #define SC_ENABLE (0x1<<0)
  201. #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
  202. #define SCI_YMIN_MASK (0xffff<<16)
  203. #define SCI_XMIN_MASK (0xffff<<0)
  204. #define SCI_YMAX_MASK (0xffff<<16)
  205. #define SCI_XMAX_MASK (0xffff<<0)
  206. #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19))
  207. #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
  208. #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
  209. #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
  210. #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4)
  211. #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
  212. #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
  213. #define MI_BATCH_BUFFER ((0x30<<23)|1)
  214. #define MI_BATCH_BUFFER_START (0x31<<23)
  215. #define MI_BATCH_BUFFER_END (0xA<<23)
  216. #define MI_BATCH_NON_SECURE (1)
  217. #define MI_WAIT_FOR_EVENT ((0x3<<23))
  218. #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
  219. #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
  220. #define MI_LOAD_SCAN_LINES_INCL ((0x12<<23))
  221. #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
  222. #define ASYNC_FLIP (1<<22)
  223. #define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
  224. #define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5])
  225. #endif