4 * Linux framebuffer driver for Intel(R) 865G integrated graphics chips.
6 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
9 * This driver consists of two parts. The first part (intelfbdrv.c) provides
10 * the basic fbdev interfaces, is derived in part from the radeonfb and
11 * vesafb drivers, and is covered by the GPL. The second part (intelfbhw.c)
12 * provides the code to program the hardware. Most of it is derived from
13 * the i810/i830 XFree86 driver. The HW-specific code is covered here
14 * under a dual license (GPL and MIT/XFree86 license).
20 /* $DHD: intelfb/intelfbhw.c,v 1.9 2003/06/27 15:06:25 dawes Exp $ */
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/errno.h>
25 #include <linux/string.h>
27 #include <linux/slab.h>
28 #include <linux/delay.h>
30 #include <linux/ioport.h>
31 #include <linux/init.h>
32 #include <linux/pci.h>
33 #include <linux/vmalloc.h>
34 #include <linux/pagemap.h>
35 #include <linux/interrupt.h>
40 #include "intelfbhw.h"
43 int min_m
, max_m
, min_m1
, max_m1
;
44 int min_m2
, max_m2
, min_n
, max_n
;
45 int min_p
, max_p
, min_p1
, max_p1
;
46 int min_vco
, max_vco
, p_transition_clk
, ref_clk
;
47 int p_inc_lo
, p_inc_hi
;
54 static struct pll_min_max plls
[PLLS_MAX
] = {
58 930000, 1400000, 165000, 48000,
64 1400000, 2800000, 200000, 96000,
68 int intelfbhw_get_chipset(struct pci_dev
*pdev
, struct intelfb_info
*dinfo
)
74 switch (pdev
->device
) {
75 case PCI_DEVICE_ID_INTEL_830M
:
76 dinfo
->name
= "Intel(R) 830M";
77 dinfo
->chipset
= INTEL_830M
;
79 dinfo
->pll_index
= PLLS_I8xx
;
81 case PCI_DEVICE_ID_INTEL_845G
:
82 dinfo
->name
= "Intel(R) 845G";
83 dinfo
->chipset
= INTEL_845G
;
85 dinfo
->pll_index
= PLLS_I8xx
;
87 case PCI_DEVICE_ID_INTEL_85XGM
:
90 dinfo
->pll_index
= PLLS_I8xx
;
91 pci_read_config_dword(pdev
, INTEL_85X_CAPID
, &tmp
);
92 switch ((tmp
>> INTEL_85X_VARIANT_SHIFT
) &
93 INTEL_85X_VARIANT_MASK
) {
94 case INTEL_VAR_855GME
:
95 dinfo
->name
= "Intel(R) 855GME";
96 dinfo
->chipset
= INTEL_855GME
;
99 dinfo
->name
= "Intel(R) 855GM";
100 dinfo
->chipset
= INTEL_855GM
;
102 case INTEL_VAR_852GME
:
103 dinfo
->name
= "Intel(R) 852GME";
104 dinfo
->chipset
= INTEL_852GME
;
106 case INTEL_VAR_852GM
:
107 dinfo
->name
= "Intel(R) 852GM";
108 dinfo
->chipset
= INTEL_852GM
;
111 dinfo
->name
= "Intel(R) 852GM/855GM";
112 dinfo
->chipset
= INTEL_85XGM
;
116 case PCI_DEVICE_ID_INTEL_865G
:
117 dinfo
->name
= "Intel(R) 865G";
118 dinfo
->chipset
= INTEL_865G
;
120 dinfo
->pll_index
= PLLS_I8xx
;
122 case PCI_DEVICE_ID_INTEL_915G
:
123 dinfo
->name
= "Intel(R) 915G";
124 dinfo
->chipset
= INTEL_915G
;
126 dinfo
->pll_index
= PLLS_I9xx
;
128 case PCI_DEVICE_ID_INTEL_915GM
:
129 dinfo
->name
= "Intel(R) 915GM";
130 dinfo
->chipset
= INTEL_915GM
;
132 dinfo
->pll_index
= PLLS_I9xx
;
134 case PCI_DEVICE_ID_INTEL_945G
:
135 dinfo
->name
= "Intel(R) 945G";
136 dinfo
->chipset
= INTEL_945G
;
138 dinfo
->pll_index
= PLLS_I9xx
;
140 case PCI_DEVICE_ID_INTEL_945GM
:
141 dinfo
->name
= "Intel(R) 945GM";
142 dinfo
->chipset
= INTEL_945GM
;
144 dinfo
->pll_index
= PLLS_I9xx
;
146 case PCI_DEVICE_ID_INTEL_965G
:
147 dinfo
->name
= "Intel(R) 965G";
148 dinfo
->chipset
= INTEL_965G
;
150 dinfo
->pll_index
= PLLS_I9xx
;
152 case PCI_DEVICE_ID_INTEL_965GM
:
153 dinfo
->name
= "Intel(R) 965GM";
154 dinfo
->chipset
= INTEL_965GM
;
156 dinfo
->pll_index
= PLLS_I9xx
;
163 int intelfbhw_get_memory(struct pci_dev
*pdev
, int *aperture_size
,
166 struct pci_dev
*bridge_dev
;
170 if (!pdev
|| !aperture_size
|| !stolen_size
)
173 /* Find the bridge device. It is always 0:0.0 */
174 if (!(bridge_dev
= pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)))) {
175 ERR_MSG("cannot find bridge device\n");
179 /* Get the fb aperture size and "stolen" memory amount. */
181 pci_read_config_word(bridge_dev
, INTEL_GMCH_CTRL
, &tmp
);
182 pci_dev_put(bridge_dev
);
184 switch (pdev
->device
) {
185 case PCI_DEVICE_ID_INTEL_915G
:
186 case PCI_DEVICE_ID_INTEL_915GM
:
187 case PCI_DEVICE_ID_INTEL_945G
:
188 case PCI_DEVICE_ID_INTEL_945GM
:
189 case PCI_DEVICE_ID_INTEL_965G
:
190 case PCI_DEVICE_ID_INTEL_965GM
:
191 /* 915, 945 and 965 chipsets support a 256MB aperture.
192 Aperture size is determined by inspected the
193 base address of the aperture. */
194 if (pci_resource_start(pdev
, 2) & 0x08000000)
195 *aperture_size
= MB(128);
197 *aperture_size
= MB(256);
200 if ((tmp
& INTEL_GMCH_MEM_MASK
) == INTEL_GMCH_MEM_64M
)
201 *aperture_size
= MB(64);
203 *aperture_size
= MB(128);
207 /* Stolen memory size is reduced by the GTT and the popup.
208 GTT is 1K per MB of aperture size, and popup is 4K. */
209 stolen_overhead
= (*aperture_size
/ MB(1)) + 4;
210 switch(pdev
->device
) {
211 case PCI_DEVICE_ID_INTEL_830M
:
212 case PCI_DEVICE_ID_INTEL_845G
:
213 switch (tmp
& INTEL_830_GMCH_GMS_MASK
) {
214 case INTEL_830_GMCH_GMS_STOLEN_512
:
215 *stolen_size
= KB(512) - KB(stolen_overhead
);
217 case INTEL_830_GMCH_GMS_STOLEN_1024
:
218 *stolen_size
= MB(1) - KB(stolen_overhead
);
220 case INTEL_830_GMCH_GMS_STOLEN_8192
:
221 *stolen_size
= MB(8) - KB(stolen_overhead
);
223 case INTEL_830_GMCH_GMS_LOCAL
:
224 ERR_MSG("only local memory found\n");
226 case INTEL_830_GMCH_GMS_DISABLED
:
227 ERR_MSG("video memory is disabled\n");
230 ERR_MSG("unexpected GMCH_GMS value: 0x%02x\n",
231 tmp
& INTEL_830_GMCH_GMS_MASK
);
236 switch (tmp
& INTEL_855_GMCH_GMS_MASK
) {
237 case INTEL_855_GMCH_GMS_STOLEN_1M
:
238 *stolen_size
= MB(1) - KB(stolen_overhead
);
240 case INTEL_855_GMCH_GMS_STOLEN_4M
:
241 *stolen_size
= MB(4) - KB(stolen_overhead
);
243 case INTEL_855_GMCH_GMS_STOLEN_8M
:
244 *stolen_size
= MB(8) - KB(stolen_overhead
);
246 case INTEL_855_GMCH_GMS_STOLEN_16M
:
247 *stolen_size
= MB(16) - KB(stolen_overhead
);
249 case INTEL_855_GMCH_GMS_STOLEN_32M
:
250 *stolen_size
= MB(32) - KB(stolen_overhead
);
252 case INTEL_915G_GMCH_GMS_STOLEN_48M
:
253 *stolen_size
= MB(48) - KB(stolen_overhead
);
255 case INTEL_915G_GMCH_GMS_STOLEN_64M
:
256 *stolen_size
= MB(64) - KB(stolen_overhead
);
258 case INTEL_855_GMCH_GMS_DISABLED
:
259 ERR_MSG("video memory is disabled\n");
262 ERR_MSG("unexpected GMCH_GMS value: 0x%02x\n",
263 tmp
& INTEL_855_GMCH_GMS_MASK
);
269 int intelfbhw_check_non_crt(struct intelfb_info
*dinfo
)
273 if (INREG(LVDS
) & PORT_ENABLE
)
275 if (INREG(DVOA
) & PORT_ENABLE
)
277 if (INREG(DVOB
) & PORT_ENABLE
)
279 if (INREG(DVOC
) & PORT_ENABLE
)
285 const char * intelfbhw_dvo_to_string(int dvo
)
289 else if (dvo
& DVOB_PORT
)
291 else if (dvo
& DVOC_PORT
)
293 else if (dvo
& LVDS_PORT
)
300 int intelfbhw_validate_mode(struct intelfb_info
*dinfo
,
301 struct fb_var_screeninfo
*var
)
307 DBG_MSG("intelfbhw_validate_mode\n");
310 bytes_per_pixel
= var
->bits_per_pixel
/ 8;
311 if (bytes_per_pixel
== 3)
314 /* Check if enough video memory. */
315 tmp
= var
->yres_virtual
* var
->xres_virtual
* bytes_per_pixel
;
316 if (tmp
> dinfo
->fb
.size
) {
317 WRN_MSG("Not enough video ram for mode "
318 "(%d KByte vs %d KByte).\n",
319 BtoKB(tmp
), BtoKB(dinfo
->fb
.size
));
323 /* Check if x/y limits are OK. */
324 if (var
->xres
- 1 > HACTIVE_MASK
) {
325 WRN_MSG("X resolution too large (%d vs %d).\n",
326 var
->xres
, HACTIVE_MASK
+ 1);
329 if (var
->yres
- 1 > VACTIVE_MASK
) {
330 WRN_MSG("Y resolution too large (%d vs %d).\n",
331 var
->yres
, VACTIVE_MASK
+ 1);
335 WRN_MSG("X resolution too small (%d vs 4).\n", var
->xres
);
339 WRN_MSG("Y resolution too small (%d vs 4).\n", var
->yres
);
343 /* Check for doublescan modes. */
344 if (var
->vmode
& FB_VMODE_DOUBLE
) {
345 WRN_MSG("Mode is double-scan.\n");
349 if ((var
->vmode
& FB_VMODE_INTERLACED
) && (var
->yres
& 1)) {
350 WRN_MSG("Odd number of lines in interlaced mode\n");
354 /* Check if clock is OK. */
355 tmp
= 1000000000 / var
->pixclock
;
356 if (tmp
< MIN_CLOCK
) {
357 WRN_MSG("Pixel clock is too low (%d MHz vs %d MHz).\n",
358 (tmp
+ 500) / 1000, MIN_CLOCK
/ 1000);
361 if (tmp
> MAX_CLOCK
) {
362 WRN_MSG("Pixel clock is too high (%d MHz vs %d MHz).\n",
363 (tmp
+ 500) / 1000, MAX_CLOCK
/ 1000);
370 int intelfbhw_pan_display(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
372 struct intelfb_info
*dinfo
= GET_DINFO(info
);
373 u32 offset
, xoffset
, yoffset
;
376 DBG_MSG("intelfbhw_pan_display\n");
379 xoffset
= ROUND_DOWN_TO(var
->xoffset
, 8);
380 yoffset
= var
->yoffset
;
382 if ((xoffset
+ var
->xres
> var
->xres_virtual
) ||
383 (yoffset
+ var
->yres
> var
->yres_virtual
))
386 offset
= (yoffset
* dinfo
->pitch
) +
387 (xoffset
* var
->bits_per_pixel
) / 8;
389 offset
+= dinfo
->fb
.offset
<< 12;
391 dinfo
->vsync
.pan_offset
= offset
;
392 if ((var
->activate
& FB_ACTIVATE_VBL
) &&
393 !intelfbhw_enable_irq(dinfo
))
394 dinfo
->vsync
.pan_display
= 1;
396 dinfo
->vsync
.pan_display
= 0;
397 OUTREG(DSPABASE
, offset
);
403 /* Blank the screen. */
404 void intelfbhw_do_blank(int blank
, struct fb_info
*info
)
406 struct intelfb_info
*dinfo
= GET_DINFO(info
);
410 DBG_MSG("intelfbhw_do_blank: blank is %d\n", blank
);
413 /* Turn plane A on or off */
414 tmp
= INREG(DSPACNTR
);
416 tmp
&= ~DISPPLANE_PLANE_ENABLE
;
418 tmp
|= DISPPLANE_PLANE_ENABLE
;
419 OUTREG(DSPACNTR
, tmp
);
421 tmp
= INREG(DSPABASE
);
422 OUTREG(DSPABASE
, tmp
);
424 /* Turn off/on the HW cursor */
426 DBG_MSG("cursor_on is %d\n", dinfo
->cursor_on
);
428 if (dinfo
->cursor_on
) {
430 intelfbhw_cursor_hide(dinfo
);
432 intelfbhw_cursor_show(dinfo
);
433 dinfo
->cursor_on
= 1;
435 dinfo
->cursor_blanked
= blank
;
438 tmp
= INREG(ADPA
) & ~ADPA_DPMS_CONTROL_MASK
;
440 case FB_BLANK_UNBLANK
:
441 case FB_BLANK_NORMAL
:
444 case FB_BLANK_VSYNC_SUSPEND
:
447 case FB_BLANK_HSYNC_SUSPEND
:
450 case FB_BLANK_POWERDOWN
:
460 void intelfbhw_setcolreg(struct intelfb_info
*dinfo
, unsigned regno
,
461 unsigned red
, unsigned green
, unsigned blue
,
464 u32 palette_reg
= (dinfo
->pipe
== PIPE_A
) ?
465 PALETTE_A
: PALETTE_B
;
468 DBG_MSG("intelfbhw_setcolreg: %d: (%d, %d, %d)\n",
469 regno
, red
, green
, blue
);
472 OUTREG(palette_reg
+ (regno
<< 2),
473 (red
<< PALETTE_8_RED_SHIFT
) |
474 (green
<< PALETTE_8_GREEN_SHIFT
) |
475 (blue
<< PALETTE_8_BLUE_SHIFT
));
479 int intelfbhw_read_hw_state(struct intelfb_info
*dinfo
,
480 struct intelfb_hwstate
*hw
, int flag
)
485 DBG_MSG("intelfbhw_read_hw_state\n");
491 /* Read in as much of the HW state as possible. */
492 hw
->vga0_divisor
= INREG(VGA0_DIVISOR
);
493 hw
->vga1_divisor
= INREG(VGA1_DIVISOR
);
494 hw
->vga_pd
= INREG(VGAPD
);
495 hw
->dpll_a
= INREG(DPLL_A
);
496 hw
->dpll_b
= INREG(DPLL_B
);
497 hw
->fpa0
= INREG(FPA0
);
498 hw
->fpa1
= INREG(FPA1
);
499 hw
->fpb0
= INREG(FPB0
);
500 hw
->fpb1
= INREG(FPB1
);
506 /* This seems to be a problem with the 852GM/855GM */
507 for (i
= 0; i
< PALETTE_8_ENTRIES
; i
++) {
508 hw
->palette_a
[i
] = INREG(PALETTE_A
+ (i
<< 2));
509 hw
->palette_b
[i
] = INREG(PALETTE_B
+ (i
<< 2));
516 hw
->htotal_a
= INREG(HTOTAL_A
);
517 hw
->hblank_a
= INREG(HBLANK_A
);
518 hw
->hsync_a
= INREG(HSYNC_A
);
519 hw
->vtotal_a
= INREG(VTOTAL_A
);
520 hw
->vblank_a
= INREG(VBLANK_A
);
521 hw
->vsync_a
= INREG(VSYNC_A
);
522 hw
->src_size_a
= INREG(SRC_SIZE_A
);
523 hw
->bclrpat_a
= INREG(BCLRPAT_A
);
524 hw
->htotal_b
= INREG(HTOTAL_B
);
525 hw
->hblank_b
= INREG(HBLANK_B
);
526 hw
->hsync_b
= INREG(HSYNC_B
);
527 hw
->vtotal_b
= INREG(VTOTAL_B
);
528 hw
->vblank_b
= INREG(VBLANK_B
);
529 hw
->vsync_b
= INREG(VSYNC_B
);
530 hw
->src_size_b
= INREG(SRC_SIZE_B
);
531 hw
->bclrpat_b
= INREG(BCLRPAT_B
);
536 hw
->adpa
= INREG(ADPA
);
537 hw
->dvoa
= INREG(DVOA
);
538 hw
->dvob
= INREG(DVOB
);
539 hw
->dvoc
= INREG(DVOC
);
540 hw
->dvoa_srcdim
= INREG(DVOA_SRCDIM
);
541 hw
->dvob_srcdim
= INREG(DVOB_SRCDIM
);
542 hw
->dvoc_srcdim
= INREG(DVOC_SRCDIM
);
543 hw
->lvds
= INREG(LVDS
);
548 hw
->pipe_a_conf
= INREG(PIPEACONF
);
549 hw
->pipe_b_conf
= INREG(PIPEBCONF
);
550 hw
->disp_arb
= INREG(DISPARB
);
555 hw
->cursor_a_control
= INREG(CURSOR_A_CONTROL
);
556 hw
->cursor_b_control
= INREG(CURSOR_B_CONTROL
);
557 hw
->cursor_a_base
= INREG(CURSOR_A_BASEADDR
);
558 hw
->cursor_b_base
= INREG(CURSOR_B_BASEADDR
);
563 for (i
= 0; i
< 4; i
++) {
564 hw
->cursor_a_palette
[i
] = INREG(CURSOR_A_PALETTE0
+ (i
<< 2));
565 hw
->cursor_b_palette
[i
] = INREG(CURSOR_B_PALETTE0
+ (i
<< 2));
571 hw
->cursor_size
= INREG(CURSOR_SIZE
);
576 hw
->disp_a_ctrl
= INREG(DSPACNTR
);
577 hw
->disp_b_ctrl
= INREG(DSPBCNTR
);
578 hw
->disp_a_base
= INREG(DSPABASE
);
579 hw
->disp_b_base
= INREG(DSPBBASE
);
580 hw
->disp_a_stride
= INREG(DSPASTRIDE
);
581 hw
->disp_b_stride
= INREG(DSPBSTRIDE
);
586 hw
->vgacntrl
= INREG(VGACNTRL
);
591 hw
->add_id
= INREG(ADD_ID
);
596 for (i
= 0; i
< 7; i
++) {
597 hw
->swf0x
[i
] = INREG(SWF00
+ (i
<< 2));
598 hw
->swf1x
[i
] = INREG(SWF10
+ (i
<< 2));
600 hw
->swf3x
[i
] = INREG(SWF30
+ (i
<< 2));
603 for (i
= 0; i
< 8; i
++)
604 hw
->fence
[i
] = INREG(FENCE
+ (i
<< 2));
606 hw
->instpm
= INREG(INSTPM
);
607 hw
->mem_mode
= INREG(MEM_MODE
);
608 hw
->fw_blc_0
= INREG(FW_BLC_0
);
609 hw
->fw_blc_1
= INREG(FW_BLC_1
);
611 hw
->hwstam
= INREG16(HWSTAM
);
612 hw
->ier
= INREG16(IER
);
613 hw
->iir
= INREG16(IIR
);
614 hw
->imr
= INREG16(IMR
);
620 static int calc_vclock3(int index
, int m
, int n
, int p
)
622 if (p
== 0 || n
== 0)
624 return plls
[index
].ref_clk
* m
/ n
/ p
;
627 static int calc_vclock(int index
, int m1
, int m2
, int n
, int p1
, int p2
,
630 struct pll_min_max
*pll
= &plls
[index
];
633 m
= (5 * (m1
+ 2)) + (m2
+ 2);
635 vco
= pll
->ref_clk
* m
/ n
;
637 if (index
== PLLS_I8xx
)
638 p
= ((p1
+ 2) * (1 << (p2
+ 1)));
640 p
= ((p1
) * (p2
? 5 : 10));
645 static void intelfbhw_get_p1p2(struct intelfb_info
*dinfo
, int dpll
,
646 int *o_p1
, int *o_p2
)
650 if (IS_I9XX(dinfo
)) {
651 if (dpll
& DPLL_P1_FORCE_DIV2
)
654 p1
= (dpll
>> DPLL_P1_SHIFT
) & 0xff;
658 p2
= (dpll
>> DPLL_I9XX_P2_SHIFT
) & DPLL_P2_MASK
;
660 if (dpll
& DPLL_P1_FORCE_DIV2
)
663 p1
= (dpll
>> DPLL_P1_SHIFT
) & DPLL_P1_MASK
;
664 p2
= (dpll
>> DPLL_P2_SHIFT
) & DPLL_P2_MASK
;
673 void intelfbhw_print_hw_state(struct intelfb_info
*dinfo
,
674 struct intelfb_hwstate
*hw
)
677 int i
, m1
, m2
, n
, p1
, p2
;
678 int index
= dinfo
->pll_index
;
679 DBG_MSG("intelfbhw_print_hw_state\n");
683 /* Read in as much of the HW state as possible. */
684 printk("hw state dump start\n");
685 printk(" VGA0_DIVISOR: 0x%08x\n", hw
->vga0_divisor
);
686 printk(" VGA1_DIVISOR: 0x%08x\n", hw
->vga1_divisor
);
687 printk(" VGAPD: 0x%08x\n", hw
->vga_pd
);
688 n
= (hw
->vga0_divisor
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
689 m1
= (hw
->vga0_divisor
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
690 m2
= (hw
->vga0_divisor
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
692 intelfbhw_get_p1p2(dinfo
, hw
->vga_pd
, &p1
, &p2
);
694 printk(" VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
696 printk(" VGA0: clock is %d\n",
697 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
699 n
= (hw
->vga1_divisor
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
700 m1
= (hw
->vga1_divisor
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
701 m2
= (hw
->vga1_divisor
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
703 intelfbhw_get_p1p2(dinfo
, hw
->vga_pd
, &p1
, &p2
);
704 printk(" VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
706 printk(" VGA1: clock is %d\n",
707 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
709 printk(" DPLL_A: 0x%08x\n", hw
->dpll_a
);
710 printk(" DPLL_B: 0x%08x\n", hw
->dpll_b
);
711 printk(" FPA0: 0x%08x\n", hw
->fpa0
);
712 printk(" FPA1: 0x%08x\n", hw
->fpa1
);
713 printk(" FPB0: 0x%08x\n", hw
->fpb0
);
714 printk(" FPB1: 0x%08x\n", hw
->fpb1
);
716 n
= (hw
->fpa0
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
717 m1
= (hw
->fpa0
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
718 m2
= (hw
->fpa0
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
720 intelfbhw_get_p1p2(dinfo
, hw
->dpll_a
, &p1
, &p2
);
722 printk(" PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
724 printk(" PLLA0: clock is %d\n",
725 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
727 n
= (hw
->fpa1
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
728 m1
= (hw
->fpa1
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
729 m2
= (hw
->fpa1
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
731 intelfbhw_get_p1p2(dinfo
, hw
->dpll_a
, &p1
, &p2
);
733 printk(" PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
735 printk(" PLLA1: clock is %d\n",
736 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
739 printk(" PALETTE_A:\n");
740 for (i
= 0; i
< PALETTE_8_ENTRIES
)
741 printk(" %3d: 0x%08x\n", i
, hw
->palette_a
[i
]);
742 printk(" PALETTE_B:\n");
743 for (i
= 0; i
< PALETTE_8_ENTRIES
)
744 printk(" %3d: 0x%08x\n", i
, hw
->palette_b
[i
]);
747 printk(" HTOTAL_A: 0x%08x\n", hw
->htotal_a
);
748 printk(" HBLANK_A: 0x%08x\n", hw
->hblank_a
);
749 printk(" HSYNC_A: 0x%08x\n", hw
->hsync_a
);
750 printk(" VTOTAL_A: 0x%08x\n", hw
->vtotal_a
);
751 printk(" VBLANK_A: 0x%08x\n", hw
->vblank_a
);
752 printk(" VSYNC_A: 0x%08x\n", hw
->vsync_a
);
753 printk(" SRC_SIZE_A: 0x%08x\n", hw
->src_size_a
);
754 printk(" BCLRPAT_A: 0x%08x\n", hw
->bclrpat_a
);
755 printk(" HTOTAL_B: 0x%08x\n", hw
->htotal_b
);
756 printk(" HBLANK_B: 0x%08x\n", hw
->hblank_b
);
757 printk(" HSYNC_B: 0x%08x\n", hw
->hsync_b
);
758 printk(" VTOTAL_B: 0x%08x\n", hw
->vtotal_b
);
759 printk(" VBLANK_B: 0x%08x\n", hw
->vblank_b
);
760 printk(" VSYNC_B: 0x%08x\n", hw
->vsync_b
);
761 printk(" SRC_SIZE_B: 0x%08x\n", hw
->src_size_b
);
762 printk(" BCLRPAT_B: 0x%08x\n", hw
->bclrpat_b
);
764 printk(" ADPA: 0x%08x\n", hw
->adpa
);
765 printk(" DVOA: 0x%08x\n", hw
->dvoa
);
766 printk(" DVOB: 0x%08x\n", hw
->dvob
);
767 printk(" DVOC: 0x%08x\n", hw
->dvoc
);
768 printk(" DVOA_SRCDIM: 0x%08x\n", hw
->dvoa_srcdim
);
769 printk(" DVOB_SRCDIM: 0x%08x\n", hw
->dvob_srcdim
);
770 printk(" DVOC_SRCDIM: 0x%08x\n", hw
->dvoc_srcdim
);
771 printk(" LVDS: 0x%08x\n", hw
->lvds
);
773 printk(" PIPEACONF: 0x%08x\n", hw
->pipe_a_conf
);
774 printk(" PIPEBCONF: 0x%08x\n", hw
->pipe_b_conf
);
775 printk(" DISPARB: 0x%08x\n", hw
->disp_arb
);
777 printk(" CURSOR_A_CONTROL: 0x%08x\n", hw
->cursor_a_control
);
778 printk(" CURSOR_B_CONTROL: 0x%08x\n", hw
->cursor_b_control
);
779 printk(" CURSOR_A_BASEADDR: 0x%08x\n", hw
->cursor_a_base
);
780 printk(" CURSOR_B_BASEADDR: 0x%08x\n", hw
->cursor_b_base
);
782 printk(" CURSOR_A_PALETTE: ");
783 for (i
= 0; i
< 4; i
++) {
784 printk("0x%08x", hw
->cursor_a_palette
[i
]);
789 printk(" CURSOR_B_PALETTE: ");
790 for (i
= 0; i
< 4; i
++) {
791 printk("0x%08x", hw
->cursor_b_palette
[i
]);
797 printk(" CURSOR_SIZE: 0x%08x\n", hw
->cursor_size
);
799 printk(" DSPACNTR: 0x%08x\n", hw
->disp_a_ctrl
);
800 printk(" DSPBCNTR: 0x%08x\n", hw
->disp_b_ctrl
);
801 printk(" DSPABASE: 0x%08x\n", hw
->disp_a_base
);
802 printk(" DSPBBASE: 0x%08x\n", hw
->disp_b_base
);
803 printk(" DSPASTRIDE: 0x%08x\n", hw
->disp_a_stride
);
804 printk(" DSPBSTRIDE: 0x%08x\n", hw
->disp_b_stride
);
806 printk(" VGACNTRL: 0x%08x\n", hw
->vgacntrl
);
807 printk(" ADD_ID: 0x%08x\n", hw
->add_id
);
809 for (i
= 0; i
< 7; i
++) {
810 printk(" SWF0%d 0x%08x\n", i
,
813 for (i
= 0; i
< 7; i
++) {
814 printk(" SWF1%d 0x%08x\n", i
,
817 for (i
= 0; i
< 3; i
++) {
818 printk(" SWF3%d 0x%08x\n", i
,
821 for (i
= 0; i
< 8; i
++)
822 printk(" FENCE%d 0x%08x\n", i
,
825 printk(" INSTPM 0x%08x\n", hw
->instpm
);
826 printk(" MEM_MODE 0x%08x\n", hw
->mem_mode
);
827 printk(" FW_BLC_0 0x%08x\n", hw
->fw_blc_0
);
828 printk(" FW_BLC_1 0x%08x\n", hw
->fw_blc_1
);
830 printk(" HWSTAM 0x%04x\n", hw
->hwstam
);
831 printk(" IER 0x%04x\n", hw
->ier
);
832 printk(" IIR 0x%04x\n", hw
->iir
);
833 printk(" IMR 0x%04x\n", hw
->imr
);
834 printk("hw state dump end\n");
840 /* Split the M parameter into M1 and M2. */
841 static int splitm(int index
, unsigned int m
, unsigned int *retm1
,
846 struct pll_min_max
*pll
= &plls
[index
];
848 /* no point optimising too much - brute force m */
849 for (m1
= pll
->min_m1
; m1
< pll
->max_m1
+ 1; m1
++) {
850 for (m2
= pll
->min_m2
; m2
< pll
->max_m2
+ 1; m2
++) {
851 testm
= (5 * (m1
+ 2)) + (m2
+ 2);
853 *retm1
= (unsigned int)m1
;
854 *retm2
= (unsigned int)m2
;
862 /* Split the P parameter into P1 and P2. */
863 static int splitp(int index
, unsigned int p
, unsigned int *retp1
,
867 struct pll_min_max
*pll
= &plls
[index
];
869 if (index
== PLLS_I9xx
) {
870 p2
= (p
% 10) ? 1 : 0;
872 p1
= p
/ (p2
? 5 : 10);
874 *retp1
= (unsigned int)p1
;
875 *retp2
= (unsigned int)p2
;
883 p1
= (p
/ (1 << (p2
+ 1))) - 2;
884 if (p
% 4 == 0 && p1
< pll
->min_p1
) {
886 p1
= (p
/ (1 << (p2
+ 1))) - 2;
888 if (p1
< pll
->min_p1
|| p1
> pll
->max_p1
||
889 (p1
+ 2) * (1 << (p2
+ 1)) != p
) {
892 *retp1
= (unsigned int)p1
;
893 *retp2
= (unsigned int)p2
;
898 static int calc_pll_params(int index
, int clock
, u32
*retm1
, u32
*retm2
,
899 u32
*retn
, u32
*retp1
, u32
*retp2
, u32
*retclock
)
901 u32 m1
, m2
, n
, p1
, p2
, n1
, testm
;
902 u32 f_vco
, p
, p_best
= 0, m
, f_out
= 0;
903 u32 err_max
, err_target
, err_best
= 10000000;
904 u32 n_best
= 0, m_best
= 0, f_best
, f_err
;
905 u32 p_min
, p_max
, p_inc
, div_max
;
906 struct pll_min_max
*pll
= &plls
[index
];
908 /* Accept 0.5% difference, but aim for 0.1% */
909 err_max
= 5 * clock
/ 1000;
910 err_target
= clock
/ 1000;
912 DBG_MSG("Clock is %d\n", clock
);
914 div_max
= pll
->max_vco
/ clock
;
916 p_inc
= (clock
<= pll
->p_transition_clk
) ? pll
->p_inc_lo
: pll
->p_inc_hi
;
918 p_max
= ROUND_DOWN_TO(div_max
, p_inc
);
919 if (p_min
< pll
->min_p
)
921 if (p_max
> pll
->max_p
)
924 DBG_MSG("p range is %d-%d (%d)\n", p_min
, p_max
, p_inc
);
928 if (splitp(index
, p
, &p1
, &p2
)) {
929 WRN_MSG("cannot split p = %d\n", p
);
937 m
= ROUND_UP_TO(f_vco
* n
, pll
->ref_clk
) / pll
->ref_clk
;
942 for (testm
= m
- 1; testm
<= m
; testm
++) {
943 f_out
= calc_vclock3(index
, testm
, n
, p
);
944 if (splitm(index
, testm
, &m1
, &m2
)) {
945 WRN_MSG("cannot split m = %d\n",
950 f_err
= clock
- f_out
;
951 else/* slightly bias the error for bigger clocks */
952 f_err
= f_out
- clock
+ 1;
954 if (f_err
< err_best
) {
963 } while ((n
<= pll
->max_n
) && (f_out
>= clock
));
965 } while ((p
<= p_max
));
968 WRN_MSG("cannot find parameters for clock %d\n", clock
);
974 splitm(index
, m
, &m1
, &m2
);
975 splitp(index
, p
, &p1
, &p2
);
978 DBG_MSG("m, n, p: %d (%d,%d), %d (%d), %d (%d,%d), "
979 "f: %d (%d), VCO: %d\n",
980 m
, m1
, m2
, n
, n1
, p
, p1
, p2
,
981 calc_vclock3(index
, m
, n
, p
),
982 calc_vclock(index
, m1
, m2
, n1
, p1
, p2
, 0),
983 calc_vclock3(index
, m
, n
, p
) * p
);
989 *retclock
= calc_vclock(index
, m1
, m2
, n1
, p1
, p2
, 0);
994 static __inline__
int check_overflow(u32 value
, u32 limit
,
995 const char *description
)
998 WRN_MSG("%s value %d exceeds limit %d\n",
999 description
, value
, limit
);
1005 /* It is assumed that hw is filled in with the initial state information. */
1006 int intelfbhw_mode_to_hw(struct intelfb_info
*dinfo
,
1007 struct intelfb_hwstate
*hw
,
1008 struct fb_var_screeninfo
*var
)
1011 u32
*dpll
, *fp0
, *fp1
;
1012 u32 m1
, m2
, n
, p1
, p2
, clock_target
, clock
;
1013 u32 hsync_start
, hsync_end
, hblank_start
, hblank_end
, htotal
, hactive
;
1014 u32 vsync_start
, vsync_end
, vblank_start
, vblank_end
, vtotal
, vactive
;
1015 u32 vsync_pol
, hsync_pol
;
1016 u32
*vs
, *vb
, *vt
, *hs
, *hb
, *ht
, *ss
, *pipe_conf
;
1017 u32 stride_alignment
;
1019 DBG_MSG("intelfbhw_mode_to_hw\n");
1022 hw
->vgacntrl
|= VGA_DISABLE
;
1024 /* Check whether pipe A or pipe B is enabled. */
1025 if (hw
->pipe_a_conf
& PIPECONF_ENABLE
)
1027 else if (hw
->pipe_b_conf
& PIPECONF_ENABLE
)
1030 /* Set which pipe's registers will be set. */
1031 if (pipe
== PIPE_B
) {
1041 ss
= &hw
->src_size_b
;
1042 pipe_conf
= &hw
->pipe_b_conf
;
1053 ss
= &hw
->src_size_a
;
1054 pipe_conf
= &hw
->pipe_a_conf
;
1057 /* Use ADPA register for sync control. */
1058 hw
->adpa
&= ~ADPA_USE_VGA_HVPOLARITY
;
1061 hsync_pol
= (var
->sync
& FB_SYNC_HOR_HIGH_ACT
) ?
1062 ADPA_SYNC_ACTIVE_HIGH
: ADPA_SYNC_ACTIVE_LOW
;
1063 vsync_pol
= (var
->sync
& FB_SYNC_VERT_HIGH_ACT
) ?
1064 ADPA_SYNC_ACTIVE_HIGH
: ADPA_SYNC_ACTIVE_LOW
;
1065 hw
->adpa
&= ~((ADPA_SYNC_ACTIVE_MASK
<< ADPA_VSYNC_ACTIVE_SHIFT
) |
1066 (ADPA_SYNC_ACTIVE_MASK
<< ADPA_HSYNC_ACTIVE_SHIFT
));
1067 hw
->adpa
|= (hsync_pol
<< ADPA_HSYNC_ACTIVE_SHIFT
) |
1068 (vsync_pol
<< ADPA_VSYNC_ACTIVE_SHIFT
);
1070 /* Connect correct pipe to the analog port DAC */
1071 hw
->adpa
&= ~(PIPE_MASK
<< ADPA_PIPE_SELECT_SHIFT
);
1072 hw
->adpa
|= (pipe
<< ADPA_PIPE_SELECT_SHIFT
);
1074 /* Set DPMS state to D0 (on) */
1075 hw
->adpa
&= ~ADPA_DPMS_CONTROL_MASK
;
1076 hw
->adpa
|= ADPA_DPMS_D0
;
1078 hw
->adpa
|= ADPA_DAC_ENABLE
;
1080 *dpll
|= (DPLL_VCO_ENABLE
| DPLL_VGA_MODE_DISABLE
);
1081 *dpll
&= ~(DPLL_RATE_SELECT_MASK
| DPLL_REFERENCE_SELECT_MASK
);
1082 *dpll
|= (DPLL_REFERENCE_DEFAULT
| DPLL_RATE_SELECT_FP0
);
1084 /* Desired clock in kHz */
1085 clock_target
= 1000000000 / var
->pixclock
;
1087 if (calc_pll_params(dinfo
->pll_index
, clock_target
, &m1
, &m2
,
1088 &n
, &p1
, &p2
, &clock
)) {
1089 WRN_MSG("calc_pll_params failed\n");
1093 /* Check for overflow. */
1094 if (check_overflow(p1
, DPLL_P1_MASK
, "PLL P1 parameter"))
1096 if (check_overflow(p2
, DPLL_P2_MASK
, "PLL P2 parameter"))
1098 if (check_overflow(m1
, FP_DIVISOR_MASK
, "PLL M1 parameter"))
1100 if (check_overflow(m2
, FP_DIVISOR_MASK
, "PLL M2 parameter"))
1102 if (check_overflow(n
, FP_DIVISOR_MASK
, "PLL N parameter"))
1105 *dpll
&= ~DPLL_P1_FORCE_DIV2
;
1106 *dpll
&= ~((DPLL_P2_MASK
<< DPLL_P2_SHIFT
) |
1107 (DPLL_P1_MASK
<< DPLL_P1_SHIFT
));
1109 if (IS_I9XX(dinfo
)) {
1110 *dpll
|= (p2
<< DPLL_I9XX_P2_SHIFT
);
1111 *dpll
|= (1 << (p1
- 1)) << DPLL_P1_SHIFT
;
1113 *dpll
|= (p2
<< DPLL_P2_SHIFT
) | (p1
<< DPLL_P1_SHIFT
);
1115 *fp0
= (n
<< FP_N_DIVISOR_SHIFT
) |
1116 (m1
<< FP_M1_DIVISOR_SHIFT
) |
1117 (m2
<< FP_M2_DIVISOR_SHIFT
);
1120 hw
->dvob
&= ~PORT_ENABLE
;
1121 hw
->dvoc
&= ~PORT_ENABLE
;
1123 /* Use display plane A. */
1124 hw
->disp_a_ctrl
|= DISPPLANE_PLANE_ENABLE
;
1125 hw
->disp_a_ctrl
&= ~DISPPLANE_GAMMA_ENABLE
;
1126 hw
->disp_a_ctrl
&= ~DISPPLANE_PIXFORMAT_MASK
;
1127 switch (intelfb_var_to_depth(var
)) {
1129 hw
->disp_a_ctrl
|= DISPPLANE_8BPP
| DISPPLANE_GAMMA_ENABLE
;
1132 hw
->disp_a_ctrl
|= DISPPLANE_15_16BPP
;
1135 hw
->disp_a_ctrl
|= DISPPLANE_16BPP
;
1138 hw
->disp_a_ctrl
|= DISPPLANE_32BPP_NO_ALPHA
;
1141 hw
->disp_a_ctrl
&= ~(PIPE_MASK
<< DISPPLANE_SEL_PIPE_SHIFT
);
1142 hw
->disp_a_ctrl
|= (pipe
<< DISPPLANE_SEL_PIPE_SHIFT
);
1144 /* Set CRTC registers. */
1145 hactive
= var
->xres
;
1146 hsync_start
= hactive
+ var
->right_margin
;
1147 hsync_end
= hsync_start
+ var
->hsync_len
;
1148 htotal
= hsync_end
+ var
->left_margin
;
1149 hblank_start
= hactive
;
1150 hblank_end
= htotal
;
1152 DBG_MSG("H: act %d, ss %d, se %d, tot %d bs %d, be %d\n",
1153 hactive
, hsync_start
, hsync_end
, htotal
, hblank_start
,
1156 vactive
= var
->yres
;
1157 if (var
->vmode
& FB_VMODE_INTERLACED
)
1158 vactive
--; /* the chip adds 2 halflines automatically */
1159 vsync_start
= vactive
+ var
->lower_margin
;
1160 vsync_end
= vsync_start
+ var
->vsync_len
;
1161 vtotal
= vsync_end
+ var
->upper_margin
;
1162 vblank_start
= vactive
;
1163 vblank_end
= vtotal
;
1164 vblank_end
= vsync_end
+ 1;
1166 DBG_MSG("V: act %d, ss %d, se %d, tot %d bs %d, be %d\n",
1167 vactive
, vsync_start
, vsync_end
, vtotal
, vblank_start
,
1170 /* Adjust for register values, and check for overflow. */
1172 if (check_overflow(hactive
, HACTIVE_MASK
, "CRTC hactive"))
1175 if (check_overflow(hsync_start
, HSYNCSTART_MASK
, "CRTC hsync_start"))
1178 if (check_overflow(hsync_end
, HSYNCEND_MASK
, "CRTC hsync_end"))
1181 if (check_overflow(htotal
, HTOTAL_MASK
, "CRTC htotal"))
1184 if (check_overflow(hblank_start
, HBLANKSTART_MASK
, "CRTC hblank_start"))
1187 if (check_overflow(hblank_end
, HBLANKEND_MASK
, "CRTC hblank_end"))
1191 if (check_overflow(vactive
, VACTIVE_MASK
, "CRTC vactive"))
1194 if (check_overflow(vsync_start
, VSYNCSTART_MASK
, "CRTC vsync_start"))
1197 if (check_overflow(vsync_end
, VSYNCEND_MASK
, "CRTC vsync_end"))
1200 if (check_overflow(vtotal
, VTOTAL_MASK
, "CRTC vtotal"))
1203 if (check_overflow(vblank_start
, VBLANKSTART_MASK
, "CRTC vblank_start"))
1206 if (check_overflow(vblank_end
, VBLANKEND_MASK
, "CRTC vblank_end"))
1209 *ht
= (htotal
<< HTOTAL_SHIFT
) | (hactive
<< HACTIVE_SHIFT
);
1210 *hb
= (hblank_start
<< HBLANKSTART_SHIFT
) |
1211 (hblank_end
<< HSYNCEND_SHIFT
);
1212 *hs
= (hsync_start
<< HSYNCSTART_SHIFT
) | (hsync_end
<< HSYNCEND_SHIFT
);
1214 *vt
= (vtotal
<< VTOTAL_SHIFT
) | (vactive
<< VACTIVE_SHIFT
);
1215 *vb
= (vblank_start
<< VBLANKSTART_SHIFT
) |
1216 (vblank_end
<< VSYNCEND_SHIFT
);
1217 *vs
= (vsync_start
<< VSYNCSTART_SHIFT
) | (vsync_end
<< VSYNCEND_SHIFT
);
1218 *ss
= (hactive
<< SRC_SIZE_HORIZ_SHIFT
) |
1219 (vactive
<< SRC_SIZE_VERT_SHIFT
);
1221 hw
->disp_a_stride
= dinfo
->pitch
;
1222 DBG_MSG("pitch is %d\n", hw
->disp_a_stride
);
1224 hw
->disp_a_base
= hw
->disp_a_stride
* var
->yoffset
+
1225 var
->xoffset
* var
->bits_per_pixel
/ 8;
1227 hw
->disp_a_base
+= dinfo
->fb
.offset
<< 12;
1229 /* Check stride alignment. */
1230 stride_alignment
= IS_I9XX(dinfo
) ? STRIDE_ALIGNMENT_I9XX
:
1232 if (hw
->disp_a_stride
% stride_alignment
!= 0) {
1233 WRN_MSG("display stride %d has bad alignment %d\n",
1234 hw
->disp_a_stride
, stride_alignment
);
1238 /* Set the palette to 8-bit mode. */
1239 *pipe_conf
&= ~PIPECONF_GAMMA
;
1241 if (var
->vmode
& FB_VMODE_INTERLACED
)
1242 *pipe_conf
|= PIPECONF_INTERLACE_W_FIELD_INDICATION
;
1244 *pipe_conf
&= ~PIPECONF_INTERLACE_MASK
;
1249 /* Program a (non-VGA) video mode. */
1250 int intelfbhw_program_mode(struct intelfb_info
*dinfo
,
1251 const struct intelfb_hwstate
*hw
, int blank
)
1255 const u32
*dpll
, *fp0
, *fp1
, *pipe_conf
;
1256 const u32
*hs
, *ht
, *hb
, *vs
, *vt
, *vb
, *ss
;
1257 u32 dpll_reg
, fp0_reg
, fp1_reg
, pipe_conf_reg
, pipe_stat_reg
;
1258 u32 hsync_reg
, htotal_reg
, hblank_reg
;
1259 u32 vsync_reg
, vtotal_reg
, vblank_reg
;
1261 u32 count
, tmp_val
[3];
1263 /* Assume single pipe, display plane A, analog CRT. */
1266 DBG_MSG("intelfbhw_program_mode\n");
1270 tmp
= INREG(VGACNTRL
);
1272 OUTREG(VGACNTRL
, tmp
);
1274 /* Check whether pipe A or pipe B is enabled. */
1275 if (hw
->pipe_a_conf
& PIPECONF_ENABLE
)
1277 else if (hw
->pipe_b_conf
& PIPECONF_ENABLE
)
1282 if (pipe
== PIPE_B
) {
1286 pipe_conf
= &hw
->pipe_b_conf
;
1293 ss
= &hw
->src_size_b
;
1297 pipe_conf_reg
= PIPEBCONF
;
1298 pipe_stat_reg
= PIPEBSTAT
;
1299 hsync_reg
= HSYNC_B
;
1300 htotal_reg
= HTOTAL_B
;
1301 hblank_reg
= HBLANK_B
;
1302 vsync_reg
= VSYNC_B
;
1303 vtotal_reg
= VTOTAL_B
;
1304 vblank_reg
= VBLANK_B
;
1305 src_size_reg
= SRC_SIZE_B
;
1310 pipe_conf
= &hw
->pipe_a_conf
;
1317 ss
= &hw
->src_size_a
;
1321 pipe_conf_reg
= PIPEACONF
;
1322 pipe_stat_reg
= PIPEASTAT
;
1323 hsync_reg
= HSYNC_A
;
1324 htotal_reg
= HTOTAL_A
;
1325 hblank_reg
= HBLANK_A
;
1326 vsync_reg
= VSYNC_A
;
1327 vtotal_reg
= VTOTAL_A
;
1328 vblank_reg
= VBLANK_A
;
1329 src_size_reg
= SRC_SIZE_A
;
1333 tmp
= INREG(pipe_conf_reg
);
1334 tmp
&= ~PIPECONF_ENABLE
;
1335 OUTREG(pipe_conf_reg
, tmp
);
1339 tmp_val
[count
% 3] = INREG(PIPEA_DSL
);
1340 if ((tmp_val
[0] == tmp_val
[1]) && (tmp_val
[1] == tmp_val
[2]))
1344 if (count
% 200 == 0) {
1345 tmp
= INREG(pipe_conf_reg
);
1346 tmp
&= ~PIPECONF_ENABLE
;
1347 OUTREG(pipe_conf_reg
, tmp
);
1349 } while (count
< 2000);
1351 OUTREG(ADPA
, INREG(ADPA
) & ~ADPA_DAC_ENABLE
);
1353 /* Disable planes A and B. */
1354 tmp
= INREG(DSPACNTR
);
1355 tmp
&= ~DISPPLANE_PLANE_ENABLE
;
1356 OUTREG(DSPACNTR
, tmp
);
1357 tmp
= INREG(DSPBCNTR
);
1358 tmp
&= ~DISPPLANE_PLANE_ENABLE
;
1359 OUTREG(DSPBCNTR
, tmp
);
1361 /* Wait for vblank. For now, just wait for a 50Hz cycle (20ms)) */
1364 OUTREG(DVOB
, INREG(DVOB
) & ~PORT_ENABLE
);
1365 OUTREG(DVOC
, INREG(DVOC
) & ~PORT_ENABLE
);
1366 OUTREG(ADPA
, INREG(ADPA
) & ~ADPA_DAC_ENABLE
);
1370 tmp
&= ~ADPA_DPMS_CONTROL_MASK
;
1371 tmp
|= ADPA_DPMS_D3
;
1374 /* do some funky magic - xyzzy */
1375 OUTREG(0x61204, 0xabcd0000);
1378 tmp
= INREG(dpll_reg
);
1379 tmp
&= ~DPLL_VCO_ENABLE
;
1380 OUTREG(dpll_reg
, tmp
);
1382 /* Set PLL parameters */
1383 OUTREG(fp0_reg
, *fp0
);
1384 OUTREG(fp1_reg
, *fp1
);
1387 OUTREG(dpll_reg
, *dpll
);
1390 OUTREG(DVOB
, hw
->dvob
);
1391 OUTREG(DVOC
, hw
->dvoc
);
1393 /* undo funky magic */
1394 OUTREG(0x61204, 0x00000000);
1397 OUTREG(ADPA
, INREG(ADPA
) | ADPA_DAC_ENABLE
);
1398 OUTREG(ADPA
, (hw
->adpa
& ~(ADPA_DPMS_CONTROL_MASK
)) | ADPA_DPMS_D3
);
1400 /* Set pipe parameters */
1401 OUTREG(hsync_reg
, *hs
);
1402 OUTREG(hblank_reg
, *hb
);
1403 OUTREG(htotal_reg
, *ht
);
1404 OUTREG(vsync_reg
, *vs
);
1405 OUTREG(vblank_reg
, *vb
);
1406 OUTREG(vtotal_reg
, *vt
);
1407 OUTREG(src_size_reg
, *ss
);
1409 switch (dinfo
->info
->var
.vmode
& (FB_VMODE_INTERLACED
|
1410 FB_VMODE_ODD_FLD_FIRST
)) {
1411 case FB_VMODE_INTERLACED
| FB_VMODE_ODD_FLD_FIRST
:
1412 OUTREG(pipe_stat_reg
, 0xFFFF | PIPESTAT_FLD_EVT_ODD_EN
);
1414 case FB_VMODE_INTERLACED
: /* even lines first */
1415 OUTREG(pipe_stat_reg
, 0xFFFF | PIPESTAT_FLD_EVT_EVEN_EN
);
1417 default: /* non-interlaced */
1418 OUTREG(pipe_stat_reg
, 0xFFFF); /* clear all status bits only */
1421 OUTREG(pipe_conf_reg
, *pipe_conf
| PIPECONF_ENABLE
);
1425 tmp
&= ~ADPA_DPMS_CONTROL_MASK
;
1426 tmp
|= ADPA_DPMS_D0
;
1429 /* setup display plane */
1430 if (dinfo
->pdev
->device
== PCI_DEVICE_ID_INTEL_830M
) {
1432 * i830M errata: the display plane must be enabled
1433 * to allow writes to the other bits in the plane
1436 tmp
= INREG(DSPACNTR
);
1437 if ((tmp
& DISPPLANE_PLANE_ENABLE
) != DISPPLANE_PLANE_ENABLE
) {
1438 tmp
|= DISPPLANE_PLANE_ENABLE
;
1439 OUTREG(DSPACNTR
, tmp
);
1441 hw
->disp_a_ctrl
|DISPPLANE_PLANE_ENABLE
);
1446 OUTREG(DSPACNTR
, hw
->disp_a_ctrl
& ~DISPPLANE_PLANE_ENABLE
);
1447 OUTREG(DSPASTRIDE
, hw
->disp_a_stride
);
1448 OUTREG(DSPABASE
, hw
->disp_a_base
);
1452 tmp
= INREG(DSPACNTR
);
1453 tmp
|= DISPPLANE_PLANE_ENABLE
;
1454 OUTREG(DSPACNTR
, tmp
);
1455 OUTREG(DSPABASE
, hw
->disp_a_base
);
1461 /* forward declarations */
1462 static void refresh_ring(struct intelfb_info
*dinfo
);
1463 static void reset_state(struct intelfb_info
*dinfo
);
1464 static void do_flush(struct intelfb_info
*dinfo
);
1466 static u32
get_ring_space(struct intelfb_info
*dinfo
)
1470 if (dinfo
->ring_tail
>= dinfo
->ring_head
)
1471 ring_space
= dinfo
->ring
.size
-
1472 (dinfo
->ring_tail
- dinfo
->ring_head
);
1474 ring_space
= dinfo
->ring_head
- dinfo
->ring_tail
;
1476 if (ring_space
> RING_MIN_FREE
)
1477 ring_space
-= RING_MIN_FREE
;
1484 static int wait_ring(struct intelfb_info
*dinfo
, int n
)
1488 u32 last_head
= INREG(PRI_RING_HEAD
) & RING_HEAD_MASK
;
1491 DBG_MSG("wait_ring: %d\n", n
);
1494 end
= jiffies
+ (HZ
* 3);
1495 while (dinfo
->ring_space
< n
) {
1496 dinfo
->ring_head
= INREG(PRI_RING_HEAD
) & RING_HEAD_MASK
;
1497 dinfo
->ring_space
= get_ring_space(dinfo
);
1499 if (dinfo
->ring_head
!= last_head
) {
1500 end
= jiffies
+ (HZ
* 3);
1501 last_head
= dinfo
->ring_head
;
1504 if (time_before(end
, jiffies
)) {
1508 refresh_ring(dinfo
);
1510 end
= jiffies
+ (HZ
* 3);
1513 WRN_MSG("ring buffer : space: %d wanted %d\n",
1514 dinfo
->ring_space
, n
);
1515 WRN_MSG("lockup - turning off hardware "
1517 dinfo
->ring_lockup
= 1;
1526 static void do_flush(struct intelfb_info
*dinfo
)
1529 OUT_RING(MI_FLUSH
| MI_WRITE_DIRTY_STATE
| MI_INVALIDATE_MAP_CACHE
);
1534 void intelfbhw_do_sync(struct intelfb_info
*dinfo
)
1537 DBG_MSG("intelfbhw_do_sync\n");
1544 * Send a flush, then wait until the ring is empty. This is what
1545 * the XFree86 driver does, and actually it doesn't seem a lot worse
1546 * than the recommended method (both have problems).
1549 wait_ring(dinfo
, dinfo
->ring
.size
- RING_MIN_FREE
);
1550 dinfo
->ring_space
= dinfo
->ring
.size
- RING_MIN_FREE
;
1553 static void refresh_ring(struct intelfb_info
*dinfo
)
1556 DBG_MSG("refresh_ring\n");
1559 dinfo
->ring_head
= INREG(PRI_RING_HEAD
) & RING_HEAD_MASK
;
1560 dinfo
->ring_tail
= INREG(PRI_RING_TAIL
) & RING_TAIL_MASK
;
1561 dinfo
->ring_space
= get_ring_space(dinfo
);
1564 static void reset_state(struct intelfb_info
*dinfo
)
1570 DBG_MSG("reset_state\n");
1573 for (i
= 0; i
< FENCE_NUM
; i
++)
1574 OUTREG(FENCE
+ (i
<< 2), 0);
1576 /* Flush the ring buffer if it's enabled. */
1577 tmp
= INREG(PRI_RING_LENGTH
);
1578 if (tmp
& RING_ENABLE
) {
1580 DBG_MSG("reset_state: ring was enabled\n");
1582 refresh_ring(dinfo
);
1583 intelfbhw_do_sync(dinfo
);
1587 OUTREG(PRI_RING_LENGTH
, 0);
1588 OUTREG(PRI_RING_HEAD
, 0);
1589 OUTREG(PRI_RING_TAIL
, 0);
1590 OUTREG(PRI_RING_START
, 0);
1593 /* Stop the 2D engine, and turn off the ring buffer. */
1594 void intelfbhw_2d_stop(struct intelfb_info
*dinfo
)
1597 DBG_MSG("intelfbhw_2d_stop: accel: %d, ring_active: %d\n",
1598 dinfo
->accel
, dinfo
->ring_active
);
1604 dinfo
->ring_active
= 0;
1609 * Enable the ring buffer, and initialise the 2D engine.
1610 * It is assumed that the graphics engine has been stopped by previously
1611 * calling intelfb_2d_stop().
1613 void intelfbhw_2d_start(struct intelfb_info
*dinfo
)
1616 DBG_MSG("intelfbhw_2d_start: accel: %d, ring_active: %d\n",
1617 dinfo
->accel
, dinfo
->ring_active
);
1623 /* Initialise the primary ring buffer. */
1624 OUTREG(PRI_RING_LENGTH
, 0);
1625 OUTREG(PRI_RING_TAIL
, 0);
1626 OUTREG(PRI_RING_HEAD
, 0);
1628 OUTREG(PRI_RING_START
, dinfo
->ring
.physical
& RING_START_MASK
);
1629 OUTREG(PRI_RING_LENGTH
,
1630 ((dinfo
->ring
.size
- GTT_PAGE_SIZE
) & RING_LENGTH_MASK
) |
1631 RING_NO_REPORT
| RING_ENABLE
);
1632 refresh_ring(dinfo
);
1633 dinfo
->ring_active
= 1;
1636 /* 2D fillrect (solid fill or invert) */
1637 void intelfbhw_do_fillrect(struct intelfb_info
*dinfo
, u32 x
, u32 y
, u32 w
,
1638 u32 h
, u32 color
, u32 pitch
, u32 bpp
, u32 rop
)
1640 u32 br00
, br09
, br13
, br14
, br16
;
1643 DBG_MSG("intelfbhw_do_fillrect: (%d,%d) %dx%d, c 0x%06x, p %d bpp %d, "
1644 "rop 0x%02x\n", x
, y
, w
, h
, color
, pitch
, bpp
, rop
);
1647 br00
= COLOR_BLT_CMD
;
1648 br09
= dinfo
->fb_start
+ (y
* pitch
+ x
* (bpp
/ 8));
1649 br13
= (rop
<< ROP_SHIFT
) | pitch
;
1650 br14
= (h
<< HEIGHT_SHIFT
) | ((w
* (bpp
/ 8)) << WIDTH_SHIFT
);
1655 br13
|= COLOR_DEPTH_8
;
1658 br13
|= COLOR_DEPTH_16
;
1661 br13
|= COLOR_DEPTH_32
;
1662 br00
|= WRITE_ALPHA
| WRITE_RGB
;
1676 DBG_MSG("ring = 0x%08x, 0x%08x (%d)\n", dinfo
->ring_head
,
1677 dinfo
->ring_tail
, dinfo
->ring_space
);
1682 intelfbhw_do_bitblt(struct intelfb_info
*dinfo
, u32 curx
, u32 cury
,
1683 u32 dstx
, u32 dsty
, u32 w
, u32 h
, u32 pitch
, u32 bpp
)
1685 u32 br00
, br09
, br11
, br12
, br13
, br22
, br23
, br26
;
1688 DBG_MSG("intelfbhw_do_bitblt: (%d,%d)->(%d,%d) %dx%d, p %d bpp %d\n",
1689 curx
, cury
, dstx
, dsty
, w
, h
, pitch
, bpp
);
1692 br00
= XY_SRC_COPY_BLT_CMD
;
1693 br09
= dinfo
->fb_start
;
1694 br11
= (pitch
<< PITCH_SHIFT
);
1695 br12
= dinfo
->fb_start
;
1696 br13
= (SRC_ROP_GXCOPY
<< ROP_SHIFT
) | (pitch
<< PITCH_SHIFT
);
1697 br22
= (dstx
<< WIDTH_SHIFT
) | (dsty
<< HEIGHT_SHIFT
);
1698 br23
= ((dstx
+ w
) << WIDTH_SHIFT
) |
1699 ((dsty
+ h
) << HEIGHT_SHIFT
);
1700 br26
= (curx
<< WIDTH_SHIFT
) | (cury
<< HEIGHT_SHIFT
);
1704 br13
|= COLOR_DEPTH_8
;
1707 br13
|= COLOR_DEPTH_16
;
1710 br13
|= COLOR_DEPTH_32
;
1711 br00
|= WRITE_ALPHA
| WRITE_RGB
;
1727 int intelfbhw_do_drawglyph(struct intelfb_info
*dinfo
, u32 fg
, u32 bg
, u32 w
,
1728 u32 h
, const u8
* cdat
, u32 x
, u32 y
, u32 pitch
,
1731 int nbytes
, ndwords
, pad
, tmp
;
1732 u32 br00
, br09
, br13
, br18
, br19
, br22
, br23
;
1733 int dat
, ix
, iy
, iw
;
1737 DBG_MSG("intelfbhw_do_drawglyph: (%d,%d) %dx%d\n", x
, y
, w
, h
);
1740 /* size in bytes of a padded scanline */
1741 nbytes
= ROUND_UP_TO(w
, 16) / 8;
1743 /* Total bytes of padded scanline data to write out. */
1744 nbytes
= nbytes
* h
;
1747 * Check if the glyph data exceeds the immediate mode limit.
1748 * It would take a large font (1K pixels) to hit this limit.
1750 if (nbytes
> MAX_MONO_IMM_SIZE
)
1753 /* Src data is packaged a dword (32-bit) at a time. */
1754 ndwords
= ROUND_UP_TO(nbytes
, 4) / 4;
1757 * Ring has to be padded to a quad word. But because the command starts
1758 with 7 bytes, pad only if there is an even number of ndwords
1760 pad
= !(ndwords
% 2);
1762 tmp
= (XY_MONO_SRC_IMM_BLT_CMD
& DW_LENGTH_MASK
) + ndwords
;
1763 br00
= (XY_MONO_SRC_IMM_BLT_CMD
& ~DW_LENGTH_MASK
) | tmp
;
1764 br09
= dinfo
->fb_start
;
1765 br13
= (SRC_ROP_GXCOPY
<< ROP_SHIFT
) | (pitch
<< PITCH_SHIFT
);
1768 br22
= (x
<< WIDTH_SHIFT
) | (y
<< HEIGHT_SHIFT
);
1769 br23
= ((x
+ w
) << WIDTH_SHIFT
) | ((y
+ h
) << HEIGHT_SHIFT
);
1773 br13
|= COLOR_DEPTH_8
;
1776 br13
|= COLOR_DEPTH_16
;
1779 br13
|= COLOR_DEPTH_32
;
1780 br00
|= WRITE_ALPHA
| WRITE_RGB
;
1784 START_RING(8 + ndwords
);
1793 iw
= ROUND_UP_TO(w
, 8) / 8;
1796 for (j
= 0; j
< 2; ++j
) {
1797 for (i
= 0; i
< 2; ++i
) {
1798 if (ix
!= iw
|| i
== 0)
1799 dat
|= cdat
[iy
*iw
+ ix
++] << (i
+j
*2)*8;
1801 if (ix
== iw
&& iy
!= (h
-1)) {
1815 /* HW cursor functions. */
1816 void intelfbhw_cursor_init(struct intelfb_info
*dinfo
)
1821 DBG_MSG("intelfbhw_cursor_init\n");
1824 if (dinfo
->mobile
|| IS_I9XX(dinfo
)) {
1825 if (!dinfo
->cursor
.physical
)
1827 tmp
= INREG(CURSOR_A_CONTROL
);
1828 tmp
&= ~(CURSOR_MODE_MASK
| CURSOR_MOBILE_GAMMA_ENABLE
|
1829 CURSOR_MEM_TYPE_LOCAL
|
1830 (1 << CURSOR_PIPE_SELECT_SHIFT
));
1831 tmp
|= CURSOR_MODE_DISABLE
;
1832 OUTREG(CURSOR_A_CONTROL
, tmp
);
1833 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1835 tmp
= INREG(CURSOR_CONTROL
);
1836 tmp
&= ~(CURSOR_FORMAT_MASK
| CURSOR_GAMMA_ENABLE
|
1837 CURSOR_ENABLE
| CURSOR_STRIDE_MASK
);
1838 tmp
= CURSOR_FORMAT_3C
;
1839 OUTREG(CURSOR_CONTROL
, tmp
);
1840 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.offset
<< 12);
1841 tmp
= (64 << CURSOR_SIZE_H_SHIFT
) |
1842 (64 << CURSOR_SIZE_V_SHIFT
);
1843 OUTREG(CURSOR_SIZE
, tmp
);
1847 void intelfbhw_cursor_hide(struct intelfb_info
*dinfo
)
1852 DBG_MSG("intelfbhw_cursor_hide\n");
1855 dinfo
->cursor_on
= 0;
1856 if (dinfo
->mobile
|| IS_I9XX(dinfo
)) {
1857 if (!dinfo
->cursor
.physical
)
1859 tmp
= INREG(CURSOR_A_CONTROL
);
1860 tmp
&= ~CURSOR_MODE_MASK
;
1861 tmp
|= CURSOR_MODE_DISABLE
;
1862 OUTREG(CURSOR_A_CONTROL
, tmp
);
1864 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1866 tmp
= INREG(CURSOR_CONTROL
);
1867 tmp
&= ~CURSOR_ENABLE
;
1868 OUTREG(CURSOR_CONTROL
, tmp
);
1872 void intelfbhw_cursor_show(struct intelfb_info
*dinfo
)
1877 DBG_MSG("intelfbhw_cursor_show\n");
1880 dinfo
->cursor_on
= 1;
1882 if (dinfo
->cursor_blanked
)
1885 if (dinfo
->mobile
|| IS_I9XX(dinfo
)) {
1886 if (!dinfo
->cursor
.physical
)
1888 tmp
= INREG(CURSOR_A_CONTROL
);
1889 tmp
&= ~CURSOR_MODE_MASK
;
1890 tmp
|= CURSOR_MODE_64_4C_AX
;
1891 OUTREG(CURSOR_A_CONTROL
, tmp
);
1893 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1895 tmp
= INREG(CURSOR_CONTROL
);
1896 tmp
|= CURSOR_ENABLE
;
1897 OUTREG(CURSOR_CONTROL
, tmp
);
1901 void intelfbhw_cursor_setpos(struct intelfb_info
*dinfo
, int x
, int y
)
1906 DBG_MSG("intelfbhw_cursor_setpos: (%d, %d)\n", x
, y
);
1910 * Sets the position. The coordinates are assumed to already
1911 * have any offset adjusted. Assume that the cursor is never
1912 * completely off-screen, and that x, y are always >= 0.
1915 tmp
= ((x
& CURSOR_POS_MASK
) << CURSOR_X_SHIFT
) |
1916 ((y
& CURSOR_POS_MASK
) << CURSOR_Y_SHIFT
);
1917 OUTREG(CURSOR_A_POSITION
, tmp
);
1920 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1923 void intelfbhw_cursor_setcolor(struct intelfb_info
*dinfo
, u32 bg
, u32 fg
)
1926 DBG_MSG("intelfbhw_cursor_setcolor\n");
1929 OUTREG(CURSOR_A_PALETTE0
, bg
& CURSOR_PALETTE_MASK
);
1930 OUTREG(CURSOR_A_PALETTE1
, fg
& CURSOR_PALETTE_MASK
);
1931 OUTREG(CURSOR_A_PALETTE2
, fg
& CURSOR_PALETTE_MASK
);
1932 OUTREG(CURSOR_A_PALETTE3
, bg
& CURSOR_PALETTE_MASK
);
1935 void intelfbhw_cursor_load(struct intelfb_info
*dinfo
, int width
, int height
,
1938 u8 __iomem
*addr
= (u8 __iomem
*)dinfo
->cursor
.virtual;
1939 int i
, j
, w
= width
/ 8;
1940 int mod
= width
% 8, t_mask
, d_mask
;
1943 DBG_MSG("intelfbhw_cursor_load\n");
1946 if (!dinfo
->cursor
.virtual)
1949 t_mask
= 0xff >> mod
;
1950 d_mask
= ~(0xff >> mod
);
1951 for (i
= height
; i
--; ) {
1952 for (j
= 0; j
< w
; j
++) {
1953 writeb(0x00, addr
+ j
);
1954 writeb(*(data
++), addr
+ j
+8);
1957 writeb(t_mask
, addr
+ j
);
1958 writeb(*(data
++) & d_mask
, addr
+ j
+8);
1964 void intelfbhw_cursor_reset(struct intelfb_info
*dinfo
)
1966 u8 __iomem
*addr
= (u8 __iomem
*)dinfo
->cursor
.virtual;
1970 DBG_MSG("intelfbhw_cursor_reset\n");
1973 if (!dinfo
->cursor
.virtual)
1976 for (i
= 64; i
--; ) {
1977 for (j
= 0; j
< 8; j
++) {
1978 writeb(0xff, addr
+ j
+0);
1979 writeb(0x00, addr
+ j
+8);
1985 static irqreturn_t
intelfbhw_irq(int irq
, void *dev_id
)
1988 struct intelfb_info
*dinfo
= dev_id
;
1990 spin_lock(&dinfo
->int_lock
);
1993 if (dinfo
->info
->var
.vmode
& FB_VMODE_INTERLACED
)
1994 tmp
&= PIPE_A_EVENT_INTERRUPT
;
1996 tmp
&= VSYNC_PIPE_A_INTERRUPT
; /* non-interlaced */
1999 spin_unlock(&dinfo
->int_lock
);
2000 return IRQ_RETVAL(0); /* not us */
2003 /* clear status bits 0-15 ASAP and don't touch bits 16-31 */
2004 OUTREG(PIPEASTAT
, INREG(PIPEASTAT
));
2007 if (dinfo
->vsync
.pan_display
) {
2008 dinfo
->vsync
.pan_display
= 0;
2009 OUTREG(DSPABASE
, dinfo
->vsync
.pan_offset
);
2012 dinfo
->vsync
.count
++;
2013 wake_up_interruptible(&dinfo
->vsync
.wait
);
2015 spin_unlock(&dinfo
->int_lock
);
2017 return IRQ_RETVAL(1);
2020 int intelfbhw_enable_irq(struct intelfb_info
*dinfo
)
2023 if (!test_and_set_bit(0, &dinfo
->irq_flags
)) {
2024 if (request_irq(dinfo
->pdev
->irq
, intelfbhw_irq
, IRQF_SHARED
,
2025 "intelfb", dinfo
)) {
2026 clear_bit(0, &dinfo
->irq_flags
);
2030 spin_lock_irq(&dinfo
->int_lock
);
2031 OUTREG16(HWSTAM
, 0xfffe); /* i830 DRM uses ffff */
2034 spin_lock_irq(&dinfo
->int_lock
);
2036 if (dinfo
->info
->var
.vmode
& FB_VMODE_INTERLACED
)
2037 tmp
= PIPE_A_EVENT_INTERRUPT
;
2039 tmp
= VSYNC_PIPE_A_INTERRUPT
; /* non-interlaced */
2040 if (tmp
!= INREG16(IER
)) {
2041 DBG_MSG("changing IER to 0x%X\n", tmp
);
2045 spin_unlock_irq(&dinfo
->int_lock
);
2049 void intelfbhw_disable_irq(struct intelfb_info
*dinfo
)
2051 if (test_and_clear_bit(0, &dinfo
->irq_flags
)) {
2052 if (dinfo
->vsync
.pan_display
) {
2053 dinfo
->vsync
.pan_display
= 0;
2054 OUTREG(DSPABASE
, dinfo
->vsync
.pan_offset
);
2056 spin_lock_irq(&dinfo
->int_lock
);
2057 OUTREG16(HWSTAM
, 0xffff);
2058 OUTREG16(IMR
, 0xffff);
2061 OUTREG16(IIR
, INREG16(IIR
)); /* clear IRQ requests */
2062 spin_unlock_irq(&dinfo
->int_lock
);
2064 free_irq(dinfo
->pdev
->irq
, dinfo
);
2068 int intelfbhw_wait_for_vsync(struct intelfb_info
*dinfo
, u32 pipe
)
2070 struct intelfb_vsync
*vsync
;
2076 vsync
= &dinfo
->vsync
;
2082 ret
= intelfbhw_enable_irq(dinfo
);
2086 count
= vsync
->count
;
2087 ret
= wait_event_interruptible_timeout(vsync
->wait
,
2088 count
!= vsync
->count
, HZ
/ 10);
2092 DBG_MSG("wait_for_vsync timed out!\n");