[igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Provide igt_fb_modifier_for_name()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Fri Nov 17 13:24:15 UTC 2023


Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>

On 16.11.2023 15.24, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Add a function that given a modifier's human readable
> name returns the actual modifier magic number.
> 
> TODO: figure out what to do about the "same" modifier with
>        multiple platform variants...
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>   lib/igt_fb.c | 10 ++++++++++
>   lib/igt_fb.h |  1 +
>   2 files changed, 11 insertions(+)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 5670bc06c778..24275c06354b 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -4944,3 +4944,13 @@ const char *igt_fb_modifier_name(uint64_t modifier)
>   
>   	return "?";
>   }
> +
> +uint64_t igt_fb_modifier_for_name(const char *name)
> +{
> +	for (int i = 0; i < ARRAY_SIZE(modifiers); i++) {
> +		if (!strcasecmp(name, modifiers[i].name))
> +			return modifiers[i].modifier;
> +	}
> +
> +	return DRM_FORMAT_MOD_INVALID;
> +}
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 834aaef54dea..3bb577c02cd9 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -230,6 +230,7 @@ int igt_fill_cts_color_square_framebuffer(uint32_t *pixmap,
>   
>   int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc);
>   const char *igt_fb_modifier_name(uint64_t modifier);
> +uint64_t igt_fb_modifier_for_name(const char *name);
>   
>   #endif /* __IGT_FB_H__ */
>   



More information about the igt-dev mailing list