OSDN Git Service

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