summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2023-10-28 21:31:00 +0300
committerBjorn Helgaas <bhelgaas@google.com>2023-10-28 21:31:00 +0300
commitdbf9527ca13da9afa0cabde32fd4fbdc73c0ae9d (patch)
tree44a56b108211c031994f7d3a3c614e228777bdd1 /include
parent79a8394a909e43422df68165189a9bb5e25dd23b (diff)
parent94cfada2a9cadec8e5302294fb1a144addfe6649 (diff)
downloadlinux-dbf9527ca13da9afa0cabde32fd4fbdc73c0ae9d.tar.xz
Merge branch 'pci/vga'
- Add pci_is_vga() helper, which checks for both PCI_CLASS_DISPLAY_VGA and PCI_CLASS_NOT_DEFINED_VGA (which catches ancient devices built before Class Codes were defined) (Sui Jingfeng) - Use the new pci_is_vga() to identify devices for the VGA arbiter, the sysfs "boot_vga" attribute, and the virtio and qxl drivers (SUi Jingfeng) * pci/vga: drm/qxl: Use pci_is_vga() to identify VGA devices drm/virtio: Use pci_is_vga() to identify VGA devices PCI/sysfs: Enable 'boot_vga' attribute via pci_is_vga() PCI/VGA: Select VGA devices earlier PCI/VGA: Use pci_is_vga() to identify VGA devices PCI: Add pci_is_vga() helper
Diffstat (limited to 'include')
-rw-r--r--include/linux/pci.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 40ac1288a2cc..ee4b91d2b373 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -713,6 +713,30 @@ static inline bool pci_is_bridge(struct pci_dev *dev)
dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
}
+/**
+ * pci_is_vga - check if the PCI device is a VGA device
+ *
+ * The PCI Code and ID Assignment spec, r1.15, secs 1.4 and 1.1, define
+ * VGA Base Class and Sub-Classes:
+ *
+ * 03 00 PCI_CLASS_DISPLAY_VGA VGA-compatible or 8514-compatible
+ * 00 01 PCI_CLASS_NOT_DEFINED_VGA VGA-compatible (before Class Code)
+ *
+ * Return true if the PCI device is a VGA device and uses the legacy VGA
+ * resources ([mem 0xa0000-0xbffff], [io 0x3b0-0x3bb], [io 0x3c0-0x3df] and
+ * aliases).
+ */
+static inline bool pci_is_vga(struct pci_dev *pdev)
+{
+ if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+ return true;
+
+ if ((pdev->class >> 8) == PCI_CLASS_NOT_DEFINED_VGA)
+ return true;
+
+ return false;
+}
+
#define for_each_pci_bridge(dev, bus) \
list_for_each_entry(dev, &bus->devices, bus_list) \
if (!pci_is_bridge(dev)) {} else