1 /*
2 * Copyright (C) 2007 Antonino Daplas <adaplas@gmail.com>
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
7 *
8 */
9
10 #include <linux/module.h>
11 #include <linux/pci.h>
12 #include <linux/sysfb.h>
13 #include <linux/vgaarb.h>
14
15 #include <asm/video.h>
16
pgprot_framebuffer(pgprot_t prot,unsigned long vm_start,unsigned long vm_end,unsigned long offset)17 pgprot_t pgprot_framebuffer(pgprot_t prot,
18 unsigned long vm_start, unsigned long vm_end,
19 unsigned long offset)
20 {
21 pgprot_val(prot) &= ~_PAGE_CACHE_MASK;
22 if (boot_cpu_data.x86 > 3)
23 pgprot_val(prot) |= cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS);
24
25 return prot;
26 }
27 EXPORT_SYMBOL(pgprot_framebuffer);
28
video_is_primary_device(struct device * dev)29 bool video_is_primary_device(struct device *dev)
30 {
31 #ifdef CONFIG_SCREEN_INFO
32 struct screen_info *si = &sysfb_primary_display.screen;
33 struct resource res[SCREEN_INFO_MAX_RESOURCES];
34 ssize_t i, numres;
35 #endif
36 struct pci_dev *pdev;
37
38 if (!dev_is_pci(dev))
39 return false;
40
41 pdev = to_pci_dev(dev);
42
43 if (!pci_is_display(pdev))
44 return false;
45
46 #ifdef CONFIG_SCREEN_INFO
47 numres = screen_info_resources(si, res, ARRAY_SIZE(res));
48 if (numres > 0) {
49 for (i = 0; i < numres; ++i) {
50 if (!(res[i].flags & IORESOURCE_MEM))
51 continue;
52
53 if (pci_find_resource(pdev, &res[i]))
54 return true;
55 }
56
57 return false;
58 }
59 #endif
60
61 /*
62 * No framebuffer was set up by the firmware/bootloader, so fall back
63 * to the default VGA device.
64 */
65 return pdev == vga_default_device();
66 }
67 EXPORT_SYMBOL(video_is_primary_device);
68
69 MODULE_LICENSE("GPL");
70