[igt-dev] [PATCH i-g-t 1/2] lib/igt_device_scan: Provide function for return integrated card
Siddiqui, Ayaz A
ayaz.siddiqui at intel.com
Thu Nov 5 06:48:21 UTC 2020
> -----Original Message-----
> From: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Sent: Wednesday, November 4, 2020 11:30 PM
> To: igt-dev at lists.freedesktop.org
> Cc: Kempczynski, Zbigniew <zbigniew.kempczynski at intel.com>; Latvala,
> Petri <petri.latvala at intel.com>; Siddiqui, Ayaz A <ayaz.siddiqui at intel.com>;
> Lyude Paul <lyude at redhat.com>
> Subject: [PATCH i-g-t 1/2] lib/igt_device_scan: Provide function for return
> integrated card
>
> Sometimes we need to get integrated card (like in intel_gpu_top)
> so add function which does it.
>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Petri Latvala <petri.latvala at intel.com>
> Cc: Ayaz A Siddiqui <ayaz.siddiqui at intel.com>
> Cc: Lyude Paul <lyude at redhat.com>
> ---
> lib/igt_device_scan.c | 29 +++++++++++++++++++++++++----
> lib/igt_device_scan.h | 1 +
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index 0967c645..c581a31a 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -465,12 +465,13 @@ __copy_dev_to_card(struct igt_device *dev,
> struct igt_device_card *card)
> }
>
> /*
> - * Iterate over all igt_devices array and find first discrete card.
> - * card->pci_slot_name will be updated only if a discrete card is present.
> + * Iterate over all igt_devices array and find first discrete/integrated card.
> + * card->pci_slot_name will be updated only if a card is found.
> */
> -bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
> +static bool __find_first_i915_card(struct igt_device_card *card, bool
> discrete)
> {
> struct igt_device *dev;
> + int cmp;
>
> memset(card, 0, sizeof(*card));
>
> @@ -479,7 +480,13 @@ bool
> igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
> if (!is_pci_subsystem(dev) || !is_vendor_matched(dev,
> "intel"))
> continue;
>
> - if ((strncmp(dev->pci_slot_name,
> INTEGRATED_I915_GPU_PCI_ID, PCI_SLOT_NAME_SIZE)) != 0) {
> + cmp = strncmp(dev->pci_slot_name,
> INTEGRATED_I915_GPU_PCI_ID,
> + PCI_SLOT_NAME_SIZE);
> +
> + if (discrete && cmp) {
> + __copy_dev_to_card(dev, card);
> + return true;
> + } else if (!discrete && !cmp) {
> __copy_dev_to_card(dev, card);
> return true;
> }
> @@ -488,6 +495,20 @@ bool
> igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
> return false;
> }
>
> +bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
> +{
> + igt_assert(card);
> +
> + return __find_first_i915_card(card, true);
> +}
> +
> +bool igt_device_find_integrated_card(struct igt_device_card *card)
> +{
> + igt_assert(card);
> +
> + return __find_first_i915_card(card, false);
> +}
> +
LGTM.
Reviewed-by: Ayaz A Siddiqui <ayaz.siddiqui at intel.com>
> static struct igt_device *igt_device_from_syspath(const char *syspath)
> {
> struct igt_device *dev;
> diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
> index 544e982c..99daee0c 100644
> --- a/lib/igt_device_scan.h
> +++ b/lib/igt_device_scan.h
> @@ -71,6 +71,7 @@ bool igt_device_card_match(const char *filter, struct
> igt_device_card *card);
> bool igt_device_card_match_pci(const char *filter,
> struct igt_device_card *card);
> bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card);
> +bool igt_device_find_integrated_card(struct igt_device_card *card);
> int igt_open_card(struct igt_device_card *card);
> int igt_open_render(struct igt_device_card *card);
>
> --
> 2.26.0
More information about the igt-dev
mailing list