File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ find_active_client(struct list_head *head)
437437 */
438438bool vga_switcheroo_client_probe_defer (struct pci_dev * pdev )
439439{
440- if ((pdev -> class >> 16 ) == PCI_BASE_CLASS_DISPLAY ) {
440+ if (pci_is_display (pdev ) ) {
441441 /*
442442 * apple-gmux is needed on pre-retina MacBook Pro
443443 * to probe the panel if pdev is the inactive GPU.
Original file line number Diff line number Diff line change 3434#define ROOT_SIZE VTD_PAGE_SIZE
3535#define CONTEXT_SIZE VTD_PAGE_SIZE
3636
37- #define IS_GFX_DEVICE (pdev ) (( pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY )
37+ #define IS_GFX_DEVICE (pdev ) pci_is_display( pdev)
3838#define IS_USB_DEVICE (pdev ) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
3939#define IS_ISA_DEVICE (pdev ) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
4040#define IS_AZALIA (pdev ) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
Original file line number Diff line number Diff line change @@ -437,8 +437,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
437437
438438bool vfio_pci_is_intel_display (struct pci_dev * pdev )
439439{
440- return (pdev -> vendor == PCI_VENDOR_ID_INTEL ) &&
441- ((pdev -> class >> 16 ) == PCI_BASE_CLASS_DISPLAY );
440+ return (pdev -> vendor == PCI_VENDOR_ID_INTEL ) && pci_is_display (pdev );
442441}
443442
444443int vfio_pci_igd_init (struct vfio_pci_core_device * vdev )
Original file line number Diff line number Diff line change @@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev)
744744 return false;
745745}
746746
747+ /**
748+ * pci_is_display - check if the PCI device is a display controller
749+ * @pdev: PCI device
750+ *
751+ * Determine whether the given PCI device corresponds to a display
752+ * controller. Display controllers are typically used for graphical output
753+ * and are identified based on their class code.
754+ *
755+ * Return: true if the PCI device is a display controller, false otherwise.
756+ */
757+ static inline bool pci_is_display (struct pci_dev * pdev )
758+ {
759+ return (pdev -> class >> 16 ) == PCI_BASE_CLASS_DISPLAY ;
760+ }
761+
747762#define for_each_pci_bridge (dev , bus ) \
748763 list_for_each_entry(dev, &bus->devices, bus_list) \
749764 if (!pci_is_bridge(dev)) {} else
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ static int i915_gfx_present(struct pci_dev *hdac_pci)
155155
156156 for_each_pci_dev (display_dev ) {
157157 if (display_dev -> vendor != PCI_VENDOR_ID_INTEL ||
158- (display_dev -> class >> 16 ) != PCI_BASE_CLASS_DISPLAY )
158+ ! pci_is_display (display_dev ) )
159159 continue ;
160160
161161 if (pci_match_id (denylist , display_dev ))
Original file line number Diff line number Diff line change @@ -1465,7 +1465,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
14651465 * the dGPU is the one who is involved in
14661466 * vgaswitcheroo.
14671467 */
1468- if ((( p -> class >> 16 ) == PCI_BASE_CLASS_DISPLAY ) &&
1468+ if (pci_is_display ( p ) &&
14691469 (atpx_present () || apple_gmux_detect (NULL , NULL )))
14701470 return p ;
14711471 pci_dev_put (p );
@@ -1477,7 +1477,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
14771477 p = pci_get_domain_bus_and_slot (pci_domain_nr (pci -> bus ),
14781478 pci -> bus -> number , 0 );
14791479 if (p ) {
1480- if (( p -> class >> 16 ) == PCI_BASE_CLASS_DISPLAY )
1480+ if (pci_is_display ( p ) )
14811481 return p ;
14821482 pci_dev_put (p );
14831483 }
You can’t perform that action at this time.
0 commit comments