18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2007 Antonino Daplas <adaplas@gmail.com>
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
58c2ecf20Sopenharmony_ci * License.  See the file COPYING in the main directory of this archive
68c2ecf20Sopenharmony_ci * for more details.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#include <linux/fb.h>
108c2ecf20Sopenharmony_ci#include <linux/pci.h>
118c2ecf20Sopenharmony_ci#include <linux/module.h>
128c2ecf20Sopenharmony_ci#include <linux/vgaarb.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciint fb_is_primary_device(struct fb_info *info)
158c2ecf20Sopenharmony_ci{
168c2ecf20Sopenharmony_ci	struct device *device = info->device;
178c2ecf20Sopenharmony_ci	struct pci_dev *default_device = vga_default_device();
188c2ecf20Sopenharmony_ci	struct pci_dev *pci_dev;
198c2ecf20Sopenharmony_ci	struct resource *res;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	if (!device || !dev_is_pci(device))
228c2ecf20Sopenharmony_ci		return 0;
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	pci_dev = to_pci_dev(device);
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci	if (default_device) {
278c2ecf20Sopenharmony_ci		if (pci_dev == default_device)
288c2ecf20Sopenharmony_ci			return 1;
298c2ecf20Sopenharmony_ci		return 0;
308c2ecf20Sopenharmony_ci	}
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	res = pci_dev->resource + PCI_ROM_RESOURCE;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	if (res->flags & IORESOURCE_ROM_SHADOW)
358c2ecf20Sopenharmony_ci		return 1;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	return 0;
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ciEXPORT_SYMBOL(fb_is_primary_device);
408c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
41