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
17pgprot_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(pcm: _PAGE_CACHE_MODE_UC_MINUS);
24
25 return prot;
26}
27EXPORT_SYMBOL(pgprot_framebuffer);
28
29bool 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}
62EXPORT_SYMBOL(video_is_primary_device);
63
64MODULE_LICENSE("GPL");
65