1 /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
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.
33 /* General customization:
36 #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
38 #define DRIVER_NAME "i915"
39 #define DRIVER_DESC "Intel Graphics"
40 #define DRIVER_DATE "20051209"
45 * 1.2: Add Power Management
46 * 1.3: Add vblank support
48 #define DRIVER_MAJOR 1
49 #define DRIVER_MINOR 3
50 #define DRIVER_PATCHLEVEL 0
52 typedef struct _drm_i915_ring_buffer {
62 } drm_i915_ring_buffer_t;
65 struct mem_block *next;
66 struct mem_block *prev;
69 DRMFILE filp; /* 0: free, -1: heap, other: real files */
72 typedef struct drm_i915_private {
73 drm_local_map_t *sarea;
74 drm_local_map_t *mmio_map;
76 drm_i915_sarea_t *sarea_priv;
77 drm_i915_ring_buffer_t ring;
79 drm_dma_handle_t *status_page_dmah;
81 dma_addr_t dma_status_page;
82 unsigned long counter;
88 int use_mi_batchbuffer_start;
90 wait_queue_head_t irq_queue;
91 atomic_t irq_received;
94 int tex_lru_log_granularity;
95 int allow_batchbuffer;
96 struct mem_block *agp_heap;
97 unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
100 extern drm_ioctl_desc_t i915_ioctls[];
101 extern int i915_max_ioctl;
104 extern void i915_kernel_lost_context(drm_device_t * dev);
105 extern int i915_driver_load(struct drm_device *, unsigned long flags);
106 extern void i915_driver_lastclose(drm_device_t * dev);
107 extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp);
108 extern int i915_driver_device_is_agp(drm_device_t * dev);
109 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
113 extern int i915_irq_emit(DRM_IOCTL_ARGS);
114 extern int i915_irq_wait(DRM_IOCTL_ARGS);
116 extern int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
117 extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
118 extern void i915_driver_irq_preinstall(drm_device_t * dev);
119 extern void i915_driver_irq_postinstall(drm_device_t * dev);
120 extern void i915_driver_irq_uninstall(drm_device_t * dev);
123 extern int i915_mem_alloc(DRM_IOCTL_ARGS);
124 extern int i915_mem_free(DRM_IOCTL_ARGS);
125 extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
126 extern void i915_mem_takedown(struct mem_block **heap);
127 extern void i915_mem_release(drm_device_t * dev,
128 DRMFILE filp, struct mem_block *heap);
130 #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
131 #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
132 #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
133 #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
135 #define I915_VERBOSE 0
137 #define RING_LOCALS unsigned int outring, ringmask, outcount; \
140 #define BEGIN_LP_RING(n) do { \
142 DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", \
144 if (dev_priv->ring.space < n*4) \
145 i915_wait_ring(dev, n*4, __FUNCTION__); \
147 outring = dev_priv->ring.tail; \
148 ringmask = dev_priv->ring.tail_mask; \
149 virt = dev_priv->ring.virtual_start; \
152 #define OUT_RING(n) do { \
153 if (I915_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
154 *(volatile unsigned int *)(virt + outring) = n; \
157 outring &= ringmask; \
160 #define ADVANCE_LP_RING() do { \
161 if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring); \
162 dev_priv->ring.tail = outring; \
163 dev_priv->ring.space -= outcount * 4; \
164 I915_WRITE(LP_RING + RING_TAIL, outring); \
167 extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
169 #define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
170 #define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
171 #define CMD_REPORT_HEAD (7<<23)
172 #define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
173 #define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
175 #define INST_PARSER_CLIENT 0x00000000
176 #define INST_OP_FLUSH 0x02000000
177 #define INST_FLUSH_MAP_CACHE 0x00000001
179 #define BB1_START_ADDR_MASK (~0x7)
180 #define BB1_PROTECTED (1<<0)
181 #define BB1_UNPROTECTED (0<<0)
182 #define BB2_END_ADDR_MASK (~0x7)
184 #define I915REG_HWSTAM 0x02098
185 #define I915REG_INT_IDENTITY_R 0x020a4
186 #define I915REG_INT_MASK_R 0x020a8
187 #define I915REG_INT_ENABLE_R 0x020a0
189 #define SRX_INDEX 0x3c4
190 #define SRX_DATA 0x3c5
192 #define SR01_SCREEN_OFF (1<<5)
195 #define PPCR_ON (1<<0)
198 #define DVOB_ON (1<<31)
200 #define DVOC_ON (1<<31)
202 #define LVDS_ON (1<<31)
205 #define ADPA_DPMS_MASK (~(3<<10))
206 #define ADPA_DPMS_ON (0<<10)
207 #define ADPA_DPMS_SUSPEND (1<<10)
208 #define ADPA_DPMS_STANDBY (2<<10)
209 #define ADPA_DPMS_OFF (3<<10)
212 #define LP_RING 0x2030
213 #define HP_RING 0x2040
214 #define RING_TAIL 0x00
215 #define TAIL_ADDR 0x001FFFF8
216 #define RING_HEAD 0x04
217 #define HEAD_WRAP_COUNT 0xFFE00000
218 #define HEAD_WRAP_ONE 0x00200000
219 #define HEAD_ADDR 0x001FFFFC
220 #define RING_START 0x08
221 #define START_ADDR 0x0xFFFFF000
222 #define RING_LEN 0x0C
223 #define RING_NR_PAGES 0x001FF000
224 #define RING_REPORT_MASK 0x00000006
225 #define RING_REPORT_64K 0x00000002
226 #define RING_REPORT_128K 0x00000004
227 #define RING_NO_REPORT 0x00000000
228 #define RING_VALID_MASK 0x00000001
229 #define RING_VALID 0x00000001
230 #define RING_INVALID 0x00000000
232 #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
233 #define SC_UPDATE_SCISSOR (0x1<<1)
234 #define SC_ENABLE_MASK (0x1<<0)
235 #define SC_ENABLE (0x1<<0)
237 #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
238 #define SCI_YMIN_MASK (0xffff<<16)
239 #define SCI_XMIN_MASK (0xffff<<0)
240 #define SCI_YMAX_MASK (0xffff<<16)
241 #define SCI_XMAX_MASK (0xffff<<0)
243 #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19))
244 #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
245 #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
246 #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
247 #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4)
248 #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
249 #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
251 #define MI_BATCH_BUFFER ((0x30<<23)|1)
252 #define MI_BATCH_BUFFER_START (0x31<<23)
253 #define MI_BATCH_BUFFER_END (0xA<<23)
254 #define MI_BATCH_NON_SECURE (1)
256 #define MI_WAIT_FOR_EVENT ((0x3<<23))
257 #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
258 #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
260 #define MI_LOAD_SCAN_LINES_INCL ((0x12<<23))
262 #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
263 #define ASYNC_FLIP (1<<22)
265 #define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
267 #define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5])