OSDN Git Service

i915: Re-report breadcrumbs on poll to the fence manager,
[android-x86/external-libdrm.git] / shared-core / i915_drv.h
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
30 #ifndef _I915_DRV_H_
31 #define _I915_DRV_H_
32
33 /* General customization:
34  */
35
36 #define DRIVER_AUTHOR           "Tungsten Graphics, Inc."
37
38 #define DRIVER_NAME             "i915"
39 #define DRIVER_DESC             "Intel Graphics"
40 #define DRIVER_DATE             "20070209"
41
42 #if defined(__linux__)
43 #define I915_HAVE_FENCE
44 #define I915_HAVE_BUFFER
45 #endif
46
47 /* Interface history:
48  *
49  * 1.1: Original.
50  * 1.2: Add Power Management
51  * 1.3: Add vblank support
52  * 1.4: Fix cmdbuffer path, add heap destroy
53  * 1.5: Add vblank pipe configuration
54  * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
55  *      - Support vertical blank on secondary display pipe
56  * 1.8: New ioctl for ARB_Occlusion_Query
57  * 1.9: Usable page flipping and triple buffering
58  * 1.10: Plane/pipe disentangling
59  * 1.11: TTM superioctl
60  * 1.12: TTM relocation optimization
61  */
62 #define DRIVER_MAJOR            1
63 #if defined(I915_HAVE_FENCE) && defined(I915_HAVE_BUFFER)
64 #define DRIVER_MINOR            12
65 #else
66 #define DRIVER_MINOR            6
67 #endif
68 #define DRIVER_PATCHLEVEL       0
69
70 #ifdef I915_HAVE_BUFFER
71 #define I915_MAX_VALIDATE_BUFFERS 4096
72 #endif
73
74 typedef struct _drm_i915_ring_buffer {
75         int tail_mask;
76         unsigned long Start;
77         unsigned long End;
78         unsigned long Size;
79         u8 *virtual_start;
80         int head;
81         int tail;
82         int space;
83         drm_local_map_t map;
84 } drm_i915_ring_buffer_t;
85
86 struct mem_block {
87         struct mem_block *next;
88         struct mem_block *prev;
89         int start;
90         int size;
91         struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
92 };
93
94 typedef struct _drm_i915_vbl_swap {
95         struct list_head head;
96         drm_drawable_t drw_id;
97         unsigned int plane;
98         unsigned int sequence;
99         int flip;
100 } drm_i915_vbl_swap_t;
101
102 typedef struct drm_i915_private {
103         drm_local_map_t *sarea;
104         drm_local_map_t *mmio_map;
105
106         drm_i915_sarea_t *sarea_priv;
107         drm_i915_ring_buffer_t ring;
108
109         drm_dma_handle_t *status_page_dmah;
110         void *hw_status_page;
111         dma_addr_t dma_status_page;
112         uint32_t counter;
113         unsigned int status_gfx_addr;
114         drm_local_map_t hws_map;
115
116         unsigned int cpp;
117         int use_mi_batchbuffer_start;
118
119         wait_queue_head_t irq_queue;
120         atomic_t irq_received;
121         atomic_t irq_emitted;
122
123         int tex_lru_log_granularity;
124         int allow_batchbuffer;
125         struct mem_block *agp_heap;
126         unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
127         int vblank_pipe;
128         DRM_SPINTYPE user_irq_lock;
129         int user_irq_refcount;
130         int fence_irq_on;
131         uint32_t irq_enable_reg;
132         int irq_enabled;
133
134 #ifdef I915_HAVE_FENCE
135         uint32_t flush_sequence;
136         uint32_t flush_flags;
137         uint32_t flush_pending;
138         uint32_t saved_flush_status;
139 #endif
140 #ifdef I915_HAVE_BUFFER
141         void *agp_iomap;
142         unsigned int max_validate_buffers;
143         struct mutex cmdbuf_mutex;
144 #endif
145
146         DRM_SPINTYPE swaps_lock;
147         drm_i915_vbl_swap_t vbl_swaps;
148         unsigned int swaps_pending;
149
150         /* Register state */
151         u8 saveLBB;
152         u32 saveDSPACNTR;
153         u32 saveDSPBCNTR;
154         u32 savePIPEACONF;
155         u32 savePIPEBCONF;
156         u32 savePIPEASRC;
157         u32 savePIPEBSRC;
158         u32 saveFPA0;
159         u32 saveFPA1;
160         u32 saveDPLL_A;
161         u32 saveDPLL_A_MD;
162         u32 saveHTOTAL_A;
163         u32 saveHBLANK_A;
164         u32 saveHSYNC_A;
165         u32 saveVTOTAL_A;
166         u32 saveVBLANK_A;
167         u32 saveVSYNC_A;
168         u32 saveBCLRPAT_A;
169         u32 saveDSPASTRIDE;
170         u32 saveDSPASIZE;
171         u32 saveDSPAPOS;
172         u32 saveDSPABASE;
173         u32 saveDSPASURF;
174         u32 saveDSPATILEOFF;
175         u32 savePFIT_PGM_RATIOS;
176         u32 saveBLC_PWM_CTL;
177         u32 saveBLC_PWM_CTL2;
178         u32 saveFPB0;
179         u32 saveFPB1;
180         u32 saveDPLL_B;
181         u32 saveDPLL_B_MD;
182         u32 saveHTOTAL_B;
183         u32 saveHBLANK_B;
184         u32 saveHSYNC_B;
185         u32 saveVTOTAL_B;
186         u32 saveVBLANK_B;
187         u32 saveVSYNC_B;
188         u32 saveBCLRPAT_B;
189         u32 saveDSPBSTRIDE;
190         u32 saveDSPBSIZE;
191         u32 saveDSPBPOS;
192         u32 saveDSPBBASE;
193         u32 saveDSPBSURF;
194         u32 saveDSPBTILEOFF;
195         u32 saveVCLK_DIVISOR_VGA0;
196         u32 saveVCLK_DIVISOR_VGA1;
197         u32 saveVCLK_POST_DIV;
198         u32 saveVGACNTRL;
199         u32 saveADPA;
200         u32 saveLVDS;
201         u32 saveLVDSPP_ON;
202         u32 saveLVDSPP_OFF;
203         u32 saveDVOA;
204         u32 saveDVOB;
205         u32 saveDVOC;
206         u32 savePP_ON;
207         u32 savePP_OFF;
208         u32 savePP_CONTROL;
209         u32 savePP_CYCLE;
210         u32 savePFIT_CONTROL;
211         u32 save_palette_a[256];
212         u32 save_palette_b[256];
213         u32 saveFBC_CFB_BASE;
214         u32 saveFBC_LL_BASE;
215         u32 saveFBC_CONTROL;
216         u32 saveFBC_CONTROL2;
217         u32 saveSWF0[16];
218         u32 saveSWF1[16];
219         u32 saveSWF2[3];
220         u8 saveMSR;
221         u8 saveSR[8];
222         u8 saveGR[24];
223         u8 saveAR_INDEX;
224         u8 saveAR[20];
225         u8 saveDACMASK;
226         u8 saveDACDATA[256*3]; /* 256 3-byte colors */
227         u8 saveCR[36];
228 } drm_i915_private_t;
229
230 enum intel_chip_family {
231         CHIP_I8XX = 0x01,
232         CHIP_I9XX = 0x02,
233         CHIP_I915 = 0x04,
234         CHIP_I965 = 0x08,
235 };
236
237 extern struct drm_ioctl_desc i915_ioctls[];
238 extern int i915_max_ioctl;
239
240                                 /* i915_dma.c */
241 extern void i915_kernel_lost_context(struct drm_device * dev);
242 extern int i915_driver_load(struct drm_device *, unsigned long flags);
243 extern int i915_driver_unload(struct drm_device *);
244 extern void i915_driver_lastclose(struct drm_device * dev);
245 extern void i915_driver_preclose(struct drm_device *dev,
246                                  struct drm_file *file_priv);
247 extern int i915_driver_device_is_agp(struct drm_device * dev);
248 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
249                               unsigned long arg);
250 extern void i915_emit_breadcrumb(struct drm_device *dev);
251 extern void i915_dispatch_flip(struct drm_device * dev, int pipes, int sync);
252 extern int i915_emit_mi_flush(struct drm_device *dev, uint32_t flush);
253 extern int i915_driver_firstopen(struct drm_device *dev);
254
255 /* i915_irq.c */
256 extern int i915_irq_emit(struct drm_device *dev, void *data,
257                          struct drm_file *file_priv);
258 extern int i915_irq_wait(struct drm_device *dev, void *data,
259                          struct drm_file *file_priv);
260
261 extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
262 extern void i915_driver_irq_preinstall(struct drm_device * dev);
263 extern int i915_driver_irq_postinstall(struct drm_device * dev);
264 extern void i915_driver_irq_uninstall(struct drm_device * dev);
265 extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
266                                 struct drm_file *file_priv);
267 extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
268                                 struct drm_file *file_priv);
269 extern int i915_emit_irq(struct drm_device * dev);
270 extern int i915_enable_vblank(struct drm_device *dev, int crtc);
271 extern void i915_disable_vblank(struct drm_device *dev, int crtc);
272 extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
273 extern int i915_vblank_swap(struct drm_device *dev, void *data,
274                             struct drm_file *file_priv);
275 extern void i915_user_irq_on(drm_i915_private_t *dev_priv);
276 extern void i915_user_irq_off(drm_i915_private_t *dev_priv);
277
278 /* i915_mem.c */
279 extern int i915_mem_alloc(struct drm_device *dev, void *data,
280                           struct drm_file *file_priv);
281 extern int i915_mem_free(struct drm_device *dev, void *data,
282                          struct drm_file *file_priv);
283 extern int i915_mem_init_heap(struct drm_device *dev, void *data,
284                               struct drm_file *file_priv);
285 extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
286                                  struct drm_file *file_priv);
287 extern void i915_mem_takedown(struct mem_block **heap);
288 extern void i915_mem_release(struct drm_device * dev,
289                              struct drm_file *file_priv,
290                              struct mem_block *heap);
291 #ifdef I915_HAVE_FENCE
292 /* i915_fence.c */
293 extern void i915_fence_handler(struct drm_device *dev);
294 extern void i915_invalidate_reported_sequence(struct drm_device *dev);
295
296 #endif
297
298 #ifdef I915_HAVE_BUFFER
299 /* i915_buffer.c */
300 extern struct drm_ttm_backend *i915_create_ttm_backend_entry(struct drm_device *dev);
301 extern int i915_fence_type(struct drm_buffer_object *bo, uint32_t *fclass,
302                            uint32_t *type);
303 extern int i915_invalidate_caches(struct drm_device *dev, uint64_t buffer_flags);
304 extern int i915_init_mem_type(struct drm_device *dev, uint32_t type,
305                                struct drm_mem_type_manager *man);
306 extern uint64_t i915_evict_flags(struct drm_buffer_object *bo);
307 extern int i915_move(struct drm_buffer_object *bo, int evict,
308                 int no_wait, struct drm_bo_mem_reg *new_mem);
309 void i915_flush_ttm(struct drm_ttm *ttm);
310 #endif
311
312 #ifdef __linux__
313 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
314 extern void intel_init_chipset_flush_compat(struct drm_device *dev);
315 extern void intel_fini_chipset_flush_compat(struct drm_device *dev);
316 #endif
317 #endif
318
319 #define I915_READ(reg)          DRM_READ32(dev_priv->mmio_map, (reg))
320 #define I915_WRITE(reg,val)     DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
321 #define I915_READ16(reg)        DRM_READ16(dev_priv->mmio_map, (reg))
322 #define I915_WRITE16(reg,val)   DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
323
324 #define I915_VERBOSE 0
325
326 #define RING_LOCALS     unsigned int outring, ringmask, outcount; \
327                         volatile char *virt;
328
329 #define BEGIN_LP_RING(n) do {                           \
330         if (I915_VERBOSE)                               \
331                 DRM_DEBUG("BEGIN_LP_RING(%d)\n",        \
332                                  (n));                  \
333         if (dev_priv->ring.space < (n)*4)                      \
334                 i915_wait_ring(dev, (n)*4, __FUNCTION__);      \
335         outcount = 0;                                   \
336         outring = dev_priv->ring.tail;                  \
337         ringmask = dev_priv->ring.tail_mask;            \
338         virt = dev_priv->ring.virtual_start;            \
339 } while (0)
340
341 #define OUT_RING(n) do {                                        \
342         if (I915_VERBOSE) DRM_DEBUG("   OUT_RING %x\n", (int)(n));      \
343         *(volatile unsigned int *)(virt + outring) = (n);               \
344         outcount++;                                             \
345         outring += 4;                                           \
346         outring &= ringmask;                                    \
347 } while (0)
348
349 #define ADVANCE_LP_RING() do {                                          \
350         if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring);   \
351         dev_priv->ring.tail = outring;                                  \
352         dev_priv->ring.space -= outcount * 4;                           \
353         I915_WRITE(LP_RING + RING_TAIL, outring);                       \
354 } while(0)
355
356 extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
357
358 /* Extended config space */
359 #define LBB 0xf4
360
361 /* VGA stuff */
362
363 #define VGA_ST01_MDA 0x3ba
364 #define VGA_ST01_CGA 0x3da
365
366 #define VGA_MSR_WRITE 0x3c2
367 #define VGA_MSR_READ 0x3cc
368 #define   VGA_MSR_MEM_EN (1<<1)
369 #define   VGA_MSR_CGA_MODE (1<<0)
370
371 #define VGA_SR_INDEX 0x3c4
372 #define VGA_SR_DATA 0x3c5
373
374 #define VGA_AR_INDEX 0x3c0
375 #define   VGA_AR_VID_EN (1<<5)
376 #define VGA_AR_DATA_WRITE 0x3c0
377 #define VGA_AR_DATA_READ 0x3c1
378
379 #define VGA_GR_INDEX 0x3ce
380 #define VGA_GR_DATA 0x3cf
381 /* GR05 */
382 #define   VGA_GR_MEM_READ_MODE_SHIFT 3
383 #define     VGA_GR_MEM_READ_MODE_PLANE 1
384 /* GR06 */
385 #define   VGA_GR_MEM_MODE_MASK 0xc
386 #define   VGA_GR_MEM_MODE_SHIFT 2
387 #define   VGA_GR_MEM_A0000_AFFFF 0
388 #define   VGA_GR_MEM_A0000_BFFFF 1
389 #define   VGA_GR_MEM_B0000_B7FFF 2
390 #define   VGA_GR_MEM_B0000_BFFFF 3
391
392 #define VGA_DACMASK 0x3c6
393 #define VGA_DACRX 0x3c7
394 #define VGA_DACWX 0x3c8
395 #define VGA_DACDATA 0x3c9
396
397 #define VGA_CR_INDEX_MDA 0x3b4
398 #define VGA_CR_DATA_MDA 0x3b5
399 #define VGA_CR_INDEX_CGA 0x3d4
400 #define VGA_CR_DATA_CGA 0x3d5
401
402 #define GFX_OP_USER_INTERRUPT           ((0<<29)|(2<<23))
403 #define GFX_OP_BREAKPOINT_INTERRUPT     ((0<<29)|(1<<23))
404 #define CMD_REPORT_HEAD                 (7<<23)
405 #define CMD_STORE_DWORD_IDX             ((0x21<<23) | 0x1)
406 #define CMD_OP_BATCH_BUFFER  ((0x0<<29)|(0x30<<23)|0x1)
407
408 #define CMD_MI_FLUSH         (0x04 << 23)
409 #define MI_NO_WRITE_FLUSH    (1 << 2)
410 #define MI_READ_FLUSH        (1 << 0)
411 #define MI_EXE_FLUSH         (1 << 1)
412 #define MI_END_SCENE         (1 << 4) /* flush binner and incr scene count */
413 #define MI_SCENE_COUNT       (1 << 3) /* just increment scene count */
414
415 /* Packet to load a register value from the ring/batch command stream:
416  */
417 #define CMD_MI_LOAD_REGISTER_IMM        ((0x22 << 23)|0x1)
418
419 #define BB1_START_ADDR_MASK   (~0x7)
420 #define BB1_PROTECTED         (1<<0)
421 #define BB1_UNPROTECTED       (0<<0)
422 #define BB2_END_ADDR_MASK     (~0x7)
423
424 /* Framebuffer compression */
425 #define FBC_CFB_BASE            0x03200 /* 4k page aligned */
426 #define FBC_LL_BASE             0x03204 /* 4k page aligned */
427 #define FBC_CONTROL             0x03208
428 #define   FBC_CTL_EN            (1<<31)
429 #define   FBC_CTL_PERIODIC      (1<<30)
430 #define   FBC_CTL_INTERVAL_SHIFT (16)
431 #define   FBC_CTL_UNCOMPRESSIBLE (1<<14)
432 #define   FBC_CTL_STRIDE_SHIFT  (5)
433 #define   FBC_CTL_FENCENO       (1<<0)
434 #define FBC_COMMAND             0x0320c
435 #define   FBC_CMD_COMPRESS      (1<<0)
436 #define FBC_STATUS              0x03210
437 #define   FBC_STAT_COMPRESSING  (1<<31)
438 #define   FBC_STAT_COMPRESSED   (1<<30)
439 #define   FBC_STAT_MODIFIED     (1<<29)
440 #define   FBC_STAT_CURRENT_LINE (1<<0)
441 #define FBC_CONTROL2            0x03214
442 #define   FBC_CTL_FENCE_DBL     (0<<4)
443 #define   FBC_CTL_IDLE_IMM      (0<<2)
444 #define   FBC_CTL_IDLE_FULL     (1<<2)
445 #define   FBC_CTL_IDLE_LINE     (2<<2)
446 #define   FBC_CTL_IDLE_DEBUG    (3<<2)
447 #define   FBC_CTL_CPU_FENCE     (1<<1)
448 #define   FBC_CTL_PLANEA        (0<<0)
449 #define   FBC_CTL_PLANEB        (1<<0)
450 #define FBC_FENCE_OFF           0x0321b
451
452 #define FBC_LL_SIZE             (1536)
453 #define FBC_LL_PAD              (32)
454
455 /* Interrupt bits:
456  */
457 #define USER_INT_FLAG    (1<<1)
458 #define VSYNC_PIPEB_FLAG (1<<5)
459 #define VSYNC_PIPEA_FLAG (1<<7)
460 #define HWB_OOM_FLAG     (1<<13) /* binner out of memory */
461
462 #define I915REG_HWSTAM          0x02098
463 #define I915REG_INT_IDENTITY_R  0x020a4
464 #define I915REG_INT_MASK_R      0x020a8
465 #define I915REG_INT_ENABLE_R    0x020a0
466 #define I915REG_INSTPM          0x020c0
467
468 #define PIPEADSL                0x70000
469 #define PIPEBDSL                0x71000
470
471 #define I915REG_PIPEASTAT       0x70024
472 #define I915REG_PIPEBSTAT       0x71024
473 /*
474  * The two pipe frame counter registers are not synchronized, so
475  * reading a stable value is somewhat tricky. The following code 
476  * should work:
477  *
478  *  do {
479  *    high1 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
480  *             PIPE_FRAME_HIGH_SHIFT;
481  *    low1 =  ((INREG(PIPEAFRAMEPIXEL) & PIPE_FRAME_LOW_MASK) >>
482  *             PIPE_FRAME_LOW_SHIFT);
483  *    high2 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
484  *             PIPE_FRAME_HIGH_SHIFT);
485  *  } while (high1 != high2);
486  *  frame = (high1 << 8) | low1;
487  */
488 #define PIPEAFRAMEHIGH          0x70040
489 #define PIPEBFRAMEHIGH          0x71040
490 #define PIPE_FRAME_HIGH_MASK    0x0000ffff
491 #define PIPE_FRAME_HIGH_SHIFT   0
492 #define PIPEAFRAMEPIXEL         0x70044
493 #define PIPEBFRAMEPIXEL         0x71044
494
495 #define PIPE_FRAME_LOW_MASK     0xff000000
496 #define PIPE_FRAME_LOW_SHIFT    24
497 /*
498  * Pixel within the current frame is counted in the PIPEAFRAMEPIXEL register
499  * and is 24 bits wide.
500  */
501 #define PIPE_PIXEL_MASK         0x00ffffff
502 #define PIPE_PIXEL_SHIFT        0
503
504 #define I915_VBLANK_INTERRUPT_ENABLE    (1UL<<17)
505 #define I915_VBLANK_CLEAR               (1UL<<1)
506
507 #define SRX_INDEX               0x3c4
508 #define SRX_DATA                0x3c5
509 #define SR01                    1
510 #define SR01_SCREEN_OFF         (1<<5)
511
512 #define PPCR                    0x61204
513 #define PPCR_ON                 (1<<0)
514
515 #define DVOB                    0x61140
516 #define DVOB_ON                 (1<<31)
517 #define DVOC                    0x61160
518 #define DVOC_ON                 (1<<31)
519 #define LVDS                    0x61180
520 #define LVDS_ON                 (1<<31)
521
522 #define ADPA                    0x61100
523 #define ADPA_DPMS_MASK          (~(3<<10))
524 #define ADPA_DPMS_ON            (0<<10)
525 #define ADPA_DPMS_SUSPEND       (1<<10)
526 #define ADPA_DPMS_STANDBY       (2<<10)
527 #define ADPA_DPMS_OFF           (3<<10)
528
529 #define NOPID                   0x2094
530 #define LP_RING                 0x2030
531 #define HP_RING                 0x2040
532 /* The binner has its own ring buffer:
533  */
534 #define HWB_RING                0x2400
535
536 #define RING_TAIL               0x00
537 #define TAIL_ADDR               0x001FFFF8
538 #define RING_HEAD               0x04
539 #define HEAD_WRAP_COUNT         0xFFE00000
540 #define HEAD_WRAP_ONE           0x00200000
541 #define HEAD_ADDR               0x001FFFFC
542 #define RING_START              0x08
543 #define START_ADDR              0x0xFFFFF000
544 #define RING_LEN                0x0C
545 #define RING_NR_PAGES           0x001FF000
546 #define RING_REPORT_MASK        0x00000006
547 #define RING_REPORT_64K         0x00000002
548 #define RING_REPORT_128K        0x00000004
549 #define RING_NO_REPORT          0x00000000
550 #define RING_VALID_MASK         0x00000001
551 #define RING_VALID              0x00000001
552 #define RING_INVALID            0x00000000
553
554 /* Instruction parser error reg:
555  */
556 #define IPEIR                   0x2088
557
558 /* Scratch pad debug 0 reg:
559  */
560 #define SCPD0                   0x209c
561
562 /* Error status reg:
563  */
564 #define ESR                     0x20b8
565
566 /* Secondary DMA fetch address debug reg:
567  */
568 #define DMA_FADD_S              0x20d4
569
570 /* Cache mode 0 reg.
571  *  - Manipulating render cache behaviour is central
572  *    to the concept of zone rendering, tuning this reg can help avoid
573  *    unnecessary render cache reads and even writes (for z/stencil)
574  *    at beginning and end of scene.
575  *
576  * - To change a bit, write to this reg with a mask bit set and the
577  * bit of interest either set or cleared.  EG: (BIT<<16) | BIT to set.
578  */
579 #define Cache_Mode_0            0x2120
580 #define CM0_MASK_SHIFT          16
581 #define CM0_IZ_OPT_DISABLE      (1<<6)
582 #define CM0_ZR_OPT_DISABLE      (1<<5)
583 #define CM0_DEPTH_EVICT_DISABLE (1<<4)
584 #define CM0_COLOR_EVICT_DISABLE (1<<3)
585 #define CM0_DEPTH_WRITE_DISABLE (1<<1)
586 #define CM0_RC_OP_FLUSH_DISABLE (1<<0)
587
588
589 /* Graphics flush control.  A CPU write flushes the GWB of all writes.
590  * The data is discarded.
591  */
592 #define GFX_FLSH_CNTL           0x2170
593
594 /* Binner control.  Defines the location of the bin pointer list:
595  */
596 #define BINCTL                  0x2420
597 #define BC_MASK                 (1 << 9)
598
599 /* Binned scene info.
600  */
601 #define BINSCENE                0x2428
602 #define BS_OP_LOAD              (1 << 8)
603 #define BS_MASK                 (1 << 22)
604
605 /* Bin command parser debug reg:
606  */
607 #define BCPD                    0x2480
608
609 /* Bin memory control debug reg:
610  */
611 #define BMCD                    0x2484
612
613 /* Bin data cache debug reg:
614  */
615 #define BDCD                    0x2488
616
617 /* Binner pointer cache debug reg:
618  */
619 #define BPCD                    0x248c
620
621 /* Binner scratch pad debug reg:
622  */
623 #define BINSKPD                 0x24f0
624
625 /* HWB scratch pad debug reg:
626  */
627 #define HWBSKPD                 0x24f4
628
629 /* Binner memory pool reg:
630  */
631 #define BMP_BUFFER              0x2430
632 #define BMP_PAGE_SIZE_4K        (0 << 10)
633 #define BMP_BUFFER_SIZE_SHIFT   1
634 #define BMP_ENABLE              (1 << 0)
635
636 /* Get/put memory from the binner memory pool:
637  */
638 #define BMP_GET                 0x2438
639 #define BMP_PUT                 0x2440
640 #define BMP_OFFSET_SHIFT        5
641
642 /* 3D state packets:
643  */
644 #define GFX_OP_RASTER_RULES    ((0x3<<29)|(0x7<<24))
645
646 #define GFX_OP_SCISSOR         ((0x3<<29)|(0x1c<<24)|(0x10<<19))
647 #define SC_UPDATE_SCISSOR       (0x1<<1)
648 #define SC_ENABLE_MASK          (0x1<<0)
649 #define SC_ENABLE               (0x1<<0)
650
651 #define GFX_OP_LOAD_INDIRECT   ((0x3<<29)|(0x1d<<24)|(0x7<<16))
652
653 #define GFX_OP_SCISSOR_INFO    ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
654 #define SCI_YMIN_MASK      (0xffff<<16)
655 #define SCI_XMIN_MASK      (0xffff<<0)
656 #define SCI_YMAX_MASK      (0xffff<<16)
657 #define SCI_XMAX_MASK      (0xffff<<0)
658
659 #define GFX_OP_SCISSOR_ENABLE    ((0x3<<29)|(0x1c<<24)|(0x10<<19))
660 #define GFX_OP_SCISSOR_RECT      ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
661 #define GFX_OP_COLOR_FACTOR      ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
662 #define GFX_OP_STIPPLE           ((0x3<<29)|(0x1d<<24)|(0x83<<16))
663 #define GFX_OP_MAP_INFO          ((0x3<<29)|(0x1d<<24)|0x4)
664 #define GFX_OP_DESTBUFFER_VARS   ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
665 #define GFX_OP_DRAWRECT_INFO     ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
666
667 #define GFX_OP_DRAWRECT_INFO_I965  ((0x7900<<16)|0x2)
668
669 #define SRC_COPY_BLT_CMD                ((2<<29)|(0x43<<22)|4)
670 #define XY_SRC_COPY_BLT_CMD             ((2<<29)|(0x53<<22)|6)
671 #define XY_SRC_COPY_BLT_WRITE_ALPHA     (1<<21)
672 #define XY_SRC_COPY_BLT_WRITE_RGB       (1<<20)
673
674 #define MI_BATCH_BUFFER         ((0x30<<23)|1)
675 #define MI_BATCH_BUFFER_START   (0x31<<23)
676 #define MI_BATCH_BUFFER_END     (0xA<<23)
677 #define MI_BATCH_NON_SECURE     (1)
678
679 #define MI_BATCH_NON_SECURE_I965 (1<<8)
680
681 #define MI_WAIT_FOR_EVENT       ((0x3<<23))
682 #define MI_WAIT_FOR_PLANE_B_FLIP      (1<<6)
683 #define MI_WAIT_FOR_PLANE_A_FLIP      (1<<2)
684 #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
685
686 #define MI_LOAD_SCAN_LINES_INCL  ((0x12<<23))
687
688 #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
689 #define ASYNC_FLIP                (1<<22)
690 #define DISPLAY_PLANE_A           (0<<20)
691 #define DISPLAY_PLANE_B           (1<<20)
692
693 /* Display regs */
694 #define DSPACNTR                0x70180
695 #define DSPBCNTR                0x71180
696 #define DISPPLANE_SEL_PIPE_MASK                 (1<<24)
697
698 /* Define the region of interest for the binner:
699  */
700 #define CMD_OP_BIN_CONTROL       ((0x3<<29)|(0x1d<<24)|(0x84<<16)|4)
701
702 #define CMD_OP_DESTBUFFER_INFO   ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
703
704 #define BREADCRUMB_BITS 31
705 #define BREADCRUMB_MASK ((1U << BREADCRUMB_BITS) - 1)
706
707 #define READ_BREADCRUMB(dev_priv)  (((volatile u32*)(dev_priv->hw_status_page))[5])
708 #define READ_HWSP(dev_priv, reg)  (((volatile u32*)(dev_priv->hw_status_page))[reg])
709
710 #define BLC_PWM_CTL             0x61254
711 #define BACKLIGHT_MODULATION_FREQ_SHIFT         (17)
712
713 #define BLC_PWM_CTL2            0x61250
714 /**
715  * This is the most significant 15 bits of the number of backlight cycles in a
716  * complete cycle of the modulated backlight control.
717  *
718  * The actual value is this field multiplied by two.
719  */
720 #define BACKLIGHT_MODULATION_FREQ_MASK          (0x7fff << 17)
721 #define BLM_LEGACY_MODE                         (1 << 16)
722 /**
723  * This is the number of cycles out of the backlight modulation cycle for which
724  * the backlight is on.
725  *
726  * This field must be no greater than the number of cycles in the complete
727  * backlight modulation cycle.
728  */
729 #define BACKLIGHT_DUTY_CYCLE_SHIFT              (0)
730 #define BACKLIGHT_DUTY_CYCLE_MASK               (0xffff)
731
732 #define I915_GCFGC                      0xf0
733 #define I915_LOW_FREQUENCY_ENABLE               (1 << 7)
734 #define I915_DISPLAY_CLOCK_190_200_MHZ          (0 << 4)
735 #define I915_DISPLAY_CLOCK_333_MHZ              (4 << 4)
736 #define I915_DISPLAY_CLOCK_MASK                 (7 << 4)
737
738 #define I855_HPLLCC                     0xc0
739 #define I855_CLOCK_CONTROL_MASK                 (3 << 0)
740 #define I855_CLOCK_133_200                      (0 << 0)
741 #define I855_CLOCK_100_200                      (1 << 0)
742 #define I855_CLOCK_100_133                      (2 << 0)
743 #define I855_CLOCK_166_250                      (3 << 0)
744
745 /* p317, 319
746  */
747 #define VCLK2_VCO_M        0x6008 /* treat as 16 bit? (includes msbs) */
748 #define VCLK2_VCO_N        0x600a
749 #define VCLK2_VCO_DIV_SEL  0x6012
750
751 #define VCLK_DIVISOR_VGA0   0x6000
752 #define VCLK_DIVISOR_VGA1   0x6004
753 #define VCLK_POST_DIV       0x6010
754 /** Selects a post divisor of 4 instead of 2. */
755 # define VGA1_PD_P2_DIV_4       (1 << 15)
756 /** Overrides the p2 post divisor field */
757 # define VGA1_PD_P1_DIV_2       (1 << 13)
758 # define VGA1_PD_P1_SHIFT       8
759 /** P1 value is 2 greater than this field */
760 # define VGA1_PD_P1_MASK        (0x1f << 8)
761 /** Selects a post divisor of 4 instead of 2. */
762 # define VGA0_PD_P2_DIV_4       (1 << 7)
763 /** Overrides the p2 post divisor field */
764 # define VGA0_PD_P1_DIV_2       (1 << 5)
765 # define VGA0_PD_P1_SHIFT       0
766 /** P1 value is 2 greater than this field */
767 # define VGA0_PD_P1_MASK        (0x1f << 0)
768
769 /* I830 CRTC registers */
770 #define HTOTAL_A        0x60000
771 #define HBLANK_A        0x60004
772 #define HSYNC_A         0x60008
773 #define VTOTAL_A        0x6000c
774 #define VBLANK_A        0x60010
775 #define VSYNC_A         0x60014
776 #define PIPEASRC        0x6001c
777 #define BCLRPAT_A       0x60020
778 #define VSYNCSHIFT_A    0x60028
779
780 #define HTOTAL_B        0x61000
781 #define HBLANK_B        0x61004
782 #define HSYNC_B         0x61008
783 #define VTOTAL_B        0x6100c
784 #define VBLANK_B        0x61010
785 #define VSYNC_B         0x61014
786 #define PIPEBSRC        0x6101c
787 #define BCLRPAT_B       0x61020
788 #define VSYNCSHIFT_B    0x61028
789
790 #define HACTIVE_MASK    0x00000fff
791 #define VTOTAL_MASK     0x00001fff
792 #define VTOTAL_SHIFT    16
793 #define VACTIVE_MASK    0x00000fff
794 #define VBLANK_END_MASK 0x00001fff
795 #define VBLANK_END_SHIFT 16
796 #define VBLANK_START_MASK 0x00001fff
797
798 #define PP_STATUS       0x61200
799 # define PP_ON                                  (1 << 31)
800 /**
801  * Indicates that all dependencies of the panel are on:
802  *
803  * - PLL enabled
804  * - pipe enabled
805  * - LVDS/DVOB/DVOC on
806  */
807 # define PP_READY                               (1 << 30)
808 # define PP_SEQUENCE_NONE                       (0 << 28)
809 # define PP_SEQUENCE_ON                         (1 << 28)
810 # define PP_SEQUENCE_OFF                        (2 << 28)
811 # define PP_SEQUENCE_MASK                       0x30000000
812 #define PP_CONTROL      0x61204
813 # define POWER_TARGET_ON                        (1 << 0)
814
815 #define LVDSPP_ON       0x61208
816 #define LVDSPP_OFF      0x6120c
817 #define PP_CYCLE        0x61210
818
819 #define PFIT_CONTROL    0x61230
820 # define PFIT_ENABLE                            (1 << 31)
821 # define PFIT_PIPE_MASK                         (3 << 29)
822 # define PFIT_PIPE_SHIFT                        29
823 # define VERT_INTERP_DISABLE                    (0 << 10)
824 # define VERT_INTERP_BILINEAR                   (1 << 10)
825 # define VERT_INTERP_MASK                       (3 << 10)
826 # define VERT_AUTO_SCALE                        (1 << 9)
827 # define HORIZ_INTERP_DISABLE                   (0 << 6)
828 # define HORIZ_INTERP_BILINEAR                  (1 << 6)
829 # define HORIZ_INTERP_MASK                      (3 << 6)
830 # define HORIZ_AUTO_SCALE                       (1 << 5)
831 # define PANEL_8TO6_DITHER_ENABLE               (1 << 3)
832
833 #define PFIT_PGM_RATIOS 0x61234
834 # define PFIT_VERT_SCALE_MASK                   0xfff00000
835 # define PFIT_HORIZ_SCALE_MASK                  0x0000fff0
836
837 #define PFIT_AUTO_RATIOS        0x61238
838
839
840 #define DPLL_A          0x06014
841 #define DPLL_B          0x06018
842 # define DPLL_VCO_ENABLE                        (1 << 31)
843 # define DPLL_DVO_HIGH_SPEED                    (1 << 30)
844 # define DPLL_SYNCLOCK_ENABLE                   (1 << 29)
845 # define DPLL_VGA_MODE_DIS                      (1 << 28)
846 # define DPLLB_MODE_DAC_SERIAL                  (1 << 26) /* i915 */
847 # define DPLLB_MODE_LVDS                        (2 << 26) /* i915 */
848 # define DPLL_MODE_MASK                         (3 << 26)
849 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10        (0 << 24) /* i915 */
850 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5         (1 << 24) /* i915 */
851 # define DPLLB_LVDS_P2_CLOCK_DIV_14             (0 << 24) /* i915 */
852 # define DPLLB_LVDS_P2_CLOCK_DIV_7              (1 << 24) /* i915 */
853 # define DPLL_P2_CLOCK_DIV_MASK                 0x03000000 /* i915 */
854 # define DPLL_FPA01_P1_POST_DIV_MASK            0x00ff0000 /* i915 */
855 /**
856  *  The i830 generation, in DAC/serial mode, defines p1 as two plus this
857  * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
858  */
859 # define DPLL_FPA01_P1_POST_DIV_MASK_I830       0x001f0000
860 /**
861  * The i830 generation, in LVDS mode, defines P1 as the bit number set within
862  * this field (only one bit may be set).
863  */
864 # define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS  0x003f0000
865 # define DPLL_FPA01_P1_POST_DIV_SHIFT           16
866 # define PLL_P2_DIVIDE_BY_4                     (1 << 23) /* i830, required in DVO non-gang */
867 # define PLL_P1_DIVIDE_BY_TWO                   (1 << 21) /* i830 */
868 # define PLL_REF_INPUT_DREFCLK                  (0 << 13)
869 # define PLL_REF_INPUT_TVCLKINA                 (1 << 13) /* i830 */
870 # define PLL_REF_INPUT_TVCLKINBC                (2 << 13) /* SDVO TVCLKIN */
871 # define PLLB_REF_INPUT_SPREADSPECTRUMIN        (3 << 13)
872 # define PLL_REF_INPUT_MASK                     (3 << 13)
873 # define PLL_LOAD_PULSE_PHASE_SHIFT             9
874 /*
875  * Parallel to Serial Load Pulse phase selection.
876  * Selects the phase for the 10X DPLL clock for the PCIe
877  * digital display port. The range is 4 to 13; 10 or more
878  * is just a flip delay. The default is 6
879  */
880 # define PLL_LOAD_PULSE_PHASE_MASK              (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
881 # define DISPLAY_RATE_SELECT_FPA1               (1 << 8)
882
883 /**
884  * SDVO multiplier for 945G/GM. Not used on 965.
885  *
886  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
887  */
888 # define SDVO_MULTIPLIER_MASK                   0x000000ff
889 # define SDVO_MULTIPLIER_SHIFT_HIRES            4
890 # define SDVO_MULTIPLIER_SHIFT_VGA              0
891
892 /** @defgroup DPLL_MD
893  * @{
894  */
895 /** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
896 #define DPLL_A_MD               0x0601c
897 /** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
898 #define DPLL_B_MD               0x06020
899 /**
900  * UDI pixel divider, controlling how many pixels are stuffed into a packet.
901  *
902  * Value is pixels minus 1.  Must be set to 1 pixel for SDVO.
903  */
904 # define DPLL_MD_UDI_DIVIDER_MASK               0x3f000000
905 # define DPLL_MD_UDI_DIVIDER_SHIFT              24
906 /** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
907 # define DPLL_MD_VGA_UDI_DIVIDER_MASK           0x003f0000
908 # define DPLL_MD_VGA_UDI_DIVIDER_SHIFT          16
909 /**
910  * SDVO/UDI pixel multiplier.
911  *
912  * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
913  * clock rate is 10 times the DPLL clock.  At low resolution/refresh rate
914  * modes, the bus rate would be below the limits, so SDVO allows for stuffing
915  * dummy bytes in the datastream at an increased clock rate, with both sides of
916  * the link knowing how many bytes are fill.
917  *
918  * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
919  * rate to 130Mhz to get a bus rate of 1.30Ghz.  The DPLL clock rate would be
920  * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
921  * through an SDVO command.
922  *
923  * This register field has values of multiplication factor minus 1, with
924  * a maximum multiplier of 5 for SDVO.
925  */
926 # define DPLL_MD_UDI_MULTIPLIER_MASK            0x00003f00
927 # define DPLL_MD_UDI_MULTIPLIER_SHIFT           8
928 /** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
929  * This best be set to the default value (3) or the CRT won't work. No,
930  * I don't entirely understand what this does...
931  */
932 # define DPLL_MD_VGA_UDI_MULTIPLIER_MASK        0x0000003f
933 # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT       0
934 /** @} */
935
936 #define DPLL_TEST               0x606c
937 # define DPLLB_TEST_SDVO_DIV_1                  (0 << 22)
938 # define DPLLB_TEST_SDVO_DIV_2                  (1 << 22)
939 # define DPLLB_TEST_SDVO_DIV_4                  (2 << 22)
940 # define DPLLB_TEST_SDVO_DIV_MASK               (3 << 22)
941 # define DPLLB_TEST_N_BYPASS                    (1 << 19)
942 # define DPLLB_TEST_M_BYPASS                    (1 << 18)
943 # define DPLLB_INPUT_BUFFER_ENABLE              (1 << 16)
944 # define DPLLA_TEST_N_BYPASS                    (1 << 3)
945 # define DPLLA_TEST_M_BYPASS                    (1 << 2)
946 # define DPLLA_INPUT_BUFFER_ENABLE              (1 << 0)
947
948 #define ADPA                    0x61100
949 #define ADPA_DAC_ENABLE         (1<<31)
950 #define ADPA_DAC_DISABLE        0
951 #define ADPA_PIPE_SELECT_MASK   (1<<30)
952 #define ADPA_PIPE_A_SELECT      0
953 #define ADPA_PIPE_B_SELECT      (1<<30)
954 #define ADPA_USE_VGA_HVPOLARITY (1<<15)
955 #define ADPA_SETS_HVPOLARITY    0
956 #define ADPA_VSYNC_CNTL_DISABLE (1<<11)
957 #define ADPA_VSYNC_CNTL_ENABLE  0
958 #define ADPA_HSYNC_CNTL_DISABLE (1<<10)
959 #define ADPA_HSYNC_CNTL_ENABLE  0
960 #define ADPA_VSYNC_ACTIVE_HIGH  (1<<4)
961 #define ADPA_VSYNC_ACTIVE_LOW   0
962 #define ADPA_HSYNC_ACTIVE_HIGH  (1<<3)
963 #define ADPA_HSYNC_ACTIVE_LOW   0
964
965 #define FPA0            0x06040
966 #define FPA1            0x06044
967 #define FPB0            0x06048
968 #define FPB1            0x0604c
969 # define FP_N_DIV_MASK                          0x003f0000
970 # define FP_N_DIV_SHIFT                         16
971 # define FP_M1_DIV_MASK                         0x00003f00
972 # define FP_M1_DIV_SHIFT                        8
973 # define FP_M2_DIV_MASK                         0x0000003f
974 # define FP_M2_DIV_SHIFT                        0
975
976
977 #define PORT_HOTPLUG_EN         0x61110
978 # define SDVOB_HOTPLUG_INT_EN                   (1 << 26)
979 # define SDVOC_HOTPLUG_INT_EN                   (1 << 25)
980 # define TV_HOTPLUG_INT_EN                      (1 << 18)
981 # define CRT_HOTPLUG_INT_EN                     (1 << 9)
982 # define CRT_HOTPLUG_FORCE_DETECT               (1 << 3)
983
984 #define PORT_HOTPLUG_STAT       0x61114
985 # define CRT_HOTPLUG_INT_STATUS                 (1 << 11)
986 # define TV_HOTPLUG_INT_STATUS                  (1 << 10)
987 # define CRT_HOTPLUG_MONITOR_MASK               (3 << 8)
988 # define CRT_HOTPLUG_MONITOR_COLOR              (3 << 8)
989 # define CRT_HOTPLUG_MONITOR_MONO               (2 << 8)
990 # define CRT_HOTPLUG_MONITOR_NONE               (0 << 8)
991 # define SDVOC_HOTPLUG_INT_STATUS               (1 << 7)
992 # define SDVOB_HOTPLUG_INT_STATUS               (1 << 6)
993
994 #define SDVOB                   0x61140
995 #define SDVOC                   0x61160
996 #define SDVO_ENABLE                             (1 << 31)
997 #define SDVO_PIPE_B_SELECT                      (1 << 30)
998 #define SDVO_STALL_SELECT                       (1 << 29)
999 #define SDVO_INTERRUPT_ENABLE                   (1 << 26)
1000 /**
1001  * 915G/GM SDVO pixel multiplier.
1002  *
1003  * Programmed value is multiplier - 1, up to 5x.
1004  *
1005  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1006  */
1007 #define SDVO_PORT_MULTIPLY_MASK                 (7 << 23)
1008 #define SDVO_PORT_MULTIPLY_SHIFT                23
1009 #define SDVO_PHASE_SELECT_MASK                  (15 << 19)
1010 #define SDVO_PHASE_SELECT_DEFAULT               (6 << 19)
1011 #define SDVO_CLOCK_OUTPUT_INVERT                (1 << 18)
1012 #define SDVOC_GANG_MODE                         (1 << 16)
1013 #define SDVO_BORDER_ENABLE                      (1 << 7)
1014 #define SDVOB_PCIE_CONCURRENCY                  (1 << 3)
1015 #define SDVO_DETECTED                           (1 << 2)
1016 /* Bits to be preserved when writing */
1017 #define SDVOB_PRESERVE_MASK                     ((1 << 17) | (1 << 16) | (1 << 14))
1018 #define SDVOC_PRESERVE_MASK                     (1 << 17)
1019
1020 /** @defgroup LVDS
1021  * @{
1022  */
1023 /**
1024  * This register controls the LVDS output enable, pipe selection, and data
1025  * format selection.
1026  *
1027  * All of the clock/data pairs are force powered down by power sequencing.
1028  */
1029 #define LVDS                    0x61180
1030 /**
1031  * Enables the LVDS port.  This bit must be set before DPLLs are enabled, as
1032  * the DPLL semantics change when the LVDS is assigned to that pipe.
1033  */
1034 # define LVDS_PORT_EN                   (1 << 31)
1035 /** Selects pipe B for LVDS data.  Must be set on pre-965. */
1036 # define LVDS_PIPEB_SELECT              (1 << 30)
1037
1038 /**
1039  * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
1040  * pixel.
1041  */
1042 # define LVDS_A0A2_CLKA_POWER_MASK      (3 << 8)
1043 # define LVDS_A0A2_CLKA_POWER_DOWN      (0 << 8)
1044 # define LVDS_A0A2_CLKA_POWER_UP        (3 << 8)
1045 /**
1046  * Controls the A3 data pair, which contains the additional LSBs for 24 bit
1047  * mode.  Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
1048  * on.
1049  */
1050 # define LVDS_A3_POWER_MASK             (3 << 6)
1051 # define LVDS_A3_POWER_DOWN             (0 << 6)
1052 # define LVDS_A3_POWER_UP               (3 << 6)
1053 /**
1054  * Controls the CLKB pair.  This should only be set when LVDS_B0B3_POWER_UP
1055  * is set.
1056  */
1057 # define LVDS_CLKB_POWER_MASK           (3 << 4)
1058 # define LVDS_CLKB_POWER_DOWN           (0 << 4)
1059 # define LVDS_CLKB_POWER_UP             (3 << 4)
1060
1061 /**
1062  * Controls the B0-B3 data pairs.  This must be set to match the DPLL p2
1063  * setting for whether we are in dual-channel mode.  The B3 pair will
1064  * additionally only be powered up when LVDS_A3_POWER_UP is set.
1065  */
1066 # define LVDS_B0B3_POWER_MASK           (3 << 2)
1067 # define LVDS_B0B3_POWER_DOWN           (0 << 2)
1068 # define LVDS_B0B3_POWER_UP             (3 << 2)
1069
1070 #define PIPEACONF 0x70008
1071 #define PIPEACONF_ENABLE        (1<<31)
1072 #define PIPEACONF_DISABLE       0
1073 #define PIPEACONF_DOUBLE_WIDE   (1<<30)
1074 #define I965_PIPECONF_ACTIVE    (1<<30)
1075 #define PIPEACONF_SINGLE_WIDE   0
1076 #define PIPEACONF_PIPE_UNLOCKED 0
1077 #define PIPEACONF_PIPE_LOCKED   (1<<25)
1078 #define PIPEACONF_PALETTE       0
1079 #define PIPEACONF_GAMMA         (1<<24)
1080 #define PIPECONF_FORCE_BORDER   (1<<25)
1081 #define PIPECONF_PROGRESSIVE    (0 << 21)
1082 #define PIPECONF_INTERLACE_W_FIELD_INDICATION   (6 << 21)
1083 #define PIPECONF_INTERLACE_FIELD_0_ONLY         (7 << 21)
1084
1085 #define PIPEBCONF 0x71008
1086 #define PIPEBCONF_ENABLE        (1<<31)
1087 #define PIPEBCONF_DISABLE       0
1088 #define PIPEBCONF_DOUBLE_WIDE   (1<<30)
1089 #define PIPEBCONF_DISABLE       0
1090 #define PIPEBCONF_GAMMA         (1<<24)
1091 #define PIPEBCONF_PALETTE       0
1092
1093 #define PIPEBGCMAXRED           0x71010
1094 #define PIPEBGCMAXGREEN         0x71014
1095 #define PIPEBGCMAXBLUE          0x71018
1096 #define PIPEBSTAT               0x71024
1097 #define PIPEBFRAMEHIGH          0x71040
1098 #define PIPEBFRAMEPIXEL         0x71044
1099
1100 #define DSPACNTR                0x70180
1101 #define DSPBCNTR                0x71180
1102 #define DISPLAY_PLANE_ENABLE                    (1<<31)
1103 #define DISPLAY_PLANE_DISABLE                   0
1104 #define DISPPLANE_GAMMA_ENABLE                  (1<<30)
1105 #define DISPPLANE_GAMMA_DISABLE                 0
1106 #define DISPPLANE_PIXFORMAT_MASK                (0xf<<26)
1107 #define DISPPLANE_8BPP                          (0x2<<26)
1108 #define DISPPLANE_15_16BPP                      (0x4<<26)
1109 #define DISPPLANE_16BPP                         (0x5<<26)
1110 #define DISPPLANE_32BPP_NO_ALPHA                (0x6<<26)
1111 #define DISPPLANE_32BPP                         (0x7<<26)
1112 #define DISPPLANE_STEREO_ENABLE                 (1<<25)
1113 #define DISPPLANE_STEREO_DISABLE                0
1114 #define DISPPLANE_SEL_PIPE_MASK                 (1<<24)
1115 #define DISPPLANE_SEL_PIPE_A                    0
1116 #define DISPPLANE_SEL_PIPE_B                    (1<<24)
1117 #define DISPPLANE_SRC_KEY_ENABLE                (1<<22)
1118 #define DISPPLANE_SRC_KEY_DISABLE               0
1119 #define DISPPLANE_LINE_DOUBLE                   (1<<20)
1120 #define DISPPLANE_NO_LINE_DOUBLE                0
1121 #define DISPPLANE_STEREO_POLARITY_FIRST         0
1122 #define DISPPLANE_STEREO_POLARITY_SECOND        (1<<18)
1123 /* plane B only */
1124 #define DISPPLANE_ALPHA_TRANS_ENABLE            (1<<15)
1125 #define DISPPLANE_ALPHA_TRANS_DISABLE           0
1126 #define DISPPLANE_SPRITE_ABOVE_DISPLAYA         0
1127 #define DISPPLANE_SPRITE_ABOVE_OVERLAY          (1)
1128
1129 #define DSPABASE                0x70184
1130 #define DSPASTRIDE              0x70188
1131
1132 #define DSPBBASE                0x71184
1133 #define DSPBADDR                DSPBBASE
1134 #define DSPBSTRIDE              0x71188
1135
1136 #define DSPAKEYVAL              0x70194
1137 #define DSPAKEYMASK             0x70198
1138
1139 #define DSPAPOS                 0x7018C /* reserved */
1140 #define DSPASIZE                0x70190
1141 #define DSPBPOS                 0x7118C
1142 #define DSPBSIZE                0x71190
1143
1144 #define DSPASURF                0x7019C
1145 #define DSPATILEOFF             0x701A4
1146
1147 #define DSPBSURF                0x7119C
1148 #define DSPBTILEOFF             0x711A4
1149
1150 #define VGACNTRL                0x71400
1151 # define VGA_DISP_DISABLE                       (1 << 31)
1152 # define VGA_2X_MODE                            (1 << 30)
1153 # define VGA_PIPE_B_SELECT                      (1 << 29)
1154
1155 /*
1156  * Some BIOS scratch area registers.  The 845 (and 830?) store the amount
1157  * of video memory available to the BIOS in SWF1.
1158  */
1159
1160 #define SWF0                    0x71410
1161
1162 /*
1163  * 855 scratch registers.
1164  */
1165 #define SWF10                   0x70410
1166
1167 #define SWF30                   0x72414
1168
1169 /*
1170  * Overlay registers.  These are overlay registers accessed via MMIO.
1171  * Those loaded via the overlay register page are defined in i830_video.c.
1172  */
1173 #define OVADD                   0x30000
1174
1175 #define DOVSTA                  0x30008
1176 #define OC_BUF                  (0x3<<20)
1177
1178 #define OGAMC5                  0x30010
1179 #define OGAMC4                  0x30014
1180 #define OGAMC3                  0x30018
1181 #define OGAMC2                  0x3001c
1182 #define OGAMC1                  0x30020
1183 #define OGAMC0                  0x30024
1184 /*
1185  * Palette registers
1186  */
1187 #define PALETTE_A               0x0a000
1188 #define PALETTE_B               0x0a800
1189
1190 #define IS_I830(dev) ((dev)->pci_device == 0x3577)
1191 #define IS_845G(dev) ((dev)->pci_device == 0x2562)
1192 #define IS_I85X(dev) ((dev)->pci_device == 0x3582)
1193 #define IS_I855(dev) ((dev)->pci_device == 0x3582)
1194 #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
1195
1196 #define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
1197 #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
1198 #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
1199 #define IS_I945GM(dev) ((dev)->pci_device == 0x27A2)
1200
1201 #define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
1202                        (dev)->pci_device == 0x2982 || \
1203                        (dev)->pci_device == 0x2992 || \
1204                        (dev)->pci_device == 0x29A2 || \
1205                        (dev)->pci_device == 0x2A02 || \
1206                        (dev)->pci_device == 0x2A12 || \
1207                        (dev)->pci_device == 0x2A42)
1208
1209 #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
1210
1211 #define IS_IGD_GM(dev) ((dev)->pci_device == 0x2A42)
1212
1213 #define IS_G33(dev)    ((dev)->pci_device == 0x29C2 ||  \
1214                         (dev)->pci_device == 0x29B2 ||  \
1215                         (dev)->pci_device == 0x29D2)
1216
1217 #define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
1218                       IS_I945GM(dev) || IS_I965G(dev) || IS_G33(dev))
1219
1220 #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
1221                         IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev))
1222
1223 #define PRIMARY_RINGBUFFER_SIZE         (128*1024)
1224
1225 #endif