[igt-dev] [PATCH i-g-t 1/2] igt_eld: add igt_is_igt

Chris Wilson chris at chris-wilson.co.uk
Thu Sep 12 10:53:05 UTC 2019


igt_is_igt, or igt_is_not_igt.

Quoting Simon Ser (2019-09-12 11:28:14)
> This function parses the monitor name from an ELD blob and checks whether it
> comes from an IGT EDID.
> 
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> ---
>  lib/igt_eld.c | 23 +++++++++++++++++++++++
>  lib/igt_eld.h |  1 +
>  2 files changed, 24 insertions(+)
> 
> diff --git a/lib/igt_eld.c b/lib/igt_eld.c
> index 16c4ac06c6f6..640496b0a160 100644
> --- a/lib/igt_eld.c
> +++ b/lib/igt_eld.c
> @@ -262,3 +262,26 @@ bool eld_has_igt(void)
>         struct eld_entry eld;
>         return eld_get_igt(&eld);
>  }
> +
> +/** eld_is_igt: check whether the ELD blob comes from an IGT EDID */
> +bool eld_is_igt(const char *eld, size_t eld_size)
> +{
> +       char name[17];
> +       int name_size;
> +
> +       igt_assert_f(eld_size >= 20 && eld_size <= 256,
> +                    "Invalid ELD size: %zu\n", eld_size);
> +
> +       name_size = eld[4] & 0x1F;
> +       igt_assert_f(name_size <= 16 && 20 + name_size <= eld_size,
> +                    "Invalid monitor name size in ELD: %d\n", name_size);

Not reading too much into either our name[] or from the eld blob.

name_size <= sizeof(name) - 1

to have one less floating number.

#define ELD_NAME_LOC 20 ???

> +       if (name_size == 0) {
> +               igt_debug("ELD doesn't contain a monitor name\n");
> +               return false;
> +       }
> +
> +       memcpy(name, &eld[20], name_size);
> +       name[name_size] = '\0';
> +       igt_debug("Checking ELD with monitor name: %s\n", name);
> +       return strcmp(name, "IGT") == 0;
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list