1 /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
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.
33 /* General customization:
36 #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
38 #define DRIVER_NAME "i915"
39 #define DRIVER_DESC "Intel Graphics"
40 #define DRIVER_DATE "20080312"
42 #if defined(__linux__)
43 #define I915_HAVE_FENCE
44 #define I915_HAVE_BUFFER
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
62 #define DRIVER_MAJOR 1
63 #if defined(I915_HAVE_FENCE) && defined(I915_HAVE_BUFFER)
64 #define DRIVER_MINOR 13
66 #define DRIVER_MINOR 6
68 #define DRIVER_PATCHLEVEL 0
70 #ifdef I915_HAVE_BUFFER
71 #define I915_MAX_VALIDATE_BUFFERS 4096
72 struct drm_i915_validate_buffer;
75 typedef struct _drm_i915_ring_buffer {
85 } drm_i915_ring_buffer_t;
88 struct mem_block *next;
89 struct mem_block *prev;
92 struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
95 typedef struct _drm_i915_vbl_swap {
96 struct list_head head;
97 drm_drawable_t drw_id;
99 unsigned int sequence;
101 } drm_i915_vbl_swap_t;
103 typedef struct drm_i915_private {
104 struct drm_device *dev;
106 drm_local_map_t *sarea;
107 drm_local_map_t *mmio_map;
109 drm_i915_sarea_t *sarea_priv;
110 drm_i915_ring_buffer_t ring;
112 drm_dma_handle_t *status_page_dmah;
113 void *hw_status_page;
114 dma_addr_t dma_status_page;
116 unsigned int status_gfx_addr;
117 drm_local_map_t hws_map;
121 wait_queue_head_t irq_queue;
122 atomic_t irq_received;
123 atomic_t irq_emitted;
125 int tex_lru_log_granularity;
126 int allow_batchbuffer;
127 struct mem_block *agp_heap;
128 unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
130 DRM_SPINTYPE user_irq_lock;
131 int user_irq_refcount;
133 uint32_t irq_mask_reg;
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;
142 #ifdef I915_HAVE_BUFFER
144 unsigned int max_validate_buffers;
145 struct mutex cmdbuf_mutex;
146 struct drm_i915_validate_buffer *val_bufs;
149 DRM_SPINTYPE swaps_lock;
150 drm_i915_vbl_swap_t vbl_swaps;
151 unsigned int swaps_pending;
152 #if defined(I915_HAVE_BUFFER)
154 struct drm_buffer_object *sarea_bo;
155 struct drm_bo_kmap_obj sarea_kmap;
184 u32 savePFIT_PGM_RATIOS;
186 u32 saveBLC_PWM_CTL2;
205 u32 saveVCLK_DIVISOR_VGA0;
206 u32 saveVCLK_DIVISOR_VGA1;
207 u32 saveVCLK_POST_DIV;
220 u32 savePFIT_CONTROL;
221 u32 save_palette_a[256];
222 u32 save_palette_b[256];
223 u32 saveFBC_CFB_BASE;
226 u32 saveFBC_CONTROL2;
230 u32 saveCACHE_MODE_0;
232 u32 saveDSPCLK_GATE_D;
233 u32 saveMI_ARB_STATE;
243 u8 saveDACDATA[256*3]; /* 256 3-byte colors */
247 struct drm_memrange gtt_space;
250 * List of objects currently involved in rendering from the
253 * A reference is held on the buffer while on this list.
255 struct list_head active_list;
258 * List of objects which are not in the ringbuffer but which
259 * still have a write_domain which needs to be flushed before
262 * A reference is held on the buffer while on this list.
264 struct list_head flushing_list;
267 * LRU list of objects which are not in the ringbuffer and
268 * are ready to unbind, but are still in the GTT.
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.
274 struct list_head inactive_list;
277 * List of breadcrumbs associated with GPU requests currently
280 struct list_head request_list;
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.
289 struct timer_list retire_timer;
290 struct work_struct retire_task;
292 uint32_t next_gem_seqno;
295 struct work_struct user_interrupt_task;
296 } drm_i915_private_t;
298 enum intel_chip_family {
305 /** driver private structure attached to each drm_gem_object */
306 struct drm_i915_gem_object {
307 struct drm_gem_object *obj;
309 /** Current space allocated to this object in the GTT, if any. */
310 struct drm_memrange_node *gtt_space;
312 /** This object's place on the active/flushing/inactive lists */
313 struct list_head list;
316 * This is set if the object is on the active or flushing lists
317 * (has pending rendering), and is not set if it's on inactive (ready
322 /** AGP memory structure for our GTT binding. */
323 DRM_AGP_MEM *agp_mem;
325 struct page **page_list;
328 * Current offset of the object in GTT space.
330 * This is the same as gtt_space->start
334 /** Boolean whether this object has a valid gtt offset. */
337 /** How many users have pinned this object in GTT space */
340 /** Breadcrumb of last rendering to the buffer. */
341 uint32_t last_rendering_seqno;
345 * Request queue structure.
347 * The request queue allows us to note sequence numbers that have been emitted
348 * and may be associated with active buffers to be retired.
350 * By keeping this list, we can avoid having to do questionable
351 * sequence-number comparisons on buffer last_rendering_seqnos, and associate
352 * an emission time with seqnos for tracking how far ahead of the GPU we are.
354 struct drm_i915_gem_request {
355 /** GEM sequence number associated with this request. */
358 /** Time at which this request was emitted, in jiffies. */
359 unsigned long emitted_jiffies;
361 /** Cache domains that were flushed at the start of the request. */
362 uint32_t flush_domains;
364 struct list_head list;
367 extern struct drm_ioctl_desc i915_ioctls[];
368 extern int i915_max_ioctl;
371 extern void i915_kernel_lost_context(struct drm_device * dev);
372 extern int i915_driver_load(struct drm_device *, unsigned long flags);
373 extern int i915_driver_unload(struct drm_device *);
374 extern void i915_driver_lastclose(struct drm_device * dev);
375 extern void i915_driver_preclose(struct drm_device *dev,
376 struct drm_file *file_priv);
377 extern int i915_driver_device_is_agp(struct drm_device * dev);
378 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
380 extern void i915_emit_breadcrumb(struct drm_device *dev);
381 extern void i915_dispatch_flip(struct drm_device * dev, int pipes, int sync);
382 extern int i915_emit_mi_flush(struct drm_device *dev, uint32_t flush);
383 extern int i915_driver_firstopen(struct drm_device *dev);
384 extern int i915_dispatch_batchbuffer(struct drm_device * dev,
385 drm_i915_batchbuffer_t * batch);
386 extern int i915_quiescent(struct drm_device *dev);
388 int i915_emit_box(struct drm_device * dev,
389 struct drm_clip_rect __user * boxes,
390 int i, int DR1, int DR4);
393 extern int i915_irq_emit(struct drm_device *dev, void *data,
394 struct drm_file *file_priv);
395 extern int i915_irq_wait(struct drm_device *dev, void *data,
396 struct drm_file *file_priv);
398 extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
399 extern void i915_driver_irq_preinstall(struct drm_device * dev);
400 extern int i915_driver_irq_postinstall(struct drm_device * dev);
401 extern void i915_driver_irq_uninstall(struct drm_device * dev);
402 extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
403 struct drm_file *file_priv);
404 extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
405 struct drm_file *file_priv);
406 extern int i915_emit_irq(struct drm_device * dev);
407 extern int i915_wait_irq(struct drm_device * dev, int irq_nr);
408 extern int i915_enable_vblank(struct drm_device *dev, int crtc);
409 extern void i915_disable_vblank(struct drm_device *dev, int crtc);
410 extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
411 extern int i915_vblank_swap(struct drm_device *dev, void *data,
412 struct drm_file *file_priv);
413 extern void i915_user_irq_on(drm_i915_private_t *dev_priv);
414 extern void i915_user_irq_off(drm_i915_private_t *dev_priv);
415 extern void i915_user_interrupt_handler(struct work_struct *work);
418 extern int i915_mem_alloc(struct drm_device *dev, void *data,
419 struct drm_file *file_priv);
420 extern int i915_mem_free(struct drm_device *dev, void *data,
421 struct drm_file *file_priv);
422 extern int i915_mem_init_heap(struct drm_device *dev, void *data,
423 struct drm_file *file_priv);
424 extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
425 struct drm_file *file_priv);
426 extern void i915_mem_takedown(struct mem_block **heap);
427 extern void i915_mem_release(struct drm_device * dev,
428 struct drm_file *file_priv,
429 struct mem_block *heap);
430 #ifdef I915_HAVE_FENCE
432 extern void i915_fence_handler(struct drm_device *dev);
433 extern void i915_invalidate_reported_sequence(struct drm_device *dev);
437 #ifdef I915_HAVE_BUFFER
439 extern struct drm_ttm_backend *i915_create_ttm_backend_entry(struct drm_device *dev);
440 extern int i915_fence_type(struct drm_buffer_object *bo, uint32_t *fclass,
442 extern int i915_invalidate_caches(struct drm_device *dev, uint64_t buffer_flags);
443 extern int i915_init_mem_type(struct drm_device *dev, uint32_t type,
444 struct drm_mem_type_manager *man);
445 extern uint64_t i915_evict_flags(struct drm_buffer_object *bo);
446 extern int i915_move(struct drm_buffer_object *bo, int evict,
447 int no_wait, struct drm_bo_mem_reg *new_mem);
448 void i915_flush_ttm(struct drm_ttm *ttm);
450 int i915_execbuffer(struct drm_device *dev, void *data,
451 struct drm_file *file_priv);
453 int i915_gem_init_ioctl(struct drm_device *dev, void *data,
454 struct drm_file *file_priv);
455 int i915_gem_execbuffer(struct drm_device *dev, void *data,
456 struct drm_file *file_priv);
457 int i915_gem_pin_ioctl(struct drm_device *dev, void *data,
458 struct drm_file *file_priv);
459 int i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
460 struct drm_file *file_priv);
461 int i915_gem_busy_ioctl(struct drm_device *dev, void *data,
462 struct drm_file *file_priv);
463 int i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
464 struct drm_file *file_priv);
465 int i915_gem_init_object(struct drm_gem_object *obj);
466 void i915_gem_free_object(struct drm_gem_object *obj);
467 int i915_gem_set_domain(struct drm_gem_object *obj,
468 struct drm_file *file_priv,
469 uint32_t read_domains,
470 uint32_t write_domain);
471 int i915_gem_flush_pwrite(struct drm_gem_object *obj,
472 uint64_t offset, uint64_t size);
473 void i915_gem_lastclose(struct drm_device *dev);
474 void i915_gem_retire_requests(struct drm_device *dev);
475 void i915_gem_retire_timeout(unsigned long data);
476 void i915_gem_retire_handler(struct work_struct *work);
480 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
481 extern void intel_init_chipset_flush_compat(struct drm_device *dev);
482 extern void intel_fini_chipset_flush_compat(struct drm_device *dev);
486 #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
487 #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
488 #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
489 #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
491 #define I915_VERBOSE 0
492 #define I915_RING_VALIDATE 0
494 #define RING_LOCALS unsigned int outring, ringmask, outcount; \
497 #if I915_RING_VALIDATE
498 void i915_ring_validate(struct drm_device *dev, const char *func, int line);
499 #define I915_RING_DO_VALIDATE(dev) i915_ring_validate(dev, __FUNCTION__, __LINE__)
501 #define I915_RING_DO_VALIDATE(dev)
504 #define BEGIN_LP_RING(n) do { \
506 DRM_DEBUG("BEGIN_LP_RING(%d)\n", \
508 I915_RING_DO_VALIDATE(dev); \
509 if (dev_priv->ring.space < (n)*4) \
510 i915_wait_ring(dev, (n)*4, __FUNCTION__); \
512 outring = dev_priv->ring.tail; \
513 ringmask = dev_priv->ring.tail_mask; \
514 virt = dev_priv->ring.virtual_start; \
517 #define OUT_RING(n) do { \
518 if (I915_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
519 *(volatile unsigned int *)(virt + outring) = (n); \
522 outring &= ringmask; \
525 #define ADVANCE_LP_RING() do { \
526 if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring); \
527 I915_RING_DO_VALIDATE(dev); \
528 dev_priv->ring.tail = outring; \
529 dev_priv->ring.space -= outcount * 4; \
530 I915_WRITE(LP_RING + RING_TAIL, outring); \
533 extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
535 /* Extended config space */
540 #define VGA_ST01_MDA 0x3ba
541 #define VGA_ST01_CGA 0x3da
543 #define VGA_MSR_WRITE 0x3c2
544 #define VGA_MSR_READ 0x3cc
545 #define VGA_MSR_MEM_EN (1<<1)
546 #define VGA_MSR_CGA_MODE (1<<0)
548 #define VGA_SR_INDEX 0x3c4
549 #define VGA_SR_DATA 0x3c5
551 #define VGA_AR_INDEX 0x3c0
552 #define VGA_AR_VID_EN (1<<5)
553 #define VGA_AR_DATA_WRITE 0x3c0
554 #define VGA_AR_DATA_READ 0x3c1
556 #define VGA_GR_INDEX 0x3ce
557 #define VGA_GR_DATA 0x3cf
559 #define VGA_GR_MEM_READ_MODE_SHIFT 3
560 #define VGA_GR_MEM_READ_MODE_PLANE 1
562 #define VGA_GR_MEM_MODE_MASK 0xc
563 #define VGA_GR_MEM_MODE_SHIFT 2
564 #define VGA_GR_MEM_A0000_AFFFF 0
565 #define VGA_GR_MEM_A0000_BFFFF 1
566 #define VGA_GR_MEM_B0000_B7FFF 2
567 #define VGA_GR_MEM_B0000_BFFFF 3
569 #define VGA_DACMASK 0x3c6
570 #define VGA_DACRX 0x3c7
571 #define VGA_DACWX 0x3c8
572 #define VGA_DACDATA 0x3c9
574 #define VGA_CR_INDEX_MDA 0x3b4
575 #define VGA_CR_DATA_MDA 0x3b5
576 #define VGA_CR_INDEX_CGA 0x3d4
577 #define VGA_CR_DATA_CGA 0x3d5
579 #define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
580 #define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
581 #define CMD_REPORT_HEAD (7<<23)
582 #define CMD_STORE_DWORD_IMM ((0x20<<23) | (0x1 << 22) | 0x1)
584 * Stores a 32-bit integer to the status page at the dword index given.
586 #define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
587 # define STORE_DWORD_INDEX_SHIFT 2
589 #define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
591 #define CMD_MI_FLUSH (0x04 << 23)
592 #define MI_NO_WRITE_FLUSH (1 << 2)
593 #define MI_READ_FLUSH (1 << 0)
594 #define MI_EXE_FLUSH (1 << 1)
595 #define MI_END_SCENE (1 << 4) /* flush binner and incr scene count */
596 #define MI_SCENE_COUNT (1 << 3) /* just increment scene count */
598 /* Packet to load a register value from the ring/batch command stream:
600 #define CMD_MI_LOAD_REGISTER_IMM ((0x22 << 23)|0x1)
602 #define BB1_START_ADDR_MASK (~0x7)
603 #define BB1_PROTECTED (1<<0)
604 #define BB1_UNPROTECTED (0<<0)
605 #define BB2_END_ADDR_MASK (~0x7)
607 /* Framebuffer compression */
608 #define FBC_CFB_BASE 0x03200 /* 4k page aligned */
609 #define FBC_LL_BASE 0x03204 /* 4k page aligned */
610 #define FBC_CONTROL 0x03208
611 #define FBC_CTL_EN (1<<31)
612 #define FBC_CTL_PERIODIC (1<<30)
613 #define FBC_CTL_INTERVAL_SHIFT (16)
614 #define FBC_CTL_UNCOMPRESSIBLE (1<<14)
615 #define FBC_CTL_STRIDE_SHIFT (5)
616 #define FBC_CTL_FENCENO (1<<0)
617 #define FBC_COMMAND 0x0320c
618 #define FBC_CMD_COMPRESS (1<<0)
619 #define FBC_STATUS 0x03210
620 #define FBC_STAT_COMPRESSING (1<<31)
621 #define FBC_STAT_COMPRESSED (1<<30)
622 #define FBC_STAT_MODIFIED (1<<29)
623 #define FBC_STAT_CURRENT_LINE (1<<0)
624 #define FBC_CONTROL2 0x03214
625 #define FBC_CTL_FENCE_DBL (0<<4)
626 #define FBC_CTL_IDLE_IMM (0<<2)
627 #define FBC_CTL_IDLE_FULL (1<<2)
628 #define FBC_CTL_IDLE_LINE (2<<2)
629 #define FBC_CTL_IDLE_DEBUG (3<<2)
630 #define FBC_CTL_CPU_FENCE (1<<1)
631 #define FBC_CTL_PLANEA (0<<0)
632 #define FBC_CTL_PLANEB (1<<0)
633 #define FBC_FENCE_OFF 0x0321b
635 #define FBC_LL_SIZE (1536)
636 #define FBC_LL_PAD (32)
640 #define I915_PIPE_CONTROL_NOTIFY_INTERRUPT (1<<18)
641 #define I915_DISPLAY_PORT_INTERRUPT (1<<17)
642 #define I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT (1<<15)
643 #define I915_GMCH_THERMAL_SENSOR_EVENT_INTERRUPT (1<<14)
644 #define I915_HWB_OOM_INTERRUPT (1<<13) /* binner out of memory */
645 #define I915_SYNC_STATUS_INTERRUPT (1<<12)
646 #define I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT (1<<11)
647 #define I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT (1<<10)
648 #define I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT (1<<9)
649 #define I915_DISPLAY_PLANE_C_FLIP_PENDING_INTERRUPT (1<<8)
650 #define I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT (1<<7)
651 #define I915_DISPLAY_PIPE_A_EVENT_INTERRUPT (1<<6)
652 #define I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT (1<<5)
653 #define I915_DISPLAY_PIPE_B_EVENT_INTERRUPT (1<<4)
654 #define I915_DEBUG_INTERRUPT (1<<2)
655 #define I915_USER_INTERRUPT (1<<1)
658 #define I915REG_HWSTAM 0x02098
659 #define I915REG_INT_IDENTITY_R 0x020a4
660 #define I915REG_INT_MASK_R 0x020a8
661 #define I915REG_INT_ENABLE_R 0x020a0
662 #define I915REG_INSTPM 0x020c0
663 #define I965REG_ACTHD 0x02074
664 #define I915REG_ACTHD 0x020C8
666 #define PIPEADSL 0x70000
667 #define PIPEBDSL 0x71000
669 #define I915REG_PIPEASTAT 0x70024
670 #define I915REG_PIPEBSTAT 0x71024
672 * The two pipe frame counter registers are not synchronized, so
673 * reading a stable value is somewhat tricky. The following code
677 * high1 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
678 * PIPE_FRAME_HIGH_SHIFT;
679 * low1 = ((INREG(PIPEAFRAMEPIXEL) & PIPE_FRAME_LOW_MASK) >>
680 * PIPE_FRAME_LOW_SHIFT);
681 * high2 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
682 * PIPE_FRAME_HIGH_SHIFT);
683 * } while (high1 != high2);
684 * frame = (high1 << 8) | low1;
686 #define PIPEAFRAMEHIGH 0x70040
687 #define PIPEBFRAMEHIGH 0x71040
688 #define PIPE_FRAME_HIGH_MASK 0x0000ffff
689 #define PIPE_FRAME_HIGH_SHIFT 0
690 #define PIPEAFRAMEPIXEL 0x70044
691 #define PIPEBFRAMEPIXEL 0x71044
693 #define PIPE_FRAME_LOW_MASK 0xff000000
694 #define PIPE_FRAME_LOW_SHIFT 24
696 * Pixel within the current frame is counted in the PIPEAFRAMEPIXEL register
697 * and is 24 bits wide.
699 #define PIPE_PIXEL_MASK 0x00ffffff
700 #define PIPE_PIXEL_SHIFT 0
702 #define I915_FIFO_UNDERRUN_STATUS (1UL<<31)
703 #define I915_CRC_ERROR_ENABLE (1UL<<29)
704 #define I915_CRC_DONE_ENABLE (1UL<<28)
705 #define I915_GMBUS_EVENT_ENABLE (1UL<<27)
706 #define I915_VSYNC_INTERRUPT_ENABLE (1UL<<25)
707 #define I915_DISPLAY_LINE_COMPARE_ENABLE (1UL<<24)
708 #define I915_DPST_EVENT_ENABLE (1UL<<23)
709 #define I915_LEGACY_BLC_EVENT_ENABLE (1UL<<22)
710 #define I915_ODD_FIELD_INTERRUPT_ENABLE (1UL<<21)
711 #define I915_EVEN_FIELD_INTERRUPT_ENABLE (1UL<<20)
712 #define I915_START_VBLANK_INTERRUPT_ENABLE (1UL<<18) /* 965 or later */
713 #define I915_VBLANK_INTERRUPT_ENABLE (1UL<<17)
714 #define I915_OVERLAY_UPDATED_ENABLE (1UL<<16)
715 #define I915_CRC_ERROR_INTERRUPT_STATUS (1UL<<13)
716 #define I915_CRC_DONE_INTERRUPT_STATUS (1UL<<12)
717 #define I915_GMBUS_INTERRUPT_STATUS (1UL<<11)
718 #define I915_VSYNC_INTERRUPT_STATUS (1UL<<9)
719 #define I915_DISPLAY_LINE_COMPARE_STATUS (1UL<<8)
720 #define I915_DPST_EVENT_STATUS (1UL<<7)
721 #define I915_LEGACY_BLC_EVENT_STATUS (1UL<<6)
722 #define I915_ODD_FIELD_INTERRUPT_STATUS (1UL<<5)
723 #define I915_EVEN_FIELD_INTERRUPT_STATUS (1UL<<4)
724 #define I915_START_VBLANK_INTERRUPT_STATUS (1UL<<2) /* 965 or later */
725 #define I915_VBLANK_INTERRUPT_STATUS (1UL<<1)
726 #define I915_OVERLAY_UPDATED_STATUS (1UL<<0)
728 #define SRX_INDEX 0x3c4
729 #define SRX_DATA 0x3c5
731 #define SR01_SCREEN_OFF (1<<5)
734 #define PPCR_ON (1<<0)
737 #define DVOB_ON (1<<31)
739 #define DVOC_ON (1<<31)
741 #define LVDS_ON (1<<31)
744 #define ADPA_DPMS_MASK (~(3<<10))
745 #define ADPA_DPMS_ON (0<<10)
746 #define ADPA_DPMS_SUSPEND (1<<10)
747 #define ADPA_DPMS_STANDBY (2<<10)
748 #define ADPA_DPMS_OFF (3<<10)
751 #define LP_RING 0x2030
752 #define HP_RING 0x2040
753 /* The binner has its own ring buffer:
755 #define HWB_RING 0x2400
757 #define RING_TAIL 0x00
758 #define TAIL_ADDR 0x001FFFF8
759 #define RING_HEAD 0x04
760 #define HEAD_WRAP_COUNT 0xFFE00000
761 #define HEAD_WRAP_ONE 0x00200000
762 #define HEAD_ADDR 0x001FFFFC
763 #define RING_START 0x08
764 #define START_ADDR 0xFFFFF000
765 #define RING_LEN 0x0C
766 #define RING_NR_PAGES 0x001FF000
767 #define RING_REPORT_MASK 0x00000006
768 #define RING_REPORT_64K 0x00000002
769 #define RING_REPORT_128K 0x00000004
770 #define RING_NO_REPORT 0x00000000
771 #define RING_VALID_MASK 0x00000001
772 #define RING_VALID 0x00000001
773 #define RING_INVALID 0x00000000
775 /* Instruction parser error reg:
779 /* Scratch pad debug 0 reg:
787 /* Secondary DMA fetch address debug reg:
789 #define DMA_FADD_S 0x20d4
791 /* Memory Interface Arbitration State
793 #define MI_ARB_STATE 0x20e4
796 * - Manipulating render cache behaviour is central
797 * to the concept of zone rendering, tuning this reg can help avoid
798 * unnecessary render cache reads and even writes (for z/stencil)
799 * at beginning and end of scene.
801 * - To change a bit, write to this reg with a mask bit set and the
802 * bit of interest either set or cleared. EG: (BIT<<16) | BIT to set.
804 #define Cache_Mode_0 0x2120
805 #define CACHE_MODE_0 0x2120
806 #define CM0_MASK_SHIFT 16
807 #define CM0_IZ_OPT_DISABLE (1<<6)
808 #define CM0_ZR_OPT_DISABLE (1<<5)
809 #define CM0_DEPTH_EVICT_DISABLE (1<<4)
810 #define CM0_COLOR_EVICT_DISABLE (1<<3)
811 #define CM0_DEPTH_WRITE_DISABLE (1<<1)
812 #define CM0_RC_OP_FLUSH_DISABLE (1<<0)
815 /* Graphics flush control. A CPU write flushes the GWB of all writes.
816 * The data is discarded.
818 #define GFX_FLSH_CNTL 0x2170
820 /* Binner control. Defines the location of the bin pointer list:
822 #define BINCTL 0x2420
823 #define BC_MASK (1 << 9)
825 /* Binned scene info.
827 #define BINSCENE 0x2428
828 #define BS_OP_LOAD (1 << 8)
829 #define BS_MASK (1 << 22)
831 /* Bin command parser debug reg:
835 /* Bin memory control debug reg:
839 /* Bin data cache debug reg:
843 /* Binner pointer cache debug reg:
847 /* Binner scratch pad debug reg:
849 #define BINSKPD 0x24f0
851 /* HWB scratch pad debug reg:
853 #define HWBSKPD 0x24f4
855 /* Binner memory pool reg:
857 #define BMP_BUFFER 0x2430
858 #define BMP_PAGE_SIZE_4K (0 << 10)
859 #define BMP_BUFFER_SIZE_SHIFT 1
860 #define BMP_ENABLE (1 << 0)
862 /* Get/put memory from the binner memory pool:
864 #define BMP_GET 0x2438
865 #define BMP_PUT 0x2440
866 #define BMP_OFFSET_SHIFT 5
870 #define GFX_OP_RASTER_RULES ((0x3<<29)|(0x7<<24))
872 #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
873 #define SC_UPDATE_SCISSOR (0x1<<1)
874 #define SC_ENABLE_MASK (0x1<<0)
875 #define SC_ENABLE (0x1<<0)
877 #define GFX_OP_LOAD_INDIRECT ((0x3<<29)|(0x1d<<24)|(0x7<<16))
879 #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
880 #define SCI_YMIN_MASK (0xffff<<16)
881 #define SCI_XMIN_MASK (0xffff<<0)
882 #define SCI_YMAX_MASK (0xffff<<16)
883 #define SCI_XMAX_MASK (0xffff<<0)
885 #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19))
886 #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
887 #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
888 #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
889 #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4)
890 #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
891 #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
893 #define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2)
895 #define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|4)
896 #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
897 #define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
898 #define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
899 #define XY_SRC_COPY_BLT_SRC_TILED (1<<15)
900 #define XY_SRC_COPY_BLT_DST_TILED (1<<11)
903 #define MI_BATCH_BUFFER ((0x30<<23)|1)
904 #define MI_BATCH_BUFFER_START (0x31<<23)
905 #define MI_BATCH_BUFFER_END (0xA<<23)
906 #define MI_BATCH_NON_SECURE (1)
908 #define MI_BATCH_NON_SECURE_I965 (1<<8)
910 #define MI_WAIT_FOR_EVENT ((0x3<<23))
911 #define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
912 #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
913 #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
915 #define MI_LOAD_SCAN_LINES_INCL ((0x12<<23))
917 #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
918 #define ASYNC_FLIP (1<<22)
919 #define DISPLAY_PLANE_A (0<<20)
920 #define DISPLAY_PLANE_B (1<<20)
923 #define DSPACNTR 0x70180
924 #define DSPBCNTR 0x71180
925 #define DISPPLANE_SEL_PIPE_MASK (1<<24)
927 /* Define the region of interest for the binner:
929 #define CMD_OP_BIN_CONTROL ((0x3<<29)|(0x1d<<24)|(0x84<<16)|4)
931 #define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
933 #define BREADCRUMB_BITS 31
934 #define BREADCRUMB_MASK ((1U << BREADCRUMB_BITS) - 1)
936 #define READ_BREADCRUMB(dev_priv) (((volatile u32*)(dev_priv->hw_status_page))[5])
939 * Reads a dword out of the status page, which is written to from the command
940 * queue by automatic updates, MI_REPORT_HEAD, MI_STORE_DATA_INDEX, or
943 * The following dwords have a reserved meaning:
944 * 0: ISR copy, updated when an ISR bit not set in the HWSTAM changes.
945 * 4: ring 0 head pointer
946 * 5: ring 1 head pointer (915-class)
947 * 6: ring 2 head pointer (915-class)
949 * The area from dword 0x10 to 0x3ff is available for driver usage.
951 #define READ_HWSP(dev_priv, reg) (((volatile u32*)(dev_priv->hw_status_page))[reg])
952 #define I915_GEM_HWS_INDEX 0x10
954 #define BLC_PWM_CTL 0x61254
955 #define BACKLIGHT_MODULATION_FREQ_SHIFT (17)
957 #define BLC_PWM_CTL2 0x61250
959 * This is the most significant 15 bits of the number of backlight cycles in a
960 * complete cycle of the modulated backlight control.
962 * The actual value is this field multiplied by two.
964 #define BACKLIGHT_MODULATION_FREQ_MASK (0x7fff << 17)
965 #define BLM_LEGACY_MODE (1 << 16)
967 * This is the number of cycles out of the backlight modulation cycle for which
968 * the backlight is on.
970 * This field must be no greater than the number of cycles in the complete
971 * backlight modulation cycle.
973 #define BACKLIGHT_DUTY_CYCLE_SHIFT (0)
974 #define BACKLIGHT_DUTY_CYCLE_MASK (0xffff)
976 #define I915_GCFGC 0xf0
977 #define I915_LOW_FREQUENCY_ENABLE (1 << 7)
978 #define I915_DISPLAY_CLOCK_190_200_MHZ (0 << 4)
979 #define I915_DISPLAY_CLOCK_333_MHZ (4 << 4)
980 #define I915_DISPLAY_CLOCK_MASK (7 << 4)
982 #define I855_HPLLCC 0xc0
983 #define I855_CLOCK_CONTROL_MASK (3 << 0)
984 #define I855_CLOCK_133_200 (0 << 0)
985 #define I855_CLOCK_100_200 (1 << 0)
986 #define I855_CLOCK_100_133 (2 << 0)
987 #define I855_CLOCK_166_250 (3 << 0)
991 #define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */
992 #define VCLK2_VCO_N 0x600a
993 #define VCLK2_VCO_DIV_SEL 0x6012
995 #define VCLK_DIVISOR_VGA0 0x6000
996 #define VCLK_DIVISOR_VGA1 0x6004
997 #define VCLK_POST_DIV 0x6010
998 /** Selects a post divisor of 4 instead of 2. */
999 # define VGA1_PD_P2_DIV_4 (1 << 15)
1000 /** Overrides the p2 post divisor field */
1001 # define VGA1_PD_P1_DIV_2 (1 << 13)
1002 # define VGA1_PD_P1_SHIFT 8
1003 /** P1 value is 2 greater than this field */
1004 # define VGA1_PD_P1_MASK (0x1f << 8)
1005 /** Selects a post divisor of 4 instead of 2. */
1006 # define VGA0_PD_P2_DIV_4 (1 << 7)
1007 /** Overrides the p2 post divisor field */
1008 # define VGA0_PD_P1_DIV_2 (1 << 5)
1009 # define VGA0_PD_P1_SHIFT 0
1010 /** P1 value is 2 greater than this field */
1011 # define VGA0_PD_P1_MASK (0x1f << 0)
1013 /* PCI D state control register */
1014 #define D_STATE 0x6104
1015 #define DSPCLK_GATE_D 0x6200
1017 /* I830 CRTC registers */
1018 #define HTOTAL_A 0x60000
1019 #define HBLANK_A 0x60004
1020 #define HSYNC_A 0x60008
1021 #define VTOTAL_A 0x6000c
1022 #define VBLANK_A 0x60010
1023 #define VSYNC_A 0x60014
1024 #define PIPEASRC 0x6001c
1025 #define BCLRPAT_A 0x60020
1026 #define VSYNCSHIFT_A 0x60028
1028 #define HTOTAL_B 0x61000
1029 #define HBLANK_B 0x61004
1030 #define HSYNC_B 0x61008
1031 #define VTOTAL_B 0x6100c
1032 #define VBLANK_B 0x61010
1033 #define VSYNC_B 0x61014
1034 #define PIPEBSRC 0x6101c
1035 #define BCLRPAT_B 0x61020
1036 #define VSYNCSHIFT_B 0x61028
1038 #define HACTIVE_MASK 0x00000fff
1039 #define VTOTAL_MASK 0x00001fff
1040 #define VTOTAL_SHIFT 16
1041 #define VACTIVE_MASK 0x00000fff
1042 #define VBLANK_END_MASK 0x00001fff
1043 #define VBLANK_END_SHIFT 16
1044 #define VBLANK_START_MASK 0x00001fff
1046 #define PP_STATUS 0x61200
1047 # define PP_ON (1 << 31)
1049 * Indicates that all dependencies of the panel are on:
1053 * - LVDS/DVOB/DVOC on
1055 # define PP_READY (1 << 30)
1056 # define PP_SEQUENCE_NONE (0 << 28)
1057 # define PP_SEQUENCE_ON (1 << 28)
1058 # define PP_SEQUENCE_OFF (2 << 28)
1059 # define PP_SEQUENCE_MASK 0x30000000
1060 #define PP_CONTROL 0x61204
1061 # define POWER_TARGET_ON (1 << 0)
1063 #define LVDSPP_ON 0x61208
1064 #define LVDSPP_OFF 0x6120c
1065 #define PP_CYCLE 0x61210
1067 #define PFIT_CONTROL 0x61230
1068 # define PFIT_ENABLE (1 << 31)
1069 # define PFIT_PIPE_MASK (3 << 29)
1070 # define PFIT_PIPE_SHIFT 29
1071 # define VERT_INTERP_DISABLE (0 << 10)
1072 # define VERT_INTERP_BILINEAR (1 << 10)
1073 # define VERT_INTERP_MASK (3 << 10)
1074 # define VERT_AUTO_SCALE (1 << 9)
1075 # define HORIZ_INTERP_DISABLE (0 << 6)
1076 # define HORIZ_INTERP_BILINEAR (1 << 6)
1077 # define HORIZ_INTERP_MASK (3 << 6)
1078 # define HORIZ_AUTO_SCALE (1 << 5)
1079 # define PANEL_8TO6_DITHER_ENABLE (1 << 3)
1081 #define PFIT_PGM_RATIOS 0x61234
1082 # define PFIT_VERT_SCALE_MASK 0xfff00000
1083 # define PFIT_HORIZ_SCALE_MASK 0x0000fff0
1085 #define PFIT_AUTO_RATIOS 0x61238
1088 #define DPLL_A 0x06014
1089 #define DPLL_B 0x06018
1090 # define DPLL_VCO_ENABLE (1 << 31)
1091 # define DPLL_DVO_HIGH_SPEED (1 << 30)
1092 # define DPLL_SYNCLOCK_ENABLE (1 << 29)
1093 # define DPLL_VGA_MODE_DIS (1 << 28)
1094 # define DPLLB_MODE_DAC_SERIAL (1 << 26) /* i915 */
1095 # define DPLLB_MODE_LVDS (2 << 26) /* i915 */
1096 # define DPLL_MODE_MASK (3 << 26)
1097 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10 (0 << 24) /* i915 */
1098 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 (1 << 24) /* i915 */
1099 # define DPLLB_LVDS_P2_CLOCK_DIV_14 (0 << 24) /* i915 */
1100 # define DPLLB_LVDS_P2_CLOCK_DIV_7 (1 << 24) /* i915 */
1101 # define DPLL_P2_CLOCK_DIV_MASK 0x03000000 /* i915 */
1102 # define DPLL_FPA01_P1_POST_DIV_MASK 0x00ff0000 /* i915 */
1104 * The i830 generation, in DAC/serial mode, defines p1 as two plus this
1105 * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
1107 # define DPLL_FPA01_P1_POST_DIV_MASK_I830 0x001f0000
1109 * The i830 generation, in LVDS mode, defines P1 as the bit number set within
1110 * this field (only one bit may be set).
1112 # define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS 0x003f0000
1113 # define DPLL_FPA01_P1_POST_DIV_SHIFT 16
1114 # define PLL_P2_DIVIDE_BY_4 (1 << 23) /* i830, required in DVO non-gang */
1115 # define PLL_P1_DIVIDE_BY_TWO (1 << 21) /* i830 */
1116 # define PLL_REF_INPUT_DREFCLK (0 << 13)
1117 # define PLL_REF_INPUT_TVCLKINA (1 << 13) /* i830 */
1118 # define PLL_REF_INPUT_TVCLKINBC (2 << 13) /* SDVO TVCLKIN */
1119 # define PLLB_REF_INPUT_SPREADSPECTRUMIN (3 << 13)
1120 # define PLL_REF_INPUT_MASK (3 << 13)
1121 # define PLL_LOAD_PULSE_PHASE_SHIFT 9
1123 * Parallel to Serial Load Pulse phase selection.
1124 * Selects the phase for the 10X DPLL clock for the PCIe
1125 * digital display port. The range is 4 to 13; 10 or more
1126 * is just a flip delay. The default is 6
1128 # define PLL_LOAD_PULSE_PHASE_MASK (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
1129 # define DISPLAY_RATE_SELECT_FPA1 (1 << 8)
1132 * SDVO multiplier for 945G/GM. Not used on 965.
1134 * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1136 # define SDVO_MULTIPLIER_MASK 0x000000ff
1137 # define SDVO_MULTIPLIER_SHIFT_HIRES 4
1138 # define SDVO_MULTIPLIER_SHIFT_VGA 0
1140 /** @defgroup DPLL_MD
1143 /** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
1144 #define DPLL_A_MD 0x0601c
1145 /** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
1146 #define DPLL_B_MD 0x06020
1148 * UDI pixel divider, controlling how many pixels are stuffed into a packet.
1150 * Value is pixels minus 1. Must be set to 1 pixel for SDVO.
1152 # define DPLL_MD_UDI_DIVIDER_MASK 0x3f000000
1153 # define DPLL_MD_UDI_DIVIDER_SHIFT 24
1154 /** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
1155 # define DPLL_MD_VGA_UDI_DIVIDER_MASK 0x003f0000
1156 # define DPLL_MD_VGA_UDI_DIVIDER_SHIFT 16
1158 * SDVO/UDI pixel multiplier.
1160 * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
1161 * clock rate is 10 times the DPLL clock. At low resolution/refresh rate
1162 * modes, the bus rate would be below the limits, so SDVO allows for stuffing
1163 * dummy bytes in the datastream at an increased clock rate, with both sides of
1164 * the link knowing how many bytes are fill.
1166 * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
1167 * rate to 130Mhz to get a bus rate of 1.30Ghz. The DPLL clock rate would be
1168 * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
1169 * through an SDVO command.
1171 * This register field has values of multiplication factor minus 1, with
1172 * a maximum multiplier of 5 for SDVO.
1174 # define DPLL_MD_UDI_MULTIPLIER_MASK 0x00003f00
1175 # define DPLL_MD_UDI_MULTIPLIER_SHIFT 8
1176 /** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
1177 * This best be set to the default value (3) or the CRT won't work. No,
1178 * I don't entirely understand what this does...
1180 # define DPLL_MD_VGA_UDI_MULTIPLIER_MASK 0x0000003f
1181 # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT 0
1184 #define DPLL_TEST 0x606c
1185 # define DPLLB_TEST_SDVO_DIV_1 (0 << 22)
1186 # define DPLLB_TEST_SDVO_DIV_2 (1 << 22)
1187 # define DPLLB_TEST_SDVO_DIV_4 (2 << 22)
1188 # define DPLLB_TEST_SDVO_DIV_MASK (3 << 22)
1189 # define DPLLB_TEST_N_BYPASS (1 << 19)
1190 # define DPLLB_TEST_M_BYPASS (1 << 18)
1191 # define DPLLB_INPUT_BUFFER_ENABLE (1 << 16)
1192 # define DPLLA_TEST_N_BYPASS (1 << 3)
1193 # define DPLLA_TEST_M_BYPASS (1 << 2)
1194 # define DPLLA_INPUT_BUFFER_ENABLE (1 << 0)
1196 #define ADPA 0x61100
1197 #define ADPA_DAC_ENABLE (1<<31)
1198 #define ADPA_DAC_DISABLE 0
1199 #define ADPA_PIPE_SELECT_MASK (1<<30)
1200 #define ADPA_PIPE_A_SELECT 0
1201 #define ADPA_PIPE_B_SELECT (1<<30)
1202 #define ADPA_USE_VGA_HVPOLARITY (1<<15)
1203 #define ADPA_SETS_HVPOLARITY 0
1204 #define ADPA_VSYNC_CNTL_DISABLE (1<<11)
1205 #define ADPA_VSYNC_CNTL_ENABLE 0
1206 #define ADPA_HSYNC_CNTL_DISABLE (1<<10)
1207 #define ADPA_HSYNC_CNTL_ENABLE 0
1208 #define ADPA_VSYNC_ACTIVE_HIGH (1<<4)
1209 #define ADPA_VSYNC_ACTIVE_LOW 0
1210 #define ADPA_HSYNC_ACTIVE_HIGH (1<<3)
1211 #define ADPA_HSYNC_ACTIVE_LOW 0
1213 #define FPA0 0x06040
1214 #define FPA1 0x06044
1215 #define FPB0 0x06048
1216 #define FPB1 0x0604c
1217 # define FP_N_DIV_MASK 0x003f0000
1218 # define FP_N_DIV_SHIFT 16
1219 # define FP_M1_DIV_MASK 0x00003f00
1220 # define FP_M1_DIV_SHIFT 8
1221 # define FP_M2_DIV_MASK 0x0000003f
1222 # define FP_M2_DIV_SHIFT 0
1225 #define PORT_HOTPLUG_EN 0x61110
1226 # define SDVOB_HOTPLUG_INT_EN (1 << 26)
1227 # define SDVOC_HOTPLUG_INT_EN (1 << 25)
1228 # define TV_HOTPLUG_INT_EN (1 << 18)
1229 # define CRT_HOTPLUG_INT_EN (1 << 9)
1230 # define CRT_HOTPLUG_FORCE_DETECT (1 << 3)
1232 #define PORT_HOTPLUG_STAT 0x61114
1233 # define CRT_HOTPLUG_INT_STATUS (1 << 11)
1234 # define TV_HOTPLUG_INT_STATUS (1 << 10)
1235 # define CRT_HOTPLUG_MONITOR_MASK (3 << 8)
1236 # define CRT_HOTPLUG_MONITOR_COLOR (3 << 8)
1237 # define CRT_HOTPLUG_MONITOR_MONO (2 << 8)
1238 # define CRT_HOTPLUG_MONITOR_NONE (0 << 8)
1239 # define SDVOC_HOTPLUG_INT_STATUS (1 << 7)
1240 # define SDVOB_HOTPLUG_INT_STATUS (1 << 6)
1242 #define SDVOB 0x61140
1243 #define SDVOC 0x61160
1244 #define SDVO_ENABLE (1 << 31)
1245 #define SDVO_PIPE_B_SELECT (1 << 30)
1246 #define SDVO_STALL_SELECT (1 << 29)
1247 #define SDVO_INTERRUPT_ENABLE (1 << 26)
1249 * 915G/GM SDVO pixel multiplier.
1251 * Programmed value is multiplier - 1, up to 5x.
1253 * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1255 #define SDVO_PORT_MULTIPLY_MASK (7 << 23)
1256 #define SDVO_PORT_MULTIPLY_SHIFT 23
1257 #define SDVO_PHASE_SELECT_MASK (15 << 19)
1258 #define SDVO_PHASE_SELECT_DEFAULT (6 << 19)
1259 #define SDVO_CLOCK_OUTPUT_INVERT (1 << 18)
1260 #define SDVOC_GANG_MODE (1 << 16)
1261 #define SDVO_BORDER_ENABLE (1 << 7)
1262 #define SDVOB_PCIE_CONCURRENCY (1 << 3)
1263 #define SDVO_DETECTED (1 << 2)
1264 /* Bits to be preserved when writing */
1265 #define SDVOB_PRESERVE_MASK ((1 << 17) | (1 << 16) | (1 << 14))
1266 #define SDVOC_PRESERVE_MASK (1 << 17)
1272 * This register controls the LVDS output enable, pipe selection, and data
1275 * All of the clock/data pairs are force powered down by power sequencing.
1277 #define LVDS 0x61180
1279 * Enables the LVDS port. This bit must be set before DPLLs are enabled, as
1280 * the DPLL semantics change when the LVDS is assigned to that pipe.
1282 # define LVDS_PORT_EN (1 << 31)
1283 /** Selects pipe B for LVDS data. Must be set on pre-965. */
1284 # define LVDS_PIPEB_SELECT (1 << 30)
1287 * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
1290 # define LVDS_A0A2_CLKA_POWER_MASK (3 << 8)
1291 # define LVDS_A0A2_CLKA_POWER_DOWN (0 << 8)
1292 # define LVDS_A0A2_CLKA_POWER_UP (3 << 8)
1294 * Controls the A3 data pair, which contains the additional LSBs for 24 bit
1295 * mode. Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
1298 # define LVDS_A3_POWER_MASK (3 << 6)
1299 # define LVDS_A3_POWER_DOWN (0 << 6)
1300 # define LVDS_A3_POWER_UP (3 << 6)
1302 * Controls the CLKB pair. This should only be set when LVDS_B0B3_POWER_UP
1305 # define LVDS_CLKB_POWER_MASK (3 << 4)
1306 # define LVDS_CLKB_POWER_DOWN (0 << 4)
1307 # define LVDS_CLKB_POWER_UP (3 << 4)
1310 * Controls the B0-B3 data pairs. This must be set to match the DPLL p2
1311 * setting for whether we are in dual-channel mode. The B3 pair will
1312 * additionally only be powered up when LVDS_A3_POWER_UP is set.
1314 # define LVDS_B0B3_POWER_MASK (3 << 2)
1315 # define LVDS_B0B3_POWER_DOWN (0 << 2)
1316 # define LVDS_B0B3_POWER_UP (3 << 2)
1318 #define PIPEACONF 0x70008
1319 #define PIPEACONF_ENABLE (1<<31)
1320 #define PIPEACONF_DISABLE 0
1321 #define PIPEACONF_DOUBLE_WIDE (1<<30)
1322 #define I965_PIPECONF_ACTIVE (1<<30)
1323 #define PIPEACONF_SINGLE_WIDE 0
1324 #define PIPEACONF_PIPE_UNLOCKED 0
1325 #define PIPEACONF_PIPE_LOCKED (1<<25)
1326 #define PIPEACONF_PALETTE 0
1327 #define PIPEACONF_GAMMA (1<<24)
1328 #define PIPECONF_FORCE_BORDER (1<<25)
1329 #define PIPECONF_PROGRESSIVE (0 << 21)
1330 #define PIPECONF_INTERLACE_W_FIELD_INDICATION (6 << 21)
1331 #define PIPECONF_INTERLACE_FIELD_0_ONLY (7 << 21)
1333 #define DSPARB 0x70030
1334 #define DSPARB_CSTART_MASK (0x7f << 7)
1335 #define DSPARB_CSTART_SHIFT 7
1336 #define DSPARB_BSTART_MASK (0x7f)
1337 #define DSPARB_BSTART_SHIFT 0
1339 #define PIPEBCONF 0x71008
1340 #define PIPEBCONF_ENABLE (1<<31)
1341 #define PIPEBCONF_DISABLE 0
1342 #define PIPEBCONF_DOUBLE_WIDE (1<<30)
1343 #define PIPEBCONF_DISABLE 0
1344 #define PIPEBCONF_GAMMA (1<<24)
1345 #define PIPEBCONF_PALETTE 0
1347 #define PIPEBGCMAXRED 0x71010
1348 #define PIPEBGCMAXGREEN 0x71014
1349 #define PIPEBGCMAXBLUE 0x71018
1350 #define PIPEBSTAT 0x71024
1351 #define PIPEBFRAMEHIGH 0x71040
1352 #define PIPEBFRAMEPIXEL 0x71044
1354 #define DSPACNTR 0x70180
1355 #define DSPBCNTR 0x71180
1356 #define DISPLAY_PLANE_ENABLE (1<<31)
1357 #define DISPLAY_PLANE_DISABLE 0
1358 #define DISPPLANE_GAMMA_ENABLE (1<<30)
1359 #define DISPPLANE_GAMMA_DISABLE 0
1360 #define DISPPLANE_PIXFORMAT_MASK (0xf<<26)
1361 #define DISPPLANE_8BPP (0x2<<26)
1362 #define DISPPLANE_15_16BPP (0x4<<26)
1363 #define DISPPLANE_16BPP (0x5<<26)
1364 #define DISPPLANE_32BPP_NO_ALPHA (0x6<<26)
1365 #define DISPPLANE_32BPP (0x7<<26)
1366 #define DISPPLANE_STEREO_ENABLE (1<<25)
1367 #define DISPPLANE_STEREO_DISABLE 0
1368 #define DISPPLANE_SEL_PIPE_MASK (1<<24)
1369 #define DISPPLANE_SEL_PIPE_A 0
1370 #define DISPPLANE_SEL_PIPE_B (1<<24)
1371 #define DISPPLANE_SRC_KEY_ENABLE (1<<22)
1372 #define DISPPLANE_SRC_KEY_DISABLE 0
1373 #define DISPPLANE_LINE_DOUBLE (1<<20)
1374 #define DISPPLANE_NO_LINE_DOUBLE 0
1375 #define DISPPLANE_STEREO_POLARITY_FIRST 0
1376 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18)
1378 #define DISPPLANE_ALPHA_TRANS_ENABLE (1<<15)
1379 #define DISPPLANE_ALPHA_TRANS_DISABLE 0
1380 #define DISPPLANE_SPRITE_ABOVE_DISPLAYA 0
1381 #define DISPPLANE_SPRITE_ABOVE_OVERLAY (1)
1383 #define DSPABASE 0x70184
1384 #define DSPASTRIDE 0x70188
1386 #define DSPBBASE 0x71184
1387 #define DSPBADDR DSPBBASE
1388 #define DSPBSTRIDE 0x71188
1390 #define DSPAKEYVAL 0x70194
1391 #define DSPAKEYMASK 0x70198
1393 #define DSPAPOS 0x7018C /* reserved */
1394 #define DSPASIZE 0x70190
1395 #define DSPBPOS 0x7118C
1396 #define DSPBSIZE 0x71190
1398 #define DSPASURF 0x7019C
1399 #define DSPATILEOFF 0x701A4
1401 #define DSPBSURF 0x7119C
1402 #define DSPBTILEOFF 0x711A4
1404 #define VGACNTRL 0x71400
1405 # define VGA_DISP_DISABLE (1 << 31)
1406 # define VGA_2X_MODE (1 << 30)
1407 # define VGA_PIPE_B_SELECT (1 << 29)
1410 * Some BIOS scratch area registers. The 845 (and 830?) store the amount
1411 * of video memory available to the BIOS in SWF1.
1414 #define SWF0 0x71410
1417 * 855 scratch registers.
1419 #define SWF10 0x70410
1421 #define SWF30 0x72414
1424 * Overlay registers. These are overlay registers accessed via MMIO.
1425 * Those loaded via the overlay register page are defined in i830_video.c.
1427 #define OVADD 0x30000
1429 #define DOVSTA 0x30008
1430 #define OC_BUF (0x3<<20)
1432 #define OGAMC5 0x30010
1433 #define OGAMC4 0x30014
1434 #define OGAMC3 0x30018
1435 #define OGAMC2 0x3001c
1436 #define OGAMC1 0x30020
1437 #define OGAMC0 0x30024
1441 #define PALETTE_A 0x0a000
1442 #define PALETTE_B 0x0a800
1444 #define IS_I830(dev) ((dev)->pci_device == 0x3577)
1445 #define IS_845G(dev) ((dev)->pci_device == 0x2562)
1446 #define IS_I85X(dev) ((dev)->pci_device == 0x3582)
1447 #define IS_I855(dev) ((dev)->pci_device == 0x3582)
1448 #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
1450 #define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
1451 #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
1452 #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
1453 #define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 ||\
1454 (dev)->pci_device == 0x27AE)
1455 #define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
1456 (dev)->pci_device == 0x2982 || \
1457 (dev)->pci_device == 0x2992 || \
1458 (dev)->pci_device == 0x29A2 || \
1459 (dev)->pci_device == 0x2A02 || \
1460 (dev)->pci_device == 0x2A12 || \
1461 (dev)->pci_device == 0x2A42)
1463 #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
1465 #define IS_IGD_GM(dev) ((dev)->pci_device == 0x2A42)
1467 #define IS_G33(dev) ((dev)->pci_device == 0x29C2 || \
1468 (dev)->pci_device == 0x29B2 || \
1469 (dev)->pci_device == 0x29D2)
1471 #define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
1472 IS_I945GM(dev) || IS_I965G(dev) || IS_G33(dev))
1474 #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
1475 IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev))
1477 #define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_IGD_GM(dev))
1479 #define PRIMARY_RINGBUFFER_SIZE (128*1024)