lib/intel_chipset: Extend intel_get_pci_device to PCI accelerator class
PATCH v2 1/1 lib/intel_chipset: Extend intel_get_pci_device to PCI accelerator class
In addition to PCI display class devices, Intel devices can also be PCI accelerator class devices. Extend intel_get_pci_device() to also find these devices.
v2: Introduce intel_get_pci_device_disp for those tools who specifically
want only display class devices (Kamiil)
Signed-off-by Ashutosh Dixit <[email protected]>
--- lib/intel_chipset.c | 82 +++++++++++++++++++++++---------- lib/intel_chipset.h | 1 + tools/intel_audio_dump.c | 2 +- tools/intel_backlight.c | 2 +- tools/intel_display_bandwidth.c | 4 +- tools/intel_display_poller.c | 4 +- tools/intel_panel_fitter.c | 2 +- tools/intel_watermark.c | 2 +- 8 files changed, 66 insertions(+), 33 deletions(-)
lib/intel_chipset.c +57 -25
@@ -63,16 +63,34 @@*/ enum pch_type intel_pch; -/** -* intel_get_pci_device: -* -* Looks up the main graphics pci device using libpciaccess. -* -* Returns: -* The pci_device, exits the program on any failures. -*/ -struct pci_device * -intel_get_pci_device (void ) +static struct pci_device *intel_pci_device_by_class (uint8_t class) +{ +struct pci_device *pci_dev; +struct pci_device_iterator *iter; +struct pci_id_match match; +int error; + + error =igt_pci_system_init (); +igt_fail_on_f (error !=0 ,"Couldn't initialize PCI system\n" ); + + match.vendor_id =0x8086 ;/* Intel */ + match.device_id =PCI_MATCH_ANY ; + match.subvendor_id =PCI_MATCH_ANY ; + match.subdevice_id =PCI_MATCH_ANY ; + + match.device_class = class <<16 ; + match.device_class_mask =0xff <<16 ; + + match.match_data =0 ; + + iter =pci_id_match_iterator_create (&match); + pci_dev =pci_device_next (iter); +pci_iterator_destroy (iter); + +return pci_dev; +} + +static struct pci_device *__intel_get_pci_device (bool accel) {struct pci_device *pci_dev;int error;
@@ -85,22 +103,12 @@ intel_get_pci_device(void)* walk the entire PCI bus for a matching device. */ pci_dev =pci_device_find_by_slot (0 ,0 ,2 ,0 );if (pci_dev ==NULL || pci_dev->vendor_id !=0x8086 ) { -struct pci_device_iterator *iter; -struct pci_id_match match; +/* PCI display class (0x3) devices */ + pci_dev =intel_pci_device_by_class (0x3 ); - match.vendor_id =0x8086 ;/* Intel */ - match.device_id =PCI_MATCH_ANY ; - match.subvendor_id =PCI_MATCH_ANY ; - match.subdevice_id =PCI_MATCH_ANY ; - - match.device_class =0x3 <<16 ; - match.device_class_mask =0xff <<16 ; - - match.match_data =0 ; - - iter =pci_id_match_iterator_create (&match); - pci_dev =pci_device_next (iter); -pci_iterator_destroy (iter); +if (!pci_dev && accel) +/* PCI accelerator class (0x12) devices */ + pci_dev =intel_pci_device_by_class (0x12 ); }igt_require_f (pci_dev,"Couldn't find Intel graphics card\n" );
@@ -114,6 +122,30 @@ intel_get_pci_device(void)return pci_dev; } +/** +* intel_get_pci_device: +* +* Looks up display and accelerator class pci devices using libpciaccess +* +* Returns: The pci_device, exits the program on any failures +*/ +struct pci_device *intel_get_pci_device (void ) +{ +return __intel_get_pci_device (true); +} + +/** +* intel_get_pci_device_disp: +* +* Looks up display class pci device using libpciaccess +* +* Returns: The pci_device, exits the program on any failures +*/ +struct pci_device *intel_get_pci_device_disp (void ) +{ +return __intel_get_pci_device (false); +} +static uint32_t __i915_get_drm_devid (int fd) {struct drm_i915_getparam gp;
lib/intel_chipset.h +1 -0
@@ -36,6 +36,7 @@#define BIT (x) (1ul <<(x))struct pci_device *intel_get_pci_device (void ); +struct pci_device *intel_get_pci_device_disp (void );uint32_t intel_get_drm_devid (int fd);struct intel_device_info {
tools/intel_audio_dump.c +1 -1
@@ -2468,7 +2468,7 @@ int main(int argc, char **argv)struct pci_device *pci_dev;struct intel_mmio_data mmio_data; - pci_dev =intel_get_pci_device (); + pci_dev =intel_get_pci_device_disp (); devid = pci_dev->device_id;/* XXX not true when mapping! */ do_self_tests ();
tools/intel_backlight.c +1 -1
@@ -41,7 +41,7 @@ int main(int argc, char** argv)struct intel_mmio_data mmio_data;uint32_t current, max; -intel_mmio_use_pci_bar (&mmio_data,intel_get_pci_device ()); +intel_mmio_use_pci_bar (&mmio_data,intel_get_pci_device_disp ()); current =INREG (BLC_PWM_CPU_CTL ) &BACKLIGHT_DUTY_CYCLE_MASK ; max =INREG (BLC_PWM_PCH_CTL2 ) >>16 ;
tools/intel_display_bandwidth.c +2 -2
@@ -152,14 +152,14 @@ int main(int argc, char *argv[]) } } - devid =intel_get_pci_device ()->device_id; + devid =intel_get_pci_device_disp ()->device_id;if (!has_de_power2 (devid)) {fprintf (stderr,"Display bandwidth counter not available\n" );return 2 ; } -intel_register_access_init (&mmio_data,intel_get_pci_device (),0 ); +intel_register_access_init (&mmio_data,intel_get_pci_device_disp (),0 );if (has_de_power2_abox0_abox1 (devid))measure_de_power2_abox0_abox1 (devid, sleep_duration);
tools/intel_display_poller.c +2 -2
@@ -1508,7 +1508,7 @@ int main(int argc, char *argv[]) } } - devid =intel_get_pci_device ()->device_id; + devid =intel_get_pci_device_disp ()->device_id;/* * check if the requires registers are
@@ -1677,7 +1677,7 @@ int main(int argc, char *argv[])break ; } -intel_register_access_init (&mmio_data,intel_get_pci_device (),0 ); +intel_register_access_init (&mmio_data,intel_get_pci_device_disp (),0 );if (auto_scanline_offset) scanline_offset =default_scanline_offset (devid, pipe);
tools/intel_panel_fitter.c +1 -1
@@ -280,7 +280,7 @@ int main (int argc, char *argv[])"with overscan compensation properties: it is just a temporary " "solution that may or may not work. Use it at your own risk.\n"); - pci_dev =intel_get_pci_device (); + pci_dev =intel_get_pci_device_disp ();intel_register_access_init (&mmio_data, pci_dev,0 ); devid = pci_dev->device_id;
tools/intel_watermark.c +1 -1
@@ -328,7 +328,7 @@ static void skl_wm_dump(void)uint32_t wm_linetime[num_pipes];uint32_t arb_ctl, arb_ctl2, wm_dbg; -intel_register_access_init (&mmio_data,intel_get_pci_device (),0 ); +intel_register_access_init (&mmio_data,intel_get_pci_device_disp (),0 ); arb_ctl =read_reg (0x45000 ); arb_ctl2 =read_reg (0x45004 );
Signature · 1 line
2.54.0