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_945GME
:
147 dinfo
->name
= "Intel(R) 945GME";
148 dinfo
->chipset
= INTEL_945GME
;
150 dinfo
->pll_index
= PLLS_I9xx
;
152 case PCI_DEVICE_ID_INTEL_965G
:
153 dinfo
->name
= "Intel(R) 965G";
154 dinfo
->chipset
= INTEL_965G
;
156 dinfo
->pll_index
= PLLS_I9xx
;
158 case PCI_DEVICE_ID_INTEL_965GM
:
159 dinfo
->name
= "Intel(R) 965GM";
160 dinfo
->chipset
= INTEL_965GM
;
162 dinfo
->pll_index
= PLLS_I9xx
;
169 int intelfbhw_get_memory(struct pci_dev
*pdev
, int *aperture_size
,
172 struct pci_dev
*bridge_dev
;
176 if (!pdev
|| !aperture_size
|| !stolen_size
)
179 /* Find the bridge device. It is always 0:0.0 */
180 if (!(bridge_dev
= pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)))) {
181 ERR_MSG("cannot find bridge device\n");
185 /* Get the fb aperture size and "stolen" memory amount. */
187 pci_read_config_word(bridge_dev
, INTEL_GMCH_CTRL
, &tmp
);
188 pci_dev_put(bridge_dev
);
190 switch (pdev
->device
) {
191 case PCI_DEVICE_ID_INTEL_915G
:
192 case PCI_DEVICE_ID_INTEL_915GM
:
193 case PCI_DEVICE_ID_INTEL_945G
:
194 case PCI_DEVICE_ID_INTEL_945GM
:
195 case PCI_DEVICE_ID_INTEL_945GME
:
196 case PCI_DEVICE_ID_INTEL_965G
:
197 case PCI_DEVICE_ID_INTEL_965GM
:
198 /* 915, 945 and 965 chipsets support a 256MB aperture.
199 Aperture size is determined by inspected the
200 base address of the aperture. */
201 if (pci_resource_start(pdev
, 2) & 0x08000000)
202 *aperture_size
= MB(128);
204 *aperture_size
= MB(256);
207 if ((tmp
& INTEL_GMCH_MEM_MASK
) == INTEL_GMCH_MEM_64M
)
208 *aperture_size
= MB(64);
210 *aperture_size
= MB(128);
214 /* Stolen memory size is reduced by the GTT and the popup.
215 GTT is 1K per MB of aperture size, and popup is 4K. */
216 stolen_overhead
= (*aperture_size
/ MB(1)) + 4;
217 switch(pdev
->device
) {
218 case PCI_DEVICE_ID_INTEL_830M
:
219 case PCI_DEVICE_ID_INTEL_845G
:
220 switch (tmp
& INTEL_830_GMCH_GMS_MASK
) {
221 case INTEL_830_GMCH_GMS_STOLEN_512
:
222 *stolen_size
= KB(512) - KB(stolen_overhead
);
224 case INTEL_830_GMCH_GMS_STOLEN_1024
:
225 *stolen_size
= MB(1) - KB(stolen_overhead
);
227 case INTEL_830_GMCH_GMS_STOLEN_8192
:
228 *stolen_size
= MB(8) - KB(stolen_overhead
);
230 case INTEL_830_GMCH_GMS_LOCAL
:
231 ERR_MSG("only local memory found\n");
233 case INTEL_830_GMCH_GMS_DISABLED
:
234 ERR_MSG("video memory is disabled\n");
237 ERR_MSG("unexpected GMCH_GMS value: 0x%02x\n",
238 tmp
& INTEL_830_GMCH_GMS_MASK
);
243 switch (tmp
& INTEL_855_GMCH_GMS_MASK
) {
244 case INTEL_855_GMCH_GMS_STOLEN_1M
:
245 *stolen_size
= MB(1) - KB(stolen_overhead
);
247 case INTEL_855_GMCH_GMS_STOLEN_4M
:
248 *stolen_size
= MB(4) - KB(stolen_overhead
);
250 case INTEL_855_GMCH_GMS_STOLEN_8M
:
251 *stolen_size
= MB(8) - KB(stolen_overhead
);
253 case INTEL_855_GMCH_GMS_STOLEN_16M
:
254 *stolen_size
= MB(16) - KB(stolen_overhead
);
256 case INTEL_855_GMCH_GMS_STOLEN_32M
:
257 *stolen_size
= MB(32) - KB(stolen_overhead
);
259 case INTEL_915G_GMCH_GMS_STOLEN_48M
:
260 *stolen_size
= MB(48) - KB(stolen_overhead
);
262 case INTEL_915G_GMCH_GMS_STOLEN_64M
:
263 *stolen_size
= MB(64) - KB(stolen_overhead
);
265 case INTEL_855_GMCH_GMS_DISABLED
:
266 ERR_MSG("video memory is disabled\n");
269 ERR_MSG("unexpected GMCH_GMS value: 0x%02x\n",
270 tmp
& INTEL_855_GMCH_GMS_MASK
);
276 int intelfbhw_check_non_crt(struct intelfb_info
*dinfo
)
280 if (INREG(LVDS
) & PORT_ENABLE
)
282 if (INREG(DVOA
) & PORT_ENABLE
)
284 if (INREG(DVOB
) & PORT_ENABLE
)
286 if (INREG(DVOC
) & PORT_ENABLE
)
292 const char * intelfbhw_dvo_to_string(int dvo
)
296 else if (dvo
& DVOB_PORT
)
298 else if (dvo
& DVOC_PORT
)
300 else if (dvo
& LVDS_PORT
)
307 int intelfbhw_validate_mode(struct intelfb_info
*dinfo
,
308 struct fb_var_screeninfo
*var
)
314 DBG_MSG("intelfbhw_validate_mode\n");
317 bytes_per_pixel
= var
->bits_per_pixel
/ 8;
318 if (bytes_per_pixel
== 3)
321 /* Check if enough video memory. */
322 tmp
= var
->yres_virtual
* var
->xres_virtual
* bytes_per_pixel
;
323 if (tmp
> dinfo
->fb
.size
) {
324 WRN_MSG("Not enough video ram for mode "
325 "(%d KByte vs %d KByte).\n",
326 BtoKB(tmp
), BtoKB(dinfo
->fb
.size
));
330 /* Check if x/y limits are OK. */
331 if (var
->xres
- 1 > HACTIVE_MASK
) {
332 WRN_MSG("X resolution too large (%d vs %d).\n",
333 var
->xres
, HACTIVE_MASK
+ 1);
336 if (var
->yres
- 1 > VACTIVE_MASK
) {
337 WRN_MSG("Y resolution too large (%d vs %d).\n",
338 var
->yres
, VACTIVE_MASK
+ 1);
342 WRN_MSG("X resolution too small (%d vs 4).\n", var
->xres
);
346 WRN_MSG("Y resolution too small (%d vs 4).\n", var
->yres
);
350 /* Check for doublescan modes. */
351 if (var
->vmode
& FB_VMODE_DOUBLE
) {
352 WRN_MSG("Mode is double-scan.\n");
356 if ((var
->vmode
& FB_VMODE_INTERLACED
) && (var
->yres
& 1)) {
357 WRN_MSG("Odd number of lines in interlaced mode\n");
361 /* Check if clock is OK. */
362 tmp
= 1000000000 / var
->pixclock
;
363 if (tmp
< MIN_CLOCK
) {
364 WRN_MSG("Pixel clock is too low (%d MHz vs %d MHz).\n",
365 (tmp
+ 500) / 1000, MIN_CLOCK
/ 1000);
368 if (tmp
> MAX_CLOCK
) {
369 WRN_MSG("Pixel clock is too high (%d MHz vs %d MHz).\n",
370 (tmp
+ 500) / 1000, MAX_CLOCK
/ 1000);
377 int intelfbhw_pan_display(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
379 struct intelfb_info
*dinfo
= GET_DINFO(info
);
380 u32 offset
, xoffset
, yoffset
;
383 DBG_MSG("intelfbhw_pan_display\n");
386 xoffset
= ROUND_DOWN_TO(var
->xoffset
, 8);
387 yoffset
= var
->yoffset
;
389 if ((xoffset
+ var
->xres
> var
->xres_virtual
) ||
390 (yoffset
+ var
->yres
> var
->yres_virtual
))
393 offset
= (yoffset
* dinfo
->pitch
) +
394 (xoffset
* var
->bits_per_pixel
) / 8;
396 offset
+= dinfo
->fb
.offset
<< 12;
398 dinfo
->vsync
.pan_offset
= offset
;
399 if ((var
->activate
& FB_ACTIVATE_VBL
) &&
400 !intelfbhw_enable_irq(dinfo
))
401 dinfo
->vsync
.pan_display
= 1;
403 dinfo
->vsync
.pan_display
= 0;
404 OUTREG(DSPABASE
, offset
);
410 /* Blank the screen. */
411 void intelfbhw_do_blank(int blank
, struct fb_info
*info
)
413 struct intelfb_info
*dinfo
= GET_DINFO(info
);
417 DBG_MSG("intelfbhw_do_blank: blank is %d\n", blank
);
420 /* Turn plane A on or off */
421 tmp
= INREG(DSPACNTR
);
423 tmp
&= ~DISPPLANE_PLANE_ENABLE
;
425 tmp
|= DISPPLANE_PLANE_ENABLE
;
426 OUTREG(DSPACNTR
, tmp
);
428 tmp
= INREG(DSPABASE
);
429 OUTREG(DSPABASE
, tmp
);
431 /* Turn off/on the HW cursor */
433 DBG_MSG("cursor_on is %d\n", dinfo
->cursor_on
);
435 if (dinfo
->cursor_on
) {
437 intelfbhw_cursor_hide(dinfo
);
439 intelfbhw_cursor_show(dinfo
);
440 dinfo
->cursor_on
= 1;
442 dinfo
->cursor_blanked
= blank
;
445 tmp
= INREG(ADPA
) & ~ADPA_DPMS_CONTROL_MASK
;
447 case FB_BLANK_UNBLANK
:
448 case FB_BLANK_NORMAL
:
451 case FB_BLANK_VSYNC_SUSPEND
:
454 case FB_BLANK_HSYNC_SUSPEND
:
457 case FB_BLANK_POWERDOWN
:
467 void intelfbhw_setcolreg(struct intelfb_info
*dinfo
, unsigned regno
,
468 unsigned red
, unsigned green
, unsigned blue
,
471 u32 palette_reg
= (dinfo
->pipe
== PIPE_A
) ?
472 PALETTE_A
: PALETTE_B
;
475 DBG_MSG("intelfbhw_setcolreg: %d: (%d, %d, %d)\n",
476 regno
, red
, green
, blue
);
479 OUTREG(palette_reg
+ (regno
<< 2),
480 (red
<< PALETTE_8_RED_SHIFT
) |
481 (green
<< PALETTE_8_GREEN_SHIFT
) |
482 (blue
<< PALETTE_8_BLUE_SHIFT
));
486 int intelfbhw_read_hw_state(struct intelfb_info
*dinfo
,
487 struct intelfb_hwstate
*hw
, int flag
)
492 DBG_MSG("intelfbhw_read_hw_state\n");
498 /* Read in as much of the HW state as possible. */
499 hw
->vga0_divisor
= INREG(VGA0_DIVISOR
);
500 hw
->vga1_divisor
= INREG(VGA1_DIVISOR
);
501 hw
->vga_pd
= INREG(VGAPD
);
502 hw
->dpll_a
= INREG(DPLL_A
);
503 hw
->dpll_b
= INREG(DPLL_B
);
504 hw
->fpa0
= INREG(FPA0
);
505 hw
->fpa1
= INREG(FPA1
);
506 hw
->fpb0
= INREG(FPB0
);
507 hw
->fpb1
= INREG(FPB1
);
513 /* This seems to be a problem with the 852GM/855GM */
514 for (i
= 0; i
< PALETTE_8_ENTRIES
; i
++) {
515 hw
->palette_a
[i
] = INREG(PALETTE_A
+ (i
<< 2));
516 hw
->palette_b
[i
] = INREG(PALETTE_B
+ (i
<< 2));
523 hw
->htotal_a
= INREG(HTOTAL_A
);
524 hw
->hblank_a
= INREG(HBLANK_A
);
525 hw
->hsync_a
= INREG(HSYNC_A
);
526 hw
->vtotal_a
= INREG(VTOTAL_A
);
527 hw
->vblank_a
= INREG(VBLANK_A
);
528 hw
->vsync_a
= INREG(VSYNC_A
);
529 hw
->src_size_a
= INREG(SRC_SIZE_A
);
530 hw
->bclrpat_a
= INREG(BCLRPAT_A
);
531 hw
->htotal_b
= INREG(HTOTAL_B
);
532 hw
->hblank_b
= INREG(HBLANK_B
);
533 hw
->hsync_b
= INREG(HSYNC_B
);
534 hw
->vtotal_b
= INREG(VTOTAL_B
);
535 hw
->vblank_b
= INREG(VBLANK_B
);
536 hw
->vsync_b
= INREG(VSYNC_B
);
537 hw
->src_size_b
= INREG(SRC_SIZE_B
);
538 hw
->bclrpat_b
= INREG(BCLRPAT_B
);
543 hw
->adpa
= INREG(ADPA
);
544 hw
->dvoa
= INREG(DVOA
);
545 hw
->dvob
= INREG(DVOB
);
546 hw
->dvoc
= INREG(DVOC
);
547 hw
->dvoa_srcdim
= INREG(DVOA_SRCDIM
);
548 hw
->dvob_srcdim
= INREG(DVOB_SRCDIM
);
549 hw
->dvoc_srcdim
= INREG(DVOC_SRCDIM
);
550 hw
->lvds
= INREG(LVDS
);
555 hw
->pipe_a_conf
= INREG(PIPEACONF
);
556 hw
->pipe_b_conf
= INREG(PIPEBCONF
);
557 hw
->disp_arb
= INREG(DISPARB
);
562 hw
->cursor_a_control
= INREG(CURSOR_A_CONTROL
);
563 hw
->cursor_b_control
= INREG(CURSOR_B_CONTROL
);
564 hw
->cursor_a_base
= INREG(CURSOR_A_BASEADDR
);
565 hw
->cursor_b_base
= INREG(CURSOR_B_BASEADDR
);
570 for (i
= 0; i
< 4; i
++) {
571 hw
->cursor_a_palette
[i
] = INREG(CURSOR_A_PALETTE0
+ (i
<< 2));
572 hw
->cursor_b_palette
[i
] = INREG(CURSOR_B_PALETTE0
+ (i
<< 2));
578 hw
->cursor_size
= INREG(CURSOR_SIZE
);
583 hw
->disp_a_ctrl
= INREG(DSPACNTR
);
584 hw
->disp_b_ctrl
= INREG(DSPBCNTR
);
585 hw
->disp_a_base
= INREG(DSPABASE
);
586 hw
->disp_b_base
= INREG(DSPBBASE
);
587 hw
->disp_a_stride
= INREG(DSPASTRIDE
);
588 hw
->disp_b_stride
= INREG(DSPBSTRIDE
);
593 hw
->vgacntrl
= INREG(VGACNTRL
);
598 hw
->add_id
= INREG(ADD_ID
);
603 for (i
= 0; i
< 7; i
++) {
604 hw
->swf0x
[i
] = INREG(SWF00
+ (i
<< 2));
605 hw
->swf1x
[i
] = INREG(SWF10
+ (i
<< 2));
607 hw
->swf3x
[i
] = INREG(SWF30
+ (i
<< 2));
610 for (i
= 0; i
< 8; i
++)
611 hw
->fence
[i
] = INREG(FENCE
+ (i
<< 2));
613 hw
->instpm
= INREG(INSTPM
);
614 hw
->mem_mode
= INREG(MEM_MODE
);
615 hw
->fw_blc_0
= INREG(FW_BLC_0
);
616 hw
->fw_blc_1
= INREG(FW_BLC_1
);
618 hw
->hwstam
= INREG16(HWSTAM
);
619 hw
->ier
= INREG16(IER
);
620 hw
->iir
= INREG16(IIR
);
621 hw
->imr
= INREG16(IMR
);
627 static int calc_vclock3(int index
, int m
, int n
, int p
)
629 if (p
== 0 || n
== 0)
631 return plls
[index
].ref_clk
* m
/ n
/ p
;
634 static int calc_vclock(int index
, int m1
, int m2
, int n
, int p1
, int p2
,
637 struct pll_min_max
*pll
= &plls
[index
];
640 m
= (5 * (m1
+ 2)) + (m2
+ 2);
642 vco
= pll
->ref_clk
* m
/ n
;
644 if (index
== PLLS_I8xx
)
645 p
= ((p1
+ 2) * (1 << (p2
+ 1)));
647 p
= ((p1
) * (p2
? 5 : 10));
652 static void intelfbhw_get_p1p2(struct intelfb_info
*dinfo
, int dpll
,
653 int *o_p1
, int *o_p2
)
657 if (IS_I9XX(dinfo
)) {
658 if (dpll
& DPLL_P1_FORCE_DIV2
)
661 p1
= (dpll
>> DPLL_P1_SHIFT
) & 0xff;
665 p2
= (dpll
>> DPLL_I9XX_P2_SHIFT
) & DPLL_P2_MASK
;
667 if (dpll
& DPLL_P1_FORCE_DIV2
)
670 p1
= (dpll
>> DPLL_P1_SHIFT
) & DPLL_P1_MASK
;
671 p2
= (dpll
>> DPLL_P2_SHIFT
) & DPLL_P2_MASK
;
680 void intelfbhw_print_hw_state(struct intelfb_info
*dinfo
,
681 struct intelfb_hwstate
*hw
)
684 int i
, m1
, m2
, n
, p1
, p2
;
685 int index
= dinfo
->pll_index
;
686 DBG_MSG("intelfbhw_print_hw_state\n");
690 /* Read in as much of the HW state as possible. */
691 printk("hw state dump start\n");
692 printk(" VGA0_DIVISOR: 0x%08x\n", hw
->vga0_divisor
);
693 printk(" VGA1_DIVISOR: 0x%08x\n", hw
->vga1_divisor
);
694 printk(" VGAPD: 0x%08x\n", hw
->vga_pd
);
695 n
= (hw
->vga0_divisor
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
696 m1
= (hw
->vga0_divisor
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
697 m2
= (hw
->vga0_divisor
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
699 intelfbhw_get_p1p2(dinfo
, hw
->vga_pd
, &p1
, &p2
);
701 printk(" VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
703 printk(" VGA0: clock is %d\n",
704 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
706 n
= (hw
->vga1_divisor
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
707 m1
= (hw
->vga1_divisor
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
708 m2
= (hw
->vga1_divisor
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
710 intelfbhw_get_p1p2(dinfo
, hw
->vga_pd
, &p1
, &p2
);
711 printk(" VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
713 printk(" VGA1: clock is %d\n",
714 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
716 printk(" DPLL_A: 0x%08x\n", hw
->dpll_a
);
717 printk(" DPLL_B: 0x%08x\n", hw
->dpll_b
);
718 printk(" FPA0: 0x%08x\n", hw
->fpa0
);
719 printk(" FPA1: 0x%08x\n", hw
->fpa1
);
720 printk(" FPB0: 0x%08x\n", hw
->fpb0
);
721 printk(" FPB1: 0x%08x\n", hw
->fpb1
);
723 n
= (hw
->fpa0
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
724 m1
= (hw
->fpa0
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
725 m2
= (hw
->fpa0
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
727 intelfbhw_get_p1p2(dinfo
, hw
->dpll_a
, &p1
, &p2
);
729 printk(" PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
731 printk(" PLLA0: clock is %d\n",
732 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
734 n
= (hw
->fpa1
>> FP_N_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
735 m1
= (hw
->fpa1
>> FP_M1_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
736 m2
= (hw
->fpa1
>> FP_M2_DIVISOR_SHIFT
) & FP_DIVISOR_MASK
;
738 intelfbhw_get_p1p2(dinfo
, hw
->dpll_a
, &p1
, &p2
);
740 printk(" PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
742 printk(" PLLA1: clock is %d\n",
743 calc_vclock(index
, m1
, m2
, n
, p1
, p2
, 0));
746 printk(" PALETTE_A:\n");
747 for (i
= 0; i
< PALETTE_8_ENTRIES
)
748 printk(" %3d: 0x%08x\n", i
, hw
->palette_a
[i
]);
749 printk(" PALETTE_B:\n");
750 for (i
= 0; i
< PALETTE_8_ENTRIES
)
751 printk(" %3d: 0x%08x\n", i
, hw
->palette_b
[i
]);
754 printk(" HTOTAL_A: 0x%08x\n", hw
->htotal_a
);
755 printk(" HBLANK_A: 0x%08x\n", hw
->hblank_a
);
756 printk(" HSYNC_A: 0x%08x\n", hw
->hsync_a
);
757 printk(" VTOTAL_A: 0x%08x\n", hw
->vtotal_a
);
758 printk(" VBLANK_A: 0x%08x\n", hw
->vblank_a
);
759 printk(" VSYNC_A: 0x%08x\n", hw
->vsync_a
);
760 printk(" SRC_SIZE_A: 0x%08x\n", hw
->src_size_a
);
761 printk(" BCLRPAT_A: 0x%08x\n", hw
->bclrpat_a
);
762 printk(" HTOTAL_B: 0x%08x\n", hw
->htotal_b
);
763 printk(" HBLANK_B: 0x%08x\n", hw
->hblank_b
);
764 printk(" HSYNC_B: 0x%08x\n", hw
->hsync_b
);
765 printk(" VTOTAL_B: 0x%08x\n", hw
->vtotal_b
);
766 printk(" VBLANK_B: 0x%08x\n", hw
->vblank_b
);
767 printk(" VSYNC_B: 0x%08x\n", hw
->vsync_b
);
768 printk(" SRC_SIZE_B: 0x%08x\n", hw
->src_size_b
);
769 printk(" BCLRPAT_B: 0x%08x\n", hw
->bclrpat_b
);
771 printk(" ADPA: 0x%08x\n", hw
->adpa
);
772 printk(" DVOA: 0x%08x\n", hw
->dvoa
);
773 printk(" DVOB: 0x%08x\n", hw
->dvob
);
774 printk(" DVOC: 0x%08x\n", hw
->dvoc
);
775 printk(" DVOA_SRCDIM: 0x%08x\n", hw
->dvoa_srcdim
);
776 printk(" DVOB_SRCDIM: 0x%08x\n", hw
->dvob_srcdim
);
777 printk(" DVOC_SRCDIM: 0x%08x\n", hw
->dvoc_srcdim
);
778 printk(" LVDS: 0x%08x\n", hw
->lvds
);
780 printk(" PIPEACONF: 0x%08x\n", hw
->pipe_a_conf
);
781 printk(" PIPEBCONF: 0x%08x\n", hw
->pipe_b_conf
);
782 printk(" DISPARB: 0x%08x\n", hw
->disp_arb
);
784 printk(" CURSOR_A_CONTROL: 0x%08x\n", hw
->cursor_a_control
);
785 printk(" CURSOR_B_CONTROL: 0x%08x\n", hw
->cursor_b_control
);
786 printk(" CURSOR_A_BASEADDR: 0x%08x\n", hw
->cursor_a_base
);
787 printk(" CURSOR_B_BASEADDR: 0x%08x\n", hw
->cursor_b_base
);
789 printk(" CURSOR_A_PALETTE: ");
790 for (i
= 0; i
< 4; i
++) {
791 printk("0x%08x", hw
->cursor_a_palette
[i
]);
796 printk(" CURSOR_B_PALETTE: ");
797 for (i
= 0; i
< 4; i
++) {
798 printk("0x%08x", hw
->cursor_b_palette
[i
]);
804 printk(" CURSOR_SIZE: 0x%08x\n", hw
->cursor_size
);
806 printk(" DSPACNTR: 0x%08x\n", hw
->disp_a_ctrl
);
807 printk(" DSPBCNTR: 0x%08x\n", hw
->disp_b_ctrl
);
808 printk(" DSPABASE: 0x%08x\n", hw
->disp_a_base
);
809 printk(" DSPBBASE: 0x%08x\n", hw
->disp_b_base
);
810 printk(" DSPASTRIDE: 0x%08x\n", hw
->disp_a_stride
);
811 printk(" DSPBSTRIDE: 0x%08x\n", hw
->disp_b_stride
);
813 printk(" VGACNTRL: 0x%08x\n", hw
->vgacntrl
);
814 printk(" ADD_ID: 0x%08x\n", hw
->add_id
);
816 for (i
= 0; i
< 7; i
++) {
817 printk(" SWF0%d 0x%08x\n", i
,
820 for (i
= 0; i
< 7; i
++) {
821 printk(" SWF1%d 0x%08x\n", i
,
824 for (i
= 0; i
< 3; i
++) {
825 printk(" SWF3%d 0x%08x\n", i
,
828 for (i
= 0; i
< 8; i
++)
829 printk(" FENCE%d 0x%08x\n", i
,
832 printk(" INSTPM 0x%08x\n", hw
->instpm
);
833 printk(" MEM_MODE 0x%08x\n", hw
->mem_mode
);
834 printk(" FW_BLC_0 0x%08x\n", hw
->fw_blc_0
);
835 printk(" FW_BLC_1 0x%08x\n", hw
->fw_blc_1
);
837 printk(" HWSTAM 0x%04x\n", hw
->hwstam
);
838 printk(" IER 0x%04x\n", hw
->ier
);
839 printk(" IIR 0x%04x\n", hw
->iir
);
840 printk(" IMR 0x%04x\n", hw
->imr
);
841 printk("hw state dump end\n");
847 /* Split the M parameter into M1 and M2. */
848 static int splitm(int index
, unsigned int m
, unsigned int *retm1
,
853 struct pll_min_max
*pll
= &plls
[index
];
855 /* no point optimising too much - brute force m */
856 for (m1
= pll
->min_m1
; m1
< pll
->max_m1
+ 1; m1
++) {
857 for (m2
= pll
->min_m2
; m2
< pll
->max_m2
+ 1; m2
++) {
858 testm
= (5 * (m1
+ 2)) + (m2
+ 2);
860 *retm1
= (unsigned int)m1
;
861 *retm2
= (unsigned int)m2
;
869 /* Split the P parameter into P1 and P2. */
870 static int splitp(int index
, unsigned int p
, unsigned int *retp1
,
874 struct pll_min_max
*pll
= &plls
[index
];
876 if (index
== PLLS_I9xx
) {
877 p2
= (p
% 10) ? 1 : 0;
879 p1
= p
/ (p2
? 5 : 10);
881 *retp1
= (unsigned int)p1
;
882 *retp2
= (unsigned int)p2
;
890 p1
= (p
/ (1 << (p2
+ 1))) - 2;
891 if (p
% 4 == 0 && p1
< pll
->min_p1
) {
893 p1
= (p
/ (1 << (p2
+ 1))) - 2;
895 if (p1
< pll
->min_p1
|| p1
> pll
->max_p1
||
896 (p1
+ 2) * (1 << (p2
+ 1)) != p
) {
899 *retp1
= (unsigned int)p1
;
900 *retp2
= (unsigned int)p2
;
905 static int calc_pll_params(int index
, int clock
, u32
*retm1
, u32
*retm2
,
906 u32
*retn
, u32
*retp1
, u32
*retp2
, u32
*retclock
)
908 u32 m1
, m2
, n
, p1
, p2
, n1
, testm
;
909 u32 f_vco
, p
, p_best
= 0, m
, f_out
= 0;
910 u32 err_max
, err_target
, err_best
= 10000000;
911 u32 n_best
= 0, m_best
= 0, f_best
, f_err
;
912 u32 p_min
, p_max
, p_inc
, div_max
;
913 struct pll_min_max
*pll
= &plls
[index
];
915 /* Accept 0.5% difference, but aim for 0.1% */
916 err_max
= 5 * clock
/ 1000;
917 err_target
= clock
/ 1000;
919 DBG_MSG("Clock is %d\n", clock
);
921 div_max
= pll
->max_vco
/ clock
;
923 p_inc
= (clock
<= pll
->p_transition_clk
) ? pll
->p_inc_lo
: pll
->p_inc_hi
;
925 p_max
= ROUND_DOWN_TO(div_max
, p_inc
);
926 if (p_min
< pll
->min_p
)
928 if (p_max
> pll
->max_p
)
931 DBG_MSG("p range is %d-%d (%d)\n", p_min
, p_max
, p_inc
);
935 if (splitp(index
, p
, &p1
, &p2
)) {
936 WRN_MSG("cannot split p = %d\n", p
);
944 m
= ROUND_UP_TO(f_vco
* n
, pll
->ref_clk
) / pll
->ref_clk
;
949 for (testm
= m
- 1; testm
<= m
; testm
++) {
950 f_out
= calc_vclock3(index
, testm
, n
, p
);
951 if (splitm(index
, testm
, &m1
, &m2
)) {
952 WRN_MSG("cannot split m = %d\n",
957 f_err
= clock
- f_out
;
958 else/* slightly bias the error for bigger clocks */
959 f_err
= f_out
- clock
+ 1;
961 if (f_err
< err_best
) {
970 } while ((n
<= pll
->max_n
) && (f_out
>= clock
));
972 } while ((p
<= p_max
));
975 WRN_MSG("cannot find parameters for clock %d\n", clock
);
981 splitm(index
, m
, &m1
, &m2
);
982 splitp(index
, p
, &p1
, &p2
);
985 DBG_MSG("m, n, p: %d (%d,%d), %d (%d), %d (%d,%d), "
986 "f: %d (%d), VCO: %d\n",
987 m
, m1
, m2
, n
, n1
, p
, p1
, p2
,
988 calc_vclock3(index
, m
, n
, p
),
989 calc_vclock(index
, m1
, m2
, n1
, p1
, p2
, 0),
990 calc_vclock3(index
, m
, n
, p
) * p
);
996 *retclock
= calc_vclock(index
, m1
, m2
, n1
, p1
, p2
, 0);
1001 static __inline__
int check_overflow(u32 value
, u32 limit
,
1002 const char *description
)
1004 if (value
> limit
) {
1005 WRN_MSG("%s value %d exceeds limit %d\n",
1006 description
, value
, limit
);
1012 /* It is assumed that hw is filled in with the initial state information. */
1013 int intelfbhw_mode_to_hw(struct intelfb_info
*dinfo
,
1014 struct intelfb_hwstate
*hw
,
1015 struct fb_var_screeninfo
*var
)
1018 u32
*dpll
, *fp0
, *fp1
;
1019 u32 m1
, m2
, n
, p1
, p2
, clock_target
, clock
;
1020 u32 hsync_start
, hsync_end
, hblank_start
, hblank_end
, htotal
, hactive
;
1021 u32 vsync_start
, vsync_end
, vblank_start
, vblank_end
, vtotal
, vactive
;
1022 u32 vsync_pol
, hsync_pol
;
1023 u32
*vs
, *vb
, *vt
, *hs
, *hb
, *ht
, *ss
, *pipe_conf
;
1024 u32 stride_alignment
;
1026 DBG_MSG("intelfbhw_mode_to_hw\n");
1029 hw
->vgacntrl
|= VGA_DISABLE
;
1031 /* Check whether pipe A or pipe B is enabled. */
1032 if (hw
->pipe_a_conf
& PIPECONF_ENABLE
)
1034 else if (hw
->pipe_b_conf
& PIPECONF_ENABLE
)
1037 /* Set which pipe's registers will be set. */
1038 if (pipe
== PIPE_B
) {
1048 ss
= &hw
->src_size_b
;
1049 pipe_conf
= &hw
->pipe_b_conf
;
1060 ss
= &hw
->src_size_a
;
1061 pipe_conf
= &hw
->pipe_a_conf
;
1064 /* Use ADPA register for sync control. */
1065 hw
->adpa
&= ~ADPA_USE_VGA_HVPOLARITY
;
1068 hsync_pol
= (var
->sync
& FB_SYNC_HOR_HIGH_ACT
) ?
1069 ADPA_SYNC_ACTIVE_HIGH
: ADPA_SYNC_ACTIVE_LOW
;
1070 vsync_pol
= (var
->sync
& FB_SYNC_VERT_HIGH_ACT
) ?
1071 ADPA_SYNC_ACTIVE_HIGH
: ADPA_SYNC_ACTIVE_LOW
;
1072 hw
->adpa
&= ~((ADPA_SYNC_ACTIVE_MASK
<< ADPA_VSYNC_ACTIVE_SHIFT
) |
1073 (ADPA_SYNC_ACTIVE_MASK
<< ADPA_HSYNC_ACTIVE_SHIFT
));
1074 hw
->adpa
|= (hsync_pol
<< ADPA_HSYNC_ACTIVE_SHIFT
) |
1075 (vsync_pol
<< ADPA_VSYNC_ACTIVE_SHIFT
);
1077 /* Connect correct pipe to the analog port DAC */
1078 hw
->adpa
&= ~(PIPE_MASK
<< ADPA_PIPE_SELECT_SHIFT
);
1079 hw
->adpa
|= (pipe
<< ADPA_PIPE_SELECT_SHIFT
);
1081 /* Set DPMS state to D0 (on) */
1082 hw
->adpa
&= ~ADPA_DPMS_CONTROL_MASK
;
1083 hw
->adpa
|= ADPA_DPMS_D0
;
1085 hw
->adpa
|= ADPA_DAC_ENABLE
;
1087 *dpll
|= (DPLL_VCO_ENABLE
| DPLL_VGA_MODE_DISABLE
);
1088 *dpll
&= ~(DPLL_RATE_SELECT_MASK
| DPLL_REFERENCE_SELECT_MASK
);
1089 *dpll
|= (DPLL_REFERENCE_DEFAULT
| DPLL_RATE_SELECT_FP0
);
1091 /* Desired clock in kHz */
1092 clock_target
= 1000000000 / var
->pixclock
;
1094 if (calc_pll_params(dinfo
->pll_index
, clock_target
, &m1
, &m2
,
1095 &n
, &p1
, &p2
, &clock
)) {
1096 WRN_MSG("calc_pll_params failed\n");
1100 /* Check for overflow. */
1101 if (check_overflow(p1
, DPLL_P1_MASK
, "PLL P1 parameter"))
1103 if (check_overflow(p2
, DPLL_P2_MASK
, "PLL P2 parameter"))
1105 if (check_overflow(m1
, FP_DIVISOR_MASK
, "PLL M1 parameter"))
1107 if (check_overflow(m2
, FP_DIVISOR_MASK
, "PLL M2 parameter"))
1109 if (check_overflow(n
, FP_DIVISOR_MASK
, "PLL N parameter"))
1112 *dpll
&= ~DPLL_P1_FORCE_DIV2
;
1113 *dpll
&= ~((DPLL_P2_MASK
<< DPLL_P2_SHIFT
) |
1114 (DPLL_P1_MASK
<< DPLL_P1_SHIFT
));
1116 if (IS_I9XX(dinfo
)) {
1117 *dpll
|= (p2
<< DPLL_I9XX_P2_SHIFT
);
1118 *dpll
|= (1 << (p1
- 1)) << DPLL_P1_SHIFT
;
1120 *dpll
|= (p2
<< DPLL_P2_SHIFT
) | (p1
<< DPLL_P1_SHIFT
);
1122 *fp0
= (n
<< FP_N_DIVISOR_SHIFT
) |
1123 (m1
<< FP_M1_DIVISOR_SHIFT
) |
1124 (m2
<< FP_M2_DIVISOR_SHIFT
);
1127 hw
->dvob
&= ~PORT_ENABLE
;
1128 hw
->dvoc
&= ~PORT_ENABLE
;
1130 /* Use display plane A. */
1131 hw
->disp_a_ctrl
|= DISPPLANE_PLANE_ENABLE
;
1132 hw
->disp_a_ctrl
&= ~DISPPLANE_GAMMA_ENABLE
;
1133 hw
->disp_a_ctrl
&= ~DISPPLANE_PIXFORMAT_MASK
;
1134 switch (intelfb_var_to_depth(var
)) {
1136 hw
->disp_a_ctrl
|= DISPPLANE_8BPP
| DISPPLANE_GAMMA_ENABLE
;
1139 hw
->disp_a_ctrl
|= DISPPLANE_15_16BPP
;
1142 hw
->disp_a_ctrl
|= DISPPLANE_16BPP
;
1145 hw
->disp_a_ctrl
|= DISPPLANE_32BPP_NO_ALPHA
;
1148 hw
->disp_a_ctrl
&= ~(PIPE_MASK
<< DISPPLANE_SEL_PIPE_SHIFT
);
1149 hw
->disp_a_ctrl
|= (pipe
<< DISPPLANE_SEL_PIPE_SHIFT
);
1151 /* Set CRTC registers. */
1152 hactive
= var
->xres
;
1153 hsync_start
= hactive
+ var
->right_margin
;
1154 hsync_end
= hsync_start
+ var
->hsync_len
;
1155 htotal
= hsync_end
+ var
->left_margin
;
1156 hblank_start
= hactive
;
1157 hblank_end
= htotal
;
1159 DBG_MSG("H: act %d, ss %d, se %d, tot %d bs %d, be %d\n",
1160 hactive
, hsync_start
, hsync_end
, htotal
, hblank_start
,
1163 vactive
= var
->yres
;
1164 if (var
->vmode
& FB_VMODE_INTERLACED
)
1165 vactive
--; /* the chip adds 2 halflines automatically */
1166 vsync_start
= vactive
+ var
->lower_margin
;
1167 vsync_end
= vsync_start
+ var
->vsync_len
;
1168 vtotal
= vsync_end
+ var
->upper_margin
;
1169 vblank_start
= vactive
;
1170 vblank_end
= vtotal
;
1171 vblank_end
= vsync_end
+ 1;
1173 DBG_MSG("V: act %d, ss %d, se %d, tot %d bs %d, be %d\n",
1174 vactive
, vsync_start
, vsync_end
, vtotal
, vblank_start
,
1177 /* Adjust for register values, and check for overflow. */
1179 if (check_overflow(hactive
, HACTIVE_MASK
, "CRTC hactive"))
1182 if (check_overflow(hsync_start
, HSYNCSTART_MASK
, "CRTC hsync_start"))
1185 if (check_overflow(hsync_end
, HSYNCEND_MASK
, "CRTC hsync_end"))
1188 if (check_overflow(htotal
, HTOTAL_MASK
, "CRTC htotal"))
1191 if (check_overflow(hblank_start
, HBLANKSTART_MASK
, "CRTC hblank_start"))
1194 if (check_overflow(hblank_end
, HBLANKEND_MASK
, "CRTC hblank_end"))
1198 if (check_overflow(vactive
, VACTIVE_MASK
, "CRTC vactive"))
1201 if (check_overflow(vsync_start
, VSYNCSTART_MASK
, "CRTC vsync_start"))
1204 if (check_overflow(vsync_end
, VSYNCEND_MASK
, "CRTC vsync_end"))
1207 if (check_overflow(vtotal
, VTOTAL_MASK
, "CRTC vtotal"))
1210 if (check_overflow(vblank_start
, VBLANKSTART_MASK
, "CRTC vblank_start"))
1213 if (check_overflow(vblank_end
, VBLANKEND_MASK
, "CRTC vblank_end"))
1216 *ht
= (htotal
<< HTOTAL_SHIFT
) | (hactive
<< HACTIVE_SHIFT
);
1217 *hb
= (hblank_start
<< HBLANKSTART_SHIFT
) |
1218 (hblank_end
<< HSYNCEND_SHIFT
);
1219 *hs
= (hsync_start
<< HSYNCSTART_SHIFT
) | (hsync_end
<< HSYNCEND_SHIFT
);
1221 *vt
= (vtotal
<< VTOTAL_SHIFT
) | (vactive
<< VACTIVE_SHIFT
);
1222 *vb
= (vblank_start
<< VBLANKSTART_SHIFT
) |
1223 (vblank_end
<< VSYNCEND_SHIFT
);
1224 *vs
= (vsync_start
<< VSYNCSTART_SHIFT
) | (vsync_end
<< VSYNCEND_SHIFT
);
1225 *ss
= (hactive
<< SRC_SIZE_HORIZ_SHIFT
) |
1226 (vactive
<< SRC_SIZE_VERT_SHIFT
);
1228 hw
->disp_a_stride
= dinfo
->pitch
;
1229 DBG_MSG("pitch is %d\n", hw
->disp_a_stride
);
1231 hw
->disp_a_base
= hw
->disp_a_stride
* var
->yoffset
+
1232 var
->xoffset
* var
->bits_per_pixel
/ 8;
1234 hw
->disp_a_base
+= dinfo
->fb
.offset
<< 12;
1236 /* Check stride alignment. */
1237 stride_alignment
= IS_I9XX(dinfo
) ? STRIDE_ALIGNMENT_I9XX
:
1239 if (hw
->disp_a_stride
% stride_alignment
!= 0) {
1240 WRN_MSG("display stride %d has bad alignment %d\n",
1241 hw
->disp_a_stride
, stride_alignment
);
1245 /* Set the palette to 8-bit mode. */
1246 *pipe_conf
&= ~PIPECONF_GAMMA
;
1248 if (var
->vmode
& FB_VMODE_INTERLACED
)
1249 *pipe_conf
|= PIPECONF_INTERLACE_W_FIELD_INDICATION
;
1251 *pipe_conf
&= ~PIPECONF_INTERLACE_MASK
;
1256 /* Program a (non-VGA) video mode. */
1257 int intelfbhw_program_mode(struct intelfb_info
*dinfo
,
1258 const struct intelfb_hwstate
*hw
, int blank
)
1262 const u32
*dpll
, *fp0
, *fp1
, *pipe_conf
;
1263 const u32
*hs
, *ht
, *hb
, *vs
, *vt
, *vb
, *ss
;
1264 u32 dpll_reg
, fp0_reg
, fp1_reg
, pipe_conf_reg
, pipe_stat_reg
;
1265 u32 hsync_reg
, htotal_reg
, hblank_reg
;
1266 u32 vsync_reg
, vtotal_reg
, vblank_reg
;
1268 u32 count
, tmp_val
[3];
1270 /* Assume single pipe, display plane A, analog CRT. */
1273 DBG_MSG("intelfbhw_program_mode\n");
1277 tmp
= INREG(VGACNTRL
);
1279 OUTREG(VGACNTRL
, tmp
);
1281 /* Check whether pipe A or pipe B is enabled. */
1282 if (hw
->pipe_a_conf
& PIPECONF_ENABLE
)
1284 else if (hw
->pipe_b_conf
& PIPECONF_ENABLE
)
1289 if (pipe
== PIPE_B
) {
1293 pipe_conf
= &hw
->pipe_b_conf
;
1300 ss
= &hw
->src_size_b
;
1304 pipe_conf_reg
= PIPEBCONF
;
1305 pipe_stat_reg
= PIPEBSTAT
;
1306 hsync_reg
= HSYNC_B
;
1307 htotal_reg
= HTOTAL_B
;
1308 hblank_reg
= HBLANK_B
;
1309 vsync_reg
= VSYNC_B
;
1310 vtotal_reg
= VTOTAL_B
;
1311 vblank_reg
= VBLANK_B
;
1312 src_size_reg
= SRC_SIZE_B
;
1317 pipe_conf
= &hw
->pipe_a_conf
;
1324 ss
= &hw
->src_size_a
;
1328 pipe_conf_reg
= PIPEACONF
;
1329 pipe_stat_reg
= PIPEASTAT
;
1330 hsync_reg
= HSYNC_A
;
1331 htotal_reg
= HTOTAL_A
;
1332 hblank_reg
= HBLANK_A
;
1333 vsync_reg
= VSYNC_A
;
1334 vtotal_reg
= VTOTAL_A
;
1335 vblank_reg
= VBLANK_A
;
1336 src_size_reg
= SRC_SIZE_A
;
1340 tmp
= INREG(pipe_conf_reg
);
1341 tmp
&= ~PIPECONF_ENABLE
;
1342 OUTREG(pipe_conf_reg
, tmp
);
1346 tmp_val
[count
% 3] = INREG(PIPEA_DSL
);
1347 if ((tmp_val
[0] == tmp_val
[1]) && (tmp_val
[1] == tmp_val
[2]))
1351 if (count
% 200 == 0) {
1352 tmp
= INREG(pipe_conf_reg
);
1353 tmp
&= ~PIPECONF_ENABLE
;
1354 OUTREG(pipe_conf_reg
, tmp
);
1356 } while (count
< 2000);
1358 OUTREG(ADPA
, INREG(ADPA
) & ~ADPA_DAC_ENABLE
);
1360 /* Disable planes A and B. */
1361 tmp
= INREG(DSPACNTR
);
1362 tmp
&= ~DISPPLANE_PLANE_ENABLE
;
1363 OUTREG(DSPACNTR
, tmp
);
1364 tmp
= INREG(DSPBCNTR
);
1365 tmp
&= ~DISPPLANE_PLANE_ENABLE
;
1366 OUTREG(DSPBCNTR
, tmp
);
1368 /* Wait for vblank. For now, just wait for a 50Hz cycle (20ms)) */
1371 OUTREG(DVOB
, INREG(DVOB
) & ~PORT_ENABLE
);
1372 OUTREG(DVOC
, INREG(DVOC
) & ~PORT_ENABLE
);
1373 OUTREG(ADPA
, INREG(ADPA
) & ~ADPA_DAC_ENABLE
);
1377 tmp
&= ~ADPA_DPMS_CONTROL_MASK
;
1378 tmp
|= ADPA_DPMS_D3
;
1381 /* do some funky magic - xyzzy */
1382 OUTREG(0x61204, 0xabcd0000);
1385 tmp
= INREG(dpll_reg
);
1386 tmp
&= ~DPLL_VCO_ENABLE
;
1387 OUTREG(dpll_reg
, tmp
);
1389 /* Set PLL parameters */
1390 OUTREG(fp0_reg
, *fp0
);
1391 OUTREG(fp1_reg
, *fp1
);
1394 OUTREG(dpll_reg
, *dpll
);
1397 OUTREG(DVOB
, hw
->dvob
);
1398 OUTREG(DVOC
, hw
->dvoc
);
1400 /* undo funky magic */
1401 OUTREG(0x61204, 0x00000000);
1404 OUTREG(ADPA
, INREG(ADPA
) | ADPA_DAC_ENABLE
);
1405 OUTREG(ADPA
, (hw
->adpa
& ~(ADPA_DPMS_CONTROL_MASK
)) | ADPA_DPMS_D3
);
1407 /* Set pipe parameters */
1408 OUTREG(hsync_reg
, *hs
);
1409 OUTREG(hblank_reg
, *hb
);
1410 OUTREG(htotal_reg
, *ht
);
1411 OUTREG(vsync_reg
, *vs
);
1412 OUTREG(vblank_reg
, *vb
);
1413 OUTREG(vtotal_reg
, *vt
);
1414 OUTREG(src_size_reg
, *ss
);
1416 switch (dinfo
->info
->var
.vmode
& (FB_VMODE_INTERLACED
|
1417 FB_VMODE_ODD_FLD_FIRST
)) {
1418 case FB_VMODE_INTERLACED
| FB_VMODE_ODD_FLD_FIRST
:
1419 OUTREG(pipe_stat_reg
, 0xFFFF | PIPESTAT_FLD_EVT_ODD_EN
);
1421 case FB_VMODE_INTERLACED
: /* even lines first */
1422 OUTREG(pipe_stat_reg
, 0xFFFF | PIPESTAT_FLD_EVT_EVEN_EN
);
1424 default: /* non-interlaced */
1425 OUTREG(pipe_stat_reg
, 0xFFFF); /* clear all status bits only */
1428 OUTREG(pipe_conf_reg
, *pipe_conf
| PIPECONF_ENABLE
);
1432 tmp
&= ~ADPA_DPMS_CONTROL_MASK
;
1433 tmp
|= ADPA_DPMS_D0
;
1436 /* setup display plane */
1437 if (dinfo
->pdev
->device
== PCI_DEVICE_ID_INTEL_830M
) {
1439 * i830M errata: the display plane must be enabled
1440 * to allow writes to the other bits in the plane
1443 tmp
= INREG(DSPACNTR
);
1444 if ((tmp
& DISPPLANE_PLANE_ENABLE
) != DISPPLANE_PLANE_ENABLE
) {
1445 tmp
|= DISPPLANE_PLANE_ENABLE
;
1446 OUTREG(DSPACNTR
, tmp
);
1448 hw
->disp_a_ctrl
|DISPPLANE_PLANE_ENABLE
);
1453 OUTREG(DSPACNTR
, hw
->disp_a_ctrl
& ~DISPPLANE_PLANE_ENABLE
);
1454 OUTREG(DSPASTRIDE
, hw
->disp_a_stride
);
1455 OUTREG(DSPABASE
, hw
->disp_a_base
);
1459 tmp
= INREG(DSPACNTR
);
1460 tmp
|= DISPPLANE_PLANE_ENABLE
;
1461 OUTREG(DSPACNTR
, tmp
);
1462 OUTREG(DSPABASE
, hw
->disp_a_base
);
1468 /* forward declarations */
1469 static void refresh_ring(struct intelfb_info
*dinfo
);
1470 static void reset_state(struct intelfb_info
*dinfo
);
1471 static void do_flush(struct intelfb_info
*dinfo
);
1473 static u32
get_ring_space(struct intelfb_info
*dinfo
)
1477 if (dinfo
->ring_tail
>= dinfo
->ring_head
)
1478 ring_space
= dinfo
->ring
.size
-
1479 (dinfo
->ring_tail
- dinfo
->ring_head
);
1481 ring_space
= dinfo
->ring_head
- dinfo
->ring_tail
;
1483 if (ring_space
> RING_MIN_FREE
)
1484 ring_space
-= RING_MIN_FREE
;
1491 static int wait_ring(struct intelfb_info
*dinfo
, int n
)
1495 u32 last_head
= INREG(PRI_RING_HEAD
) & RING_HEAD_MASK
;
1498 DBG_MSG("wait_ring: %d\n", n
);
1501 end
= jiffies
+ (HZ
* 3);
1502 while (dinfo
->ring_space
< n
) {
1503 dinfo
->ring_head
= INREG(PRI_RING_HEAD
) & RING_HEAD_MASK
;
1504 dinfo
->ring_space
= get_ring_space(dinfo
);
1506 if (dinfo
->ring_head
!= last_head
) {
1507 end
= jiffies
+ (HZ
* 3);
1508 last_head
= dinfo
->ring_head
;
1511 if (time_before(end
, jiffies
)) {
1515 refresh_ring(dinfo
);
1517 end
= jiffies
+ (HZ
* 3);
1520 WRN_MSG("ring buffer : space: %d wanted %d\n",
1521 dinfo
->ring_space
, n
);
1522 WRN_MSG("lockup - turning off hardware "
1524 dinfo
->ring_lockup
= 1;
1533 static void do_flush(struct intelfb_info
*dinfo
)
1536 OUT_RING(MI_FLUSH
| MI_WRITE_DIRTY_STATE
| MI_INVALIDATE_MAP_CACHE
);
1541 void intelfbhw_do_sync(struct intelfb_info
*dinfo
)
1544 DBG_MSG("intelfbhw_do_sync\n");
1551 * Send a flush, then wait until the ring is empty. This is what
1552 * the XFree86 driver does, and actually it doesn't seem a lot worse
1553 * than the recommended method (both have problems).
1556 wait_ring(dinfo
, dinfo
->ring
.size
- RING_MIN_FREE
);
1557 dinfo
->ring_space
= dinfo
->ring
.size
- RING_MIN_FREE
;
1560 static void refresh_ring(struct intelfb_info
*dinfo
)
1563 DBG_MSG("refresh_ring\n");
1566 dinfo
->ring_head
= INREG(PRI_RING_HEAD
) & RING_HEAD_MASK
;
1567 dinfo
->ring_tail
= INREG(PRI_RING_TAIL
) & RING_TAIL_MASK
;
1568 dinfo
->ring_space
= get_ring_space(dinfo
);
1571 static void reset_state(struct intelfb_info
*dinfo
)
1577 DBG_MSG("reset_state\n");
1580 for (i
= 0; i
< FENCE_NUM
; i
++)
1581 OUTREG(FENCE
+ (i
<< 2), 0);
1583 /* Flush the ring buffer if it's enabled. */
1584 tmp
= INREG(PRI_RING_LENGTH
);
1585 if (tmp
& RING_ENABLE
) {
1587 DBG_MSG("reset_state: ring was enabled\n");
1589 refresh_ring(dinfo
);
1590 intelfbhw_do_sync(dinfo
);
1594 OUTREG(PRI_RING_LENGTH
, 0);
1595 OUTREG(PRI_RING_HEAD
, 0);
1596 OUTREG(PRI_RING_TAIL
, 0);
1597 OUTREG(PRI_RING_START
, 0);
1600 /* Stop the 2D engine, and turn off the ring buffer. */
1601 void intelfbhw_2d_stop(struct intelfb_info
*dinfo
)
1604 DBG_MSG("intelfbhw_2d_stop: accel: %d, ring_active: %d\n",
1605 dinfo
->accel
, dinfo
->ring_active
);
1611 dinfo
->ring_active
= 0;
1616 * Enable the ring buffer, and initialise the 2D engine.
1617 * It is assumed that the graphics engine has been stopped by previously
1618 * calling intelfb_2d_stop().
1620 void intelfbhw_2d_start(struct intelfb_info
*dinfo
)
1623 DBG_MSG("intelfbhw_2d_start: accel: %d, ring_active: %d\n",
1624 dinfo
->accel
, dinfo
->ring_active
);
1630 /* Initialise the primary ring buffer. */
1631 OUTREG(PRI_RING_LENGTH
, 0);
1632 OUTREG(PRI_RING_TAIL
, 0);
1633 OUTREG(PRI_RING_HEAD
, 0);
1635 OUTREG(PRI_RING_START
, dinfo
->ring
.physical
& RING_START_MASK
);
1636 OUTREG(PRI_RING_LENGTH
,
1637 ((dinfo
->ring
.size
- GTT_PAGE_SIZE
) & RING_LENGTH_MASK
) |
1638 RING_NO_REPORT
| RING_ENABLE
);
1639 refresh_ring(dinfo
);
1640 dinfo
->ring_active
= 1;
1643 /* 2D fillrect (solid fill or invert) */
1644 void intelfbhw_do_fillrect(struct intelfb_info
*dinfo
, u32 x
, u32 y
, u32 w
,
1645 u32 h
, u32 color
, u32 pitch
, u32 bpp
, u32 rop
)
1647 u32 br00
, br09
, br13
, br14
, br16
;
1650 DBG_MSG("intelfbhw_do_fillrect: (%d,%d) %dx%d, c 0x%06x, p %d bpp %d, "
1651 "rop 0x%02x\n", x
, y
, w
, h
, color
, pitch
, bpp
, rop
);
1654 br00
= COLOR_BLT_CMD
;
1655 br09
= dinfo
->fb_start
+ (y
* pitch
+ x
* (bpp
/ 8));
1656 br13
= (rop
<< ROP_SHIFT
) | pitch
;
1657 br14
= (h
<< HEIGHT_SHIFT
) | ((w
* (bpp
/ 8)) << WIDTH_SHIFT
);
1662 br13
|= COLOR_DEPTH_8
;
1665 br13
|= COLOR_DEPTH_16
;
1668 br13
|= COLOR_DEPTH_32
;
1669 br00
|= WRITE_ALPHA
| WRITE_RGB
;
1683 DBG_MSG("ring = 0x%08x, 0x%08x (%d)\n", dinfo
->ring_head
,
1684 dinfo
->ring_tail
, dinfo
->ring_space
);
1689 intelfbhw_do_bitblt(struct intelfb_info
*dinfo
, u32 curx
, u32 cury
,
1690 u32 dstx
, u32 dsty
, u32 w
, u32 h
, u32 pitch
, u32 bpp
)
1692 u32 br00
, br09
, br11
, br12
, br13
, br22
, br23
, br26
;
1695 DBG_MSG("intelfbhw_do_bitblt: (%d,%d)->(%d,%d) %dx%d, p %d bpp %d\n",
1696 curx
, cury
, dstx
, dsty
, w
, h
, pitch
, bpp
);
1699 br00
= XY_SRC_COPY_BLT_CMD
;
1700 br09
= dinfo
->fb_start
;
1701 br11
= (pitch
<< PITCH_SHIFT
);
1702 br12
= dinfo
->fb_start
;
1703 br13
= (SRC_ROP_GXCOPY
<< ROP_SHIFT
) | (pitch
<< PITCH_SHIFT
);
1704 br22
= (dstx
<< WIDTH_SHIFT
) | (dsty
<< HEIGHT_SHIFT
);
1705 br23
= ((dstx
+ w
) << WIDTH_SHIFT
) |
1706 ((dsty
+ h
) << HEIGHT_SHIFT
);
1707 br26
= (curx
<< WIDTH_SHIFT
) | (cury
<< HEIGHT_SHIFT
);
1711 br13
|= COLOR_DEPTH_8
;
1714 br13
|= COLOR_DEPTH_16
;
1717 br13
|= COLOR_DEPTH_32
;
1718 br00
|= WRITE_ALPHA
| WRITE_RGB
;
1734 int intelfbhw_do_drawglyph(struct intelfb_info
*dinfo
, u32 fg
, u32 bg
, u32 w
,
1735 u32 h
, const u8
* cdat
, u32 x
, u32 y
, u32 pitch
,
1738 int nbytes
, ndwords
, pad
, tmp
;
1739 u32 br00
, br09
, br13
, br18
, br19
, br22
, br23
;
1740 int dat
, ix
, iy
, iw
;
1744 DBG_MSG("intelfbhw_do_drawglyph: (%d,%d) %dx%d\n", x
, y
, w
, h
);
1747 /* size in bytes of a padded scanline */
1748 nbytes
= ROUND_UP_TO(w
, 16) / 8;
1750 /* Total bytes of padded scanline data to write out. */
1751 nbytes
= nbytes
* h
;
1754 * Check if the glyph data exceeds the immediate mode limit.
1755 * It would take a large font (1K pixels) to hit this limit.
1757 if (nbytes
> MAX_MONO_IMM_SIZE
)
1760 /* Src data is packaged a dword (32-bit) at a time. */
1761 ndwords
= ROUND_UP_TO(nbytes
, 4) / 4;
1764 * Ring has to be padded to a quad word. But because the command starts
1765 with 7 bytes, pad only if there is an even number of ndwords
1767 pad
= !(ndwords
% 2);
1769 tmp
= (XY_MONO_SRC_IMM_BLT_CMD
& DW_LENGTH_MASK
) + ndwords
;
1770 br00
= (XY_MONO_SRC_IMM_BLT_CMD
& ~DW_LENGTH_MASK
) | tmp
;
1771 br09
= dinfo
->fb_start
;
1772 br13
= (SRC_ROP_GXCOPY
<< ROP_SHIFT
) | (pitch
<< PITCH_SHIFT
);
1775 br22
= (x
<< WIDTH_SHIFT
) | (y
<< HEIGHT_SHIFT
);
1776 br23
= ((x
+ w
) << WIDTH_SHIFT
) | ((y
+ h
) << HEIGHT_SHIFT
);
1780 br13
|= COLOR_DEPTH_8
;
1783 br13
|= COLOR_DEPTH_16
;
1786 br13
|= COLOR_DEPTH_32
;
1787 br00
|= WRITE_ALPHA
| WRITE_RGB
;
1791 START_RING(8 + ndwords
);
1800 iw
= ROUND_UP_TO(w
, 8) / 8;
1803 for (j
= 0; j
< 2; ++j
) {
1804 for (i
= 0; i
< 2; ++i
) {
1805 if (ix
!= iw
|| i
== 0)
1806 dat
|= cdat
[iy
*iw
+ ix
++] << (i
+j
*2)*8;
1808 if (ix
== iw
&& iy
!= (h
-1)) {
1822 /* HW cursor functions. */
1823 void intelfbhw_cursor_init(struct intelfb_info
*dinfo
)
1828 DBG_MSG("intelfbhw_cursor_init\n");
1831 if (dinfo
->mobile
|| IS_I9XX(dinfo
)) {
1832 if (!dinfo
->cursor
.physical
)
1834 tmp
= INREG(CURSOR_A_CONTROL
);
1835 tmp
&= ~(CURSOR_MODE_MASK
| CURSOR_MOBILE_GAMMA_ENABLE
|
1836 CURSOR_MEM_TYPE_LOCAL
|
1837 (1 << CURSOR_PIPE_SELECT_SHIFT
));
1838 tmp
|= CURSOR_MODE_DISABLE
;
1839 OUTREG(CURSOR_A_CONTROL
, tmp
);
1840 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1842 tmp
= INREG(CURSOR_CONTROL
);
1843 tmp
&= ~(CURSOR_FORMAT_MASK
| CURSOR_GAMMA_ENABLE
|
1844 CURSOR_ENABLE
| CURSOR_STRIDE_MASK
);
1845 tmp
= CURSOR_FORMAT_3C
;
1846 OUTREG(CURSOR_CONTROL
, tmp
);
1847 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.offset
<< 12);
1848 tmp
= (64 << CURSOR_SIZE_H_SHIFT
) |
1849 (64 << CURSOR_SIZE_V_SHIFT
);
1850 OUTREG(CURSOR_SIZE
, tmp
);
1854 void intelfbhw_cursor_hide(struct intelfb_info
*dinfo
)
1859 DBG_MSG("intelfbhw_cursor_hide\n");
1862 dinfo
->cursor_on
= 0;
1863 if (dinfo
->mobile
|| IS_I9XX(dinfo
)) {
1864 if (!dinfo
->cursor
.physical
)
1866 tmp
= INREG(CURSOR_A_CONTROL
);
1867 tmp
&= ~CURSOR_MODE_MASK
;
1868 tmp
|= CURSOR_MODE_DISABLE
;
1869 OUTREG(CURSOR_A_CONTROL
, tmp
);
1871 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1873 tmp
= INREG(CURSOR_CONTROL
);
1874 tmp
&= ~CURSOR_ENABLE
;
1875 OUTREG(CURSOR_CONTROL
, tmp
);
1879 void intelfbhw_cursor_show(struct intelfb_info
*dinfo
)
1884 DBG_MSG("intelfbhw_cursor_show\n");
1887 dinfo
->cursor_on
= 1;
1889 if (dinfo
->cursor_blanked
)
1892 if (dinfo
->mobile
|| IS_I9XX(dinfo
)) {
1893 if (!dinfo
->cursor
.physical
)
1895 tmp
= INREG(CURSOR_A_CONTROL
);
1896 tmp
&= ~CURSOR_MODE_MASK
;
1897 tmp
|= CURSOR_MODE_64_4C_AX
;
1898 OUTREG(CURSOR_A_CONTROL
, tmp
);
1900 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1902 tmp
= INREG(CURSOR_CONTROL
);
1903 tmp
|= CURSOR_ENABLE
;
1904 OUTREG(CURSOR_CONTROL
, tmp
);
1908 void intelfbhw_cursor_setpos(struct intelfb_info
*dinfo
, int x
, int y
)
1913 DBG_MSG("intelfbhw_cursor_setpos: (%d, %d)\n", x
, y
);
1917 * Sets the position. The coordinates are assumed to already
1918 * have any offset adjusted. Assume that the cursor is never
1919 * completely off-screen, and that x, y are always >= 0.
1922 tmp
= ((x
& CURSOR_POS_MASK
) << CURSOR_X_SHIFT
) |
1923 ((y
& CURSOR_POS_MASK
) << CURSOR_Y_SHIFT
);
1924 OUTREG(CURSOR_A_POSITION
, tmp
);
1927 OUTREG(CURSOR_A_BASEADDR
, dinfo
->cursor
.physical
);
1930 void intelfbhw_cursor_setcolor(struct intelfb_info
*dinfo
, u32 bg
, u32 fg
)
1933 DBG_MSG("intelfbhw_cursor_setcolor\n");
1936 OUTREG(CURSOR_A_PALETTE0
, bg
& CURSOR_PALETTE_MASK
);
1937 OUTREG(CURSOR_A_PALETTE1
, fg
& CURSOR_PALETTE_MASK
);
1938 OUTREG(CURSOR_A_PALETTE2
, fg
& CURSOR_PALETTE_MASK
);
1939 OUTREG(CURSOR_A_PALETTE3
, bg
& CURSOR_PALETTE_MASK
);
1942 void intelfbhw_cursor_load(struct intelfb_info
*dinfo
, int width
, int height
,
1945 u8 __iomem
*addr
= (u8 __iomem
*)dinfo
->cursor
.virtual;
1946 int i
, j
, w
= width
/ 8;
1947 int mod
= width
% 8, t_mask
, d_mask
;
1950 DBG_MSG("intelfbhw_cursor_load\n");
1953 if (!dinfo
->cursor
.virtual)
1956 t_mask
= 0xff >> mod
;
1957 d_mask
= ~(0xff >> mod
);
1958 for (i
= height
; i
--; ) {
1959 for (j
= 0; j
< w
; j
++) {
1960 writeb(0x00, addr
+ j
);
1961 writeb(*(data
++), addr
+ j
+8);
1964 writeb(t_mask
, addr
+ j
);
1965 writeb(*(data
++) & d_mask
, addr
+ j
+8);
1971 void intelfbhw_cursor_reset(struct intelfb_info
*dinfo
)
1973 u8 __iomem
*addr
= (u8 __iomem
*)dinfo
->cursor
.virtual;
1977 DBG_MSG("intelfbhw_cursor_reset\n");
1980 if (!dinfo
->cursor
.virtual)
1983 for (i
= 64; i
--; ) {
1984 for (j
= 0; j
< 8; j
++) {
1985 writeb(0xff, addr
+ j
+0);
1986 writeb(0x00, addr
+ j
+8);
1992 static irqreturn_t
intelfbhw_irq(int irq
, void *dev_id
)
1995 struct intelfb_info
*dinfo
= dev_id
;
1997 spin_lock(&dinfo
->int_lock
);
2000 if (dinfo
->info
->var
.vmode
& FB_VMODE_INTERLACED
)
2001 tmp
&= PIPE_A_EVENT_INTERRUPT
;
2003 tmp
&= VSYNC_PIPE_A_INTERRUPT
; /* non-interlaced */
2006 spin_unlock(&dinfo
->int_lock
);
2007 return IRQ_RETVAL(0); /* not us */
2010 /* clear status bits 0-15 ASAP and don't touch bits 16-31 */
2011 OUTREG(PIPEASTAT
, INREG(PIPEASTAT
));
2014 if (dinfo
->vsync
.pan_display
) {
2015 dinfo
->vsync
.pan_display
= 0;
2016 OUTREG(DSPABASE
, dinfo
->vsync
.pan_offset
);
2019 dinfo
->vsync
.count
++;
2020 wake_up_interruptible(&dinfo
->vsync
.wait
);
2022 spin_unlock(&dinfo
->int_lock
);
2024 return IRQ_RETVAL(1);
2027 int intelfbhw_enable_irq(struct intelfb_info
*dinfo
)
2030 if (!test_and_set_bit(0, &dinfo
->irq_flags
)) {
2031 if (request_irq(dinfo
->pdev
->irq
, intelfbhw_irq
, IRQF_SHARED
,
2032 "intelfb", dinfo
)) {
2033 clear_bit(0, &dinfo
->irq_flags
);
2037 spin_lock_irq(&dinfo
->int_lock
);
2038 OUTREG16(HWSTAM
, 0xfffe); /* i830 DRM uses ffff */
2041 spin_lock_irq(&dinfo
->int_lock
);
2043 if (dinfo
->info
->var
.vmode
& FB_VMODE_INTERLACED
)
2044 tmp
= PIPE_A_EVENT_INTERRUPT
;
2046 tmp
= VSYNC_PIPE_A_INTERRUPT
; /* non-interlaced */
2047 if (tmp
!= INREG16(IER
)) {
2048 DBG_MSG("changing IER to 0x%X\n", tmp
);
2052 spin_unlock_irq(&dinfo
->int_lock
);
2056 void intelfbhw_disable_irq(struct intelfb_info
*dinfo
)
2058 if (test_and_clear_bit(0, &dinfo
->irq_flags
)) {
2059 if (dinfo
->vsync
.pan_display
) {
2060 dinfo
->vsync
.pan_display
= 0;
2061 OUTREG(DSPABASE
, dinfo
->vsync
.pan_offset
);
2063 spin_lock_irq(&dinfo
->int_lock
);
2064 OUTREG16(HWSTAM
, 0xffff);
2065 OUTREG16(IMR
, 0xffff);
2068 OUTREG16(IIR
, INREG16(IIR
)); /* clear IRQ requests */
2069 spin_unlock_irq(&dinfo
->int_lock
);
2071 free_irq(dinfo
->pdev
->irq
, dinfo
);
2075 int intelfbhw_wait_for_vsync(struct intelfb_info
*dinfo
, u32 pipe
)
2077 struct intelfb_vsync
*vsync
;
2083 vsync
= &dinfo
->vsync
;
2089 ret
= intelfbhw_enable_irq(dinfo
);
2093 count
= vsync
->count
;
2094 ret
= wait_event_interruptible_timeout(vsync
->wait
,
2095 count
!= vsync
->count
, HZ
/ 10);
2099 DBG_MSG("wait_for_vsync timed out!\n");