4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/
5 * 945G/945GM integrated graphics chips.
7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
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
111 #include <linux/config.h>
112 #include <linux/module.h>
113 #include <linux/kernel.h>
114 #include <linux/errno.h>
115 #include <linux/string.h>
116 #include <linux/mm.h>
117 #include <linux/tty.h>
118 #include <linux/slab.h>
119 #include <linux/delay.h>
120 #include <linux/fb.h>
121 #include <linux/ioport.h>
122 #include <linux/init.h>
123 #include <linux/pci.h>
124 #include <linux/vmalloc.h>
125 #include <linux/pagemap.h>
130 #include <asm/mtrr.h>
134 #include "intelfbhw.h"
137 static void __devinit get_initial_mode(struct intelfb_info *dinfo);
138 static void update_dinfo(struct intelfb_info *dinfo,
139 struct fb_var_screeninfo *var);
140 static int intelfb_open(struct fb_info *info, int user);
141 static int intelfb_release(struct fb_info *info, int user);
142 static int intelfb_check_var(struct fb_var_screeninfo *var,
143 struct fb_info *info);
144 static int intelfb_set_par(struct fb_info *info);
145 static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
146 unsigned blue, unsigned transp,
147 struct fb_info *info);
149 static int intelfb_blank(int blank, struct fb_info *info);
150 static int intelfb_pan_display(struct fb_var_screeninfo *var,
151 struct fb_info *info);
153 static void intelfb_fillrect(struct fb_info *info,
154 const struct fb_fillrect *rect);
155 static void intelfb_copyarea(struct fb_info *info,
156 const struct fb_copyarea *region);
157 static void intelfb_imageblit(struct fb_info *info,
158 const struct fb_image *image);
159 static int intelfb_cursor(struct fb_info *info,
160 struct fb_cursor *cursor);
162 static int intelfb_sync(struct fb_info *info);
164 static int intelfb_ioctl(struct fb_info *info,
165 unsigned int cmd, unsigned long arg);
167 static int __devinit intelfb_pci_register(struct pci_dev *pdev,
168 const struct pci_device_id *ent);
169 static void __devexit intelfb_pci_unregister(struct pci_dev *pdev);
170 static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo);
173 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the
174 * mobile chipsets from being registered.
176 #if DETECT_VGA_CLASS_ONLY
177 #define INTELFB_CLASS_MASK ~0 << 8
179 #define INTELFB_CLASS_MASK 0
182 static struct pci_device_id intelfb_pci_table[] __devinitdata = {
183 { 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 },
184 { 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 },
185 { 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 },
186 { 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 },
187 { 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 },
188 { 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 },
189 { 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 },
190 { 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 },
195 static int num_registered = 0;
198 static struct fb_ops intel_fb_ops = {
199 .owner = THIS_MODULE,
200 .fb_open = intelfb_open,
201 .fb_release = intelfb_release,
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 = 0;
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 hardware 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) + 1, 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 intelfbhw_disable_irq(dinfo);
456 fb_dealloc_cmap(&dinfo->info->cmap);
457 kfree(dinfo->info->pixmap.addr);
459 if (dinfo->registered)
460 unregister_framebuffer(dinfo->info);
464 if (dinfo->fbmem_gart && dinfo->gtt_fb_mem) {
465 agp_unbind_memory(dinfo->gtt_fb_mem);
466 agp_free_memory(dinfo->gtt_fb_mem);
468 if (dinfo->gtt_cursor_mem) {
469 agp_unbind_memory(dinfo->gtt_cursor_mem);
470 agp_free_memory(dinfo->gtt_cursor_mem);
472 if (dinfo->gtt_ring_mem) {
473 agp_unbind_memory(dinfo->gtt_ring_mem);
474 agp_free_memory(dinfo->gtt_ring_mem);
477 if (dinfo->mmio_base)
478 iounmap((void __iomem *)dinfo->mmio_base);
479 if (dinfo->aperture.virtual)
480 iounmap((void __iomem *)dinfo->aperture.virtual);
482 if (dinfo->flag & INTELFB_MMIO_ACQUIRED)
483 release_mem_region(dinfo->mmio_base_phys, INTEL_REG_SIZE);
484 if (dinfo->flag & INTELFB_FB_ACQUIRED)
485 release_mem_region(dinfo->aperture.physical,
486 dinfo->aperture.size);
487 framebuffer_release(dinfo->info);
490 #define bailout(dinfo) do { \
491 DBG_MSG("bailout\n"); \
493 INF_MSG("Not going to register framebuffer, exiting...\n"); \
499 intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
501 struct fb_info *info;
502 struct intelfb_info *dinfo;
504 int aperture_size, stolen_size;
505 struct agp_kern_info gtt_info;
508 struct agp_bridge_data *bridge;
509 int aperture_bar = 0;
513 DBG_MSG("intelfb_pci_register\n");
516 if (num_registered != 1) {
517 ERR_MSG("Attempted to register %d devices "
518 "(should be only 1).\n", num_registered);
522 info = framebuffer_alloc(sizeof(struct intelfb_info), &pdev->dev);
524 ERR_MSG("Could not allocate memory for intelfb_info.\n");
527 if (fb_alloc_cmap(&info->cmap, 256, 1) < 0) {
528 ERR_MSG("Could not allocate cmap for intelfb_info.\n");
535 dinfo->fbops = &intel_fb_ops;
538 /* Reserve pixmap space. */
539 info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL);
540 if (info->pixmap.addr == NULL) {
541 ERR_MSG("Cannot reserve pixmap memory.\n");
544 memset(info->pixmap.addr, 0, 64 * 1024);
546 /* set early this option because it could be changed by tv encoder
548 dinfo->fixed_mode = fixed;
551 if ((err = pci_enable_device(pdev))) {
552 ERR_MSG("Cannot enable device.\n");
557 /* Set base addresses. */
558 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) ||
559 (ent->device == PCI_DEVICE_ID_INTEL_915GM) ||
560 (ent->device == PCI_DEVICE_ID_INTEL_945G) ||
561 (ent->device == PCI_DEVICE_ID_INTEL_945GM)) {
565 dinfo->aperture.physical = pci_resource_start(pdev, aperture_bar);
566 dinfo->aperture.size = pci_resource_len(pdev, aperture_bar);
567 dinfo->mmio_base_phys = pci_resource_start(pdev, mmio_bar);
568 DBG_MSG("fb aperture: 0x%llx/0x%llx, MMIO region: 0x%llx/0x%llx\n",
569 (unsigned long long)pci_resource_start(pdev, aperture_bar),
570 (unsigned long long)pci_resource_len(pdev, aperture_bar),
571 (unsigned long long)pci_resource_start(pdev, mmio_bar),
572 (unsigned long long)pci_resource_len(pdev, mmio_bar));
574 /* Reserve the fb and MMIO regions */
575 if (!request_mem_region(dinfo->aperture.physical, dinfo->aperture.size,
576 INTELFB_MODULE_NAME)) {
577 ERR_MSG("Cannot reserve FB region.\n");
582 dinfo->flag |= INTELFB_FB_ACQUIRED;
584 if (!request_mem_region(dinfo->mmio_base_phys,
586 INTELFB_MODULE_NAME)) {
587 ERR_MSG("Cannot reserve MMIO region.\n");
592 dinfo->flag |= INTELFB_MMIO_ACQUIRED;
594 /* Get the chipset info. */
595 dinfo->pci_chipset = pdev->device;
597 if (intelfbhw_get_chipset(pdev, dinfo)) {
602 if (intelfbhw_get_memory(pdev, &aperture_size,&stolen_size)) {
607 INF_MSG("%02x:%02x.%d: %s, aperture size %dMB, "
608 "stolen memory %dkB\n",
609 pdev->bus->number, PCI_SLOT(pdev->devfn),
610 PCI_FUNC(pdev->devfn), dinfo->name,
611 BtoMB(aperture_size), BtoKB(stolen_size));
613 /* Set these from the options. */
614 dinfo->accel = accel;
615 dinfo->hwcursor = hwcursor;
617 if (NOACCEL_CHIPSET(dinfo) && dinfo->accel == 1) {
618 INF_MSG("Acceleration is not supported for the %s chipset.\n",
623 /* Framebuffer parameters - Use all the stolen memory if >= vram */
624 if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) {
625 dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size);
626 dinfo->fbmem_gart = 0;
628 dinfo->fb.size = MB(vram);
629 dinfo->fbmem_gart = 1;
632 /* Allocate space for the ring buffer and HW cursor if enabled. */
634 dinfo->ring.size = RINGBUFFER_SIZE;
635 dinfo->ring_tail_mask = dinfo->ring.size - 1;
637 if (dinfo->hwcursor) {
638 dinfo->cursor.size = HW_CURSOR_SIZE;
641 /* Use agpgart to manage the GATT */
642 if (!(bridge = agp_backend_acquire(pdev))) {
643 ERR_MSG("cannot acquire agp\n");
648 /* get the current gatt info */
649 if (agp_copy_info(bridge, >t_info)) {
650 ERR_MSG("cannot get agp info\n");
651 agp_backend_release(bridge);
656 if (MB(voffset) < stolen_size)
657 offset = (stolen_size >> 12);
659 offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
661 /* set the mem offsets - set them after the already used pages */
663 dinfo->ring.offset = offset + gtt_info.current_memory;
665 if (dinfo->hwcursor) {
666 dinfo->cursor.offset = offset +
667 + gtt_info.current_memory + (dinfo->ring.size >> 12);
669 if (dinfo->fbmem_gart) {
670 dinfo->fb.offset = offset +
671 + gtt_info.current_memory + (dinfo->ring.size >> 12)
672 + (dinfo->cursor.size >> 12);
675 /* Allocate memories (which aren't stolen) */
676 /* Map the fb and MMIO regions */
677 /* ioremap only up to the end of used aperture */
678 dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache
679 (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12)
681 if (!dinfo->aperture.virtual) {
682 ERR_MSG("Cannot remap FB region.\n");
688 (u8 __iomem *)ioremap_nocache(dinfo->mmio_base_phys,
690 if (!dinfo->mmio_base) {
691 ERR_MSG("Cannot remap MMIO region.\n");
697 if (!(dinfo->gtt_ring_mem =
698 agp_allocate_memory(bridge, dinfo->ring.size >> 12,
699 AGP_NORMAL_MEMORY))) {
700 ERR_MSG("cannot allocate ring buffer memory\n");
701 agp_backend_release(bridge);
705 if (agp_bind_memory(dinfo->gtt_ring_mem,
706 dinfo->ring.offset)) {
707 ERR_MSG("cannot bind ring buffer memory\n");
708 agp_backend_release(bridge);
712 dinfo->ring.physical = dinfo->aperture.physical
713 + (dinfo->ring.offset << 12);
714 dinfo->ring.virtual = dinfo->aperture.virtual
715 + (dinfo->ring.offset << 12);
716 dinfo->ring_head = 0;
718 if (dinfo->hwcursor) {
719 agp_memtype = dinfo->mobile ? AGP_PHYSICAL_MEMORY
721 if (!(dinfo->gtt_cursor_mem =
722 agp_allocate_memory(bridge, dinfo->cursor.size >> 12,
724 ERR_MSG("cannot allocate cursor memory\n");
725 agp_backend_release(bridge);
729 if (agp_bind_memory(dinfo->gtt_cursor_mem,
730 dinfo->cursor.offset)) {
731 ERR_MSG("cannot bind cursor memory\n");
732 agp_backend_release(bridge);
737 dinfo->cursor.physical
738 = dinfo->gtt_cursor_mem->physical;
740 dinfo->cursor.physical = dinfo->aperture.physical
741 + (dinfo->cursor.offset << 12);
742 dinfo->cursor.virtual = dinfo->aperture.virtual
743 + (dinfo->cursor.offset << 12);
745 if (dinfo->fbmem_gart) {
746 if (!(dinfo->gtt_fb_mem =
747 agp_allocate_memory(bridge, dinfo->fb.size >> 12,
748 AGP_NORMAL_MEMORY))) {
749 WRN_MSG("cannot allocate framebuffer memory - use "
751 dinfo->fbmem_gart = 0;
753 if (agp_bind_memory(dinfo->gtt_fb_mem,
755 WRN_MSG("cannot bind framebuffer memory - use "
757 dinfo->fbmem_gart = 0;
761 /* update framebuffer memory parameters */
762 if (!dinfo->fbmem_gart)
763 dinfo->fb.offset = 0; /* starts at offset 0 */
764 dinfo->fb.physical = dinfo->aperture.physical
765 + (dinfo->fb.offset << 12);
766 dinfo->fb.virtual = dinfo->aperture.virtual + (dinfo->fb.offset << 12);
767 dinfo->fb_start = dinfo->fb.offset << 12;
769 /* release agpgart */
770 agp_backend_release(bridge);
775 DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%p)\n",
776 dinfo->fb.physical, dinfo->fb.offset, dinfo->fb.size,
778 DBG_MSG("MMIO: 0x%x/0x%x (0x%p)\n",
779 dinfo->mmio_base_phys, INTEL_REG_SIZE,
781 DBG_MSG("ring buffer: 0x%x/0x%x (0x%p)\n",
782 dinfo->ring.physical, dinfo->ring.size,
783 dinfo->ring.virtual);
784 DBG_MSG("HW cursor: 0x%x/0x%x (0x%p) (offset 0x%x) (phys 0x%x)\n",
785 dinfo->cursor.physical, dinfo->cursor.size,
786 dinfo->cursor.virtual, dinfo->cursor.offset,
787 dinfo->cursor.physical);
789 DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, "
790 "noinit = %d\n", vram, accel, hwcursor, fixed, noinit);
791 DBG_MSG("options: mode = \"%s\"\n", mode ? mode : "");
797 * Check if the LVDS port or any DVO ports are enabled. If so,
798 * don't allow mode switching
800 dvo = intelfbhw_check_non_crt(dinfo);
802 dinfo->fixed_mode = 1;
803 WRN_MSG("Non-CRT device is enabled ( ");
807 s = intelfbhw_dvo_to_string(1 << i);
814 printk("). Disabling mode switching.\n");
820 if (FIXED_MODE(dinfo) && ORIG_VIDEO_ISVGA != VIDEO_TYPE_VLFB) {
821 ERR_MSG("Video mode must be programmed at boot time.\n");
829 /* Initialise dinfo and related data. */
830 /* If an initial mode was programmed at boot time, get its details. */
831 if (ORIG_VIDEO_ISVGA == VIDEO_TYPE_VLFB)
832 get_initial_mode(dinfo);
837 if (FIXED_MODE(dinfo)) {
838 /* remap fb address */
839 update_dinfo(dinfo, &dinfo->initial_var);
846 if (intelfb_set_fbinfo(dinfo)) {
857 pci_set_drvdata(pdev, dinfo);
859 /* Save the initial register state. */
860 i = intelfbhw_read_hw_state(dinfo, &dinfo->save_state,
861 bailearly > 6 ? bailearly - 6 : 0);
863 DBG_MSG("intelfbhw_read_hw_state returned %d\n", i);
867 intelfbhw_print_hw_state(dinfo, &dinfo->save_state);
872 /* Cursor initialisation */
873 if (dinfo->hwcursor) {
874 intelfbhw_cursor_init(dinfo);
875 intelfbhw_cursor_reset(dinfo);
881 /* 2d acceleration init */
883 intelfbhw_2d_start(dinfo);
891 if (register_framebuffer(dinfo->info) < 0) {
892 ERR_MSG("Cannot register framebuffer.\n");
897 dinfo->registered = 1;
900 init_waitqueue_head(&dinfo->vsync.wait);
901 spin_lock_init(&dinfo->int_lock);
902 dinfo->irq_flags = 0;
907 fb_dealloc_cmap(&info->cmap);
909 framebuffer_release(info);
913 static void __devexit
914 intelfb_pci_unregister(struct pci_dev *pdev)
916 struct intelfb_info *dinfo = pci_get_drvdata(pdev);
918 DBG_MSG("intelfb_pci_unregister\n");
925 pci_set_drvdata(pdev, NULL);
928 /***************************************************************
930 ***************************************************************/
933 intelfb_var_to_depth(const struct fb_var_screeninfo *var)
935 DBG_MSG("intelfb_var_to_depth: bpp: %d, green.length is %d\n",
936 var->bits_per_pixel, var->green.length);
938 switch (var->bits_per_pixel) {
940 return (var->green.length == 6) ? 16 : 15;
944 return var->bits_per_pixel;
949 static __inline__ int
950 var_to_refresh(const struct fb_var_screeninfo *var)
952 int xtot = var->xres + var->left_margin + var->right_margin +
954 int ytot = var->yres + var->upper_margin + var->lower_margin +
957 return (1000000000 / var->pixclock * 1000 + 500) / xtot / ytot;
960 /***************************************************************
961 * Various intialisation functions *
962 ***************************************************************/
964 static void __devinit
965 get_initial_mode(struct intelfb_info *dinfo)
967 struct fb_var_screeninfo *var;
970 DBG_MSG("get_initial_mode\n");
972 dinfo->initial_vga = 1;
973 dinfo->initial_fb_base = screen_info.lfb_base;
974 dinfo->initial_video_ram = screen_info.lfb_size * KB(64);
975 dinfo->initial_pitch = screen_info.lfb_linelength;
977 var = &dinfo->initial_var;
978 memset(var, 0, sizeof(*var));
979 var->xres = screen_info.lfb_width;
980 var->yres = screen_info.lfb_height;
981 var->bits_per_pixel = screen_info.lfb_depth;
982 switch (screen_info.lfb_depth) {
984 var->bits_per_pixel = 16;
987 var->bits_per_pixel = 32;
991 DBG_MSG("Initial info: FB is 0x%x/0x%x (%d kByte)\n",
992 dinfo->initial_fb_base, dinfo->initial_video_ram,
993 BtoKB(dinfo->initial_video_ram));
995 DBG_MSG("Initial info: mode is %dx%d-%d (%d)\n",
996 var->xres, var->yres, var->bits_per_pixel,
997 dinfo->initial_pitch);
999 /* Dummy timing values (assume 60Hz) */
1000 var->left_margin = (var->xres / 8) & 0xf8;
1001 var->right_margin = 32;
1002 var->upper_margin = 16;
1003 var->lower_margin = 4;
1004 var->hsync_len = (var->xres / 8) & 0xf8;
1007 xtot = var->xres + var->left_margin +
1008 var->right_margin + var->hsync_len;
1009 ytot = var->yres + var->upper_margin +
1010 var->lower_margin + var->vsync_len;
1011 var->pixclock = 10000000 / xtot * 1000 / ytot * 100 / 60;
1016 if (var->bits_per_pixel > 8) {
1017 var->red.offset = screen_info.red_pos;
1018 var->red.length = screen_info.red_size;
1019 var->green.offset = screen_info.green_pos;
1020 var->green.length = screen_info.green_size;
1021 var->blue.offset = screen_info.blue_pos;
1022 var->blue.length = screen_info.blue_size;
1023 var->transp.offset = screen_info.rsvd_pos;
1024 var->transp.length = screen_info.rsvd_size;
1026 var->red.length = 8;
1027 var->green.length = 8;
1028 var->blue.length = 8;
1032 static int __devinit
1033 intelfb_init_var(struct intelfb_info *dinfo)
1035 struct fb_var_screeninfo *var;
1038 DBG_MSG("intelfb_init_var\n");
1040 var = &dinfo->info->var;
1041 if (FIXED_MODE(dinfo)) {
1042 memcpy(var, &dinfo->initial_var,
1043 sizeof(struct fb_var_screeninfo));
1046 const u8 *edid_s = fb_firmware_edid(&dinfo->pdev->dev);
1050 edid_d = kmalloc(EDID_LENGTH, GFP_KERNEL);
1053 memcpy(edid_d, edid_s, EDID_LENGTH);
1054 fb_edid_to_monspecs(edid_d,
1055 &dinfo->info->monspecs);
1061 printk("intelfb: Looking for mode in private "
1063 msrc = fb_find_mode(var, dinfo->info, mode,
1064 dinfo->info->monspecs.modedb,
1065 dinfo->info->monspecs.modedb_len,
1068 if (msrc && msrc > 1) {
1069 printk("intelfb: No mode in private database, "
1070 "intelfb: looking for mode in global "
1072 msrc = fb_find_mode(var, dinfo->info, mode,
1082 msrc = fb_find_mode(var, dinfo->info, PREFERRED_MODE,
1088 ERR_MSG("Cannot find a suitable video mode.\n");
1092 INF_MSG("Initial video mode is %dx%d-%d@%d.\n", var->xres, var->yres,
1093 var->bits_per_pixel, var_to_refresh(var));
1095 DBG_MSG("Initial video mode is from %d.\n", msrc);
1097 #if ALLOCATE_FOR_PANNING
1098 /* Allow use of half of the video ram for panning */
1099 var->xres_virtual = var->xres;
1101 dinfo->fb.size / 2 / (var->bits_per_pixel * var->xres);
1102 if (var->yres_virtual < var->yres)
1103 var->yres_virtual = var->yres;
1105 var->yres_virtual = var->yres;
1109 var->accel_flags |= FB_ACCELF_TEXT;
1111 var->accel_flags &= ~FB_ACCELF_TEXT;
1116 static int __devinit
1117 intelfb_set_fbinfo(struct intelfb_info *dinfo)
1119 struct fb_info *info = dinfo->info;
1121 DBG_MSG("intelfb_set_fbinfo\n");
1123 info->flags = FBINFO_FLAG_DEFAULT;
1124 info->fbops = &intel_fb_ops;
1125 info->pseudo_palette = dinfo->pseudo_palette;
1127 info->pixmap.size = 64*1024;
1128 info->pixmap.buf_align = 8;
1129 info->pixmap.access_align = 32;
1130 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1132 if (intelfb_init_var(dinfo))
1135 info->pixmap.scan_align = 1;
1136 strcpy(info->fix.id, dinfo->name);
1137 info->fix.smem_start = dinfo->fb.physical;
1138 info->fix.smem_len = dinfo->fb.size;
1139 info->fix.type = FB_TYPE_PACKED_PIXELS;
1140 info->fix.type_aux = 0;
1141 info->fix.xpanstep = 8;
1142 info->fix.ypanstep = 1;
1143 info->fix.ywrapstep = 0;
1144 info->fix.mmio_start = dinfo->mmio_base_phys;
1145 info->fix.mmio_len = INTEL_REG_SIZE;
1146 info->fix.accel = FB_ACCEL_I830;
1147 update_dinfo(dinfo, &info->var);
1152 /* Update dinfo to match the active video mode. */
1154 update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var)
1156 DBG_MSG("update_dinfo\n");
1158 dinfo->bpp = var->bits_per_pixel;
1159 dinfo->depth = intelfb_var_to_depth(var);
1160 dinfo->xres = var->xres;
1161 dinfo->yres = var->xres;
1162 dinfo->pixclock = var->pixclock;
1164 dinfo->info->fix.visual = dinfo->visual;
1165 dinfo->info->fix.line_length = dinfo->pitch;
1167 switch (dinfo->bpp) {
1169 dinfo->visual = FB_VISUAL_PSEUDOCOLOR;
1170 dinfo->pitch = var->xres_virtual;
1173 dinfo->visual = FB_VISUAL_TRUECOLOR;
1174 dinfo->pitch = var->xres_virtual * 2;
1177 dinfo->visual = FB_VISUAL_TRUECOLOR;
1178 dinfo->pitch = var->xres_virtual * 4;
1182 /* Make sure the line length is a aligned correctly. */
1184 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT_I9XX);
1186 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT);
1188 if (FIXED_MODE(dinfo))
1189 dinfo->pitch = dinfo->initial_pitch;
1191 dinfo->info->screen_base = (char __iomem *)dinfo->fb.virtual;
1192 dinfo->info->fix.line_length = dinfo->pitch;
1193 dinfo->info->fix.visual = dinfo->visual;
1196 /* fbops functions */
1198 /***************************************************************
1200 ***************************************************************/
1203 intelfb_open(struct fb_info *info, int user)
1205 struct intelfb_info *dinfo = GET_DINFO(info);
1215 intelfb_release(struct fb_info *info, int user)
1217 struct intelfb_info *dinfo = GET_DINFO(info);
1223 intelfbhw_disable_irq(dinfo);
1231 intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
1234 struct fb_var_screeninfo v;
1235 struct intelfb_info *dinfo;
1236 static int first = 1;
1238 /* Good pitches to allow tiling. Don't care about pitches < 1024. */
1239 static const int pitches[] = {
1247 DBG_MSG("intelfb_check_var: accel_flags is %d\n", var->accel_flags);
1249 dinfo = GET_DINFO(info);
1251 /* update the pitch */
1252 if (intelfbhw_validate_mode(dinfo, var) != 0)
1257 for (i = 0; pitches[i] != 0; i++) {
1258 if (pitches[i] >= v.xres_virtual) {
1259 v.xres_virtual = pitches[i];
1264 /* Check for a supported bpp. */
1265 if (v.bits_per_pixel <= 8) {
1266 v.bits_per_pixel = 8;
1267 } else if (v.bits_per_pixel <= 16) {
1268 if (v.bits_per_pixel == 16)
1270 v.bits_per_pixel = 16;
1271 } else if (v.bits_per_pixel <= 32) {
1272 v.bits_per_pixel = 32;
1276 change_var = ((info->var.xres != var->xres) ||
1277 (info->var.yres != var->yres) ||
1278 (info->var.xres_virtual != var->xres_virtual) ||
1279 (info->var.yres_virtual != var->yres_virtual) ||
1280 (info->var.bits_per_pixel != var->bits_per_pixel) ||
1281 memcmp(&info->var.red, &var->red, sizeof(var->red)) ||
1282 memcmp(&info->var.green, &var->green,
1283 sizeof(var->green)) ||
1284 memcmp(&info->var.blue, &var->blue, sizeof(var->blue)));
1286 if (FIXED_MODE(dinfo) &&
1288 var->yres_virtual > dinfo->initial_var.yres_virtual ||
1289 var->yres_virtual < dinfo->initial_var.yres ||
1290 var->xoffset || var->nonstd)) {
1292 ERR_MSG("Changing the video mode is not supported.\n");
1298 switch (intelfb_var_to_depth(&v)) {
1300 v.red.offset = v.green.offset = v.blue.offset = 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 = 5;
1309 v.transp.offset = v.transp.length = 0;
1318 v.transp.offset = v.transp.length = 0;
1324 v.red.length = v.green.length = v.blue.length = 8;
1325 v.transp.offset = v.transp.length = 0;
1331 v.red.length = v.green.length = v.blue.length = 8;
1332 v.transp.offset = 24;
1333 v.transp.length = 8;
1342 if (v.xoffset > v.xres_virtual - v.xres)
1343 v.xoffset = v.xres_virtual - v.xres;
1344 if (v.yoffset > v.yres_virtual - v.yres)
1345 v.yoffset = v.yres_virtual - v.yres;
1347 v.red.msb_right = v.green.msb_right = v.blue.msb_right =
1348 v.transp.msb_right = 0;
1356 intelfb_set_par(struct fb_info *info)
1358 struct intelfb_hwstate *hw;
1359 struct intelfb_info *dinfo = GET_DINFO(info);
1361 if (FIXED_MODE(dinfo)) {
1362 ERR_MSG("Changing the video mode is not supported.\n");
1366 hw = kmalloc(sizeof(*hw), GFP_ATOMIC);
1370 DBG_MSG("intelfb_set_par (%dx%d-%d)\n", info->var.xres,
1371 info->var.yres, info->var.bits_per_pixel);
1373 intelfb_blank(FB_BLANK_POWERDOWN, info);
1375 if (ACCEL(dinfo, info))
1376 intelfbhw_2d_stop(dinfo);
1378 memcpy(hw, &dinfo->save_state, sizeof(*hw));
1379 if (intelfbhw_mode_to_hw(dinfo, hw, &info->var))
1381 if (intelfbhw_program_mode(dinfo, hw, 0))
1385 intelfbhw_read_hw_state(dinfo, hw, 0);
1386 intelfbhw_print_hw_state(dinfo, hw);
1389 update_dinfo(dinfo, &info->var);
1391 if (ACCEL(dinfo, info))
1392 intelfbhw_2d_start(dinfo);
1394 intelfb_pan_display(&info->var, info);
1396 intelfb_blank(FB_BLANK_UNBLANK, info);
1398 if (ACCEL(dinfo, info)) {
1399 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
1400 FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
1401 FBINFO_HWACCEL_IMAGEBLIT;
1403 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1413 intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
1414 unsigned blue, unsigned transp, struct fb_info *info)
1416 struct intelfb_info *dinfo = GET_DINFO(info);
1419 DBG_MSG("intelfb_setcolreg: regno %d, depth %d\n", regno, dinfo->depth);
1425 if (dinfo->depth == 8) {
1430 intelfbhw_setcolreg(dinfo, regno, red, green, blue,
1435 switch (dinfo->depth) {
1437 dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
1438 ((green & 0xf800) >> 6) |
1439 ((blue & 0xf800) >> 11);
1442 dinfo->pseudo_palette[regno] = (red & 0xf800) |
1443 ((green & 0xfc00) >> 5) |
1444 ((blue & 0xf800) >> 11);
1447 dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) |
1449 ((blue & 0xff00) >> 8);
1458 intelfb_blank(int blank, struct fb_info *info)
1460 intelfbhw_do_blank(blank, info);
1465 intelfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
1467 intelfbhw_pan_display(var, info);
1471 /* When/if we have our own ioctls. */
1473 intelfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
1476 struct intelfb_info *dinfo = GET_DINFO(info);
1480 case FBIO_WAITFORVSYNC:
1481 if (get_user(pipe, (__u32 __user *)arg))
1484 retval = intelfbhw_wait_for_vsync(dinfo, pipe);
1494 intelfb_fillrect (struct fb_info *info, const struct fb_fillrect *rect)
1496 struct intelfb_info *dinfo = GET_DINFO(info);
1500 DBG_MSG("intelfb_fillrect\n");
1503 if (!ACCEL(dinfo, info) || dinfo->depth == 4)
1504 return cfb_fillrect(info, rect);
1506 if (rect->rop == ROP_COPY)
1507 rop = PAT_ROP_GXCOPY;
1509 rop = PAT_ROP_GXXOR;
1511 if (dinfo->depth != 8)
1512 color = dinfo->pseudo_palette[rect->color];
1514 color = rect->color;
1516 intelfbhw_do_fillrect(dinfo, rect->dx, rect->dy,
1517 rect->width, rect->height, color,
1518 dinfo->pitch, info->var.bits_per_pixel,
1523 intelfb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
1525 struct intelfb_info *dinfo = GET_DINFO(info);
1528 DBG_MSG("intelfb_copyarea\n");
1531 if (!ACCEL(dinfo, info) || dinfo->depth == 4)
1532 return cfb_copyarea(info, region);
1534 intelfbhw_do_bitblt(dinfo, region->sx, region->sy, region->dx,
1535 region->dy, region->width, region->height,
1536 dinfo->pitch, info->var.bits_per_pixel);
1540 intelfb_imageblit(struct fb_info *info, const struct fb_image *image)
1542 struct intelfb_info *dinfo = GET_DINFO(info);
1543 u32 fgcolor, bgcolor;
1546 DBG_MSG("intelfb_imageblit\n");
1549 if (!ACCEL(dinfo, info) || dinfo->depth == 4
1550 || image->depth != 1)
1551 return cfb_imageblit(info, image);
1553 if (dinfo->depth != 8) {
1554 fgcolor = dinfo->pseudo_palette[image->fg_color];
1555 bgcolor = dinfo->pseudo_palette[image->bg_color];
1557 fgcolor = image->fg_color;
1558 bgcolor = image->bg_color;
1561 if (!intelfbhw_do_drawglyph(dinfo, fgcolor, bgcolor, image->width,
1562 image->height, image->data,
1563 image->dx, image->dy,
1564 dinfo->pitch, info->var.bits_per_pixel))
1565 return cfb_imageblit(info, image);
1569 intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1571 struct intelfb_info *dinfo = GET_DINFO(info);
1574 DBG_MSG("intelfb_cursor\n");
1577 if (!dinfo->hwcursor)
1580 intelfbhw_cursor_hide(dinfo);
1582 /* If XFree killed the cursor - restore it */
1583 physical = (dinfo->mobile || IS_I9XX(dinfo)) ? dinfo->cursor.physical :
1584 (dinfo->cursor.offset << 12);
1586 if (INREG(CURSOR_A_BASEADDR) != physical) {
1589 DBG_MSG("the cursor was killed - restore it !!\n");
1590 DBG_MSG("size %d, %d pos %d, %d\n",
1591 cursor->image.width, cursor->image.height,
1592 cursor->image.dx, cursor->image.dy);
1594 intelfbhw_cursor_init(dinfo);
1595 intelfbhw_cursor_reset(dinfo);
1596 intelfbhw_cursor_setpos(dinfo, cursor->image.dx,
1599 if (dinfo->depth != 8) {
1600 fg =dinfo->pseudo_palette[cursor->image.fg_color];
1601 bg =dinfo->pseudo_palette[cursor->image.bg_color];
1603 fg = cursor->image.fg_color;
1604 bg = cursor->image.bg_color;
1606 intelfbhw_cursor_setcolor(dinfo, bg, fg);
1607 intelfbhw_cursor_load(dinfo, cursor->image.width,
1608 cursor->image.height,
1612 intelfbhw_cursor_show(dinfo);
1616 if (cursor->set & FB_CUR_SETPOS) {
1619 dx = cursor->image.dx - info->var.xoffset;
1620 dy = cursor->image.dy - info->var.yoffset;
1622 intelfbhw_cursor_setpos(dinfo, dx, dy);
1625 if (cursor->set & FB_CUR_SETSIZE) {
1626 if (cursor->image.width > 64 || cursor->image.height > 64)
1629 intelfbhw_cursor_reset(dinfo);
1632 if (cursor->set & FB_CUR_SETCMAP) {
1635 if (dinfo->depth != 8) {
1636 fg = dinfo->pseudo_palette[cursor->image.fg_color];
1637 bg = dinfo->pseudo_palette[cursor->image.bg_color];
1639 fg = cursor->image.fg_color;
1640 bg = cursor->image.bg_color;
1643 intelfbhw_cursor_setcolor(dinfo, bg, fg);
1646 if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
1647 u32 s_pitch = (ROUND_UP_TO(cursor->image.width, 8) / 8);
1648 u32 size = s_pitch * cursor->image.height;
1649 u8 *dat = (u8 *) cursor->image.data;
1650 u8 *msk = (u8 *) cursor->mask;
1654 if (cursor->image.depth != 1)
1657 switch (cursor->rop) {
1659 for (i = 0; i < size; i++)
1660 src[i] = dat[i] ^ msk[i];
1664 for (i = 0; i < size; i++)
1665 src[i] = dat[i] & msk[i];
1669 /* save the bitmap to restore it when XFree will
1670 make the cursor dirty */
1671 memcpy(dinfo->cursor_src, src, size);
1673 intelfbhw_cursor_load(dinfo, cursor->image.width,
1674 cursor->image.height, src);
1678 intelfbhw_cursor_show(dinfo);
1684 intelfb_sync(struct fb_info *info)
1686 struct intelfb_info *dinfo = GET_DINFO(info);
1689 DBG_MSG("intelfb_sync\n");
1692 if (dinfo->ring_lockup)
1695 intelfbhw_do_sync(dinfo);