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