xref: /linux/arch/x86/video/video-common.c (revision 68a052239fc4b351e961f698b824f7654a346091)
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/screen_info.h>
13 #include <linux/vgaarb.h>
14 
15 #include <asm/video.h>
16 
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 
29 bool video_is_primary_device(struct device *dev)
30 {
31 #ifdef CONFIG_SCREEN_INFO
32 	struct screen_info *si = &screen_info;
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 	if (pdev == vga_default_device())
47 		return true;
48 
49 #ifdef CONFIG_SCREEN_INFO
50 	numres = screen_info_resources(si, res, ARRAY_SIZE(res));
51 	for (i = 0; i < numres; ++i) {
52 		if (!(res[i].flags & IORESOURCE_MEM))
53 			continue;
54 
55 		if (pci_find_resource(pdev, &res[i]))
56 			return true;
57 	}
58 #endif
59 
60 	return false;
61 }
62 EXPORT_SYMBOL(video_is_primary_device);
63 
64 MODULE_LICENSE("GPL");
65