From: Jani Nikula <jani.nikula@intel.com>
To: "Michał Grzelak" <michal.grzelak@intel.com>,
igt-dev@lists.freedesktop.org
Cc: "Suraj Kandpal" <suraj.kandpal@intel.com>,
"Michał Grzelak" <michal.grzelak@intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>
Subject: Re: [PATCH i-g-t v3 04/10] lib/intel_device_info: add a helper to guess the PCI ID for a codename
Date: Mon, 15 Jun 2026 12:57:23 +0300 [thread overview]
Message-ID: <79496f3655e5309fc4f22b940a4115a06c0f8dc7@intel.com> (raw)
In-Reply-To: <20260615093137.681050-5-michal.grzelak@intel.com>
On Mon, 15 Jun 2026, Michał Grzelak <michal.grzelak@intel.com> wrote:
> From: Jani Nikula <jani.nikula@intel.com>
>
> From: Jani Nikula <jani.nikula@intel.com>
>
Where did the dupe From: come from?
Anyway, would be more helpful to get the original patches merged than
include them here, especially since there were review comments on them.
> The struct intel_device_info contains the codenames for the
> corresponding PCI device IDs. Add a reverse lookup to get a PCI ID for a
> codename.
>
> It's a bit fuzzy, though. The codenames aren't always spelled the same,
> there are suffixes sometimes omitted, and you can only pick one of the
> matching PCI IDs. Name the helper intel_guess_device_id() to emphasize
> the point, and try increasing fuzziness in the matching to find an
> appropriate struct intel_device_info.
>
> There's nothing exact about this, and it should not be considered as
> such. But it will be useful in VBT parsing.
>
> Cc: Michał Grzelak <michal.grzelak@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
You *must* add your own Signed-off-by when sending someone else's
patches. See [1] for what Signed-off-by means.
BR,
Jani.
[1] https://developercertificate.org/
> ---
> lib/intel_chipset.h | 1 +
> lib/intel_device_info.c | 75 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 76 insertions(+)
>
> diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
> index 3fcc5b18d6..98a2a81fcf 100644
> --- a/lib/intel_chipset.h
> +++ b/lib/intel_chipset.h
> @@ -103,6 +103,7 @@ struct intel_device_info {
> };
>
> const struct intel_device_info *intel_get_device_info(uint16_t devid) __attribute__((pure));
> +uint16_t intel_guess_device_id(const char *codenameish) __attribute__((pure));
>
> const struct intel_cmds_info *intel_get_cmds_info(uint16_t devid) __attribute__((pure));
> unsigned intel_gen(uint16_t devid) __attribute__((pure));
> diff --git a/lib/intel_device_info.c b/lib/intel_device_info.c
> index da0b9f3988..3b53732650 100644
> --- a/lib/intel_device_info.c
> +++ b/lib/intel_device_info.c
> @@ -3,6 +3,7 @@
> #include "i915_pciids_local.h"
>
> #include <strings.h> /* ffs() */
> +#include <ctype.h>
>
> static const struct intel_device_info intel_generic_info = {
> .graphics_ver = 0,
> @@ -746,6 +747,80 @@ out:
> return cache;
> }
>
> +static bool char_eq(char c1, char c2)
> +{
> + c1 = isalnum(c1) ? tolower(c1) : '-';
> + c2 = isalnum(c2) ? tolower(c2) : '-';
> +
> + return c1 == c2;
> +}
> +
> +/*
> + * Return true if the codenames s1 and s2 match, with fuzziness.
> + *
> + * Case insensitive matching, ignoring differences in non-alnum characters. With
> + * non-zero fuzziness, accept matches up to the first non-alnum character.
> + */
> +static bool codename_match(const char *s1, const char *s2, int fuzziness)
> +{
> + while (*s1 && *s2 && char_eq(*s1, *s2)) {
> + s1++;
> + s2++;
> + }
> +
> + /* full match */
> + if (!*s1 && !*s2)
> + return true;
> +
> + /* sub-string match up to a non-alnum char */
> + if (fuzziness >=1) {
> + if (!*s1 && !isalnum(*s2))
> + return true;
> + if (!*s2 && !isalnum(*s1))
> + return true;
> + }
> +
> + return false;
> +}
> +
> +static uint16_t lookup_device_id(const char *codename, int fuzziness)
> +{
> + int i;
> +
> + for (i = 0; intel_device_match[i].device_id != PCI_MATCH_ANY; i++) {
> + const struct intel_device_info *info = (void *)intel_device_match[i].match_data;
> +
> + if (codename_match(info->codename, codename, fuzziness))
> + return intel_device_match[i].device_id;
> + }
> +
> + return 0;
> +}
> +
> +/**
> + * intel_guess_device_id:
> + * @codenameish: something resembling a codename
> + *
> + * Based on something resembling a codename, try to fuzzy find the first PCI
> + * device ID matching the codename.
> + *
> + * Returns:
> + * PCI device ID fuzzy matching the @codenameish, or 0 if no match was found.
> + */
> +uint16_t intel_guess_device_id(const char *codenameish)
> +{
> + uint16_t devid;
> + int fuzziness;
> +
> + for (fuzziness = 0; fuzziness < 2; fuzziness++) {
> + devid = lookup_device_id(codenameish, fuzziness);
> + if (devid)
> + return devid;
> + }
> +
> + return 0;
> +}
> +
> /**
> * intel_get_cmds_info:
> * @devid: pci device id
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-06-15 9:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 9:31 [PATCH i-g-t v3 00/10] Vswing / Pre-emphasis Override decoding Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 01/10] tools/vbt_decode: fix tables' offset reading Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 02/10] tools/vbt_decode: rename VBT#57 related vars Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 03/10] tools/intel_vbt_decode: store codename from VBT signature to context Michał Grzelak
2026-06-15 10:31 ` Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 04/10] lib/intel_device_info: add a helper to guess the PCI ID for a codename Michał Grzelak
2026-06-15 9:57 ` Jani Nikula [this message]
2026-06-15 10:21 ` Michał Grzelak
2026-06-15 10:32 ` Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 05/10] tools/vbt_decode: return 0 from get_device_id() Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 06/10] tools/intel_vbt_decode: fall back to guessing PCI ID from VBT signature Michał Grzelak
2026-06-15 10:33 ` Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 07/10] tools/vbt_decode: validate DEVICE env var Michał Grzelak
2026-06-15 11:21 ` Jani Nikula
2026-06-15 9:31 ` [PATCH i-g-t v3 08/10] tools/vbt_decode: parse & dump VS/PE-O tables for LT Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 09/10] tools/vbt_decode: parse & dump VS/PE-O tables for Snps Michał Grzelak
2026-06-15 9:31 ` [PATCH i-g-t v3 10/10] tools/vbt_decode: parse & dump VS/PE-O tables for Combo Michał Grzelak
2026-06-15 16:51 ` ✓ Xe.CI.BAT: success for Vswing / Pre-emphasis Override decoding (rev2) Patchwork
2026-06-15 17:05 ` ✓ i915.CI.BAT: " Patchwork
2026-06-15 18:06 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-06-16 0:10 ` ✓ i915.CI.Full: success " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=79496f3655e5309fc4f22b940a4115a06c0f8dc7@intel.com \
--to=jani.nikula@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=michal.grzelak@intel.com \
--cc=suraj.kandpal@intel.com \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox