4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G
5 * integrated graphics chips.
7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
10 * This driver consists of two parts. The first part (intelfbdrv.c) provides
11 * the basic fbdev interfaces, is derived in part from the radeonfb and
12 * vesafb drivers, and is covered by the GPL. The second part (intelfbhw.c)
13 * provides the code to program the hardware. Most of it is derived from
14 * the i810/i830 XFree86 driver. The HW-specific code is covered here
15 * under a dual license (GPL and MIT/XFree86 license).
21 /* $DHD: intelfb/intelfbdrv.c,v 1.20 2003/06/27 15:17:40 dawes Exp $ */
25 * 01/2003 - Initial driver (0.1.0), no mode switching, no acceleration.
26 * This initial version is a basic core that works a lot like
27 * the vesafb driver. It must be built-in to the kernel,
28 * and the initial video mode must be set with vga=XXX at
29 * boot time. (David Dawes)
31 * 01/2003 - Version 0.2.0: Mode switching added, colormap support
32 * implemented, Y panning, and soft screen blanking implemented.
33 * No acceleration yet. (David Dawes)
35 * 01/2003 - Version 0.3.0: fbcon acceleration support added. Module
36 * option handling added. (David Dawes)
38 * 01/2003 - Version 0.4.0: fbcon HW cursor support added. (David Dawes)
40 * 01/2003 - Version 0.4.1: Add auto-generation of built-in modes.
43 * 02/2003 - Version 0.4.2: Add check for active non-CRT devices, and
44 * mode validation checks. (David Dawes)
46 * 02/2003 - Version 0.4.3: Check when the VC is in graphics mode so that
47 * acceleration is disabled while an XFree86 server is running.
50 * 02/2003 - Version 0.4.4: Monitor DPMS support. (David Dawes)
52 * 02/2003 - Version 0.4.5: Basic XFree86 + fbdev working. (David Dawes)
54 * 02/2003 - Version 0.5.0: Modify to work with the 2.5.32 kernel as well
55 * as 2.4.x kernels. (David Dawes)
57 * 02/2003 - Version 0.6.0: Split out HW-specifics into a separate file.
60 * 02/2003 - Version 0.7.0: Test on 852GM/855GM. Acceleration and HW
61 * cursor are disabled on this platform. (David Dawes)
63 * 02/2003 - Version 0.7.1: Test on 845G. Acceleration is disabled
64 * on this platform. (David Dawes)
66 * 02/2003 - Version 0.7.2: Test on 830M. Acceleration and HW
67 * cursor are disabled on this platform. (David Dawes)
69 * 02/2003 - Version 0.7.3: Fix 8-bit modes for mobile platforms
72 * 02/2003 - Version 0.7.4: Add checks for FB and FBCON_HAS_CFB* configured
73 * in the kernel, and add mode bpp verification and default
74 * bpp selection based on which FBCON_HAS_CFB* are configured.
77 * 02/2003 - Version 0.7.5: Add basic package/install scripts based on the
78 * DRI packaging scripts. (David Dawes)
80 * 04/2003 - Version 0.7.6: Fix typo that affects builds with SMP-enabled
81 * kernels. (David Dawes, reported by Anupam).
83 * 06/2003 - Version 0.7.7:
84 * Fix Makefile.kernel build problem (Tsutomu Yasuda).
85 * Fix mis-placed #endif (2.4.21 kernel).
87 * 09/2004 - Version 0.9.0 - by Sylvain Meyer
88 * Port to linux 2.6 kernel fbdev
89 * Fix HW accel and HW cursor on i845G
90 * Use of agpgart for fb memory reservation
93 * 10/2004 - Version 0.9.1
94 * Use module_param instead of old MODULE_PARM
97 * 11/2004 - Version 0.9.2
98 * Add vram option to reserve more memory than stolen by BIOS
99 * Fix intelfbhw_pan_display typo
100 * Add __initdata annotations
110 #include <linux/config.h>
111 #include <linux/module.h>
112 #include <linux/kernel.h>
113 #include <linux/errno.h>
114 #include <linux/string.h>
115 #include <linux/mm.h>
116 #include <linux/tty.h>
117 #include <linux/slab.h>
118 #include <linux/delay.h>
119 #include <linux/fb.h>
120 #include <linux/console.h>
121 #include <linux/selection.h>
122 #include <linux/ioport.h>
123 #include <linux/init.h>
124 #include <linux/pci.h>
125 #include <linux/vmalloc.h>
126 #include <linux/kd.h>
127 #include <linux/vt_kern.h>
128 #include <linux/pagemap.h>
129 #include <linux/version.h>
134 #include <asm/mtrr.h>
138 #include "intelfbhw.h"
140 static void __devinit
get_initial_mode(struct intelfb_info
*dinfo
);
141 static void update_dinfo(struct intelfb_info
*dinfo
,
142 struct fb_var_screeninfo
*var
);
143 static int intelfb_get_fix(struct fb_fix_screeninfo
*fix
,
144 struct fb_info
*info
);
146 static int intelfb_check_var(struct fb_var_screeninfo
*var
,
147 struct fb_info
*info
);
148 static int intelfb_set_par(struct fb_info
*info
);
149 static int intelfb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
150 unsigned blue
, unsigned transp
,
151 struct fb_info
*info
);
153 static int intelfb_blank(int blank
, struct fb_info
*info
);
154 static int intelfb_pan_display(struct fb_var_screeninfo
*var
,
155 struct fb_info
*info
);
157 static void intelfb_fillrect(struct fb_info
*info
,
158 const struct fb_fillrect
*rect
);
159 static void intelfb_copyarea(struct fb_info
*info
,
160 const struct fb_copyarea
*region
);
161 static void intelfb_imageblit(struct fb_info
*info
,
162 const struct fb_image
*image
);
163 static int intelfb_cursor(struct fb_info
*info
,
164 struct fb_cursor
*cursor
);
166 static int intelfb_sync(struct fb_info
*info
);
168 static int intelfb_ioctl(struct inode
*inode
, struct file
*file
,
169 unsigned int cmd
, unsigned long arg
,
170 struct fb_info
*info
);
172 static int __devinit
intelfb_pci_register(struct pci_dev
*pdev
,
173 const struct pci_device_id
*ent
);
174 static void __devexit
intelfb_pci_unregister(struct pci_dev
*pdev
);
175 static int __devinit
intelfb_set_fbinfo(struct intelfb_info
*dinfo
);
178 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the
179 * mobile chipsets from being registered.
181 #if DETECT_VGA_CLASS_ONLY
182 #define INTELFB_CLASS_MASK ~0 << 8
184 #define INTELFB_CLASS_MASK 0
187 static struct pci_device_id intelfb_pci_table
[] __devinitdata
= {
188 { PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_830M
, PCI_ANY_ID
, PCI_ANY_ID
, PCI_CLASS_DISPLAY_VGA
<< 8, INTELFB_CLASS_MASK
, INTEL_830M
},
189 { PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_845G
, PCI_ANY_ID
, PCI_ANY_ID
, PCI_CLASS_DISPLAY_VGA
<< 8, INTELFB_CLASS_MASK
, INTEL_845G
},
190 { PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_85XGM
, PCI_ANY_ID
, PCI_ANY_ID
, PCI_CLASS_DISPLAY_VGA
<< 8, INTELFB_CLASS_MASK
, INTEL_85XGM
},
191 { PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_865G
, PCI_ANY_ID
, PCI_ANY_ID
, PCI_CLASS_DISPLAY_VGA
<< 8, INTELFB_CLASS_MASK
, INTEL_865G
},
192 { PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_915G
, PCI_ANY_ID
, PCI_ANY_ID
, PCI_CLASS_DISPLAY_VGA
<< 8, INTELFB_CLASS_MASK
, INTEL_915G
},
197 static int num_registered
= 0;
200 static struct fb_ops intel_fb_ops
= {
201 .owner
= THIS_MODULE
,
202 .fb_check_var
= intelfb_check_var
,
203 .fb_set_par
= intelfb_set_par
,
204 .fb_setcolreg
= intelfb_setcolreg
,
205 .fb_blank
= intelfb_blank
,
206 .fb_pan_display
= intelfb_pan_display
,
207 .fb_fillrect
= intelfb_fillrect
,
208 .fb_copyarea
= intelfb_copyarea
,
209 .fb_imageblit
= intelfb_imageblit
,
210 .fb_cursor
= intelfb_cursor
,
211 .fb_sync
= intelfb_sync
,
212 .fb_ioctl
= intelfb_ioctl
215 /* PCI driver module table */
216 static struct pci_driver intelfb_driver
= {
218 .id_table
= intelfb_pci_table
,
219 .probe
= intelfb_pci_register
,
220 .remove
= __devexit_p(intelfb_pci_unregister
)
223 /* Module description/parameters */
224 MODULE_AUTHOR("David Dawes <dawes@tungstengraphics.com>, "
225 "Sylvain Meyer <sylvain.meyer@worldonline.fr>");
227 "Framebuffer driver for Intel(R) " SUPPORTED_CHIPSETS
" chipsets");
228 MODULE_LICENSE("Dual BSD/GPL");
229 MODULE_DEVICE_TABLE(pci
, intelfb_pci_table
);
231 static int accel
= 1;
233 static int hwcursor
= 1;
235 static int fixed
= 0;
236 static int noinit
= 0;
237 static int noregister
= 0;
238 static int probeonly
= 0;
239 static int idonly
= 0;
240 static int bailearly
= 0;
241 static int voffset
= 48;
242 static char *mode
= NULL
;
244 module_param(accel
, bool, S_IRUGO
);
245 MODULE_PARM_DESC(accel
, "Enable console acceleration");
246 module_param(vram
, int, S_IRUGO
);
247 MODULE_PARM_DESC(vram
, "System RAM to allocate to framebuffer in MiB");
248 module_param(voffset
, int, S_IRUGO
);
249 MODULE_PARM_DESC(voffset
, "Offset of framebuffer in MiB");
250 module_param(hwcursor
, bool, S_IRUGO
);
251 MODULE_PARM_DESC(hwcursor
, "Enable HW cursor");
252 module_param(mtrr
, bool, S_IRUGO
);
253 MODULE_PARM_DESC(mtrr
, "Enable MTRR support");
254 module_param(fixed
, bool, S_IRUGO
);
255 MODULE_PARM_DESC(fixed
, "Disable mode switching");
256 module_param(noinit
, bool, 0);
257 MODULE_PARM_DESC(noinit
, "Don't initialise graphics mode when loading");
258 module_param(noregister
, bool, 0);
259 MODULE_PARM_DESC(noregister
, "Don't register, just probe and exit (debug)");
260 module_param(probeonly
, bool, 0);
261 MODULE_PARM_DESC(probeonly
, "Do a minimal probe (debug)");
262 module_param(idonly
, bool, 0);
263 MODULE_PARM_DESC(idonly
, "Just identify without doing anything else (debug)");
264 module_param(bailearly
, bool, 0);
265 MODULE_PARM_DESC(bailearly
, "Bail out early, depending on value (debug)");
266 module_param(mode
, charp
, S_IRUGO
);
267 MODULE_PARM_DESC(mode
,
268 "Initial video mode \"<xres>x<yres>[-<depth>][@<refresh>]\"");
271 #define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name)))
272 #define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name), NULL, 0)
273 #define OPT_STRVAL(opt, name) (opt + strlen(name))
275 static __inline__
char *
276 get_opt_string(const char *this_opt
, const char *name
)
282 p
= OPT_STRVAL(this_opt
, name
);
284 while (p
[i
] && p
[i
] != ' ' && p
[i
] != ',')
286 ret
= kmalloc(i
+ 1, GFP_KERNEL
);
294 static __inline__
int
295 get_opt_int(const char *this_opt
, const char *name
, int *ret
)
300 if (!OPT_EQUAL(this_opt
, name
))
303 *ret
= OPT_INTVAL(this_opt
, name
);
307 static __inline__
int
308 get_opt_bool(const char *this_opt
, const char *name
, int *ret
)
313 if (OPT_EQUAL(this_opt
, name
)) {
314 if (this_opt
[strlen(name
)] == '=')
315 *ret
= simple_strtoul(this_opt
+ strlen(name
) + 1,
320 if (OPT_EQUAL(this_opt
, "no") && OPT_EQUAL(this_opt
+ 2, name
))
329 intelfb_setup(char *options
)
333 DBG_MSG("intelfb_setup\n");
335 if (!options
|| !*options
) {
336 DBG_MSG("no options\n");
339 DBG_MSG("options: %s\n", options
);
342 * These are the built-in options analogous to the module parameters
347 * video=intelfb:[mode][,<param>=<val>] ...
351 * video=intelfb:1024x768-16@75,accel=0
354 while ((this_opt
= strsep(&options
, ","))) {
357 if (get_opt_bool(this_opt
, "accel", &accel
))
359 else if (get_opt_int(this_opt
, "vram", &vram
))
361 else if (get_opt_bool(this_opt
, "hwcursor", &hwcursor
))
363 else if (get_opt_bool(this_opt
, "mtrr", &mtrr
))
365 else if (get_opt_bool(this_opt
, "fixed", &fixed
))
367 else if (get_opt_bool(this_opt
, "init", &noinit
))
369 else if (OPT_EQUAL(this_opt
, "mode="))
370 mode
= get_opt_string(this_opt
, "mode=");
387 DBG_MSG("intelfb_init\n");
389 INF_MSG("Framebuffer driver for "
390 "Intel(R) " SUPPORTED_CHIPSETS
" chipsets\n");
391 INF_MSG("Version " INTELFB_VERSION
"\n");
397 if (fb_get_options("intelfb", &option
))
399 intelfb_setup(option
);
402 return pci_register_driver(&intelfb_driver
);
408 DBG_MSG("intelfb_exit\n");
409 pci_unregister_driver(&intelfb_driver
);
412 module_init(intelfb_init
);
413 module_exit(intelfb_exit
);
415 /***************************************************************
416 * mtrr support functions *
417 ***************************************************************/
420 static inline void __devinit
set_mtrr(struct intelfb_info
*dinfo
)
422 dinfo
->mtrr_reg
= mtrr_add(dinfo
->aperture
.physical
,
423 dinfo
->aperture
.size
, MTRR_TYPE_WRCOMB
, 1);
424 if (dinfo
->mtrr_reg
< 0) {
425 ERR_MSG("unable to set MTRR\n");
430 static inline void unset_mtrr(struct intelfb_info
*dinfo
)
433 mtrr_del(dinfo
->mtrr_reg
, dinfo
->aperture
.physical
,
434 dinfo
->aperture
.size
);
437 #define set_mtrr(x) WRN_MSG("MTRR is disabled in the kernel\n")
439 #define unset_mtrr(x) do { } while (0)
440 #endif /* CONFIG_MTRR */
442 /***************************************************************
443 * driver init / cleanup *
444 ***************************************************************/
447 cleanup(struct intelfb_info
*dinfo
)
449 DBG_MSG("cleanup\n");
454 fb_dealloc_cmap(&dinfo
->info
->cmap
);
455 kfree(dinfo
->info
->pixmap
.addr
);
457 if (dinfo
->registered
)
458 unregister_framebuffer(dinfo
->info
);
462 if (dinfo
->fbmem_gart
&& dinfo
->gtt_fb_mem
) {
463 agp_unbind_memory(dinfo
->gtt_fb_mem
);
464 agp_free_memory(dinfo
->gtt_fb_mem
);
466 if (dinfo
->gtt_cursor_mem
) {
467 agp_unbind_memory(dinfo
->gtt_cursor_mem
);
468 agp_free_memory(dinfo
->gtt_cursor_mem
);
470 if (dinfo
->gtt_ring_mem
) {
471 agp_unbind_memory(dinfo
->gtt_ring_mem
);
472 agp_free_memory(dinfo
->gtt_ring_mem
);
475 if (dinfo
->mmio_base
)
476 iounmap((void __iomem
*)dinfo
->mmio_base
);
477 if (dinfo
->aperture
.virtual)
478 iounmap((void __iomem
*)dinfo
->aperture
.virtual);
480 if (dinfo
->mmio_base_phys
)
481 release_mem_region(dinfo
->mmio_base_phys
, INTEL_REG_SIZE
);
482 if (dinfo
->aperture
.physical
)
483 release_mem_region(dinfo
->aperture
.physical
,
484 dinfo
->aperture
.size
);
485 framebuffer_release(dinfo
->info
);
488 #define bailout(dinfo) do { \
489 DBG_MSG("bailout\n"); \
491 INF_MSG("Not going to register framebuffer, exiting...\n"); \
497 intelfb_pci_register(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
499 struct fb_info
*info
;
500 struct intelfb_info
*dinfo
;
502 int aperture_size
, stolen_size
;
503 struct agp_kern_info gtt_info
;
506 struct agp_bridge_data
*bridge
;
507 int aperture_bar
= 0;
511 DBG_MSG("intelfb_pci_register\n");
514 if (num_registered
!= 1) {
515 ERR_MSG("Attempted to register %d devices "
516 "(should be only 1).\n", num_registered
);
520 info
= framebuffer_alloc(sizeof(struct intelfb_info
), &pdev
->dev
);
522 ERR_MSG("Could not allocate memory for intelfb_info.\n");
525 if (fb_alloc_cmap(&info
->cmap
, 256, 1) < 0) {
526 ERR_MSG("Could not allocate cmap for intelfb_info.\n");
533 dinfo
->fbops
= &intel_fb_ops
;
536 /* Reserve pixmap space. */
537 info
->pixmap
.addr
= kmalloc(64 * 1024, GFP_KERNEL
);
538 if (info
->pixmap
.addr
== NULL
) {
539 ERR_MSG("Cannot reserve pixmap memory.\n");
542 memset(info
->pixmap
.addr
, 0, 64 * 1024);
544 /* set early this option because it could be changed by tv encoder
546 dinfo
->fixed_mode
= fixed
;
549 if ((err
= pci_enable_device(pdev
))) {
550 ERR_MSG("Cannot enable device.\n");
555 /* Set base addresses. */
556 if (ent
->device
== PCI_DEVICE_ID_INTEL_915G
) {
559 /* Disable HW cursor on 915G (not implemented yet) */
562 dinfo
->aperture
.physical
= pci_resource_start(pdev
, aperture_bar
);
563 dinfo
->aperture
.size
= pci_resource_len(pdev
, aperture_bar
);
564 dinfo
->mmio_base_phys
= pci_resource_start(pdev
, mmio_bar
);
565 DBG_MSG("fb aperture: 0x%llx/0x%llx, MMIO region: 0x%llx/0x%llx\n",
566 (unsigned long long)pci_resource_start(pdev
, aperture_bar
),
567 (unsigned long long)pci_resource_len(pdev
, aperture_bar
),
568 (unsigned long long)pci_resource_start(pdev
, mmio_bar
),
569 (unsigned long long)pci_resource_len(pdev
, mmio_bar
));
571 /* Reserve the fb and MMIO regions */
572 if (!request_mem_region(dinfo
->aperture
.physical
, dinfo
->aperture
.size
,
573 INTELFB_MODULE_NAME
)) {
574 ERR_MSG("Cannot reserve FB region.\n");
578 if (!request_mem_region(dinfo
->mmio_base_phys
,
580 INTELFB_MODULE_NAME
)) {
581 ERR_MSG("Cannot reserve MMIO region.\n");
586 /* Get the chipset info. */
587 dinfo
->pci_chipset
= pdev
->device
;
589 if (intelfbhw_get_chipset(pdev
, &dinfo
->name
, &dinfo
->chipset
,
595 if (intelfbhw_get_memory(pdev
, &aperture_size
,&stolen_size
)) {
600 INF_MSG("%02x:%02x.%d: %s, aperture size %dMB, "
601 "stolen memory %dkB\n",
602 pdev
->bus
->number
, PCI_SLOT(pdev
->devfn
),
603 PCI_FUNC(pdev
->devfn
), dinfo
->name
,
604 BtoMB(aperture_size
), BtoKB(stolen_size
));
606 /* Set these from the options. */
607 dinfo
->accel
= accel
;
608 dinfo
->hwcursor
= hwcursor
;
610 if (NOACCEL_CHIPSET(dinfo
) && dinfo
->accel
== 1) {
611 INF_MSG("Acceleration is not supported for the %s chipset.\n",
616 if (MB(voffset
) < stolen_size
)
617 offset
= (stolen_size
>> 12);
619 offset
= ROUND_UP_TO_PAGE(MB(voffset
))/GTT_PAGE_SIZE
;
621 /* Framebuffer parameters - Use all the stolen memory if >= vram */
622 if (ROUND_UP_TO_PAGE(stolen_size
) >= ((offset
<< 12) + MB(vram
))) {
623 dinfo
->fb
.size
= ROUND_UP_TO_PAGE(stolen_size
);
624 dinfo
->fb
.offset
= 0;
625 dinfo
->fbmem_gart
= 0;
627 dinfo
->fb
.size
= MB(vram
);
628 dinfo
->fbmem_gart
= 1;
631 /* Allocate space for the ring buffer and HW cursor if enabled. */
633 dinfo
->ring
.size
= RINGBUFFER_SIZE
;
634 dinfo
->ring_tail_mask
= dinfo
->ring
.size
- 1;
636 if (dinfo
->hwcursor
) {
637 dinfo
->cursor
.size
= HW_CURSOR_SIZE
;
640 /* Use agpgart to manage the GATT */
641 if (!(bridge
= agp_backend_acquire(pdev
))) {
642 ERR_MSG("cannot acquire agp\n");
647 /* get the current gatt info */
648 if (agp_copy_info(bridge
, >t_info
)) {
649 ERR_MSG("cannot get agp info\n");
650 agp_backend_release(bridge
);
655 /* set the mem offsets - set them after the already used pages */
657 dinfo
->ring
.offset
= offset
+ gtt_info
.current_memory
;
659 if (dinfo
->hwcursor
) {
660 dinfo
->cursor
.offset
= offset
+
661 + gtt_info
.current_memory
+ (dinfo
->ring
.size
>> 12);
663 if (dinfo
->fbmem_gart
) {
664 dinfo
->fb
.offset
= offset
+
665 + gtt_info
.current_memory
+ (dinfo
->ring
.size
>> 12)
666 + (dinfo
->cursor
.size
>> 12);
669 /* Map the fb and MMIO regions */
670 /* ioremap only up to the end of used aperture */
671 dinfo
->aperture
.virtual = (u8 __iomem
*)ioremap_nocache
672 (dinfo
->aperture
.physical
, (dinfo
->fb
.offset
<< 12)
674 if (!dinfo
->aperture
.virtual) {
675 ERR_MSG("Cannot remap FB region.\n");
681 (u8 __iomem
*)ioremap_nocache(dinfo
->mmio_base_phys
,
683 if (!dinfo
->mmio_base
) {
684 ERR_MSG("Cannot remap MMIO region.\n");
689 /* Allocate memories (which aren't stolen) */
691 if (!(dinfo
->gtt_ring_mem
=
692 agp_allocate_memory(bridge
, dinfo
->ring
.size
>> 12,
693 AGP_NORMAL_MEMORY
))) {
694 ERR_MSG("cannot allocate ring buffer memory\n");
695 agp_backend_release(bridge
);
699 if (agp_bind_memory(dinfo
->gtt_ring_mem
,
700 dinfo
->ring
.offset
)) {
701 ERR_MSG("cannot bind ring buffer memory\n");
702 agp_backend_release(bridge
);
706 dinfo
->ring
.physical
= dinfo
->aperture
.physical
707 + (dinfo
->ring
.offset
<< 12);
708 dinfo
->ring
.virtual = dinfo
->aperture
.virtual
709 + (dinfo
->ring
.offset
<< 12);
710 dinfo
->ring_head
= dinfo
->ring
.virtual;
712 if (dinfo
->hwcursor
) {
713 agp_memtype
= dinfo
->mobile
? AGP_PHYSICAL_MEMORY
715 if (!(dinfo
->gtt_cursor_mem
=
716 agp_allocate_memory(bridge
, dinfo
->cursor
.size
>> 12,
718 ERR_MSG("cannot allocate cursor memory\n");
719 agp_backend_release(bridge
);
723 if (agp_bind_memory(dinfo
->gtt_cursor_mem
,
724 dinfo
->cursor
.offset
)) {
725 ERR_MSG("cannot bind cursor memory\n");
726 agp_backend_release(bridge
);
731 dinfo
->cursor
.physical
732 = dinfo
->gtt_cursor_mem
->physical
;
734 dinfo
->cursor
.physical
= dinfo
->aperture
.physical
735 + (dinfo
->cursor
.offset
<< 12);
736 dinfo
->cursor
.virtual = dinfo
->aperture
.virtual
737 + (dinfo
->cursor
.offset
<< 12);
739 if (dinfo
->fbmem_gart
) {
740 if (!(dinfo
->gtt_fb_mem
=
741 agp_allocate_memory(bridge
, dinfo
->fb
.size
>> 12,
742 AGP_NORMAL_MEMORY
))) {
743 WRN_MSG("cannot allocate framebuffer memory - use "
745 dinfo
->fbmem_gart
= 0;
747 if (agp_bind_memory(dinfo
->gtt_fb_mem
,
749 WRN_MSG("cannot bind framebuffer memory - use "
751 dinfo
->fbmem_gart
= 0;
755 /* update framebuffer memory parameters */
756 if (!dinfo
->fbmem_gart
)
757 dinfo
->fb
.offset
= 0; /* starts at offset 0 */
758 dinfo
->fb
.physical
= dinfo
->aperture
.physical
759 + (dinfo
->fb
.offset
<< 12);
760 dinfo
->fb
.virtual = dinfo
->aperture
.virtual + (dinfo
->fb
.offset
<< 12);
761 dinfo
->fb_start
= dinfo
->fb
.offset
<< 12;
763 /* release agpgart */
764 agp_backend_release(bridge
);
769 DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%x)\n",
770 dinfo
->fb
.physical
, dinfo
->fb
.offset
, dinfo
->fb
.size
,
771 (u32 __iomem
) dinfo
->fb
.virtual);
772 DBG_MSG("MMIO: 0x%x/0x%x (0x%x)\n",
773 dinfo
->mmio_base_phys
, INTEL_REG_SIZE
,
774 (u32 __iomem
) dinfo
->mmio_base
);
775 DBG_MSG("ring buffer: 0x%x/0x%x (0x%x)\n",
776 dinfo
->ring
.physical
, dinfo
->ring
.size
,
777 (u32 __iomem
) dinfo
->ring
.virtual);
778 DBG_MSG("HW cursor: 0x%x/0x%x (0x%x) (offset 0x%x) (phys 0x%x)\n",
779 dinfo
->cursor
.physical
, dinfo
->cursor
.size
,
780 (u32 __iomem
) dinfo
->cursor
.virtual, dinfo
->cursor
.offset
,
781 dinfo
->cursor
.physical
);
783 DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, "
784 "noinit = %d\n", vram
, accel
, hwcursor
, fixed
, noinit
);
785 DBG_MSG("options: mode = \"%s\"\n", mode
? mode
: "");
791 * Check if the LVDS port or any DVO ports are enabled. If so,
792 * don't allow mode switching
794 dvo
= intelfbhw_check_non_crt(dinfo
);
796 dinfo
->fixed_mode
= 1;
797 WRN_MSG("Non-CRT device is enabled ( ");
801 s
= intelfbhw_dvo_to_string(1 << i
);
808 printk("). Disabling mode switching.\n");
814 if (FIXED_MODE(dinfo
) && ORIG_VIDEO_ISVGA
!= VIDEO_TYPE_VLFB
) {
815 ERR_MSG("Video mode must be programmed at boot time.\n");
823 /* Initialise dinfo and related data. */
824 /* If an initial mode was programmed at boot time, get its details. */
825 if (ORIG_VIDEO_ISVGA
== VIDEO_TYPE_VLFB
)
826 get_initial_mode(dinfo
);
831 if (FIXED_MODE(dinfo
)) {
832 /* remap fb address */
833 update_dinfo(dinfo
, &dinfo
->initial_var
);
840 if (intelfb_set_fbinfo(dinfo
)) {
848 for (i
= 0; i
< 16; i
++) {
850 dinfo
->palette
[i
].red
= default_red
[j
];
851 dinfo
->palette
[i
].green
= default_grn
[j
];
852 dinfo
->palette
[i
].blue
= default_blu
[j
];
858 pci_set_drvdata(pdev
, dinfo
);
860 /* Save the initial register state. */
861 i
= intelfbhw_read_hw_state(dinfo
, &dinfo
->save_state
,
862 bailearly
> 6 ? bailearly
- 6 : 0);
864 DBG_MSG("intelfbhw_read_hw_state returned %d\n", i
);
868 intelfbhw_print_hw_state(dinfo
, &dinfo
->save_state
);
873 /* Cursor initialisation */
874 if (dinfo
->hwcursor
) {
875 intelfbhw_cursor_init(dinfo
);
876 intelfbhw_cursor_reset(dinfo
);
882 /* 2d acceleration init */
884 intelfbhw_2d_start(dinfo
);
892 if (register_framebuffer(dinfo
->info
) < 0) {
893 ERR_MSG("Cannot register framebuffer.\n");
898 dinfo
->registered
= 1;
903 fb_dealloc_cmap(&info
->cmap
);
905 framebuffer_release(info
);
909 static void __devexit
910 intelfb_pci_unregister(struct pci_dev
*pdev
)
912 struct intelfb_info
*dinfo
= pci_get_drvdata(pdev
);
914 DBG_MSG("intelfb_pci_unregister\n");
921 pci_set_drvdata(pdev
, NULL
);
924 /***************************************************************
926 ***************************************************************/
929 intelfb_var_to_depth(const struct fb_var_screeninfo
*var
)
931 DBG_MSG("intelfb_var_to_depth: bpp: %d, green.length is %d\n",
932 var
->bits_per_pixel
, var
->green
.length
);
934 switch (var
->bits_per_pixel
) {
936 return (var
->green
.length
== 6) ? 16 : 15;
940 return var
->bits_per_pixel
;
945 static __inline__
int
946 var_to_refresh(const struct fb_var_screeninfo
*var
)
948 int xtot
= var
->xres
+ var
->left_margin
+ var
->right_margin
+
950 int ytot
= var
->yres
+ var
->upper_margin
+ var
->lower_margin
+
953 return (1000000000 / var
->pixclock
* 1000 + 500) / xtot
/ ytot
;
956 /***************************************************************
957 * Various intialisation functions *
958 ***************************************************************/
960 static void __devinit
961 get_initial_mode(struct intelfb_info
*dinfo
)
963 struct fb_var_screeninfo
*var
;
966 DBG_MSG("get_initial_mode\n");
968 dinfo
->initial_vga
= 1;
969 dinfo
->initial_fb_base
= screen_info
.lfb_base
;
970 dinfo
->initial_video_ram
= screen_info
.lfb_size
* KB(64);
971 dinfo
->initial_pitch
= screen_info
.lfb_linelength
;
973 var
= &dinfo
->initial_var
;
974 memset(var
, 0, sizeof(*var
));
975 var
->xres
= screen_info
.lfb_width
;
976 var
->yres
= screen_info
.lfb_height
;
977 var
->bits_per_pixel
= screen_info
.lfb_depth
;
978 switch (screen_info
.lfb_depth
) {
980 var
->bits_per_pixel
= 16;
983 var
->bits_per_pixel
= 32;
987 DBG_MSG("Initial info: FB is 0x%x/0x%x (%d kByte)\n",
988 dinfo
->initial_fb_base
, dinfo
->initial_video_ram
,
989 BtoKB(dinfo
->initial_video_ram
));
991 DBG_MSG("Initial info: mode is %dx%d-%d (%d)\n",
992 var
->xres
, var
->yres
, var
->bits_per_pixel
,
993 dinfo
->initial_pitch
);
995 /* Dummy timing values (assume 60Hz) */
996 var
->left_margin
= (var
->xres
/ 8) & 0xf8;
997 var
->right_margin
= 32;
998 var
->upper_margin
= 16;
999 var
->lower_margin
= 4;
1000 var
->hsync_len
= (var
->xres
/ 8) & 0xf8;
1003 xtot
= var
->xres
+ var
->left_margin
+
1004 var
->right_margin
+ var
->hsync_len
;
1005 ytot
= var
->yres
+ var
->upper_margin
+
1006 var
->lower_margin
+ var
->vsync_len
;
1007 var
->pixclock
= 10000000 / xtot
* 1000 / ytot
* 100 / 60;
1012 if (var
->bits_per_pixel
> 8) {
1013 var
->red
.offset
= screen_info
.red_pos
;
1014 var
->red
.length
= screen_info
.red_size
;
1015 var
->green
.offset
= screen_info
.green_pos
;
1016 var
->green
.length
= screen_info
.green_size
;
1017 var
->blue
.offset
= screen_info
.blue_pos
;
1018 var
->blue
.length
= screen_info
.blue_size
;
1019 var
->transp
.offset
= screen_info
.rsvd_pos
;
1020 var
->transp
.length
= screen_info
.rsvd_size
;
1022 var
->red
.length
= 8;
1023 var
->green
.length
= 8;
1024 var
->blue
.length
= 8;
1028 static int __devinit
1029 intelfb_init_var(struct intelfb_info
*dinfo
)
1031 struct fb_var_screeninfo
*var
;
1034 DBG_MSG("intelfb_init_var\n");
1036 var
= &dinfo
->info
->var
;
1037 if (FIXED_MODE(dinfo
)) {
1038 memcpy(var
, &dinfo
->initial_var
,
1039 sizeof(struct fb_var_screeninfo
));
1043 msrc
= fb_find_mode(var
, dinfo
->info
, mode
,
1044 vesa_modes
, VESA_MODEDB_SIZE
,
1050 msrc
= fb_find_mode(var
, dinfo
->info
, PREFERRED_MODE
,
1051 vesa_modes
, VESA_MODEDB_SIZE
,
1057 ERR_MSG("Cannot find a suitable video mode.\n");
1061 INF_MSG("Initial video mode is %dx%d-%d@%d.\n", var
->xres
, var
->yres
,
1062 var
->bits_per_pixel
, var_to_refresh(var
));
1064 DBG_MSG("Initial video mode is from %d.\n", msrc
);
1066 #if ALLOCATE_FOR_PANNING
1067 /* Allow use of half of the video ram for panning */
1068 var
->xres_virtual
= var
->xres
;
1070 dinfo
->fb
.size
/ 2 / (var
->bits_per_pixel
* var
->xres
);
1071 if (var
->yres_virtual
< var
->yres
)
1072 var
->yres_virtual
= var
->yres
;
1074 var
->yres_virtual
= var
->yres
;
1078 var
->accel_flags
|= FB_ACCELF_TEXT
;
1080 var
->accel_flags
&= ~FB_ACCELF_TEXT
;
1085 static int __devinit
1086 intelfb_set_fbinfo(struct intelfb_info
*dinfo
)
1088 struct fb_info
*info
= dinfo
->info
;
1090 DBG_MSG("intelfb_set_fbinfo\n");
1092 info
->flags
= FBINFO_FLAG_DEFAULT
;
1093 info
->fbops
= &intel_fb_ops
;
1094 info
->pseudo_palette
= dinfo
->pseudo_palette
;
1096 info
->pixmap
.size
= 64*1024;
1097 info
->pixmap
.buf_align
= 8;
1098 info
->pixmap
.access_align
= 32;
1099 info
->pixmap
.flags
= FB_PIXMAP_SYSTEM
;
1101 if (intelfb_init_var(dinfo
))
1104 info
->pixmap
.scan_align
= 1;
1106 update_dinfo(dinfo
, &info
->var
);
1111 /* Update dinfo to match the active video mode. */
1113 update_dinfo(struct intelfb_info
*dinfo
, struct fb_var_screeninfo
*var
)
1115 DBG_MSG("update_dinfo\n");
1117 dinfo
->bpp
= var
->bits_per_pixel
;
1118 dinfo
->depth
= intelfb_var_to_depth(var
);
1119 dinfo
->xres
= var
->xres
;
1120 dinfo
->yres
= var
->xres
;
1121 dinfo
->pixclock
= var
->pixclock
;
1123 intelfb_get_fix(&dinfo
->info
->fix
, dinfo
->info
);
1125 switch (dinfo
->bpp
) {
1127 dinfo
->visual
= FB_VISUAL_PSEUDOCOLOR
;
1128 dinfo
->pitch
= var
->xres_virtual
;
1131 dinfo
->visual
= FB_VISUAL_TRUECOLOR
;
1132 dinfo
->pitch
= var
->xres_virtual
* 2;
1135 dinfo
->visual
= FB_VISUAL_TRUECOLOR
;
1136 dinfo
->pitch
= var
->xres_virtual
* 4;
1140 /* Make sure the line length is a aligned correctly. */
1141 dinfo
->pitch
= ROUND_UP_TO(dinfo
->pitch
, STRIDE_ALIGNMENT
);
1143 if (FIXED_MODE(dinfo
))
1144 dinfo
->pitch
= dinfo
->initial_pitch
;
1146 dinfo
->info
->screen_base
= (char __iomem
*)dinfo
->fb
.virtual;
1147 dinfo
->info
->fix
.line_length
= dinfo
->pitch
;
1148 dinfo
->info
->fix
.visual
= dinfo
->visual
;
1151 /* fbops functions */
1154 intelfb_get_fix(struct fb_fix_screeninfo
*fix
, struct fb_info
*info
)
1156 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1158 DBG_MSG("intelfb_get_fix\n");
1160 memset(fix
, 0, sizeof(*fix
));
1161 strcpy(fix
->id
, dinfo
->name
);
1162 fix
->smem_start
= dinfo
->fb
.physical
;
1163 fix
->smem_len
= dinfo
->fb
.size
;
1164 fix
->type
= FB_TYPE_PACKED_PIXELS
;
1166 fix
->visual
= dinfo
->visual
;
1170 fix
->line_length
= dinfo
->pitch
;
1171 fix
->mmio_start
= dinfo
->mmio_base_phys
;
1172 fix
->mmio_len
= INTEL_REG_SIZE
;
1173 fix
->accel
= FB_ACCEL_I830
;
1177 /***************************************************************
1179 ***************************************************************/
1182 intelfb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
1185 struct fb_var_screeninfo v
;
1186 struct intelfb_info
*dinfo
;
1187 static int first
= 1;
1189 DBG_MSG("intelfb_check_var: accel_flags is %d\n", var
->accel_flags
);
1191 dinfo
= GET_DINFO(info
);
1193 if (intelfbhw_validate_mode(dinfo
, var
) != 0)
1198 /* Check for a supported bpp. */
1199 if (v
.bits_per_pixel
<= 8) {
1200 v
.bits_per_pixel
= 8;
1201 } else if (v
.bits_per_pixel
<= 16) {
1202 if (v
.bits_per_pixel
== 16)
1204 v
.bits_per_pixel
= 16;
1205 } else if (v
.bits_per_pixel
<= 32) {
1206 v
.bits_per_pixel
= 32;
1210 change_var
= ((info
->var
.xres
!= var
->xres
) ||
1211 (info
->var
.yres
!= var
->yres
) ||
1212 (info
->var
.xres_virtual
!= var
->xres_virtual
) ||
1213 (info
->var
.yres_virtual
!= var
->yres_virtual
) ||
1214 (info
->var
.bits_per_pixel
!= var
->bits_per_pixel
) ||
1215 memcmp(&info
->var
.red
, &var
->red
, sizeof(var
->red
)) ||
1216 memcmp(&info
->var
.green
, &var
->green
,
1217 sizeof(var
->green
)) ||
1218 memcmp(&info
->var
.blue
, &var
->blue
, sizeof(var
->blue
)));
1220 if (FIXED_MODE(dinfo
) &&
1222 var
->yres_virtual
> dinfo
->initial_var
.yres_virtual
||
1223 var
->yres_virtual
< dinfo
->initial_var
.yres
||
1224 var
->xoffset
|| var
->nonstd
)) {
1226 ERR_MSG("Changing the video mode is not supported.\n");
1232 switch (intelfb_var_to_depth(&v
)) {
1234 v
.red
.offset
= v
.green
.offset
= v
.blue
.offset
= 0;
1235 v
.red
.length
= v
.green
.length
= v
.blue
.length
= 8;
1236 v
.transp
.offset
= v
.transp
.length
= 0;
1242 v
.red
.length
= v
.green
.length
= v
.blue
.length
= 5;
1243 v
.transp
.offset
= v
.transp
.length
= 0;
1252 v
.transp
.offset
= v
.transp
.length
= 0;
1258 v
.red
.length
= v
.green
.length
= v
.blue
.length
= 8;
1259 v
.transp
.offset
= v
.transp
.length
= 0;
1265 v
.red
.length
= v
.green
.length
= v
.blue
.length
= 8;
1266 v
.transp
.offset
= 24;
1267 v
.transp
.length
= 8;
1276 if (v
.xoffset
> v
.xres_virtual
- v
.xres
)
1277 v
.xoffset
= v
.xres_virtual
- v
.xres
;
1278 if (v
.yoffset
> v
.yres_virtual
- v
.yres
)
1279 v
.yoffset
= v
.yres_virtual
- v
.yres
;
1281 v
.red
.msb_right
= v
.green
.msb_right
= v
.blue
.msb_right
=
1282 v
.transp
.msb_right
= 0;
1290 intelfb_set_par(struct fb_info
*info
)
1292 struct intelfb_hwstate
*hw
;
1293 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1295 if (FIXED_MODE(dinfo
)) {
1296 ERR_MSG("Changing the video mode is not supported.\n");
1300 hw
= kmalloc(sizeof(*hw
), GFP_ATOMIC
);
1304 DBG_MSG("intelfb_set_par (%dx%d-%d)\n", info
->var
.xres
,
1305 info
->var
.yres
, info
->var
.bits_per_pixel
);
1307 intelfb_blank(FB_BLANK_POWERDOWN
, info
);
1309 if (ACCEL(dinfo
, info
))
1310 intelfbhw_2d_stop(dinfo
);
1312 memcpy(hw
, &dinfo
->save_state
, sizeof(*hw
));
1313 if (intelfbhw_mode_to_hw(dinfo
, hw
, &info
->var
))
1315 if (intelfbhw_program_mode(dinfo
, hw
, 0))
1319 intelfbhw_read_hw_state(dinfo
, hw
, 0);
1320 intelfbhw_print_hw_state(dinfo
, hw
);
1323 update_dinfo(dinfo
, &info
->var
);
1325 if (ACCEL(dinfo
, info
))
1326 intelfbhw_2d_start(dinfo
);
1328 intelfb_pan_display(&info
->var
, info
);
1330 intelfb_blank(FB_BLANK_UNBLANK
, info
);
1332 if (ACCEL(dinfo
, info
)) {
1333 info
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
|
1334 FBINFO_HWACCEL_COPYAREA
| FBINFO_HWACCEL_FILLRECT
|
1335 FBINFO_HWACCEL_IMAGEBLIT
;
1337 info
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1347 intelfb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
1348 unsigned blue
, unsigned transp
, struct fb_info
*info
)
1350 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1353 DBG_MSG("intelfb_setcolreg: regno %d, depth %d\n", regno
, dinfo
->depth
);
1359 switch (dinfo
->depth
) {
1366 dinfo
->palette
[regno
].red
= red
;
1367 dinfo
->palette
[regno
].green
= green
;
1368 dinfo
->palette
[regno
].blue
= blue
;
1370 intelfbhw_setcolreg(dinfo
, regno
, red
, green
, blue
,
1375 dinfo
->pseudo_palette
[regno
] = ((red
& 0xf800) >> 1) |
1376 ((green
& 0xf800) >> 6) |
1377 ((blue
& 0xf800) >> 11);
1380 dinfo
->pseudo_palette
[regno
] = (red
& 0xf800) |
1381 ((green
& 0xfc00) >> 5) |
1382 ((blue
& 0xf800) >> 11);
1385 dinfo
->pseudo_palette
[regno
] = ((red
& 0xff00) << 8) |
1387 ((blue
& 0xff00) >> 8);
1394 intelfb_blank(int blank
, struct fb_info
*info
)
1396 intelfbhw_do_blank(blank
, info
);
1401 intelfb_pan_display(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
1403 intelfbhw_pan_display(var
, info
);
1407 /* When/if we have our own ioctls. */
1409 intelfb_ioctl(struct inode
*inode
, struct file
*file
, unsigned int cmd
,
1410 unsigned long arg
, struct fb_info
*info
)
1418 intelfb_fillrect (struct fb_info
*info
, const struct fb_fillrect
*rect
)
1420 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1424 DBG_MSG("intelfb_fillrect\n");
1427 if (!ACCEL(dinfo
, info
) || dinfo
->depth
== 4)
1428 return cfb_fillrect(info
, rect
);
1430 if (rect
->rop
== ROP_COPY
)
1431 rop
= PAT_ROP_GXCOPY
;
1433 rop
= PAT_ROP_GXXOR
;
1435 if (dinfo
->depth
!= 8)
1436 color
= dinfo
->pseudo_palette
[rect
->color
];
1438 color
= rect
->color
;
1440 intelfbhw_do_fillrect(dinfo
, rect
->dx
, rect
->dy
,
1441 rect
->width
, rect
->height
, color
,
1442 dinfo
->pitch
, info
->var
.bits_per_pixel
,
1447 intelfb_copyarea(struct fb_info
*info
, const struct fb_copyarea
*region
)
1449 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1452 DBG_MSG("intelfb_copyarea\n");
1455 if (!ACCEL(dinfo
, info
) || dinfo
->depth
== 4)
1456 return cfb_copyarea(info
, region
);
1458 intelfbhw_do_bitblt(dinfo
, region
->sx
, region
->sy
, region
->dx
,
1459 region
->dy
, region
->width
, region
->height
,
1460 dinfo
->pitch
, info
->var
.bits_per_pixel
);
1464 intelfb_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
1466 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1467 u32 fgcolor
, bgcolor
;
1470 DBG_MSG("intelfb_imageblit\n");
1473 if (!ACCEL(dinfo
, info
) || dinfo
->depth
== 4
1474 || image
->depth
!= 1)
1475 return cfb_imageblit(info
, image
);
1477 if (dinfo
->depth
!= 8) {
1478 fgcolor
= dinfo
->pseudo_palette
[image
->fg_color
];
1479 bgcolor
= dinfo
->pseudo_palette
[image
->bg_color
];
1481 fgcolor
= image
->fg_color
;
1482 bgcolor
= image
->bg_color
;
1485 if (!intelfbhw_do_drawglyph(dinfo
, fgcolor
, bgcolor
, image
->width
,
1486 image
->height
, image
->data
,
1487 image
->dx
, image
->dy
,
1488 dinfo
->pitch
, info
->var
.bits_per_pixel
))
1489 return cfb_imageblit(info
, image
);
1493 intelfb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
1495 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1498 DBG_MSG("intelfb_cursor\n");
1501 if (!dinfo
->hwcursor
)
1502 return soft_cursor(info
, cursor
);
1504 intelfbhw_cursor_hide(dinfo
);
1506 /* If XFree killed the cursor - restore it */
1507 if (INREG(CURSOR_A_BASEADDR
) != dinfo
->cursor
.offset
<< 12) {
1510 DBG_MSG("the cursor was killed - restore it !!\n");
1511 DBG_MSG("size %d, %d pos %d, %d\n",
1512 cursor
->image
.width
, cursor
->image
.height
,
1513 cursor
->image
.dx
, cursor
->image
.dy
);
1515 intelfbhw_cursor_init(dinfo
);
1516 intelfbhw_cursor_reset(dinfo
);
1517 intelfbhw_cursor_setpos(dinfo
, cursor
->image
.dx
,
1520 if (dinfo
->depth
!= 8) {
1521 fg
=dinfo
->pseudo_palette
[cursor
->image
.fg_color
];
1522 bg
=dinfo
->pseudo_palette
[cursor
->image
.bg_color
];
1524 fg
= cursor
->image
.fg_color
;
1525 bg
= cursor
->image
.bg_color
;
1527 intelfbhw_cursor_setcolor(dinfo
, bg
, fg
);
1528 intelfbhw_cursor_load(dinfo
, cursor
->image
.width
,
1529 cursor
->image
.height
,
1533 intelfbhw_cursor_show(dinfo
);
1537 if (cursor
->set
& FB_CUR_SETPOS
) {
1540 dx
= cursor
->image
.dx
- info
->var
.xoffset
;
1541 dy
= cursor
->image
.dy
- info
->var
.yoffset
;
1543 intelfbhw_cursor_setpos(dinfo
, dx
, dy
);
1546 if (cursor
->set
& FB_CUR_SETSIZE
) {
1547 if (cursor
->image
.width
> 64 || cursor
->image
.height
> 64)
1550 intelfbhw_cursor_reset(dinfo
);
1553 if (cursor
->set
& FB_CUR_SETCMAP
) {
1556 if (dinfo
->depth
!= 8) {
1557 fg
= dinfo
->pseudo_palette
[cursor
->image
.fg_color
];
1558 bg
= dinfo
->pseudo_palette
[cursor
->image
.bg_color
];
1560 fg
= cursor
->image
.fg_color
;
1561 bg
= cursor
->image
.bg_color
;
1564 intelfbhw_cursor_setcolor(dinfo
, bg
, fg
);
1567 if (cursor
->set
& (FB_CUR_SETSHAPE
| FB_CUR_SETIMAGE
)) {
1568 u32 s_pitch
= (ROUND_UP_TO(cursor
->image
.width
, 8) / 8);
1569 u32 size
= s_pitch
* cursor
->image
.height
;
1570 u8
*dat
= (u8
*) cursor
->image
.data
;
1571 u8
*msk
= (u8
*) cursor
->mask
;
1575 if (cursor
->image
.depth
!= 1)
1578 switch (cursor
->rop
) {
1580 for (i
= 0; i
< size
; i
++)
1581 src
[i
] = dat
[i
] ^ msk
[i
];
1585 for (i
= 0; i
< size
; i
++)
1586 src
[i
] = dat
[i
] & msk
[i
];
1590 /* save the bitmap to restore it when XFree will
1591 make the cursor dirty */
1592 memcpy(dinfo
->cursor_src
, src
, size
);
1594 intelfbhw_cursor_load(dinfo
, cursor
->image
.width
,
1595 cursor
->image
.height
, src
);
1599 intelfbhw_cursor_show(dinfo
);
1605 intelfb_sync(struct fb_info
*info
)
1607 struct intelfb_info
*dinfo
= GET_DINFO(info
);
1610 DBG_MSG("intelfb_sync\n");
1613 if (dinfo
->ring_lockup
)
1616 intelfbhw_do_sync(dinfo
);