Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 1 | /* |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 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> |
Paul Gortmaker | 7c52d55 | 2011-05-27 12:33:10 -0400 | [diff] [blame] | 11 | #include <linux/module.h> |
Matthew Garrett | 8867408 | 2012-04-16 16:26:04 -0400 | [diff] [blame] | 12 | #include <linux/vgaarb.h> |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 13 | |
| 14 | int fb_is_primary_device(struct fb_info *info) |
| 15 | { |
Antonino A. Daplas | 623e71b | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 16 | struct device *device = info->device; |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 17 | struct pci_dev *pci_dev = NULL; |
Matthew Garrett | 8867408 | 2012-04-16 16:26:04 -0400 | [diff] [blame] | 18 | struct pci_dev *default_device = vga_default_device(); |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 19 | struct resource *res = NULL; |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 20 | |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 21 | if (device) |
| 22 | pci_dev = to_pci_dev(device); |
| 23 | |
Matthew Garrett | 8867408 | 2012-04-16 16:26:04 -0400 | [diff] [blame] | 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]; |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 35 | |
| 36 | if (res && res->flags & IORESOURCE_ROM_SHADOW) |
Matthew Garrett | 8867408 | 2012-04-16 16:26:04 -0400 | [diff] [blame] | 37 | return 1; |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 38 | |
Matthew Garrett | 8867408 | 2012-04-16 16:26:04 -0400 | [diff] [blame] | 39 | return 0; |
Antonino A. Daplas | 317b3c2 | 2007-07-17 04:05:28 -0700 | [diff] [blame] | 40 | } |
| 41 | EXPORT_SYMBOL(fb_is_primary_device); |
Adrian Bunk | 7b04fa0 | 2008-05-02 13:32:32 -0700 | [diff] [blame] | 42 | MODULE_LICENSE("GPL"); |