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