4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/
5 * 945G/945GM/945GME/965G/965GM integrated graphics chips.
11 * This driver consists of two parts. The first part (intelfbdrv.c) provides
12 * the basic fbdev interfaces, is derived in part from the radeonfb and
13 * vesafb drivers, and is covered by the GPL. The second part (intelfbhw.c)
14 * provides the code to program the hardware. Most of it is derived from
15 * the i810/i830 XFree86 driver. The HW-specific code is covered here
16 * under a dual license (GPL and MIT/XFree86 license).
22 /* $DHD: intelfb/intelfbdrv.c,v 1.20 2003/06/27 15:17:40 dawes Exp $ */
26 * 01/2003 - Initial driver (0.1.0), no mode switching, no acceleration.
27 * This initial version is a basic core that works a lot like
28 * the vesafb driver. It must be built-in to the kernel,
29 * and the initial video mode must be set with vga=XXX at
30 * boot time. (David Dawes)
32 * 01/2003 - Version 0.2.0: Mode switching added, colormap support
33 * implemented, Y panning, and soft screen blanking implemented.
34 * No acceleration yet. (David Dawes)
36 * 01/2003 - Version 0.3.0: fbcon acceleration support added. Module
37 * option handling added. (David Dawes)
39 * 01/2003 - Version 0.4.0: fbcon HW cursor support added. (David Dawes)
41 * 01/2003 - Version 0.4.1: Add auto-generation of built-in modes.
44 * 02/2003 - Version 0.4.2: Add check for active non-CRT devices, and
45 * mode validation checks. (David Dawes)
47 * 02/2003 - Version 0.4.3: Check when the VC is in graphics mode so that
48 * acceleration is disabled while an XFree86 server is running.
51 * 02/2003 - Version 0.4.4: Monitor DPMS support. (David Dawes)
53 * 02/2003 - Version 0.4.5: Basic XFree86 + fbdev working. (David Dawes)
55 * 02/2003 - Version 0.5.0: Modify to work with the 2.5.32 kernel as well
56 * as 2.4.x kernels. (David Dawes)
58 * 02/2003 - Version 0.6.0: Split out HW-specifics into a separate file.
61 * 02/2003 - Version 0.7.0: Test on 852GM/855GM. Acceleration and HW
62 * cursor are disabled on this platform. (David Dawes)
64 * 02/2003 - Version 0.7.1: Test on 845G. Acceleration is disabled
65 * on this platform. (David Dawes)
67 * 02/2003 - Version 0.7.2: Test on 830M. Acceleration and HW
68 * cursor are disabled on this platform. (David Dawes)
70 * 02/2003 - Version 0.7.3: Fix 8-bit modes for mobile platforms
73 * 02/2003 - Version 0.7.4: Add checks for FB and FBCON_HAS_CFB* configured
74 * in the kernel, and add mode bpp verification and default
75 * bpp selection based on which FBCON_HAS_CFB* are configured.
78 * 02/2003 - Version 0.7.5: Add basic package/install scripts based on the
79 * DRI packaging scripts. (David Dawes)
81 * 04/2003 - Version 0.7.6: Fix typo that affects builds with SMP-enabled
82 * kernels. (David Dawes, reported by Anupam).
84 * 06/2003 - Version 0.7.7:
85 * Fix Makefile.kernel build problem (Tsutomu Yasuda).
86 * Fix mis-placed #endif (2.4.21 kernel).
88 * 09/2004 - Version 0.9.0 - by Sylvain Meyer
89 * Port to linux 2.6 kernel fbdev
90 * Fix HW accel and HW cursor on i845G
91 * Use of agpgart for fb memory reservation
94 * 10/2004 - Version 0.9.1
95 * Use module_param instead of old MODULE_PARM
98 * 11/2004 - Version 0.9.2
99 * Add vram option to reserve more memory than stolen by BIOS
100 * Fix intelfbhw_pan_display typo
101 * Add __initdata annotations
103 * 04/2008 - Version 0.9.5
106 * 08/2008 - Version 0.9.6
110 #include <linux/aperture.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/slab.h>
117 #include <linux/delay.h>
118 #include <linux/fb.h>
119 #include <linux/ioport.h>
120 #include <linux/init.h>
121 #include <linux/pci.h>
122 #include <linux/vmalloc.h>
123 #include <linux/pagemap.h>
124 #include <linux/screen_info.h>
129 #include "intelfbhw.h"
132 static void get_initial_mode(struct intelfb_info *dinfo);
133 static void update_dinfo(struct intelfb_info *dinfo,
134 struct fb_var_screeninfo *var);
135 static int intelfb_open(struct fb_info *info, int user);
136 static int intelfb_release(struct fb_info *info, int user);
137 static int intelfb_check_var(struct fb_var_screeninfo *var,
138 struct fb_info *info);
139 static int intelfb_set_par(struct fb_info *info);
140 static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
141 unsigned blue, unsigned transp,
142 struct fb_info *info);
144 static int intelfb_blank(int blank, struct fb_info *info);
145 static int intelfb_pan_display(struct fb_var_screeninfo *var,
146 struct fb_info *info);
148 static void intelfb_fillrect(struct fb_info *info,
149 const struct fb_fillrect *rect);
150 static void intelfb_copyarea(struct fb_info *info,
151 const struct fb_copyarea *region);
152 static void intelfb_imageblit(struct fb_info *info,
153 const struct fb_image *image);
154 static int intelfb_cursor(struct fb_info *info,
155 struct fb_cursor *cursor);
157 static int intelfb_sync(struct fb_info *info);
159 static int intelfb_ioctl(struct fb_info *info,
160 unsigned int cmd, unsigned long arg);
162 static int intelfb_pci_register(struct pci_dev *pdev,
163 const struct pci_device_id *ent);
164 static void intelfb_pci_unregister(struct pci_dev *pdev);
165 static int intelfb_set_fbinfo(struct intelfb_info *dinfo);
168 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the
169 * mobile chipsets from being registered.
171 #if DETECT_VGA_CLASS_ONLY
172 #define INTELFB_CLASS_MASK ~0 << 8
174 #define INTELFB_CLASS_MASK 0
177 static const struct pci_device_id intelfb_pci_table[] = {
178 { 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 },
179 { 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 },
180 { 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 },
181 { 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 },
182 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_854, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_854 },
183 { 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 },
184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM },
185 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G },
186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM },
187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GME, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GME },
188 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965G },
189 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965GM },
194 static int num_registered = 0;
197 static const struct fb_ops intel_fb_ops = {
198 .owner = THIS_MODULE,
199 .fb_open = intelfb_open,
200 .fb_release = intelfb_release,
201 .fb_check_var = intelfb_check_var,
202 .fb_set_par = intelfb_set_par,
203 .fb_setcolreg = intelfb_setcolreg,
204 .fb_blank = intelfb_blank,
205 .fb_pan_display = intelfb_pan_display,
206 .fb_fillrect = intelfb_fillrect,
207 .fb_copyarea = intelfb_copyarea,
208 .fb_imageblit = intelfb_imageblit,
209 .fb_cursor = intelfb_cursor,
210 .fb_sync = intelfb_sync,
211 .fb_ioctl = intelfb_ioctl
214 /* PCI driver module table */
215 static struct pci_driver intelfb_driver = {
217 .id_table = intelfb_pci_table,
218 .probe = intelfb_pci_register,
219 .remove = intelfb_pci_unregister,
222 /* Module description/parameters */
225 MODULE_DESCRIPTION("Framebuffer driver for Intel(R) " SUPPORTED_CHIPSETS
227 MODULE_LICENSE("Dual BSD/GPL");
228 MODULE_DEVICE_TABLE(pci, intelfb_pci_table);
230 static bool accel = 1;
232 static bool hwcursor = 0;
233 static bool mtrr = 1;
234 static bool fixed = 0;
235 static bool noinit = 0;
236 static bool noregister = 0;
237 static bool probeonly = 0;
238 static bool idonly = 0;
239 static int bailearly = 0;
240 static int voffset = 48;
241 static char *mode = NULL;
243 module_param(accel, bool, S_IRUGO);
244 MODULE_PARM_DESC(accel, "Enable hardware acceleration");
245 module_param(vram, int, S_IRUGO);
246 MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB");
247 module_param(voffset, int, S_IRUGO);
248 MODULE_PARM_DESC(voffset, "Offset of framebuffer in MiB");
249 module_param(hwcursor, bool, S_IRUGO);
250 MODULE_PARM_DESC(hwcursor, "Enable HW cursor");
251 module_param(mtrr, bool, S_IRUGO);
252 MODULE_PARM_DESC(mtrr, "Enable MTRR support");
253 module_param(fixed, bool, S_IRUGO);
254 MODULE_PARM_DESC(fixed, "Disable mode switching");
255 module_param(noinit, bool, 0);
256 MODULE_PARM_DESC(noinit, "Don't initialise graphics mode when loading");
257 module_param(noregister, bool, 0);
258 MODULE_PARM_DESC(noregister, "Don't register, just probe and exit (debug)");
259 module_param(probeonly, bool, 0);
260 MODULE_PARM_DESC(probeonly, "Do a minimal probe (debug)");
261 module_param(idonly, bool, 0);
262 MODULE_PARM_DESC(idonly, "Just identify without doing anything else (debug)");
263 module_param(bailearly, int, 0);
264 MODULE_PARM_DESC(bailearly, "Bail out early, depending on value (debug)");
265 module_param(mode, charp, S_IRUGO);
266 MODULE_PARM_DESC(mode,
267 "Initial video mode \"<xres>x<yres>[-<depth>][@<refresh>]\"");
270 #define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name)))
271 #define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name) + 1, NULL, 0)
272 #define OPT_STRVAL(opt, name) (opt + strlen(name))
274 static __inline__ char * get_opt_string(const char *this_opt, const char *name)
280 p = OPT_STRVAL(this_opt, name);
282 while (p[i] && p[i] != ' ' && p[i] != ',')
284 ret = kmalloc(i + 1, GFP_KERNEL);
292 static __inline__ int get_opt_int(const char *this_opt, const char *name,
298 if (!OPT_EQUAL(this_opt, name))
301 *ret = OPT_INTVAL(this_opt, name);
305 static __inline__ int get_opt_bool(const char *this_opt, const char *name,
311 if (OPT_EQUAL(this_opt, name)) {
312 if (this_opt[strlen(name)] == '=')
313 *ret = simple_strtoul(this_opt + strlen(name) + 1,
318 if (OPT_EQUAL(this_opt, "no") && OPT_EQUAL(this_opt + 2, name))
326 static int __init intelfb_setup(char *options)
330 DBG_MSG("intelfb_setup\n");
332 if (!options || !*options) {
333 DBG_MSG("no options\n");
336 DBG_MSG("options: %s\n", options);
339 * These are the built-in options analogous to the module parameters
344 * video=intelfb:[mode][,<param>=<val>] ...
348 * video=intelfb:1024x768-16@75,accel=0
351 while ((this_opt = strsep(&options, ","))) {
354 if (get_opt_bool(this_opt, "accel", &accel))
356 else if (get_opt_int(this_opt, "vram", &vram))
358 else if (get_opt_bool(this_opt, "hwcursor", &hwcursor))
360 else if (get_opt_bool(this_opt, "mtrr", &mtrr))
362 else if (get_opt_bool(this_opt, "fixed", &fixed))
364 else if (get_opt_bool(this_opt, "init", &noinit))
366 else if (OPT_EQUAL(this_opt, "mode="))
367 mode = get_opt_string(this_opt, "mode=");
377 static int __init intelfb_init(void)
383 DBG_MSG("intelfb_init\n");
385 INF_MSG("Framebuffer driver for "
386 "Intel(R) " SUPPORTED_CHIPSETS " chipsets\n");
387 INF_MSG("Version " INTELFB_VERSION "\n");
392 if (fb_modesetting_disabled("intelfb"))
396 if (fb_get_options("intelfb", &option))
398 intelfb_setup(option);
401 return pci_register_driver(&intelfb_driver);
404 static void __exit intelfb_exit(void)
406 DBG_MSG("intelfb_exit\n");
407 pci_unregister_driver(&intelfb_driver);
410 module_init(intelfb_init);
411 module_exit(intelfb_exit);
413 /***************************************************************
414 * driver init / cleanup *
415 ***************************************************************/
417 static void cleanup(struct intelfb_info *dinfo)
419 DBG_MSG("cleanup\n");
424 intelfbhw_disable_irq(dinfo);
426 fb_dealloc_cmap(&dinfo->info->cmap);
427 kfree(dinfo->info->pixmap.addr);
429 if (dinfo->registered)
430 unregister_framebuffer(dinfo->info);
432 arch_phys_wc_del(dinfo->wc_cookie);
434 if (dinfo->fbmem_gart && dinfo->gtt_fb_mem) {
435 agp_unbind_memory(dinfo->gtt_fb_mem);
436 agp_free_memory(dinfo->gtt_fb_mem);
438 if (dinfo->gtt_cursor_mem) {
439 agp_unbind_memory(dinfo->gtt_cursor_mem);
440 agp_free_memory(dinfo->gtt_cursor_mem);
442 if (dinfo->gtt_ring_mem) {
443 agp_unbind_memory(dinfo->gtt_ring_mem);
444 agp_free_memory(dinfo->gtt_ring_mem);
447 #ifdef CONFIG_FB_INTEL_I2C
448 /* un-register I2C bus */
449 intelfb_delete_i2c_busses(dinfo);
452 if (dinfo->mmio_base)
453 iounmap((void __iomem *)dinfo->mmio_base);
454 if (dinfo->aperture.virtual)
455 iounmap((void __iomem *)dinfo->aperture.virtual);
457 if (dinfo->flag & INTELFB_MMIO_ACQUIRED)
458 release_mem_region(dinfo->mmio_base_phys, INTEL_REG_SIZE);
459 if (dinfo->flag & INTELFB_FB_ACQUIRED)
460 release_mem_region(dinfo->aperture.physical,
461 dinfo->aperture.size);
462 framebuffer_release(dinfo->info);
465 #define bailout(dinfo) do { \
466 DBG_MSG("bailout\n"); \
468 INF_MSG("Not going to register framebuffer, exiting...\n"); \
473 static int intelfb_pci_register(struct pci_dev *pdev,
474 const struct pci_device_id *ent)
476 struct fb_info *info;
477 struct intelfb_info *dinfo;
479 int aperture_size, stolen_size = 0;
480 struct agp_kern_info gtt_info;
483 struct agp_bridge_data *bridge;
484 int aperture_bar = 0;
488 DBG_MSG("intelfb_pci_register\n");
490 err = aperture_remove_conflicting_pci_devices(pdev, "intelfb");
495 if (num_registered != 1) {
496 ERR_MSG("Attempted to register %d devices "
497 "(should be only 1).\n", num_registered);
501 info = framebuffer_alloc(sizeof(struct intelfb_info), &pdev->dev);
505 if (fb_alloc_cmap(&info->cmap, 256, 1) < 0) {
506 ERR_MSG("Could not allocate cmap for intelfb_info.\n");
512 dinfo->fbops = &intel_fb_ops;
515 /* Reserve pixmap space. */
516 info->pixmap.addr = kzalloc(64 * 1024, GFP_KERNEL);
517 if (info->pixmap.addr == NULL) {
518 ERR_MSG("Cannot reserve pixmap memory.\n");
522 /* set early this option because it could be changed by tv encoder
524 dinfo->fixed_mode = fixed;
527 if ((err = pci_enable_device(pdev))) {
528 ERR_MSG("Cannot enable device.\n");
533 /* Set base addresses. */
534 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) ||
535 (ent->device == PCI_DEVICE_ID_INTEL_915GM) ||
536 (ent->device == PCI_DEVICE_ID_INTEL_945G) ||
537 (ent->device == PCI_DEVICE_ID_INTEL_945GM) ||
538 (ent->device == PCI_DEVICE_ID_INTEL_945GME) ||
539 (ent->device == PCI_DEVICE_ID_INTEL_965G) ||
540 (ent->device == PCI_DEVICE_ID_INTEL_965GM)) {
545 dinfo->aperture.physical = pci_resource_start(pdev, aperture_bar);
546 dinfo->aperture.size = pci_resource_len(pdev, aperture_bar);
547 dinfo->mmio_base_phys = pci_resource_start(pdev, mmio_bar);
548 DBG_MSG("fb aperture: 0x%llx/0x%llx, MMIO region: 0x%llx/0x%llx\n",
549 (unsigned long long)pci_resource_start(pdev, aperture_bar),
550 (unsigned long long)pci_resource_len(pdev, aperture_bar),
551 (unsigned long long)pci_resource_start(pdev, mmio_bar),
552 (unsigned long long)pci_resource_len(pdev, mmio_bar));
554 /* Reserve the fb and MMIO regions */
555 if (!request_mem_region(dinfo->aperture.physical, dinfo->aperture.size,
556 INTELFB_MODULE_NAME)) {
557 ERR_MSG("Cannot reserve FB region.\n");
562 dinfo->flag |= INTELFB_FB_ACQUIRED;
564 if (!request_mem_region(dinfo->mmio_base_phys,
566 INTELFB_MODULE_NAME)) {
567 ERR_MSG("Cannot reserve MMIO region.\n");
572 dinfo->flag |= INTELFB_MMIO_ACQUIRED;
574 /* Get the chipset info. */
575 dinfo->pci_chipset = pdev->device;
577 if (intelfbhw_get_chipset(pdev, dinfo)) {
582 if (intelfbhw_get_memory(pdev, &aperture_size, &stolen_size)) {
587 INF_MSG("%02x:%02x.%d: %s, aperture size %dMB, "
588 "stolen memory %dkB\n",
589 pdev->bus->number, PCI_SLOT(pdev->devfn),
590 PCI_FUNC(pdev->devfn), dinfo->name,
591 BtoMB(aperture_size), BtoKB(stolen_size));
593 /* Set these from the options. */
594 dinfo->accel = accel;
595 dinfo->hwcursor = hwcursor;
597 if (NOACCEL_CHIPSET(dinfo) && dinfo->accel == 1) {
598 INF_MSG("Acceleration is not supported for the %s chipset.\n",
603 /* Framebuffer parameters - Use all the stolen memory if >= vram */
604 if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) {
605 dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size);
606 dinfo->fbmem_gart = 0;
608 dinfo->fb.size = MB(vram);
609 dinfo->fbmem_gart = 1;
612 /* Allocate space for the ring buffer and HW cursor if enabled. */
614 dinfo->ring.size = RINGBUFFER_SIZE;
615 dinfo->ring_tail_mask = dinfo->ring.size - 1;
618 dinfo->cursor.size = HW_CURSOR_SIZE;
620 /* Use agpgart to manage the GATT */
621 if (!(bridge = agp_backend_acquire(pdev))) {
622 ERR_MSG("cannot acquire agp\n");
627 /* get the current gatt info */
628 if (agp_copy_info(bridge, >t_info)) {
629 ERR_MSG("cannot get agp info\n");
630 agp_backend_release(bridge);
635 if (MB(voffset) < stolen_size)
636 offset = (stolen_size >> 12);
638 offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
640 /* set the mem offsets - set them after the already used pages */
642 dinfo->ring.offset = offset + gtt_info.current_memory;
644 dinfo->cursor.offset = offset +
645 + gtt_info.current_memory + (dinfo->ring.size >> 12);
646 if (dinfo->fbmem_gart)
647 dinfo->fb.offset = offset +
648 + gtt_info.current_memory + (dinfo->ring.size >> 12)
649 + (dinfo->cursor.size >> 12);
651 /* Allocate memories (which aren't stolen) */
652 /* Map the fb and MMIO regions */
653 /* ioremap only up to the end of used aperture */
654 dinfo->aperture.virtual = (u8 __iomem *)ioremap_wc
655 (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12)
657 if (!dinfo->aperture.virtual) {
658 ERR_MSG("Cannot remap FB region.\n");
659 agp_backend_release(bridge);
665 (u8 __iomem *)ioremap(dinfo->mmio_base_phys,
667 if (!dinfo->mmio_base) {
668 ERR_MSG("Cannot remap MMIO region.\n");
669 agp_backend_release(bridge);
675 if (!(dinfo->gtt_ring_mem =
676 agp_allocate_memory(bridge, dinfo->ring.size >> 12,
677 AGP_NORMAL_MEMORY))) {
678 ERR_MSG("cannot allocate ring buffer memory\n");
679 agp_backend_release(bridge);
683 if (agp_bind_memory(dinfo->gtt_ring_mem,
684 dinfo->ring.offset)) {
685 ERR_MSG("cannot bind ring buffer memory\n");
686 agp_backend_release(bridge);
690 dinfo->ring.physical = dinfo->aperture.physical
691 + (dinfo->ring.offset << 12);
692 dinfo->ring.virtual = dinfo->aperture.virtual
693 + (dinfo->ring.offset << 12);
694 dinfo->ring_head = 0;
696 if (dinfo->hwcursor) {
697 agp_memtype = dinfo->mobile ? AGP_PHYSICAL_MEMORY
699 if (!(dinfo->gtt_cursor_mem =
700 agp_allocate_memory(bridge, dinfo->cursor.size >> 12,
702 ERR_MSG("cannot allocate cursor memory\n");
703 agp_backend_release(bridge);
707 if (agp_bind_memory(dinfo->gtt_cursor_mem,
708 dinfo->cursor.offset)) {
709 ERR_MSG("cannot bind cursor memory\n");
710 agp_backend_release(bridge);
715 dinfo->cursor.physical
716 = dinfo->gtt_cursor_mem->physical;
718 dinfo->cursor.physical = dinfo->aperture.physical
719 + (dinfo->cursor.offset << 12);
720 dinfo->cursor.virtual = dinfo->aperture.virtual
721 + (dinfo->cursor.offset << 12);
723 if (dinfo->fbmem_gart) {
724 if (!(dinfo->gtt_fb_mem =
725 agp_allocate_memory(bridge, dinfo->fb.size >> 12,
726 AGP_NORMAL_MEMORY))) {
727 WRN_MSG("cannot allocate framebuffer memory - use "
729 dinfo->fbmem_gart = 0;
731 if (agp_bind_memory(dinfo->gtt_fb_mem,
733 WRN_MSG("cannot bind framebuffer memory - use "
735 dinfo->fbmem_gart = 0;
739 /* update framebuffer memory parameters */
740 if (!dinfo->fbmem_gart)
741 dinfo->fb.offset = 0; /* starts at offset 0 */
742 dinfo->fb.physical = dinfo->aperture.physical
743 + (dinfo->fb.offset << 12);
744 dinfo->fb.virtual = dinfo->aperture.virtual + (dinfo->fb.offset << 12);
745 dinfo->fb_start = dinfo->fb.offset << 12;
747 /* release agpgart */
748 agp_backend_release(bridge);
751 dinfo->wc_cookie = arch_phys_wc_add(dinfo->aperture.physical,
752 dinfo->aperture.size);
754 DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%p)\n",
755 dinfo->fb.physical, dinfo->fb.offset, dinfo->fb.size,
757 DBG_MSG("MMIO: 0x%x/0x%x (0x%p)\n",
758 dinfo->mmio_base_phys, INTEL_REG_SIZE,
760 DBG_MSG("ring buffer: 0x%x/0x%x (0x%p)\n",
761 dinfo->ring.physical, dinfo->ring.size,
762 dinfo->ring.virtual);
763 DBG_MSG("HW cursor: 0x%x/0x%x (0x%p) (offset 0x%x) (phys 0x%x)\n",
764 dinfo->cursor.physical, dinfo->cursor.size,
765 dinfo->cursor.virtual, dinfo->cursor.offset,
766 dinfo->cursor.physical);
768 DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, "
769 "noinit = %d\n", vram, accel, hwcursor, fixed, noinit);
770 DBG_MSG("options: mode = \"%s\"\n", mode ? mode : "");
776 * Check if the LVDS port or any DVO ports are enabled. If so,
777 * don't allow mode switching
779 dvo = intelfbhw_check_non_crt(dinfo);
781 dinfo->fixed_mode = 1;
782 WRN_MSG("Non-CRT device is enabled ( ");
786 s = intelfbhw_dvo_to_string(1 << i);
793 printk("). Disabling mode switching.\n");
799 if (FIXED_MODE(dinfo) &&
800 screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) {
801 ERR_MSG("Video mode must be programmed at boot time.\n");
809 /* Initialise dinfo and related data. */
810 /* If an initial mode was programmed at boot time, get its details. */
811 if (screen_info.orig_video_isVGA == VIDEO_TYPE_VLFB)
812 get_initial_mode(dinfo);
817 if (FIXED_MODE(dinfo)) /* remap fb address */
818 update_dinfo(dinfo, &dinfo->initial_var);
824 if (intelfb_set_fbinfo(dinfo)) {
832 #ifdef CONFIG_FB_INTEL_I2C
833 /* register I2C bus */
834 intelfb_create_i2c_busses(dinfo);
840 pci_set_drvdata(pdev, dinfo);
842 /* Save the initial register state. */
843 i = intelfbhw_read_hw_state(dinfo, &dinfo->save_state,
844 bailearly > 6 ? bailearly - 6 : 0);
846 DBG_MSG("intelfbhw_read_hw_state returned %d\n", i);
850 intelfbhw_print_hw_state(dinfo, &dinfo->save_state);
855 /* read active pipe */
856 dinfo->pipe = intelfbhw_active_pipe(&dinfo->save_state);
858 /* Cursor initialisation */
859 if (dinfo->hwcursor) {
860 intelfbhw_cursor_init(dinfo);
861 intelfbhw_cursor_reset(dinfo);
867 /* 2d acceleration init */
869 intelfbhw_2d_start(dinfo);
877 if (register_framebuffer(dinfo->info) < 0) {
878 ERR_MSG("Cannot register framebuffer.\n");
883 dinfo->registered = 1;
886 init_waitqueue_head(&dinfo->vsync.wait);
887 spin_lock_init(&dinfo->int_lock);
888 dinfo->irq_flags = 0;
889 dinfo->vsync.pan_display = 0;
890 dinfo->vsync.pan_offset = 0;
895 fb_dealloc_cmap(&info->cmap);
897 framebuffer_release(info);
901 static void intelfb_pci_unregister(struct pci_dev *pdev)
903 struct intelfb_info *dinfo = pci_get_drvdata(pdev);
905 DBG_MSG("intelfb_pci_unregister\n");
913 /***************************************************************
915 ***************************************************************/
917 __inline__ int intelfb_var_to_depth(const struct fb_var_screeninfo *var)
919 DBG_MSG("intelfb_var_to_depth: bpp: %d, green.length is %d\n",
920 var->bits_per_pixel, var->green.length);
922 switch (var->bits_per_pixel) {
924 return (var->green.length == 6) ? 16 : 15;
928 return var->bits_per_pixel;
933 static __inline__ int var_to_refresh(const struct fb_var_screeninfo *var)
935 int xtot = var->xres + var->left_margin + var->right_margin +
937 int ytot = var->yres + var->upper_margin + var->lower_margin +
940 return (1000000000 / var->pixclock * 1000 + 500) / xtot / ytot;
943 /***************************************************************
944 * Various initialisation functions *
945 ***************************************************************/
947 static void get_initial_mode(struct intelfb_info *dinfo)
949 struct fb_var_screeninfo *var;
952 DBG_MSG("get_initial_mode\n");
954 dinfo->initial_vga = 1;
955 dinfo->initial_fb_base = screen_info.lfb_base;
956 dinfo->initial_video_ram = screen_info.lfb_size * KB(64);
957 dinfo->initial_pitch = screen_info.lfb_linelength;
959 var = &dinfo->initial_var;
960 memset(var, 0, sizeof(*var));
961 var->xres = screen_info.lfb_width;
962 var->yres = screen_info.lfb_height;
963 var->bits_per_pixel = screen_info.lfb_depth;
964 switch (screen_info.lfb_depth) {
966 var->bits_per_pixel = 16;
969 var->bits_per_pixel = 32;
973 DBG_MSG("Initial info: FB is 0x%x/0x%x (%d kByte)\n",
974 dinfo->initial_fb_base, dinfo->initial_video_ram,
975 BtoKB(dinfo->initial_video_ram));
977 DBG_MSG("Initial info: mode is %dx%d-%d (%d)\n",
978 var->xres, var->yres, var->bits_per_pixel,
979 dinfo->initial_pitch);
981 /* Dummy timing values (assume 60Hz) */
982 var->left_margin = (var->xres / 8) & 0xf8;
983 var->right_margin = 32;
984 var->upper_margin = 16;
985 var->lower_margin = 4;
986 var->hsync_len = (var->xres / 8) & 0xf8;
989 xtot = var->xres + var->left_margin +
990 var->right_margin + var->hsync_len;
991 ytot = var->yres + var->upper_margin +
992 var->lower_margin + var->vsync_len;
993 var->pixclock = 10000000 / xtot * 1000 / ytot * 100 / 60;
998 if (var->bits_per_pixel > 8) {
999 var->red.offset = screen_info.red_pos;
1000 var->red.length = screen_info.red_size;
1001 var->green.offset = screen_info.green_pos;
1002 var->green.length = screen_info.green_size;
1003 var->blue.offset = screen_info.blue_pos;
1004 var->blue.length = screen_info.blue_size;
1005 var->transp.offset = screen_info.rsvd_pos;
1006 var->transp.length = screen_info.rsvd_size;
1008 var->red.length = 8;
1009 var->green.length = 8;
1010 var->blue.length = 8;
1014 static int intelfb_init_var(struct intelfb_info *dinfo)
1016 struct fb_var_screeninfo *var;
1019 DBG_MSG("intelfb_init_var\n");
1021 var = &dinfo->info->var;
1022 if (FIXED_MODE(dinfo)) {
1023 memcpy(var, &dinfo->initial_var,
1024 sizeof(struct fb_var_screeninfo));
1027 const u8 *edid_s = fb_firmware_edid(&dinfo->pdev->dev);
1031 edid_d = kmemdup(edid_s, EDID_LENGTH, GFP_KERNEL);
1034 fb_edid_to_monspecs(edid_d,
1035 &dinfo->info->monspecs);
1041 printk("intelfb: Looking for mode in private "
1043 msrc = fb_find_mode(var, dinfo->info, mode,
1044 dinfo->info->monspecs.modedb,
1045 dinfo->info->monspecs.modedb_len,
1048 if (msrc && msrc > 1) {
1049 printk("intelfb: No mode in private database, "
1050 "intelfb: looking for mode in global "
1052 msrc = fb_find_mode(var, dinfo->info, mode,
1062 msrc = fb_find_mode(var, dinfo->info, PREFERRED_MODE,
1067 ERR_MSG("Cannot find a suitable video mode.\n");
1071 INF_MSG("Initial video mode is %dx%d-%d@%d.\n", var->xres, var->yres,
1072 var->bits_per_pixel, var_to_refresh(var));
1074 DBG_MSG("Initial video mode is from %d.\n", msrc);
1076 #if ALLOCATE_FOR_PANNING
1077 /* Allow use of half of the video ram for panning */
1078 var->xres_virtual = var->xres;
1080 dinfo->fb.size / 2 / (var->bits_per_pixel * var->xres);
1081 if (var->yres_virtual < var->yres)
1082 var->yres_virtual = var->yres;
1084 var->yres_virtual = var->yres;
1088 var->accel_flags |= FB_ACCELF_TEXT;
1090 var->accel_flags &= ~FB_ACCELF_TEXT;
1095 static int intelfb_set_fbinfo(struct intelfb_info *dinfo)
1097 struct fb_info *info = dinfo->info;
1099 DBG_MSG("intelfb_set_fbinfo\n");
1101 info->flags = FBINFO_FLAG_DEFAULT;
1102 info->fbops = &intel_fb_ops;
1103 info->pseudo_palette = dinfo->pseudo_palette;
1105 info->pixmap.size = 64*1024;
1106 info->pixmap.buf_align = 8;
1107 info->pixmap.access_align = 32;
1108 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1110 if (intelfb_init_var(dinfo))
1113 info->pixmap.scan_align = 1;
1114 strcpy(info->fix.id, dinfo->name);
1115 info->fix.smem_start = dinfo->fb.physical;
1116 info->fix.smem_len = dinfo->fb.size;
1117 info->fix.type = FB_TYPE_PACKED_PIXELS;
1118 info->fix.type_aux = 0;
1119 info->fix.xpanstep = 8;
1120 info->fix.ypanstep = 1;
1121 info->fix.ywrapstep = 0;
1122 info->fix.mmio_start = dinfo->mmio_base_phys;
1123 info->fix.mmio_len = INTEL_REG_SIZE;
1124 info->fix.accel = FB_ACCEL_I830;
1125 update_dinfo(dinfo, &info->var);
1130 /* Update dinfo to match the active video mode. */
1131 static void update_dinfo(struct intelfb_info *dinfo,
1132 struct fb_var_screeninfo *var)
1134 DBG_MSG("update_dinfo\n");
1136 dinfo->bpp = var->bits_per_pixel;
1137 dinfo->depth = intelfb_var_to_depth(var);
1138 dinfo->xres = var->xres;
1139 dinfo->yres = var->xres;
1140 dinfo->pixclock = var->pixclock;
1142 dinfo->info->fix.visual = dinfo->visual;
1143 dinfo->info->fix.line_length = dinfo->pitch;
1145 switch (dinfo->bpp) {
1147 dinfo->visual = FB_VISUAL_PSEUDOCOLOR;
1148 dinfo->pitch = var->xres_virtual;
1151 dinfo->visual = FB_VISUAL_TRUECOLOR;
1152 dinfo->pitch = var->xres_virtual * 2;
1155 dinfo->visual = FB_VISUAL_TRUECOLOR;
1156 dinfo->pitch = var->xres_virtual * 4;
1160 /* Make sure the line length is a aligned correctly. */
1162 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT_I9XX);
1164 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT);
1166 if (FIXED_MODE(dinfo))
1167 dinfo->pitch = dinfo->initial_pitch;
1169 dinfo->info->screen_base = (char __iomem *)dinfo->fb.virtual;
1170 dinfo->info->fix.line_length = dinfo->pitch;
1171 dinfo->info->fix.visual = dinfo->visual;
1174 /* fbops functions */
1176 /***************************************************************
1178 ***************************************************************/
1180 static int intelfb_open(struct fb_info *info, int user)
1182 struct intelfb_info *dinfo = GET_DINFO(info);
1190 static int intelfb_release(struct fb_info *info, int user)
1192 struct intelfb_info *dinfo = GET_DINFO(info);
1198 intelfbhw_disable_irq(dinfo);
1204 static int intelfb_check_var(struct fb_var_screeninfo *var,
1205 struct fb_info *info)
1208 struct fb_var_screeninfo v;
1209 struct intelfb_info *dinfo;
1210 static int first = 1;
1212 /* Good pitches to allow tiling. Don't care about pitches < 1024. */
1213 static const int pitches[] = {
1221 DBG_MSG("intelfb_check_var: accel_flags is %d\n", var->accel_flags);
1223 dinfo = GET_DINFO(info);
1228 /* update the pitch */
1229 if (intelfbhw_validate_mode(dinfo, var) != 0)
1234 for (i = 0; pitches[i] != 0; i++) {
1235 if (pitches[i] >= v.xres_virtual) {
1236 v.xres_virtual = pitches[i];
1241 /* Check for a supported bpp. */
1242 if (v.bits_per_pixel <= 8)
1243 v.bits_per_pixel = 8;
1244 else if (v.bits_per_pixel <= 16) {
1245 if (v.bits_per_pixel == 16)
1247 v.bits_per_pixel = 16;
1248 } else if (v.bits_per_pixel <= 32)
1249 v.bits_per_pixel = 32;
1253 change_var = ((info->var.xres != var->xres) ||
1254 (info->var.yres != var->yres) ||
1255 (info->var.xres_virtual != var->xres_virtual) ||
1256 (info->var.yres_virtual != var->yres_virtual) ||
1257 (info->var.bits_per_pixel != var->bits_per_pixel) ||
1258 memcmp(&info->var.red, &var->red, sizeof(var->red)) ||
1259 memcmp(&info->var.green, &var->green,
1260 sizeof(var->green)) ||
1261 memcmp(&info->var.blue, &var->blue, sizeof(var->blue)));
1263 if (FIXED_MODE(dinfo) &&
1265 var->yres_virtual > dinfo->initial_var.yres_virtual ||
1266 var->yres_virtual < dinfo->initial_var.yres ||
1267 var->xoffset || var->nonstd)) {
1269 ERR_MSG("Changing the video mode is not supported.\n");
1275 switch (intelfb_var_to_depth(&v)) {
1277 v.red.offset = v.green.offset = v.blue.offset = 0;
1278 v.red.length = v.green.length = v.blue.length = 8;
1279 v.transp.offset = v.transp.length = 0;
1285 v.red.length = v.green.length = v.blue.length = 5;
1286 v.transp.offset = v.transp.length = 0;
1295 v.transp.offset = v.transp.length = 0;
1301 v.red.length = v.green.length = v.blue.length = 8;
1302 v.transp.offset = v.transp.length = 0;
1308 v.red.length = v.green.length = v.blue.length = 8;
1309 v.transp.offset = 24;
1310 v.transp.length = 8;
1314 if (v.xoffset > v.xres_virtual - v.xres)
1315 v.xoffset = v.xres_virtual - v.xres;
1316 if (v.yoffset > v.yres_virtual - v.yres)
1317 v.yoffset = v.yres_virtual - v.yres;
1319 v.red.msb_right = v.green.msb_right = v.blue.msb_right =
1320 v.transp.msb_right = 0;
1327 static int intelfb_set_par(struct fb_info *info)
1329 struct intelfb_hwstate *hw;
1330 struct intelfb_info *dinfo = GET_DINFO(info);
1332 if (FIXED_MODE(dinfo)) {
1333 ERR_MSG("Changing the video mode is not supported.\n");
1337 hw = kmalloc(sizeof(*hw), GFP_ATOMIC);
1341 DBG_MSG("intelfb_set_par (%dx%d-%d)\n", info->var.xres,
1342 info->var.yres, info->var.bits_per_pixel);
1345 * Disable VCO prior to timing register change.
1347 OUTREG(DPLL_A, INREG(DPLL_A) & ~DPLL_VCO_ENABLE);
1349 intelfb_blank(FB_BLANK_POWERDOWN, info);
1351 if (ACCEL(dinfo, info))
1352 intelfbhw_2d_stop(dinfo);
1354 memcpy(hw, &dinfo->save_state, sizeof(*hw));
1355 if (intelfbhw_mode_to_hw(dinfo, hw, &info->var))
1357 if (intelfbhw_program_mode(dinfo, hw, 0))
1361 intelfbhw_read_hw_state(dinfo, hw, 0);
1362 intelfbhw_print_hw_state(dinfo, hw);
1365 update_dinfo(dinfo, &info->var);
1367 if (ACCEL(dinfo, info))
1368 intelfbhw_2d_start(dinfo);
1370 intelfb_pan_display(&info->var, info);
1372 intelfb_blank(FB_BLANK_UNBLANK, info);
1374 if (ACCEL(dinfo, info)) {
1375 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
1376 FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
1377 FBINFO_HWACCEL_IMAGEBLIT;
1379 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1388 static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
1389 unsigned blue, unsigned transp,
1390 struct fb_info *info)
1392 struct intelfb_info *dinfo = GET_DINFO(info);
1395 DBG_MSG("intelfb_setcolreg: regno %d, depth %d\n", regno, dinfo->depth);
1401 if (dinfo->depth == 8) {
1406 intelfbhw_setcolreg(dinfo, regno, red, green, blue,
1411 switch (dinfo->depth) {
1413 dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
1414 ((green & 0xf800) >> 6) |
1415 ((blue & 0xf800) >> 11);
1418 dinfo->pseudo_palette[regno] = (red & 0xf800) |
1419 ((green & 0xfc00) >> 5) |
1420 ((blue & 0xf800) >> 11);
1423 dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) |
1425 ((blue & 0xff00) >> 8);
1433 static int intelfb_blank(int blank, struct fb_info *info)
1435 intelfbhw_do_blank(blank, info);
1439 static int intelfb_pan_display(struct fb_var_screeninfo *var,
1440 struct fb_info *info)
1442 intelfbhw_pan_display(var, info);
1446 /* When/if we have our own ioctls. */
1447 static int intelfb_ioctl(struct fb_info *info, unsigned int cmd,
1451 struct intelfb_info *dinfo = GET_DINFO(info);
1455 case FBIO_WAITFORVSYNC:
1456 if (get_user(pipe, (__u32 __user *)arg))
1459 retval = intelfbhw_wait_for_vsync(dinfo, pipe);
1468 static void intelfb_fillrect (struct fb_info *info,
1469 const struct fb_fillrect *rect)
1471 struct intelfb_info *dinfo = GET_DINFO(info);
1475 DBG_MSG("intelfb_fillrect\n");
1478 if (!ACCEL(dinfo, info) || dinfo->depth == 4) {
1479 cfb_fillrect(info, rect);
1483 if (rect->rop == ROP_COPY)
1484 rop = PAT_ROP_GXCOPY;
1486 rop = PAT_ROP_GXXOR;
1488 if (dinfo->depth != 8)
1489 color = dinfo->pseudo_palette[rect->color];
1491 color = rect->color;
1493 intelfbhw_do_fillrect(dinfo, rect->dx, rect->dy,
1494 rect->width, rect->height, color,
1495 dinfo->pitch, info->var.bits_per_pixel,
1499 static void intelfb_copyarea(struct fb_info *info,
1500 const struct fb_copyarea *region)
1502 struct intelfb_info *dinfo = GET_DINFO(info);
1505 DBG_MSG("intelfb_copyarea\n");
1508 if (!ACCEL(dinfo, info) || dinfo->depth == 4) {
1509 cfb_copyarea(info, region);
1513 intelfbhw_do_bitblt(dinfo, region->sx, region->sy, region->dx,
1514 region->dy, region->width, region->height,
1515 dinfo->pitch, info->var.bits_per_pixel);
1518 static void intelfb_imageblit(struct fb_info *info,
1519 const struct fb_image *image)
1521 struct intelfb_info *dinfo = GET_DINFO(info);
1522 u32 fgcolor, bgcolor;
1525 DBG_MSG("intelfb_imageblit\n");
1528 if (!ACCEL(dinfo, info) || dinfo->depth == 4
1529 || image->depth != 1) {
1530 cfb_imageblit(info, image);
1534 if (dinfo->depth != 8) {
1535 fgcolor = dinfo->pseudo_palette[image->fg_color];
1536 bgcolor = dinfo->pseudo_palette[image->bg_color];
1538 fgcolor = image->fg_color;
1539 bgcolor = image->bg_color;
1542 if (!intelfbhw_do_drawglyph(dinfo, fgcolor, bgcolor, image->width,
1543 image->height, image->data,
1544 image->dx, image->dy,
1545 dinfo->pitch, info->var.bits_per_pixel)) {
1546 cfb_imageblit(info, image);
1551 static int intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1553 struct intelfb_info *dinfo = GET_DINFO(info);
1556 DBG_MSG("intelfb_cursor\n");
1559 if (!dinfo->hwcursor)
1562 intelfbhw_cursor_hide(dinfo);
1564 /* If XFree killed the cursor - restore it */
1565 physical = (dinfo->mobile || IS_I9XX(dinfo)) ? dinfo->cursor.physical :
1566 (dinfo->cursor.offset << 12);
1568 if (INREG(CURSOR_A_BASEADDR) != physical) {
1571 DBG_MSG("the cursor was killed - restore it !!\n");
1572 DBG_MSG("size %d, %d pos %d, %d\n",
1573 cursor->image.width, cursor->image.height,
1574 cursor->image.dx, cursor->image.dy);
1576 intelfbhw_cursor_init(dinfo);
1577 intelfbhw_cursor_reset(dinfo);
1578 intelfbhw_cursor_setpos(dinfo, cursor->image.dx,
1581 if (dinfo->depth != 8) {
1582 fg =dinfo->pseudo_palette[cursor->image.fg_color];
1583 bg =dinfo->pseudo_palette[cursor->image.bg_color];
1585 fg = cursor->image.fg_color;
1586 bg = cursor->image.bg_color;
1588 intelfbhw_cursor_setcolor(dinfo, bg, fg);
1589 intelfbhw_cursor_load(dinfo, cursor->image.width,
1590 cursor->image.height,
1594 intelfbhw_cursor_show(dinfo);
1598 if (cursor->set & FB_CUR_SETPOS) {
1601 dx = cursor->image.dx - info->var.xoffset;
1602 dy = cursor->image.dy - info->var.yoffset;
1604 intelfbhw_cursor_setpos(dinfo, dx, dy);
1607 if (cursor->set & FB_CUR_SETSIZE) {
1608 if (cursor->image.width > 64 || cursor->image.height > 64)
1611 intelfbhw_cursor_reset(dinfo);
1614 if (cursor->set & FB_CUR_SETCMAP) {
1617 if (dinfo->depth != 8) {
1618 fg = dinfo->pseudo_palette[cursor->image.fg_color];
1619 bg = dinfo->pseudo_palette[cursor->image.bg_color];
1621 fg = cursor->image.fg_color;
1622 bg = cursor->image.bg_color;
1625 intelfbhw_cursor_setcolor(dinfo, bg, fg);
1628 if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
1629 u32 s_pitch = (ROUND_UP_TO(cursor->image.width, 8) / 8);
1630 u32 size = s_pitch * cursor->image.height;
1631 u8 *dat = (u8 *) cursor->image.data;
1632 u8 *msk = (u8 *) cursor->mask;
1636 if (cursor->image.depth != 1)
1639 switch (cursor->rop) {
1641 for (i = 0; i < size; i++)
1642 src[i] = dat[i] ^ msk[i];
1646 for (i = 0; i < size; i++)
1647 src[i] = dat[i] & msk[i];
1651 /* save the bitmap to restore it when XFree will
1652 make the cursor dirty */
1653 memcpy(dinfo->cursor_src, src, size);
1655 intelfbhw_cursor_load(dinfo, cursor->image.width,
1656 cursor->image.height, src);
1660 intelfbhw_cursor_show(dinfo);
1665 static int intelfb_sync(struct fb_info *info)
1667 struct intelfb_info *dinfo = GET_DINFO(info);
1670 DBG_MSG("intelfb_sync\n");
1673 if (dinfo->ring_lockup)
1676 intelfbhw_do_sync(dinfo);