Linux Audio

Check our new training course

Loading...
v3.5.6
 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#include <linux/fb.h>
10#include <linux/pci.h>
11#include <linux/module.h>
12#include <linux/vgaarb.h>
13
14int fb_is_primary_device(struct fb_info *info)
15{
16	struct device *device = info->device;
17	struct pci_dev *pci_dev = NULL;
18	struct pci_dev *default_device = vga_default_device();
19	struct resource *res = NULL;
 
20
21	if (device)
22		pci_dev = to_pci_dev(device);
23
24	if (!pci_dev)
25		return 0;
26
 
 
27	if (default_device) {
28		if (pci_dev == default_device)
29			return 1;
30		else
31			return 0;
32	}
33
34	res = &pci_dev->resource[PCI_ROM_RESOURCE];
35
36	if (res && res->flags & IORESOURCE_ROM_SHADOW)
37		return 1;
38
39	return 0;
40}
41EXPORT_SYMBOL(fb_is_primary_device);
42MODULE_LICENSE("GPL");
v4.6
 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#include <linux/fb.h>
10#include <linux/pci.h>
11#include <linux/module.h>
12#include <linux/vgaarb.h>
13
14int fb_is_primary_device(struct fb_info *info)
15{
16	struct device *device = info->device;
 
17	struct pci_dev *default_device = vga_default_device();
18	struct pci_dev *pci_dev;
19	struct resource *res;
20
21	if (!device || !dev_is_pci(device))
 
 
 
22		return 0;
23
24	pci_dev = to_pci_dev(device);
25
26	if (default_device) {
27		if (pci_dev == default_device)
28			return 1;
29		return 0;
 
30	}
31
32	res = pci_dev->resource + PCI_ROM_RESOURCE;
33
34	if (res->flags & IORESOURCE_ROM_SHADOW)
35		return 1;
36
37	return 0;
38}
39EXPORT_SYMBOL(fb_is_primary_device);
40MODULE_LICENSE("GPL");