Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88674088 authored by Matthew Garrett's avatar Matthew Garrett Committed by Dave Airlie
Browse files

x86: Use vga_default_device() when determining whether an fb is primary



IORESOURCE_ROM_SHADOW is not necessarily an indication that the hardware
is the primary device. Add support for using the vgaarb functions and
fall back if nothing's set them.

Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
Cc: mingo@redhat.com
Acked-by: default avatar <hpa@zytor.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 2fbe8c7c
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -9,24 +9,34 @@
#include <linux/fb.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/vgaarb.h>

int fb_is_primary_device(struct fb_info *info)
{
	struct device *device = info->device;
	struct pci_dev *pci_dev = NULL;
	struct pci_dev *default_device = vga_default_device();
	struct resource *res = NULL;
	int retval = 0;

	if (device)
		pci_dev = to_pci_dev(device);

	if (pci_dev)
	if (!pci_dev)
		return 0;

	if (default_device) {
		if (pci_dev == default_device)
			return 1;
		else
			return 0;
	}

	res = &pci_dev->resource[PCI_ROM_RESOURCE];

	if (res && res->flags & IORESOURCE_ROM_SHADOW)
		retval = 1;
		return 1;

	return retval;
	return 0;
}
EXPORT_SYMBOL(fb_is_primary_device);
MODULE_LICENSE("GPL");