i915_drv.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 "20060119"
  37. /* Interface history:
  38. *
  39. * 1.1: Original.
  40. * 1.2: Add Power Management
  41. * 1.3: Add vblank support
  42. * 1.4: Fix cmdbuffer path, add heap destroy
  43. * 1.5: Add vblank pipe configuration
  44. */
  45. #define DRIVER_MAJOR 1
  46. #define DRIVER_MINOR 5
  47. #define DRIVER_PATCHLEVEL 0
  48. typedef struct _drm_i915_ring_buffer {
  49. int tail_mask;
  50. unsigned long Start;
  51. unsigned long End;
  52. unsigned long Size;
  53. u8 *virtual_start;
  54. int head;
  55. int tail;
  56. int space;
  57. drm_local_map_t map;
  58. } drm_i915_ring_buffer_t;
  59. struct mem_block {
  60. struct mem_block *next;
  61. struct mem_block *prev;
  62. int start;
  63. int size;
  64. DRMFILE filp; /* 0: free, -1: heap, other: real files */
  65. };
  66. typedef struct drm_i915_private {
  67. drm_local_map_t *sarea;
  68. drm_local_map_t *mmio_map;
  69. drm_i915_sarea_t *sarea_priv;
  70. drm_i915_ring_buffer_t ring;
  71. drm_dma_handle_t *status_page_dmah;
  72. void *hw_status_page;
  73. dma_addr_t dma_status_page;
  74. unsigned long counter;
  75. int back_offset;
  76. int front_offset;
  77. int current_page;
  78. int page_flipping;
  79. int use_mi_batchbuffer_start;
  80. wait_queue_head_t irq_queue;
  81. atomic_t irq_received;
  82. atomic_t irq_emitted;
  83. int tex_lru_log_granularity;
  84. int allow_batchbuffer;
  85. struct mem_block *agp_heap;
  86. unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
  87. int vblank_pipe;
  88. } drm_i915_private_t;
  89. extern drm_ioctl_desc_t i915_ioctls[];
  90. extern int i915_max_ioctl;
  91. /* i915_dma.c */
  92. extern void i915_kernel_lost_context(drm_device_t * dev);
  93. extern int i915_driver_load(struct drm_device *, unsigned long flags);
  94. extern void i915_driver_lastclose(drm_device_t * dev);
  95. extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp);
  96. extern int i915_driver_device_is_agp(drm_device_t * dev);
  97. extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  98. unsigned long arg);
  99. /* i915_irq.c */
  100. extern int i915_irq_emit(DRM_IOCTL_ARGS);
  101. extern int i915_irq_wait(DRM_IOCTL_ARGS);
  102. extern int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
  103. extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
  104. extern void i915_driver_irq_preinstall(drm_device_t * dev);
  105. extern void i915_driver_irq_postinstall(drm_device_t * dev);
  106. extern void i915_driver_irq_uninstall(drm_device_t * dev);
  107. extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS);
  108. extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS);
  109. /* i915_mem.c */
  110. extern int i915_mem_alloc(DRM_IOCTL_ARGS);
  111. extern int i915_mem_free(DRM_IOCTL_ARGS);
  112. extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
  113. extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
  114. extern void i915_mem_takedown(struct mem_block **heap);
  115. extern void i915_mem_release(drm_device_t * dev,
  116. DRMFILE filp, struct mem_block *heap);
  117. #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
  118. #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
  119. #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
  120. #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
  121. #define I915_VERBOSE 0
  122. #define RING_LOCALS unsigned int outring, ringmask, outcount; \
  123. volatile char *virt;
  124. #define BEGIN_LP_RING(n) do { \
  125. if (I915_VERBOSE) \
  126. DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", \
  127. (n), __FUNCTION__); \
  128. if (dev_priv->ring.space < (n)*4) \
  129. i915_wait_ring(dev, (n)*4, __FUNCTION__); \
  130. outcount = 0; \
  131. outring = dev_priv->ring.tail; \
  132. ringmask = dev_priv->ring.tail_mask; \
  133. virt = dev_priv->ring.virtual_start; \
  134. } while (0)
  135. #define OUT_RING(n) do { \
  136. if (I915_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
  137. *(volatile unsigned int *)(virt + outring) = (n); \
  138. outcount++; \
  139. outring += 4; \
  140. outring &= ringmask; \
  141. } while (0)
  142. #define ADVANCE_LP_RING() do { \
  143. if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring); \
  144. dev_priv->ring.tail = outring; \
  145. dev_priv->ring.space -= outcount * 4; \
  146. I915_WRITE(LP_RING + RING_TAIL, outring); \
  147. } while(0)
  148. extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
  149. #define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
  150. #define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
  151. #define CMD_REPORT_HEAD (7<<23)
  152. #define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
  153. #define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
  154. #define INST_PARSER_CLIENT 0x00000000
  155. #define INST_OP_FLUSH 0x02000000
  156. #define INST_FLUSH_MAP_CACHE 0x00000001
  157. #define BB1_START_ADDR_MASK (~0x7)
  158. #define BB1_PROTECTED (1<<0)
  159. #define BB1_UNPROTECTED (0<<0)
  160. #define BB2_END_ADDR_MASK (~0x7)
  161. #define I915REG_HWSTAM 0x02098
  162. #define I915REG_INT_IDENTITY_R 0x020a4
  163. #define I915REG_INT_MASK_R 0x020a8
  164. #define I915REG_INT_ENABLE_R 0x020a0
  165. #define SRX_INDEX 0x3c4
  166. #define SRX_DATA 0x3c5
  167. #define SR01 1
  168. #define SR01_SCREEN_OFF (1<<5)
  169. #define PPCR 0x61204
  170. #define PPCR_ON (1<<0)
  171. #define DVOB 0x61140
  172. #define DVOB_ON (1<<31)
  173. #define DVOC 0x61160
  174. #define DVOC_ON (1<<31)
  175. #define LVDS 0x61180
  176. #define LVDS_ON (1<<31)
  177. #define ADPA 0x61100
  178. #define ADPA_DPMS_MASK (~(3<<10))
  179. #define ADPA_DPMS_ON (0<<10)
  180. #define ADPA_DPMS_SUSPEND (1<<10)
  181. #define ADPA_DPMS_STANDBY (2<<10)
  182. #define ADPA_DPMS_OFF (3<<10)
  183. #define NOPID 0x2094
  184. #define LP_RING 0x2030
  185. #define HP_RING 0x2040
  186. #define RING_TAIL 0x00
  187. #define TAIL_ADDR 0x001FFFF8
  188. #define RING_HEAD 0x04
  189. #define HEAD_WRAP_COUNT 0xFFE00000
  190. #define HEAD_WRAP_ONE 0x00200000
  191. #define HEAD_ADDR 0x001FFFFC
  192. #define RING_START 0x08
  193. #define START_ADDR 0x0xFFFFF000
  194. #define RING_LEN 0x0C
  195. #define RING_NR_PAGES 0x001FF000
  196. #define RING_REPORT_MASK 0x00000006
  197. #define RING_REPORT_64K 0x00000002
  198. #define RING_REPORT_128K 0x00000004
  199. #define RING_NO_REPORT 0x00000000
  200. #define RING_VALID_MASK 0x00000001
  201. #define RING_VALID 0x00000001
  202. #define RING_INVALID 0x00000000
  203. #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
  204. #define SC_UPDATE_SCISSOR (0x1<<1)
  205. #define SC_ENABLE_MASK (0x1<<0)
  206. #define SC_ENABLE (0x1<<0)
  207. #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
  208. #define SCI_YMIN_MASK (0xffff<<16)
  209. #define SCI_XMIN_MASK (0xffff<<0)
  210. #define SCI_YMAX_MASK (0xffff<<16)
  211. #define SCI_XMAX_MASK (0xffff<<0)
  212. #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19))
  213. #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
  214. #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
  215. #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
  216. #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4)
  217. #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
  218. #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
  219. #define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2)
  220. #define MI_BATCH_BUFFER ((0x30<<23)|1)
  221. #define MI_BATCH_BUFFER_START (0x31<<23)
  222. #define MI_BATCH_BUFFER_END (0xA<<23)
  223. #define MI_BATCH_NON_SECURE (1)
  224. #define MI_WAIT_FOR_EVENT ((0x3<<23))
  225. #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
  226. #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
  227. #define MI_LOAD_SCAN_LINES_INCL ((0x12<<23))
  228. #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
  229. #define ASYNC_FLIP (1<<22)
  230. #define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
  231. #define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5])
  232. #endif