blob: d5644bbe8cbac5de5432005d1d694ffc36112563 [file] [log] [blame]
Antonino A. Daplas317b3c22007-07-17 04:05:28 -07001/*
Antonino A. Daplas317b3c22007-07-17 04:05:28 -07002 * 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>
Paul Gortmaker7c52d552011-05-27 12:33:10 -040011#include <linux/module.h>
Matthew Garrett88674082012-04-16 16:26:04 -040012#include <linux/vgaarb.h>
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070013
14int fb_is_primary_device(struct fb_info *info)
15{
Antonino A. Daplas623e71b2007-07-17 04:05:28 -070016 struct device *device = info->device;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070017 struct pci_dev *pci_dev = NULL;
Matthew Garrett88674082012-04-16 16:26:04 -040018 struct pci_dev *default_device = vga_default_device();
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070019 struct resource *res = NULL;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070020
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070021 if (device)
22 pci_dev = to_pci_dev(device);
23
Matthew Garrett88674082012-04-16 16:26:04 -040024 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];
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070035
36 if (res && res->flags & IORESOURCE_ROM_SHADOW)
Matthew Garrett88674082012-04-16 16:26:04 -040037 return 1;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070038
Matthew Garrett88674082012-04-16 16:26:04 -040039 return 0;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070040}
41EXPORT_SYMBOL(fb_is_primary_device);
Adrian Bunk7b04fa02008-05-02 13:32:32 -070042MODULE_LICENSE("GPL");