blob: 9fd24846d0943628c565f20fccebb4062a019592 [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;
Matthew Garrett88674082012-04-16 16:26:04 -040017 struct pci_dev *default_device = vga_default_device();
Vitaly Kuznetsov743146d2016-03-15 09:20:33 +010018 struct pci_dev *pci_dev;
19 struct resource *res;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070020
Vitaly Kuznetsov743146d2016-03-15 09:20:33 +010021 if (!device || !dev_is_pci(device))
Matthew Garrett88674082012-04-16 16:26:04 -040022 return 0;
23
Vitaly Kuznetsov743146d2016-03-15 09:20:33 +010024 pci_dev = to_pci_dev(device);
25
Matthew Garrett88674082012-04-16 16:26:04 -040026 if (default_device) {
27 if (pci_dev == default_device)
28 return 1;
Vitaly Kuznetsov743146d2016-03-15 09:20:33 +010029 return 0;
Matthew Garrett88674082012-04-16 16:26:04 -040030 }
31
Vitaly Kuznetsov743146d2016-03-15 09:20:33 +010032 res = pci_dev->resource + PCI_ROM_RESOURCE;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070033
Vitaly Kuznetsov743146d2016-03-15 09:20:33 +010034 if (res->flags & IORESOURCE_ROM_SHADOW)
Matthew Garrett88674082012-04-16 16:26:04 -040035 return 1;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070036
Matthew Garrett88674082012-04-16 16:26:04 -040037 return 0;
Antonino A. Daplas317b3c22007-07-17 04:05:28 -070038}
39EXPORT_SYMBOL(fb_is_primary_device);
Adrian Bunk7b04fa02008-05-02 13:32:32 -070040MODULE_LICENSE("GPL");