Re: [igt-dev] [PATCH i-g-t 2/3] lib/igt_kms: Add igt_reduce_format()

Chris Wilson
2020-01-30T15:38:20Z

Quoting Ville Syrjala (2020-01-30 15:12:28)
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Add a helper to reduce a pixel format to a "base" format.
> Ie. group all formats to some idea of classes based on the
> bits per pixel + component sizes etc. ignoring any component ordering.
> Let's us skip potentially redundant tests when all we might care
> about is testing each format "class" the once.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> lib/igt_kms.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++
> lib/igt_kms.h | 1 +
> 2 files changed, 80 insertions(+)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index d20daaad7764..2b075c435291 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -4474,3 +4474,82 @@ void igt_parse_connector_tile_blob(drmModePropertyBlobPtr blob,
> tile->tile_h_size = atoi(strtok(NULL, ":"));
> tile->tile_v_size = atoi(strtok(NULL, ":"));
> }
> +
> +uint32_t igt_reduce_format(uint32_t format)
> +{

/*
* Any words of wisdom on how/why these are reduced to a representative
* format for each class? Just in case a new format is introduced and we
* want to decide if it's a new class or should be aliased to an older
* one.
*/
> + switch (format) {
> + case DRM_FORMAT_RGB332:
> + case DRM_FORMAT_BGR233:
> + return DRM_FORMAT_RGB332;