82d2c50ccb56beab509432e88ebf91f7442903f1
[profile/ivi/libdrm.git] / shared-core / i915_drv.h
1 /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
2  */
3 /*
4  *
5  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6  * All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sub license, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice (including the
17  * next paragraph) shall be included in all copies or substantial portions
18  * of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
23  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
24  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  *
28  */
29
30 #ifndef _I915_DRV_H_
31 #define _I915_DRV_H_
32
33 /* General customization:
34  */
35
36 #define DRIVER_AUTHOR           "Tungsten Graphics, Inc."
37
38 #define DRIVER_NAME             "i915"
39 #define DRIVER_DESC             "Intel Graphics"
40 #define DRIVER_DATE             "20080611"
41
42 #if defined(__linux__)
43 #define I915_HAVE_FENCE
44 #define I915_HAVE_BUFFER
45 #endif
46
47 /* Interface history:
48  *
49  * 1.1: Original.
50  * 1.2: Add Power Management
51  * 1.3: Add vblank support
52  * 1.4: Fix cmdbuffer path, add heap destroy
53  * 1.5: Add vblank pipe configuration
54  * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
55  *      - Support vertical blank on secondary display pipe
56  * 1.8: New ioctl for ARB_Occlusion_Query
57  * 1.9: Usable page flipping and triple buffering
58  * 1.10: Plane/pipe disentangling
59  * 1.11: TTM superioctl
60  * 1.12: TTM relocation optimization
61  */
62 #define DRIVER_MAJOR            1
63 #if defined(I915_HAVE_FENCE) && defined(I915_HAVE_BUFFER)
64 #define DRIVER_MINOR            14
65 #else
66 #define DRIVER_MINOR            6
67 #endif
68 #define DRIVER_PATCHLEVEL       0
69
70 #ifdef I915_HAVE_BUFFER
71 #define I915_MAX_VALIDATE_BUFFERS 4096
72 struct drm_i915_validate_buffer;
73 #endif
74
75 typedef struct _drm_i915_ring_buffer {
76         int tail_mask;
77         unsigned long Size;
78         u8 *virtual_start;
79         int head;
80         int tail;
81         int space;
82         drm_local_map_t map;
83         struct drm_gem_object *ring_obj;
84 } drm_i915_ring_buffer_t;
85
86 struct mem_block {
87         struct mem_block *next;
88         struct mem_block *prev;
89         int start;
90         int size;
91         struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
92 };
93
94 typedef struct _drm_i915_vbl_swap {
95         struct list_head head;
96         drm_drawable_t drw_id;
97         unsigned int plane;
98         unsigned int sequence;
99         int flip;
100 } drm_i915_vbl_swap_t;
101
102 typedef struct drm_i915_private {
103         struct drm_device *dev;
104
105         drm_local_map_t *sarea;
106         drm_local_map_t *mmio_map;
107
108         drm_i915_sarea_t *sarea_priv;
109         drm_i915_ring_buffer_t ring;
110
111         drm_dma_handle_t *status_page_dmah;
112         void *hw_status_page;
113         dma_addr_t dma_status_page;
114         uint32_t counter;
115         unsigned int status_gfx_addr;
116         drm_local_map_t hws_map;
117
118         unsigned int cpp;
119
120         wait_queue_head_t irq_queue;
121         atomic_t irq_received;
122
123         int tex_lru_log_granularity;
124         int allow_batchbuffer;
125         struct mem_block *agp_heap;
126         unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
127         int vblank_pipe;
128         DRM_SPINTYPE user_irq_lock;
129         int user_irq_refcount;
130         int fence_irq_on;
131         uint32_t irq_mask_reg;
132         uint32_t irq_enable_reg;
133         int irq_use_mask;
134         int irq_enabled;
135
136 #ifdef I915_HAVE_FENCE
137         uint32_t flush_sequence;
138         uint32_t flush_flags;
139         uint32_t flush_pending;
140         uint32_t saved_flush_status;
141 #endif
142 #ifdef I915_HAVE_BUFFER
143         void *agp_iomap;
144         unsigned int max_validate_buffers;
145         struct mutex cmdbuf_mutex;
146         struct drm_i915_validate_buffer *val_bufs;
147 #endif
148
149         DRM_SPINTYPE swaps_lock;
150         drm_i915_vbl_swap_t vbl_swaps;
151         unsigned int swaps_pending;
152 #if defined(I915_HAVE_BUFFER)
153         /* DRI2 sarea */
154         struct drm_buffer_object *sarea_bo;
155         struct drm_bo_kmap_obj sarea_kmap;
156 #endif
157         /* Register state */
158         u8 saveLBB;
159         u32 saveDSPACNTR;
160         u32 saveDSPBCNTR;
161         u32 saveDSPARB;
162         u32 savePIPEACONF;
163         u32 savePIPEBCONF;
164         u32 savePIPEASRC;
165         u32 savePIPEBSRC;
166         u32 saveFPA0;
167         u32 saveFPA1;
168         u32 saveDPLL_A;
169         u32 saveDPLL_A_MD;
170         u32 saveHTOTAL_A;
171         u32 saveHBLANK_A;
172         u32 saveHSYNC_A;
173         u32 saveVTOTAL_A;
174         u32 saveVBLANK_A;
175         u32 saveVSYNC_A;
176         u32 saveBCLRPAT_A;
177         u32 savePIPEASTAT;
178         u32 saveDSPASTRIDE;
179         u32 saveDSPASIZE;
180         u32 saveDSPAPOS;
181         u32 saveDSPABASE;
182         u32 saveDSPASURF;
183         u32 saveDSPATILEOFF;
184         u32 savePFIT_PGM_RATIOS;
185         u32 saveBLC_PWM_CTL;
186         u32 saveBLC_PWM_CTL2;
187         u32 saveFPB0;
188         u32 saveFPB1;
189         u32 saveDPLL_B;
190         u32 saveDPLL_B_MD;
191         u32 saveHTOTAL_B;
192         u32 saveHBLANK_B;
193         u32 saveHSYNC_B;
194         u32 saveVTOTAL_B;
195         u32 saveVBLANK_B;
196         u32 saveVSYNC_B;
197         u32 saveBCLRPAT_B;
198         u32 savePIPEBSTAT;
199         u32 saveDSPBSTRIDE;
200         u32 saveDSPBSIZE;
201         u32 saveDSPBPOS;
202         u32 saveDSPBBASE;
203         u32 saveDSPBSURF;
204         u32 saveDSPBTILEOFF;
205         u32 saveVCLK_DIVISOR_VGA0;
206         u32 saveVCLK_DIVISOR_VGA1;
207         u32 saveVCLK_POST_DIV;
208         u32 saveVGACNTRL;
209         u32 saveADPA;
210         u32 saveLVDS;
211         u32 saveLVDSPP_ON;
212         u32 saveLVDSPP_OFF;
213         u32 saveDVOA;
214         u32 saveDVOB;
215         u32 saveDVOC;
216         u32 savePP_ON;
217         u32 savePP_OFF;
218         u32 savePP_CONTROL;
219         u32 savePP_CYCLE;
220         u32 savePFIT_CONTROL;
221         u32 save_palette_a[256];
222         u32 save_palette_b[256];
223         u32 saveFBC_CFB_BASE;
224         u32 saveFBC_LL_BASE;
225         u32 saveFBC_CONTROL;
226         u32 saveFBC_CONTROL2;
227         u32 saveIER;
228         u32 saveIIR;
229         u32 saveIMR;
230         u32 saveCACHE_MODE_0;
231         u32 saveD_STATE;
232         u32 saveDSPCLK_GATE_D;
233         u32 saveMI_ARB_STATE;
234         u32 saveSWF0[16];
235         u32 saveSWF1[16];
236         u32 saveSWF2[3];
237         u8 saveMSR;
238         u8 saveSR[8];
239         u8 saveGR[25];
240         u8 saveAR_INDEX;
241         u8 saveAR[21];
242         u8 saveDACMASK;
243         u8 saveDACDATA[256*3]; /* 256 3-byte colors */
244         u8 saveCR[37];
245
246         struct {
247                 struct drm_memrange gtt_space;
248
249                 /**
250                  * List of objects currently involved in rendering from the
251                  * ringbuffer.
252                  *
253                  * A reference is held on the buffer while on this list.
254                  */
255                 struct list_head active_list;
256
257                 /**
258                  * List of objects which are not in the ringbuffer but which
259                  * still have a write_domain which needs to be flushed before
260                  * unbinding.
261                  *
262                  * A reference is held on the buffer while on this list.
263                  */
264                 struct list_head flushing_list;
265
266                 /**
267                  * LRU list of objects which are not in the ringbuffer and
268                  * are ready to unbind, but are still in the GTT.
269                  *
270                  * A reference is not held on the buffer while on this list,
271                  * as merely being GTT-bound shouldn't prevent its being
272                  * freed, and we'll pull it off the list in the free path.
273                  */
274                 struct list_head inactive_list;
275
276                 /**
277                  * List of breadcrumbs associated with GPU requests currently
278                  * outstanding.
279                  */
280                 struct list_head request_list;
281
282                 /**
283                  * We leave the user IRQ off as much as possible,
284                  * but this means that requests will finish and never
285                  * be retired once the system goes idle. Set a timer to
286                  * fire periodically while the ring is running. When it
287                  * fires, go retire requests.
288                  */
289                 struct delayed_work retire_work;
290                 
291                 uint32_t next_gem_seqno;
292
293                 /**
294                  * Waiting sequence number, if any
295                  */
296                 uint32_t waiting_gem_seqno;
297         
298                 /**
299                  * Last seq seen at irq time
300                  */
301                 uint32_t irq_gem_seqno;
302
303                 /**
304                  * Flag if the X Server, and thus DRM, is not currently in
305                  * control of the device.
306                  *
307                  * This is set between LeaveVT and EnterVT.  It needs to be
308                  * replaced with a semaphore.  It also needs to be
309                  * transitioned away from for kernel modesetting.
310                  */
311                 int suspended;
312         } mm;
313 } drm_i915_private_t;
314
315 struct drm_i915_file_private {
316         struct {
317                 uint32_t last_gem_seqno;
318                 uint32_t last_gem_throttle_seqno;
319         } mm;
320 };
321
322 enum intel_chip_family {
323         CHIP_I8XX = 0x01,
324         CHIP_I9XX = 0x02,
325         CHIP_I915 = 0x04,
326         CHIP_I965 = 0x08,
327 };
328
329 /** driver private structure attached to each drm_gem_object */
330 struct drm_i915_gem_object {
331         struct drm_gem_object *obj;
332
333         /** Current space allocated to this object in the GTT, if any. */
334         struct drm_memrange_node *gtt_space;
335
336         /** This object's place on the active/flushing/inactive lists */
337         struct list_head list;
338
339         /**
340          * This is set if the object is on the active or flushing lists
341          * (has pending rendering), and is not set if it's on inactive (ready
342          * to be unbound).
343          */
344         int active;
345
346         /**
347          * This is set if the object has been written to since last bound
348          * to the GTT
349          */
350         int dirty;
351
352         /** AGP memory structure for our GTT binding. */
353         DRM_AGP_MEM *agp_mem;
354
355         struct page **page_list;
356
357         /**
358          * Current offset of the object in GTT space.
359          *
360          * This is the same as gtt_space->start
361          */
362         uint32_t gtt_offset;
363
364         /** Boolean whether this object has a valid gtt offset. */
365         int gtt_bound;
366
367         /** How many users have pinned this object in GTT space */
368         int pin_count;
369
370         /** Breadcrumb of last rendering to the buffer. */
371         uint32_t last_rendering_seqno;
372 };
373
374 /**
375  * Request queue structure.
376  *
377  * The request queue allows us to note sequence numbers that have been emitted
378  * and may be associated with active buffers to be retired.
379  *
380  * By keeping this list, we can avoid having to do questionable
381  * sequence-number comparisons on buffer last_rendering_seqnos, and associate
382  * an emission time with seqnos for tracking how far ahead of the GPU we are.
383  */
384 struct drm_i915_gem_request {
385         /** GEM sequence number associated with this request. */
386         uint32_t seqno;
387
388         /** Time at which this request was emitted, in jiffies. */
389         unsigned long emitted_jiffies;
390
391         /** Cache domains that were flushed at the start of the request. */
392         uint32_t flush_domains;
393
394         struct list_head list;
395 };
396
397 extern struct drm_ioctl_desc i915_ioctls[];
398 extern int i915_max_ioctl;
399
400                                 /* i915_dma.c */
401 extern void i915_kernel_lost_context(struct drm_device * dev);
402 extern int i915_driver_load(struct drm_device *, unsigned long flags);
403 extern int i915_driver_unload(struct drm_device *);
404 extern void i915_driver_lastclose(struct drm_device * dev);
405 extern int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv);
406 extern void i915_driver_preclose(struct drm_device *dev,
407                                  struct drm_file *file_priv);
408 extern void i915_driver_postclose(struct drm_device *dev,
409                                   struct drm_file *file_priv);
410 extern int i915_driver_device_is_agp(struct drm_device * dev);
411 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
412                               unsigned long arg);
413 extern void i915_emit_breadcrumb(struct drm_device *dev);
414 extern void i915_dispatch_flip(struct drm_device * dev, int pipes, int sync);
415 extern int i915_emit_mi_flush(struct drm_device *dev, uint32_t flush);
416 extern int i915_driver_firstopen(struct drm_device *dev);
417 extern int i915_dispatch_batchbuffer(struct drm_device * dev,
418                                      drm_i915_batchbuffer_t * batch);
419 extern int i915_quiescent(struct drm_device *dev);
420
421 int i915_emit_box(struct drm_device * dev,
422                   struct drm_clip_rect __user * boxes,
423                   int i, int DR1, int DR4);
424
425 /* i915_irq.c */
426 extern int i915_irq_emit(struct drm_device *dev, void *data,
427                          struct drm_file *file_priv);
428 extern int i915_irq_wait(struct drm_device *dev, void *data,
429                          struct drm_file *file_priv);
430
431 extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
432 extern void i915_driver_irq_preinstall(struct drm_device * dev);
433 extern int i915_driver_irq_postinstall(struct drm_device * dev);
434 extern void i915_driver_irq_uninstall(struct drm_device * dev);
435 extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
436                                 struct drm_file *file_priv);
437 extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
438                                 struct drm_file *file_priv);
439 extern int i915_emit_irq(struct drm_device * dev);
440 extern int i915_wait_irq(struct drm_device * dev, int irq_nr);
441 extern int i915_enable_vblank(struct drm_device *dev, int crtc);
442 extern void i915_disable_vblank(struct drm_device *dev, int crtc);
443 extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
444 extern int i915_vblank_swap(struct drm_device *dev, void *data,
445                             struct drm_file *file_priv);
446 extern void i915_user_irq_on(drm_i915_private_t *dev_priv);
447 extern void i915_user_irq_off(drm_i915_private_t *dev_priv);
448
449 /* i915_mem.c */
450 extern int i915_mem_alloc(struct drm_device *dev, void *data,
451                           struct drm_file *file_priv);
452 extern int i915_mem_free(struct drm_device *dev, void *data,
453                          struct drm_file *file_priv);
454 extern int i915_mem_init_heap(struct drm_device *dev, void *data,
455                               struct drm_file *file_priv);
456 extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
457                                  struct drm_file *file_priv);
458 extern void i915_mem_takedown(struct mem_block **heap);
459 extern void i915_mem_release(struct drm_device * dev,
460                              struct drm_file *file_priv,
461                              struct mem_block *heap);
462 #ifdef I915_HAVE_FENCE
463 /* i915_fence.c */
464 extern void i915_fence_handler(struct drm_device *dev);
465 extern void i915_invalidate_reported_sequence(struct drm_device *dev);
466
467 #endif
468
469 #ifdef I915_HAVE_BUFFER
470 /* i915_buffer.c */
471 extern struct drm_ttm_backend *i915_create_ttm_backend_entry(struct drm_device *dev);
472 extern int i915_fence_type(struct drm_buffer_object *bo, uint32_t *fclass,
473                            uint32_t *type);
474 extern int i915_invalidate_caches(struct drm_device *dev, uint64_t buffer_flags);
475 extern int i915_init_mem_type(struct drm_device *dev, uint32_t type,
476                                struct drm_mem_type_manager *man);
477 extern uint64_t i915_evict_flags(struct drm_buffer_object *bo);
478 extern int i915_move(struct drm_buffer_object *bo, int evict,
479                 int no_wait, struct drm_bo_mem_reg *new_mem);
480 void i915_flush_ttm(struct drm_ttm *ttm);
481 /* i915_execbuf.c */
482 int i915_execbuffer(struct drm_device *dev, void *data,
483                                    struct drm_file *file_priv);
484 /* i915_gem.c */
485 int i915_gem_init_ioctl(struct drm_device *dev, void *data,
486                         struct drm_file *file_priv);
487 int i915_gem_create_ioctl(struct drm_device *dev, void *data,
488                           struct drm_file *file_priv);
489 int i915_gem_pread_ioctl(struct drm_device *dev, void *data,
490                          struct drm_file *file_priv);
491 int i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
492                           struct drm_file *file_priv);
493 int i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
494                         struct drm_file *file_priv);
495 int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
496                               struct drm_file *file_priv);
497 int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
498                              struct drm_file *file_priv);
499 int i915_gem_execbuffer(struct drm_device *dev, void *data,
500                         struct drm_file *file_priv);
501 int i915_gem_pin_ioctl(struct drm_device *dev, void *data,
502                        struct drm_file *file_priv);
503 int i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
504                          struct drm_file *file_priv);
505 int i915_gem_busy_ioctl(struct drm_device *dev, void *data,
506                         struct drm_file *file_priv);
507 int i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
508                             struct drm_file *file_priv);
509 int i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
510                            struct drm_file *file_priv);
511 int i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
512                            struct drm_file *file_priv);
513 int i915_gem_proc_init(struct drm_minor *minor);
514 void i915_gem_proc_cleanup(struct drm_minor *minor);
515 int i915_gem_init_object(struct drm_gem_object *obj);
516 void i915_gem_free_object(struct drm_gem_object *obj);
517 int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment);
518 void i915_gem_object_unpin(struct drm_gem_object *obj);
519 void i915_gem_lastclose(struct drm_device *dev);
520 uint32_t i915_get_gem_seqno(struct drm_device *dev);
521 void i915_gem_retire_requests(struct drm_device *dev);
522 void i915_gem_retire_work_handler(struct work_struct *work);
523 #endif
524
525 #ifdef __linux__
526 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
527 extern void intel_init_chipset_flush_compat(struct drm_device *dev);
528 extern void intel_fini_chipset_flush_compat(struct drm_device *dev);
529 #endif
530 #endif
531
532 #define I915_READ(reg)          DRM_READ32(dev_priv->mmio_map, (reg))
533 #define I915_WRITE(reg,val)     DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
534 #define I915_READ16(reg)        DRM_READ16(dev_priv->mmio_map, (reg))
535 #define I915_WRITE16(reg,val)   DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
536
537 #define I915_VERBOSE 0
538 #define I915_RING_VALIDATE 0
539
540 #define RING_LOCALS     unsigned int outring, ringmask, outcount; \
541                         volatile char *virt;
542
543 #if I915_RING_VALIDATE
544 void i915_ring_validate(struct drm_device *dev, const char *func, int line);
545 #define I915_RING_DO_VALIDATE(dev) i915_ring_validate(dev, __FUNCTION__, __LINE__)
546 #else
547 #define I915_RING_DO_VALIDATE(dev)
548 #endif
549
550 #define BEGIN_LP_RING(n) do {                           \
551         if (I915_VERBOSE)                               \
552                 DRM_DEBUG("BEGIN_LP_RING(%d)\n",        \
553                                  (n));                  \
554         I915_RING_DO_VALIDATE(dev);                     \
555         if (dev_priv->ring.space < (n)*4)                      \
556                 i915_wait_ring(dev, (n)*4, __FUNCTION__);      \
557         outcount = 0;                                   \
558         outring = dev_priv->ring.tail;                  \
559         ringmask = dev_priv->ring.tail_mask;            \
560         virt = dev_priv->ring.virtual_start;            \
561 } while (0)
562
563 #define OUT_RING(n) do {                                        \
564         if (I915_VERBOSE) DRM_DEBUG("   OUT_RING %x\n", (int)(n));      \
565         *(volatile unsigned int *)(virt + outring) = (n);               \
566         outcount++;                                             \
567         outring += 4;                                           \
568         outring &= ringmask;                                    \
569 } while (0)
570
571 #define ADVANCE_LP_RING() do {                                          \
572         if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring);   \
573         I915_RING_DO_VALIDATE(dev);                                     \
574         dev_priv->ring.tail = outring;                                  \
575         dev_priv->ring.space -= outcount * 4;                           \
576         I915_WRITE(LP_RING + RING_TAIL, outring);                       \
577 } while(0)
578
579 extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
580
581 /* Extended config space */
582 #define LBB 0xf4
583
584 /* VGA stuff */
585
586 #define VGA_ST01_MDA 0x3ba
587 #define VGA_ST01_CGA 0x3da
588
589 #define VGA_MSR_WRITE 0x3c2
590 #define VGA_MSR_READ 0x3cc
591 #define   VGA_MSR_MEM_EN (1<<1)
592 #define   VGA_MSR_CGA_MODE (1<<0)
593
594 #define VGA_SR_INDEX 0x3c4
595 #define VGA_SR_DATA 0x3c5
596
597 #define VGA_AR_INDEX 0x3c0
598 #define   VGA_AR_VID_EN (1<<5)
599 #define VGA_AR_DATA_WRITE 0x3c0
600 #define VGA_AR_DATA_READ 0x3c1
601
602 #define VGA_GR_INDEX 0x3ce
603 #define VGA_GR_DATA 0x3cf
604 /* GR05 */
605 #define   VGA_GR_MEM_READ_MODE_SHIFT 3
606 #define     VGA_GR_MEM_READ_MODE_PLANE 1
607 /* GR06 */
608 #define   VGA_GR_MEM_MODE_MASK 0xc
609 #define   VGA_GR_MEM_MODE_SHIFT 2
610 #define   VGA_GR_MEM_A0000_AFFFF 0
611 #define   VGA_GR_MEM_A0000_BFFFF 1
612 #define   VGA_GR_MEM_B0000_B7FFF 2
613 #define   VGA_GR_MEM_B0000_BFFFF 3
614
615 #define VGA_DACMASK 0x3c6
616 #define VGA_DACRX 0x3c7
617 #define VGA_DACWX 0x3c8
618 #define VGA_DACDATA 0x3c9
619
620 #define VGA_CR_INDEX_MDA 0x3b4
621 #define VGA_CR_DATA_MDA 0x3b5
622 #define VGA_CR_INDEX_CGA 0x3d4
623 #define VGA_CR_DATA_CGA 0x3d5
624
625 #define GFX_OP_USER_INTERRUPT           ((0<<29)|(2<<23))
626 #define GFX_OP_BREAKPOINT_INTERRUPT     ((0<<29)|(1<<23))
627 #define CMD_REPORT_HEAD                 (7<<23)
628 #define CMD_STORE_DWORD_IMM             ((0x20<<23) | (0x1 << 22) | 0x1)
629 /**
630  * Stores a 32-bit integer to the status page at the dword index given.
631  */
632 #define CMD_STORE_DWORD_IDX             ((0x21<<23) | 0x1)
633 # define STORE_DWORD_INDEX_SHIFT                2
634
635 #define CMD_OP_BATCH_BUFFER  ((0x0<<29)|(0x30<<23)|0x1)
636
637 #define CMD_MI_FLUSH         (0x04 << 23)
638 #define MI_NO_WRITE_FLUSH    (1 << 2)
639 #define MI_READ_FLUSH        (1 << 0)
640 #define MI_EXE_FLUSH         (1 << 1)
641 #define MI_END_SCENE         (1 << 4) /* flush binner and incr scene count */
642 #define MI_SCENE_COUNT       (1 << 3) /* just increment scene count */
643
644 /* Packet to load a register value from the ring/batch command stream:
645  */
646 #define CMD_MI_LOAD_REGISTER_IMM        ((0x22 << 23)|0x1)
647
648 #define BB1_START_ADDR_MASK   (~0x7)
649 #define BB1_PROTECTED         (1<<0)
650 #define BB1_UNPROTECTED       (0<<0)
651 #define BB2_END_ADDR_MASK     (~0x7)
652
653 /* Framebuffer compression */
654 #define FBC_CFB_BASE            0x03200 /* 4k page aligned */
655 #define FBC_LL_BASE             0x03204 /* 4k page aligned */
656 #define FBC_CONTROL             0x03208
657 #define   FBC_CTL_EN            (1<<31)
658 #define   FBC_CTL_PERIODIC      (1<<30)
659 #define   FBC_CTL_INTERVAL_SHIFT (16)
660 #define   FBC_CTL_UNCOMPRESSIBLE (1<<14)
661 #define   FBC_CTL_STRIDE_SHIFT  (5)
662 #define   FBC_CTL_FENCENO       (1<<0)
663 #define FBC_COMMAND             0x0320c
664 #define   FBC_CMD_COMPRESS      (1<<0)
665 #define FBC_STATUS              0x03210
666 #define   FBC_STAT_COMPRESSING  (1<<31)
667 #define   FBC_STAT_COMPRESSED   (1<<30)
668 #define   FBC_STAT_MODIFIED     (1<<29)
669 #define   FBC_STAT_CURRENT_LINE (1<<0)
670 #define FBC_CONTROL2            0x03214
671 #define   FBC_CTL_FENCE_DBL     (0<<4)
672 #define   FBC_CTL_IDLE_IMM      (0<<2)
673 #define   FBC_CTL_IDLE_FULL     (1<<2)
674 #define   FBC_CTL_IDLE_LINE     (2<<2)
675 #define   FBC_CTL_IDLE_DEBUG    (3<<2)
676 #define   FBC_CTL_CPU_FENCE     (1<<1)
677 #define   FBC_CTL_PLANEA        (0<<0)
678 #define   FBC_CTL_PLANEB        (1<<0)
679 #define FBC_FENCE_OFF           0x0321b
680
681 #define FBC_LL_SIZE             (1536)
682 #define FBC_LL_PAD              (32)
683
684 /* Interrupt bits:
685  */
686 #define I915_PIPE_CONTROL_NOTIFY_INTERRUPT              (1<<18)
687 #define I915_DISPLAY_PORT_INTERRUPT                     (1<<17)
688 #define I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT      (1<<15)
689 #define I915_GMCH_THERMAL_SENSOR_EVENT_INTERRUPT        (1<<14)
690 #define I915_HWB_OOM_INTERRUPT                          (1<<13) /* binner out of memory */
691 #define I915_SYNC_STATUS_INTERRUPT                      (1<<12)
692 #define I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT     (1<<11)
693 #define I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT     (1<<10)
694 #define I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT       (1<<9)
695 #define I915_DISPLAY_PLANE_C_FLIP_PENDING_INTERRUPT     (1<<8)
696 #define I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT            (1<<7)
697 #define I915_DISPLAY_PIPE_A_EVENT_INTERRUPT             (1<<6)
698 #define I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT            (1<<5)
699 #define I915_DISPLAY_PIPE_B_EVENT_INTERRUPT             (1<<4)
700 #define I915_DEBUG_INTERRUPT                            (1<<2)
701 #define I915_USER_INTERRUPT                             (1<<1)
702
703
704 #define I915REG_HWSTAM          0x02098
705 #define I915REG_INT_IDENTITY_R  0x020a4
706 #define I915REG_INT_MASK_R      0x020a8
707 #define I915REG_INT_ENABLE_R    0x020a0
708 #define I915REG_INSTPM          0x020c0
709 #define I965REG_ACTHD           0x02074
710 #define I915REG_ACTHD           0x020C8
711
712 #define PIPEADSL                0x70000
713 #define PIPEBDSL                0x71000
714
715 #define I915REG_PIPEASTAT       0x70024
716 #define I915REG_PIPEBSTAT       0x71024
717 /*
718  * The two pipe frame counter registers are not synchronized, so
719  * reading a stable value is somewhat tricky. The following code 
720  * should work:
721  *
722  *  do {
723  *    high1 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
724  *             PIPE_FRAME_HIGH_SHIFT;
725  *    low1 =  ((INREG(PIPEAFRAMEPIXEL) & PIPE_FRAME_LOW_MASK) >>
726  *             PIPE_FRAME_LOW_SHIFT);
727  *    high2 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
728  *             PIPE_FRAME_HIGH_SHIFT);
729  *  } while (high1 != high2);
730  *  frame = (high1 << 8) | low1;
731  */
732 #define PIPEAFRAMEHIGH          0x70040
733 #define PIPEBFRAMEHIGH          0x71040
734 #define PIPE_FRAME_HIGH_MASK    0x0000ffff
735 #define PIPE_FRAME_HIGH_SHIFT   0
736 #define PIPEAFRAMEPIXEL         0x70044
737 #define PIPEBFRAMEPIXEL         0x71044
738
739 #define PIPE_FRAME_LOW_MASK     0xff000000
740 #define PIPE_FRAME_LOW_SHIFT    24
741 /*
742  * Pixel within the current frame is counted in the PIPEAFRAMEPIXEL register
743  * and is 24 bits wide.
744  */
745 #define PIPE_PIXEL_MASK         0x00ffffff
746 #define PIPE_PIXEL_SHIFT        0
747
748 #define I915_FIFO_UNDERRUN_STATUS               (1UL<<31)
749 #define I915_CRC_ERROR_ENABLE                   (1UL<<29)
750 #define I915_CRC_DONE_ENABLE                    (1UL<<28)
751 #define I915_GMBUS_EVENT_ENABLE                 (1UL<<27)
752 #define I915_VSYNC_INTERRUPT_ENABLE             (1UL<<25)
753 #define I915_DISPLAY_LINE_COMPARE_ENABLE        (1UL<<24)
754 #define I915_DPST_EVENT_ENABLE                  (1UL<<23)
755 #define I915_LEGACY_BLC_EVENT_ENABLE            (1UL<<22)
756 #define I915_ODD_FIELD_INTERRUPT_ENABLE         (1UL<<21)
757 #define I915_EVEN_FIELD_INTERRUPT_ENABLE        (1UL<<20)
758 #define I915_START_VBLANK_INTERRUPT_ENABLE      (1UL<<18)       /* 965 or later */
759 #define I915_VBLANK_INTERRUPT_ENABLE            (1UL<<17)
760 #define I915_OVERLAY_UPDATED_ENABLE             (1UL<<16)
761 #define I915_CRC_ERROR_INTERRUPT_STATUS         (1UL<<13)
762 #define I915_CRC_DONE_INTERRUPT_STATUS          (1UL<<12)
763 #define I915_GMBUS_INTERRUPT_STATUS             (1UL<<11)
764 #define I915_VSYNC_INTERRUPT_STATUS             (1UL<<9)
765 #define I915_DISPLAY_LINE_COMPARE_STATUS        (1UL<<8)
766 #define I915_DPST_EVENT_STATUS                  (1UL<<7)
767 #define I915_LEGACY_BLC_EVENT_STATUS            (1UL<<6)
768 #define I915_ODD_FIELD_INTERRUPT_STATUS         (1UL<<5)
769 #define I915_EVEN_FIELD_INTERRUPT_STATUS        (1UL<<4)
770 #define I915_START_VBLANK_INTERRUPT_STATUS      (1UL<<2)        /* 965 or later */
771 #define I915_VBLANK_INTERRUPT_STATUS            (1UL<<1)
772 #define I915_OVERLAY_UPDATED_STATUS             (1UL<<0)
773
774 #define SRX_INDEX               0x3c4
775 #define SRX_DATA                0x3c5
776 #define SR01                    1
777 #define SR01_SCREEN_OFF         (1<<5)
778
779 #define PPCR                    0x61204
780 #define PPCR_ON                 (1<<0)
781
782 #define DVOB                    0x61140
783 #define DVOB_ON                 (1<<31)
784 #define DVOC                    0x61160
785 #define DVOC_ON                 (1<<31)
786 #define LVDS                    0x61180
787 #define LVDS_ON                 (1<<31)
788
789 #define ADPA                    0x61100
790 #define ADPA_DPMS_MASK          (~(3<<10))
791 #define ADPA_DPMS_ON            (0<<10)
792 #define ADPA_DPMS_SUSPEND       (1<<10)
793 #define ADPA_DPMS_STANDBY       (2<<10)
794 #define ADPA_DPMS_OFF           (3<<10)
795
796 #define NOPID                   0x2094
797 #define LP_RING                 0x2030
798 #define HP_RING                 0x2040
799 /* The binner has its own ring buffer:
800  */
801 #define HWB_RING                0x2400
802
803 #define RING_TAIL               0x00
804 #define TAIL_ADDR               0x001FFFF8
805 #define RING_HEAD               0x04
806 #define HEAD_WRAP_COUNT         0xFFE00000
807 #define HEAD_WRAP_ONE           0x00200000
808 #define HEAD_ADDR               0x001FFFFC
809 #define RING_START              0x08
810 #define START_ADDR              0xFFFFF000
811 #define RING_LEN                0x0C
812 #define RING_NR_PAGES           0x001FF000
813 #define RING_REPORT_MASK        0x00000006
814 #define RING_REPORT_64K         0x00000002
815 #define RING_REPORT_128K        0x00000004
816 #define RING_NO_REPORT          0x00000000
817 #define RING_VALID_MASK         0x00000001
818 #define RING_VALID              0x00000001
819 #define RING_INVALID            0x00000000
820
821 /* Instruction parser error reg:
822  */
823 #define IPEIR                   0x2088
824
825 /* Scratch pad debug 0 reg:
826  */
827 #define SCPD0                   0x209c
828
829 /* Error status reg:
830  */
831 #define ESR                     0x20b8
832
833 /* Secondary DMA fetch address debug reg:
834  */
835 #define DMA_FADD_S              0x20d4
836
837 /* Memory Interface Arbitration State
838  */
839 #define MI_ARB_STATE            0x20e4
840
841 /* Cache mode 0 reg.
842  *  - Manipulating render cache behaviour is central
843  *    to the concept of zone rendering, tuning this reg can help avoid
844  *    unnecessary render cache reads and even writes (for z/stencil)
845  *    at beginning and end of scene.
846  *
847  * - To change a bit, write to this reg with a mask bit set and the
848  * bit of interest either set or cleared.  EG: (BIT<<16) | BIT to set.
849  */
850 #define Cache_Mode_0            0x2120
851 #define CACHE_MODE_0            0x2120
852 #define CM0_MASK_SHIFT          16
853 #define CM0_IZ_OPT_DISABLE      (1<<6)
854 #define CM0_ZR_OPT_DISABLE      (1<<5)
855 #define CM0_DEPTH_EVICT_DISABLE (1<<4)
856 #define CM0_COLOR_EVICT_DISABLE (1<<3)
857 #define CM0_DEPTH_WRITE_DISABLE (1<<1)
858 #define CM0_RC_OP_FLUSH_DISABLE (1<<0)
859
860
861 /* Graphics flush control.  A CPU write flushes the GWB of all writes.
862  * The data is discarded.
863  */
864 #define GFX_FLSH_CNTL           0x2170
865
866 /* Binner control.  Defines the location of the bin pointer list:
867  */
868 #define BINCTL                  0x2420
869 #define BC_MASK                 (1 << 9)
870
871 /* Binned scene info.
872  */
873 #define BINSCENE                0x2428
874 #define BS_OP_LOAD              (1 << 8)
875 #define BS_MASK                 (1 << 22)
876
877 /* Bin command parser debug reg:
878  */
879 #define BCPD                    0x2480
880
881 /* Bin memory control debug reg:
882  */
883 #define BMCD                    0x2484
884
885 /* Bin data cache debug reg:
886  */
887 #define BDCD                    0x2488
888
889 /* Binner pointer cache debug reg:
890  */
891 #define BPCD                    0x248c
892
893 /* Binner scratch pad debug reg:
894  */
895 #define BINSKPD                 0x24f0
896
897 /* HWB scratch pad debug reg:
898  */
899 #define HWBSKPD                 0x24f4
900
901 /* Binner memory pool reg:
902  */
903 #define BMP_BUFFER              0x2430
904 #define BMP_PAGE_SIZE_4K        (0 << 10)
905 #define BMP_BUFFER_SIZE_SHIFT   1
906 #define BMP_ENABLE              (1 << 0)
907
908 /* Get/put memory from the binner memory pool:
909  */
910 #define BMP_GET                 0x2438
911 #define BMP_PUT                 0x2440
912 #define BMP_OFFSET_SHIFT        5
913
914 /* 3D state packets:
915  */
916 #define GFX_OP_RASTER_RULES    ((0x3<<29)|(0x7<<24))
917
918 #define GFX_OP_SCISSOR         ((0x3<<29)|(0x1c<<24)|(0x10<<19))
919 #define SC_UPDATE_SCISSOR       (0x1<<1)
920 #define SC_ENABLE_MASK          (0x1<<0)
921 #define SC_ENABLE               (0x1<<0)
922
923 #define GFX_OP_LOAD_INDIRECT   ((0x3<<29)|(0x1d<<24)|(0x7<<16))
924
925 #define GFX_OP_SCISSOR_INFO    ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
926 #define SCI_YMIN_MASK      (0xffff<<16)
927 #define SCI_XMIN_MASK      (0xffff<<0)
928 #define SCI_YMAX_MASK      (0xffff<<16)
929 #define SCI_XMAX_MASK      (0xffff<<0)
930
931 #define GFX_OP_SCISSOR_ENABLE    ((0x3<<29)|(0x1c<<24)|(0x10<<19))
932 #define GFX_OP_SCISSOR_RECT      ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
933 #define GFX_OP_COLOR_FACTOR      ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
934 #define GFX_OP_STIPPLE           ((0x3<<29)|(0x1d<<24)|(0x83<<16))
935 #define GFX_OP_MAP_INFO          ((0x3<<29)|(0x1d<<24)|0x4)
936 #define GFX_OP_DESTBUFFER_VARS   ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
937 #define GFX_OP_DRAWRECT_INFO     ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
938
939 #define GFX_OP_DRAWRECT_INFO_I965  ((0x7900<<16)|0x2)
940
941 #define SRC_COPY_BLT_CMD                ((2<<29)|(0x43<<22)|4)
942 #define XY_SRC_COPY_BLT_CMD             ((2<<29)|(0x53<<22)|6)
943 #define XY_SRC_COPY_BLT_WRITE_ALPHA     (1<<21)
944 #define XY_SRC_COPY_BLT_WRITE_RGB       (1<<20)
945 #define XY_SRC_COPY_BLT_SRC_TILED       (1<<15)
946 #define XY_SRC_COPY_BLT_DST_TILED       (1<<11)
947
948 #define MI_NOOP                 (0)
949 #define  MI_NOOP_ENABLE_NOPID   (1 << 22)
950 #define  MI_NOOP_ID_MASK        ((1 << 22) - 1)
951
952 #define MI_BATCH_BUFFER         ((0x30<<23)|1)
953 #define MI_BATCH_BUFFER_START   (0x31<<23)
954 #define MI_BATCH_BUFFER_END     (0xA<<23)
955 #define MI_BATCH_NON_SECURE     (1)
956
957 #define MI_BATCH_NON_SECURE_I965 (1<<8)
958
959 #define MI_WAIT_FOR_EVENT       ((0x3<<23))
960 #define MI_WAIT_FOR_PLANE_B_FLIP      (1<<6)
961 #define MI_WAIT_FOR_PLANE_A_FLIP      (1<<2)
962 #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
963
964 #define MI_LOAD_SCAN_LINES_INCL  ((0x12<<23))
965
966 #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
967 #define ASYNC_FLIP                (1<<22)
968 #define DISPLAY_PLANE_A           (0<<20)
969 #define DISPLAY_PLANE_B           (1<<20)
970
971 /* Display regs */
972 #define DSPACNTR                0x70180
973 #define DSPBCNTR                0x71180
974 #define DISPPLANE_SEL_PIPE_MASK                 (1<<24)
975
976 /* Define the region of interest for the binner:
977  */
978 #define CMD_OP_BIN_CONTROL       ((0x3<<29)|(0x1d<<24)|(0x84<<16)|4)
979
980 #define CMD_OP_DESTBUFFER_INFO   ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
981
982 #define BREADCRUMB_BITS 31
983 #define BREADCRUMB_MASK ((1U << BREADCRUMB_BITS) - 1)
984
985 #define READ_BREADCRUMB(dev_priv)  (((volatile u32*)(dev_priv->hw_status_page))[5])
986
987 /**
988  * Reads a dword out of the status page, which is written to from the command
989  * queue by automatic updates, MI_REPORT_HEAD, MI_STORE_DATA_INDEX, or
990  * MI_STORE_DATA_IMM.
991  *
992  * The following dwords have a reserved meaning:
993  * 0: ISR copy, updated when an ISR bit not set in the HWSTAM changes.
994  * 4: ring 0 head pointer
995  * 5: ring 1 head pointer (915-class)
996  * 6: ring 2 head pointer (915-class)
997  *
998  * The area from dword 0x10 to 0x3ff is available for driver usage.
999  */
1000 #define READ_HWSP(dev_priv, reg)  (((volatile u32*)(dev_priv->hw_status_page))[reg])
1001 #define I915_GEM_HWS_INDEX              0x10
1002
1003 #define BLC_PWM_CTL             0x61254
1004 #define BACKLIGHT_MODULATION_FREQ_SHIFT         (17)
1005
1006 #define BLC_PWM_CTL2            0x61250
1007 /**
1008  * This is the most significant 15 bits of the number of backlight cycles in a
1009  * complete cycle of the modulated backlight control.
1010  *
1011  * The actual value is this field multiplied by two.
1012  */
1013 #define BACKLIGHT_MODULATION_FREQ_MASK          (0x7fff << 17)
1014 #define BLM_LEGACY_MODE                         (1 << 16)
1015 /**
1016  * This is the number of cycles out of the backlight modulation cycle for which
1017  * the backlight is on.
1018  *
1019  * This field must be no greater than the number of cycles in the complete
1020  * backlight modulation cycle.
1021  */
1022 #define BACKLIGHT_DUTY_CYCLE_SHIFT              (0)
1023 #define BACKLIGHT_DUTY_CYCLE_MASK               (0xffff)
1024
1025 #define I915_GCFGC                      0xf0
1026 #define I915_LOW_FREQUENCY_ENABLE               (1 << 7)
1027 #define I915_DISPLAY_CLOCK_190_200_MHZ          (0 << 4)
1028 #define I915_DISPLAY_CLOCK_333_MHZ              (4 << 4)
1029 #define I915_DISPLAY_CLOCK_MASK                 (7 << 4)
1030
1031 #define I855_HPLLCC                     0xc0
1032 #define I855_CLOCK_CONTROL_MASK                 (3 << 0)
1033 #define I855_CLOCK_133_200                      (0 << 0)
1034 #define I855_CLOCK_100_200                      (1 << 0)
1035 #define I855_CLOCK_100_133                      (2 << 0)
1036 #define I855_CLOCK_166_250                      (3 << 0)
1037
1038 /* p317, 319
1039  */
1040 #define VCLK2_VCO_M        0x6008 /* treat as 16 bit? (includes msbs) */
1041 #define VCLK2_VCO_N        0x600a
1042 #define VCLK2_VCO_DIV_SEL  0x6012
1043
1044 #define VCLK_DIVISOR_VGA0   0x6000
1045 #define VCLK_DIVISOR_VGA1   0x6004
1046 #define VCLK_POST_DIV       0x6010
1047 /** Selects a post divisor of 4 instead of 2. */
1048 # define VGA1_PD_P2_DIV_4       (1 << 15)
1049 /** Overrides the p2 post divisor field */
1050 # define VGA1_PD_P1_DIV_2       (1 << 13)
1051 # define VGA1_PD_P1_SHIFT       8
1052 /** P1 value is 2 greater than this field */
1053 # define VGA1_PD_P1_MASK        (0x1f << 8)
1054 /** Selects a post divisor of 4 instead of 2. */
1055 # define VGA0_PD_P2_DIV_4       (1 << 7)
1056 /** Overrides the p2 post divisor field */
1057 # define VGA0_PD_P1_DIV_2       (1 << 5)
1058 # define VGA0_PD_P1_SHIFT       0
1059 /** P1 value is 2 greater than this field */
1060 # define VGA0_PD_P1_MASK        (0x1f << 0)
1061
1062 /* PCI D state control register */
1063 #define D_STATE         0x6104
1064 #define DSPCLK_GATE_D   0x6200
1065
1066 /* I830 CRTC registers */
1067 #define HTOTAL_A        0x60000
1068 #define HBLANK_A        0x60004
1069 #define HSYNC_A         0x60008
1070 #define VTOTAL_A        0x6000c
1071 #define VBLANK_A        0x60010
1072 #define VSYNC_A         0x60014
1073 #define PIPEASRC        0x6001c
1074 #define BCLRPAT_A       0x60020
1075 #define VSYNCSHIFT_A    0x60028
1076
1077 #define HTOTAL_B        0x61000
1078 #define HBLANK_B        0x61004
1079 #define HSYNC_B         0x61008
1080 #define VTOTAL_B        0x6100c
1081 #define VBLANK_B        0x61010
1082 #define VSYNC_B         0x61014
1083 #define PIPEBSRC        0x6101c
1084 #define BCLRPAT_B       0x61020
1085 #define VSYNCSHIFT_B    0x61028
1086
1087 #define HACTIVE_MASK    0x00000fff
1088 #define VTOTAL_MASK     0x00001fff
1089 #define VTOTAL_SHIFT    16
1090 #define VACTIVE_MASK    0x00000fff
1091 #define VBLANK_END_MASK 0x00001fff
1092 #define VBLANK_END_SHIFT 16
1093 #define VBLANK_START_MASK 0x00001fff
1094
1095 #define PP_STATUS       0x61200
1096 # define PP_ON                                  (1 << 31)
1097 /**
1098  * Indicates that all dependencies of the panel are on:
1099  *
1100  * - PLL enabled
1101  * - pipe enabled
1102  * - LVDS/DVOB/DVOC on
1103  */
1104 # define PP_READY                               (1 << 30)
1105 # define PP_SEQUENCE_NONE                       (0 << 28)
1106 # define PP_SEQUENCE_ON                         (1 << 28)
1107 # define PP_SEQUENCE_OFF                        (2 << 28)
1108 # define PP_SEQUENCE_MASK                       0x30000000
1109 #define PP_CONTROL      0x61204
1110 # define POWER_TARGET_ON                        (1 << 0)
1111
1112 #define LVDSPP_ON       0x61208
1113 #define LVDSPP_OFF      0x6120c
1114 #define PP_CYCLE        0x61210
1115
1116 #define PFIT_CONTROL    0x61230
1117 # define PFIT_ENABLE                            (1 << 31)
1118 # define PFIT_PIPE_MASK                         (3 << 29)
1119 # define PFIT_PIPE_SHIFT                        29
1120 # define VERT_INTERP_DISABLE                    (0 << 10)
1121 # define VERT_INTERP_BILINEAR                   (1 << 10)
1122 # define VERT_INTERP_MASK                       (3 << 10)
1123 # define VERT_AUTO_SCALE                        (1 << 9)
1124 # define HORIZ_INTERP_DISABLE                   (0 << 6)
1125 # define HORIZ_INTERP_BILINEAR                  (1 << 6)
1126 # define HORIZ_INTERP_MASK                      (3 << 6)
1127 # define HORIZ_AUTO_SCALE                       (1 << 5)
1128 # define PANEL_8TO6_DITHER_ENABLE               (1 << 3)
1129
1130 #define PFIT_PGM_RATIOS 0x61234
1131 # define PFIT_VERT_SCALE_MASK                   0xfff00000
1132 # define PFIT_HORIZ_SCALE_MASK                  0x0000fff0
1133
1134 #define PFIT_AUTO_RATIOS        0x61238
1135
1136
1137 #define DPLL_A          0x06014
1138 #define DPLL_B          0x06018
1139 # define DPLL_VCO_ENABLE                        (1 << 31)
1140 # define DPLL_DVO_HIGH_SPEED                    (1 << 30)
1141 # define DPLL_SYNCLOCK_ENABLE                   (1 << 29)
1142 # define DPLL_VGA_MODE_DIS                      (1 << 28)
1143 # define DPLLB_MODE_DAC_SERIAL                  (1 << 26) /* i915 */
1144 # define DPLLB_MODE_LVDS                        (2 << 26) /* i915 */
1145 # define DPLL_MODE_MASK                         (3 << 26)
1146 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10        (0 << 24) /* i915 */
1147 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5         (1 << 24) /* i915 */
1148 # define DPLLB_LVDS_P2_CLOCK_DIV_14             (0 << 24) /* i915 */
1149 # define DPLLB_LVDS_P2_CLOCK_DIV_7              (1 << 24) /* i915 */
1150 # define DPLL_P2_CLOCK_DIV_MASK                 0x03000000 /* i915 */
1151 # define DPLL_FPA01_P1_POST_DIV_MASK            0x00ff0000 /* i915 */
1152 /**
1153  *  The i830 generation, in DAC/serial mode, defines p1 as two plus this
1154  * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
1155  */
1156 # define DPLL_FPA01_P1_POST_DIV_MASK_I830       0x001f0000
1157 /**
1158  * The i830 generation, in LVDS mode, defines P1 as the bit number set within
1159  * this field (only one bit may be set).
1160  */
1161 # define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS  0x003f0000
1162 # define DPLL_FPA01_P1_POST_DIV_SHIFT           16
1163 # define PLL_P2_DIVIDE_BY_4                     (1 << 23) /* i830, required in DVO non-gang */
1164 # define PLL_P1_DIVIDE_BY_TWO                   (1 << 21) /* i830 */
1165 # define PLL_REF_INPUT_DREFCLK                  (0 << 13)
1166 # define PLL_REF_INPUT_TVCLKINA                 (1 << 13) /* i830 */
1167 # define PLL_REF_INPUT_TVCLKINBC                (2 << 13) /* SDVO TVCLKIN */
1168 # define PLLB_REF_INPUT_SPREADSPECTRUMIN        (3 << 13)
1169 # define PLL_REF_INPUT_MASK                     (3 << 13)
1170 # define PLL_LOAD_PULSE_PHASE_SHIFT             9
1171 /*
1172  * Parallel to Serial Load Pulse phase selection.
1173  * Selects the phase for the 10X DPLL clock for the PCIe
1174  * digital display port. The range is 4 to 13; 10 or more
1175  * is just a flip delay. The default is 6
1176  */
1177 # define PLL_LOAD_PULSE_PHASE_MASK              (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
1178 # define DISPLAY_RATE_SELECT_FPA1               (1 << 8)
1179
1180 /**
1181  * SDVO multiplier for 945G/GM. Not used on 965.
1182  *
1183  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1184  */
1185 # define SDVO_MULTIPLIER_MASK                   0x000000ff
1186 # define SDVO_MULTIPLIER_SHIFT_HIRES            4
1187 # define SDVO_MULTIPLIER_SHIFT_VGA              0
1188
1189 /** @defgroup DPLL_MD
1190  * @{
1191  */
1192 /** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
1193 #define DPLL_A_MD               0x0601c
1194 /** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
1195 #define DPLL_B_MD               0x06020
1196 /**
1197  * UDI pixel divider, controlling how many pixels are stuffed into a packet.
1198  *
1199  * Value is pixels minus 1.  Must be set to 1 pixel for SDVO.
1200  */
1201 # define DPLL_MD_UDI_DIVIDER_MASK               0x3f000000
1202 # define DPLL_MD_UDI_DIVIDER_SHIFT              24
1203 /** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
1204 # define DPLL_MD_VGA_UDI_DIVIDER_MASK           0x003f0000
1205 # define DPLL_MD_VGA_UDI_DIVIDER_SHIFT          16
1206 /**
1207  * SDVO/UDI pixel multiplier.
1208  *
1209  * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
1210  * clock rate is 10 times the DPLL clock.  At low resolution/refresh rate
1211  * modes, the bus rate would be below the limits, so SDVO allows for stuffing
1212  * dummy bytes in the datastream at an increased clock rate, with both sides of
1213  * the link knowing how many bytes are fill.
1214  *
1215  * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
1216  * rate to 130Mhz to get a bus rate of 1.30Ghz.  The DPLL clock rate would be
1217  * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
1218  * through an SDVO command.
1219  *
1220  * This register field has values of multiplication factor minus 1, with
1221  * a maximum multiplier of 5 for SDVO.
1222  */
1223 # define DPLL_MD_UDI_MULTIPLIER_MASK            0x00003f00
1224 # define DPLL_MD_UDI_MULTIPLIER_SHIFT           8
1225 /** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
1226  * This best be set to the default value (3) or the CRT won't work. No,
1227  * I don't entirely understand what this does...
1228  */
1229 # define DPLL_MD_VGA_UDI_MULTIPLIER_MASK        0x0000003f
1230 # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT       0
1231 /** @} */
1232
1233 #define DPLL_TEST               0x606c
1234 # define DPLLB_TEST_SDVO_DIV_1                  (0 << 22)
1235 # define DPLLB_TEST_SDVO_DIV_2                  (1 << 22)
1236 # define DPLLB_TEST_SDVO_DIV_4                  (2 << 22)
1237 # define DPLLB_TEST_SDVO_DIV_MASK               (3 << 22)
1238 # define DPLLB_TEST_N_BYPASS                    (1 << 19)
1239 # define DPLLB_TEST_M_BYPASS                    (1 << 18)
1240 # define DPLLB_INPUT_BUFFER_ENABLE              (1 << 16)
1241 # define DPLLA_TEST_N_BYPASS                    (1 << 3)
1242 # define DPLLA_TEST_M_BYPASS                    (1 << 2)
1243 # define DPLLA_INPUT_BUFFER_ENABLE              (1 << 0)
1244
1245 #define ADPA                    0x61100
1246 #define ADPA_DAC_ENABLE         (1<<31)
1247 #define ADPA_DAC_DISABLE        0
1248 #define ADPA_PIPE_SELECT_MASK   (1<<30)
1249 #define ADPA_PIPE_A_SELECT      0
1250 #define ADPA_PIPE_B_SELECT      (1<<30)
1251 #define ADPA_USE_VGA_HVPOLARITY (1<<15)
1252 #define ADPA_SETS_HVPOLARITY    0
1253 #define ADPA_VSYNC_CNTL_DISABLE (1<<11)
1254 #define ADPA_VSYNC_CNTL_ENABLE  0
1255 #define ADPA_HSYNC_CNTL_DISABLE (1<<10)
1256 #define ADPA_HSYNC_CNTL_ENABLE  0
1257 #define ADPA_VSYNC_ACTIVE_HIGH  (1<<4)
1258 #define ADPA_VSYNC_ACTIVE_LOW   0
1259 #define ADPA_HSYNC_ACTIVE_HIGH  (1<<3)
1260 #define ADPA_HSYNC_ACTIVE_LOW   0
1261
1262 #define FPA0            0x06040
1263 #define FPA1            0x06044
1264 #define FPB0            0x06048
1265 #define FPB1            0x0604c
1266 # define FP_N_DIV_MASK                          0x003f0000
1267 # define FP_N_DIV_SHIFT                         16
1268 # define FP_M1_DIV_MASK                         0x00003f00
1269 # define FP_M1_DIV_SHIFT                        8
1270 # define FP_M2_DIV_MASK                         0x0000003f
1271 # define FP_M2_DIV_SHIFT                        0
1272
1273
1274 #define PORT_HOTPLUG_EN         0x61110
1275 # define SDVOB_HOTPLUG_INT_EN                   (1 << 26)
1276 # define SDVOC_HOTPLUG_INT_EN                   (1 << 25)
1277 # define TV_HOTPLUG_INT_EN                      (1 << 18)
1278 # define CRT_HOTPLUG_INT_EN                     (1 << 9)
1279 # define CRT_HOTPLUG_FORCE_DETECT               (1 << 3)
1280
1281 #define PORT_HOTPLUG_STAT       0x61114
1282 # define CRT_HOTPLUG_INT_STATUS                 (1 << 11)
1283 # define TV_HOTPLUG_INT_STATUS                  (1 << 10)
1284 # define CRT_HOTPLUG_MONITOR_MASK               (3 << 8)
1285 # define CRT_HOTPLUG_MONITOR_COLOR              (3 << 8)
1286 # define CRT_HOTPLUG_MONITOR_MONO               (2 << 8)
1287 # define CRT_HOTPLUG_MONITOR_NONE               (0 << 8)
1288 # define SDVOC_HOTPLUG_INT_STATUS               (1 << 7)
1289 # define SDVOB_HOTPLUG_INT_STATUS               (1 << 6)
1290
1291 #define SDVOB                   0x61140
1292 #define SDVOC                   0x61160
1293 #define SDVO_ENABLE                             (1 << 31)
1294 #define SDVO_PIPE_B_SELECT                      (1 << 30)
1295 #define SDVO_STALL_SELECT                       (1 << 29)
1296 #define SDVO_INTERRUPT_ENABLE                   (1 << 26)
1297 /**
1298  * 915G/GM SDVO pixel multiplier.
1299  *
1300  * Programmed value is multiplier - 1, up to 5x.
1301  *
1302  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1303  */
1304 #define SDVO_PORT_MULTIPLY_MASK                 (7 << 23)
1305 #define SDVO_PORT_MULTIPLY_SHIFT                23
1306 #define SDVO_PHASE_SELECT_MASK                  (15 << 19)
1307 #define SDVO_PHASE_SELECT_DEFAULT               (6 << 19)
1308 #define SDVO_CLOCK_OUTPUT_INVERT                (1 << 18)
1309 #define SDVOC_GANG_MODE                         (1 << 16)
1310 #define SDVO_BORDER_ENABLE                      (1 << 7)
1311 #define SDVOB_PCIE_CONCURRENCY                  (1 << 3)
1312 #define SDVO_DETECTED                           (1 << 2)
1313 /* Bits to be preserved when writing */
1314 #define SDVOB_PRESERVE_MASK                     ((1 << 17) | (1 << 16) | (1 << 14))
1315 #define SDVOC_PRESERVE_MASK                     (1 << 17)
1316
1317 /** @defgroup LVDS
1318  * @{
1319  */
1320 /**
1321  * This register controls the LVDS output enable, pipe selection, and data
1322  * format selection.
1323  *
1324  * All of the clock/data pairs are force powered down by power sequencing.
1325  */
1326 #define LVDS                    0x61180
1327 /**
1328  * Enables the LVDS port.  This bit must be set before DPLLs are enabled, as
1329  * the DPLL semantics change when the LVDS is assigned to that pipe.
1330  */
1331 # define LVDS_PORT_EN                   (1 << 31)
1332 /** Selects pipe B for LVDS data.  Must be set on pre-965. */
1333 # define LVDS_PIPEB_SELECT              (1 << 30)
1334
1335 /**
1336  * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
1337  * pixel.
1338  */
1339 # define LVDS_A0A2_CLKA_POWER_MASK      (3 << 8)
1340 # define LVDS_A0A2_CLKA_POWER_DOWN      (0 << 8)
1341 # define LVDS_A0A2_CLKA_POWER_UP        (3 << 8)
1342 /**
1343  * Controls the A3 data pair, which contains the additional LSBs for 24 bit
1344  * mode.  Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
1345  * on.
1346  */
1347 # define LVDS_A3_POWER_MASK             (3 << 6)
1348 # define LVDS_A3_POWER_DOWN             (0 << 6)
1349 # define LVDS_A3_POWER_UP               (3 << 6)
1350 /**
1351  * Controls the CLKB pair.  This should only be set when LVDS_B0B3_POWER_UP
1352  * is set.
1353  */
1354 # define LVDS_CLKB_POWER_MASK           (3 << 4)
1355 # define LVDS_CLKB_POWER_DOWN           (0 << 4)
1356 # define LVDS_CLKB_POWER_UP             (3 << 4)
1357
1358 /**
1359  * Controls the B0-B3 data pairs.  This must be set to match the DPLL p2
1360  * setting for whether we are in dual-channel mode.  The B3 pair will
1361  * additionally only be powered up when LVDS_A3_POWER_UP is set.
1362  */
1363 # define LVDS_B0B3_POWER_MASK           (3 << 2)
1364 # define LVDS_B0B3_POWER_DOWN           (0 << 2)
1365 # define LVDS_B0B3_POWER_UP             (3 << 2)
1366
1367 #define PIPEACONF 0x70008
1368 #define PIPEACONF_ENABLE        (1<<31)
1369 #define PIPEACONF_DISABLE       0
1370 #define PIPEACONF_DOUBLE_WIDE   (1<<30)
1371 #define I965_PIPECONF_ACTIVE    (1<<30)
1372 #define PIPEACONF_SINGLE_WIDE   0
1373 #define PIPEACONF_PIPE_UNLOCKED 0
1374 #define PIPEACONF_PIPE_LOCKED   (1<<25)
1375 #define PIPEACONF_PALETTE       0
1376 #define PIPEACONF_GAMMA         (1<<24)
1377 #define PIPECONF_FORCE_BORDER   (1<<25)
1378 #define PIPECONF_PROGRESSIVE    (0 << 21)
1379 #define PIPECONF_INTERLACE_W_FIELD_INDICATION   (6 << 21)
1380 #define PIPECONF_INTERLACE_FIELD_0_ONLY         (7 << 21)
1381
1382 #define DSPARB    0x70030
1383 #define DSPARB_CSTART_MASK      (0x7f << 7)
1384 #define DSPARB_CSTART_SHIFT     7
1385 #define DSPARB_BSTART_MASK      (0x7f)           
1386 #define DSPARB_BSTART_SHIFT     0
1387
1388 #define PIPEBCONF 0x71008
1389 #define PIPEBCONF_ENABLE        (1<<31)
1390 #define PIPEBCONF_DISABLE       0
1391 #define PIPEBCONF_DOUBLE_WIDE   (1<<30)
1392 #define PIPEBCONF_DISABLE       0
1393 #define PIPEBCONF_GAMMA         (1<<24)
1394 #define PIPEBCONF_PALETTE       0
1395
1396 #define PIPEBGCMAXRED           0x71010
1397 #define PIPEBGCMAXGREEN         0x71014
1398 #define PIPEBGCMAXBLUE          0x71018
1399 #define PIPEBSTAT               0x71024
1400 #define PIPEBFRAMEHIGH          0x71040
1401 #define PIPEBFRAMEPIXEL         0x71044
1402
1403 #define DSPACNTR                0x70180
1404 #define DSPBCNTR                0x71180
1405 #define DISPLAY_PLANE_ENABLE                    (1<<31)
1406 #define DISPLAY_PLANE_DISABLE                   0
1407 #define DISPPLANE_GAMMA_ENABLE                  (1<<30)
1408 #define DISPPLANE_GAMMA_DISABLE                 0
1409 #define DISPPLANE_PIXFORMAT_MASK                (0xf<<26)
1410 #define DISPPLANE_8BPP                          (0x2<<26)
1411 #define DISPPLANE_15_16BPP                      (0x4<<26)
1412 #define DISPPLANE_16BPP                         (0x5<<26)
1413 #define DISPPLANE_32BPP_NO_ALPHA                (0x6<<26)
1414 #define DISPPLANE_32BPP                         (0x7<<26)
1415 #define DISPPLANE_STEREO_ENABLE                 (1<<25)
1416 #define DISPPLANE_STEREO_DISABLE                0
1417 #define DISPPLANE_SEL_PIPE_MASK                 (1<<24)
1418 #define DISPPLANE_SEL_PIPE_A                    0
1419 #define DISPPLANE_SEL_PIPE_B                    (1<<24)
1420 #define DISPPLANE_SRC_KEY_ENABLE                (1<<22)
1421 #define DISPPLANE_SRC_KEY_DISABLE               0
1422 #define DISPPLANE_LINE_DOUBLE                   (1<<20)
1423 #define DISPPLANE_NO_LINE_DOUBLE                0
1424 #define DISPPLANE_STEREO_POLARITY_FIRST         0
1425 #define DISPPLANE_STEREO_POLARITY_SECOND        (1<<18)
1426 /* plane B only */
1427 #define DISPPLANE_ALPHA_TRANS_ENABLE            (1<<15)
1428 #define DISPPLANE_ALPHA_TRANS_DISABLE           0
1429 #define DISPPLANE_SPRITE_ABOVE_DISPLAYA         0
1430 #define DISPPLANE_SPRITE_ABOVE_OVERLAY          (1)
1431
1432 #define DSPABASE                0x70184
1433 #define DSPASTRIDE              0x70188
1434
1435 #define DSPBBASE                0x71184
1436 #define DSPBADDR                DSPBBASE
1437 #define DSPBSTRIDE              0x71188
1438
1439 #define DSPAKEYVAL              0x70194
1440 #define DSPAKEYMASK             0x70198
1441
1442 #define DSPAPOS                 0x7018C /* reserved */
1443 #define DSPASIZE                0x70190
1444 #define DSPBPOS                 0x7118C
1445 #define DSPBSIZE                0x71190
1446
1447 #define DSPASURF                0x7019C
1448 #define DSPATILEOFF             0x701A4
1449
1450 #define DSPBSURF                0x7119C
1451 #define DSPBTILEOFF             0x711A4
1452
1453 #define VGACNTRL                0x71400
1454 # define VGA_DISP_DISABLE                       (1 << 31)
1455 # define VGA_2X_MODE                            (1 << 30)
1456 # define VGA_PIPE_B_SELECT                      (1 << 29)
1457
1458 /*
1459  * Some BIOS scratch area registers.  The 845 (and 830?) store the amount
1460  * of video memory available to the BIOS in SWF1.
1461  */
1462
1463 #define SWF0                    0x71410
1464
1465 /*
1466  * 855 scratch registers.
1467  */
1468 #define SWF10                   0x70410
1469
1470 #define SWF30                   0x72414
1471
1472 /*
1473  * Overlay registers.  These are overlay registers accessed via MMIO.
1474  * Those loaded via the overlay register page are defined in i830_video.c.
1475  */
1476 #define OVADD                   0x30000
1477
1478 #define DOVSTA                  0x30008
1479 #define OC_BUF                  (0x3<<20)
1480
1481 #define OGAMC5                  0x30010
1482 #define OGAMC4                  0x30014
1483 #define OGAMC3                  0x30018
1484 #define OGAMC2                  0x3001c
1485 #define OGAMC1                  0x30020
1486 #define OGAMC0                  0x30024
1487 /*
1488  * Palette registers
1489  */
1490 #define PALETTE_A               0x0a000
1491 #define PALETTE_B               0x0a800
1492
1493 #define IS_I830(dev) ((dev)->pci_device == 0x3577)
1494 #define IS_845G(dev) ((dev)->pci_device == 0x2562)
1495 #define IS_I85X(dev) ((dev)->pci_device == 0x3582)
1496 #define IS_I855(dev) ((dev)->pci_device == 0x3582)
1497 #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
1498
1499 #define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
1500 #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
1501 #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
1502 #define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 ||\
1503                         (dev)->pci_device == 0x27AE)
1504 #define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
1505                        (dev)->pci_device == 0x2982 || \
1506                        (dev)->pci_device == 0x2992 || \
1507                        (dev)->pci_device == 0x29A2 || \
1508                        (dev)->pci_device == 0x2A02 || \
1509                        (dev)->pci_device == 0x2A12 || \
1510                        (dev)->pci_device == 0x2A42)
1511
1512 #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
1513
1514 #define IS_IGD_GM(dev) ((dev)->pci_device == 0x2A42)
1515
1516 #define IS_G33(dev)    ((dev)->pci_device == 0x29C2 ||  \
1517                         (dev)->pci_device == 0x29B2 ||  \
1518                         (dev)->pci_device == 0x29D2)
1519
1520 #define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
1521                       IS_I945GM(dev) || IS_I965G(dev) || IS_G33(dev))
1522
1523 #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
1524                         IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev))
1525
1526 #define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_IGD_GM(dev))
1527
1528 #define PRIMARY_RINGBUFFER_SIZE         (128*1024)
1529
1530 #endif