[PATCH i-g-t v15 1/5] lib/igt_kms: Add support to retrieve async modifiers and formats
Karthik B S
karthik.b.s at intel.com
Thu Jun 26 06:09:23 UTC 2025
On 6/23/2025 4:39 PM, Santhosh Reddy Guddati wrote:
> Parse "IN_FORMATS_ASYNC" plane property to identify supported
> format modifier pairs for async flips
>
> V2: Add new fields async_formats and reset idx.
>
> V3: Improve commit message , remove unused declaration (Chaitanya)
> Introduce structure to hold a format modifier and its
> associated format list.
>
> V4: Implement format+modifier tuples for async similar to IN_FORMATS
> (Chaitanya).
>
> V5: Re use local variables for async formats and free blob after
> usage(Chaitanya)
>
> V6: Initialize async_modifiers and async_formats to NULL. (Chaitanya)
>
> V7: Fix async format count to return 0 on failures (Chaitanya)
>
> V8: Refactor parsing blob to a common function. (Ville)
>
> Signed-off-by: Santhosh Reddy Guddati <santhosh.reddy.guddati at intel.com>
> Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
Reviewed-by: Karthik B S <karthik.b.s at intel.com>
> ---
> lib/igt_kms.c | 73 +++++++++++++++++++++++++++++++--------------------
> lib/igt_kms.h | 7 ++++-
> 2 files changed, 50 insertions(+), 30 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 9ee03e870..599901ee8 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -701,6 +701,7 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
> [IGT_PLANE_FB_DAMAGE_CLIPS] = "FB_DAMAGE_CLIPS",
> [IGT_PLANE_SCALING_FILTER] = "SCALING_FILTER",
> [IGT_PLANE_SIZE_HINTS] = "SIZE_HINTS",
> + [IGT_PLANE_IN_FORMATS_ASYNC] = "IN_FORMATS_ASYNC",
> };
>
> const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
> @@ -5786,13 +5787,43 @@ static int igt_count_plane_format_mod(const struct drm_format_modifier_blob *blo
> return count;
> }
>
> +static void igt_parse_format_mod_blob(const struct drm_format_modifier_blob *blob_data,
> + uint32_t **formats, uint64_t **modifiers, int *count)
> +{
> + const struct drm_format_modifier *m = modifiers_ptr(blob_data);
> + const uint32_t *f = formats_ptr(blob_data);
> + int idx = 0;
> +
> + *count = igt_count_plane_format_mod(blob_data);
> + if (*count == 0)
> + return;
> +
> + *formats = calloc(*count, sizeof((*formats)[0]));
> + igt_assert(*formats);
> + *modifiers = calloc(*count, sizeof((*modifiers)[0]));
> + igt_assert(*modifiers);
> +
> + for (int i = 0; i < blob_data->count_modifiers; i++) {
> + for (int j = 0; j < 64; j++) {
> + if (!(m[i].formats & (1ULL << j)))
> + continue;
> +
> + (*formats)[idx] = f[m[i].offset + j];
> + (*modifiers)[idx] = m[i].modifier;
> + idx++;
> + igt_assert_lte(idx, *count);
> + }
> + }
> +
> + igt_assert_eq(idx, *count);
> +}
> +
> static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane)
> {
> const struct drm_format_modifier_blob *blob_data;
> drmModePropertyBlobPtr blob;
> uint64_t blob_id;
> - int idx = 0;
> - int count;
> + int count = 0;
>
> if (!igt_plane_has_prop(plane, IGT_PLANE_IN_FORMATS)) {
> drmModePlanePtr p = plane->drm_plane;
> @@ -5818,40 +5849,24 @@ static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane
> }
>
> blob_id = igt_plane_get_prop(plane, IGT_PLANE_IN_FORMATS);
> -
> blob = drmModeGetPropertyBlob(display->drm_fd, blob_id);
> if (!blob)
> return;
>
> - blob_data = (const struct drm_format_modifier_blob *) blob->data;
> -
> - count = igt_count_plane_format_mod(blob_data);
> - if (!count)
> - return;
> -
> - plane->format_mod_count = count;
> - plane->formats = calloc(count, sizeof(plane->formats[0]));
> - igt_assert(plane->formats);
> - plane->modifiers = calloc(count, sizeof(plane->modifiers[0]));
> - igt_assert(plane->modifiers);
> + blob_data = (const struct drm_format_modifier_blob *)blob->data;
> + igt_parse_format_mod_blob(blob_data, &plane->formats, &plane->modifiers, &plane->format_mod_count);
> + drmModeFreePropertyBlob(blob);
>
> - for (int i = 0; i < blob_data->count_modifiers; i++) {
> - for (int j = 0; j < 64; j++) {
> - const struct drm_format_modifier *modifiers =
> - modifiers_ptr(blob_data);
> - const uint32_t *formats = formats_ptr(blob_data);
> -
> - if (!(modifiers[i].formats & (1ULL << j)))
> - continue;
> + if (igt_plane_has_prop(plane, IGT_PLANE_IN_FORMATS_ASYNC)) {
> + blob_id = igt_plane_get_prop(plane, IGT_PLANE_IN_FORMATS_ASYNC);
> + blob = drmModeGetPropertyBlob(display->drm_fd, blob_id);
> + if (!blob)
> + return;
>
> - plane->formats[idx] = formats[modifiers[i].offset + j];
> - plane->modifiers[idx] = modifiers[i].modifier;
> - idx++;
> - igt_assert_lte(idx, plane->format_mod_count);
> - }
> + blob_data = (const struct drm_format_modifier_blob *)blob->data;
> + igt_parse_format_mod_blob(blob_data, &plane->async_formats, &plane->async_modifiers, &plane->async_format_mod_count);
> + drmModeFreePropertyBlob(blob);
> }
> -
> - igt_assert_eq(idx, plane->format_mod_count);
> }
>
> /**
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index a85fee515..7bc1a6886 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -365,7 +365,8 @@ enum igt_atomic_plane_properties {
> IGT_PLANE_HOTSPOT_X,
> IGT_PLANE_HOTSPOT_Y,
> IGT_PLANE_SIZE_HINTS,
> - IGT_NUM_PLANE_PROPS
> + IGT_PLANE_IN_FORMATS_ASYNC,
> + IGT_NUM_PLANE_PROPS,
> };
>
> /**
> @@ -438,6 +439,10 @@ typedef struct igt_plane {
> uint64_t *modifiers;
> uint32_t *formats;
> int format_mod_count;
> +
> + uint64_t *async_modifiers;
> + uint32_t *async_formats;
> + int async_format_mod_count;
> } igt_plane_t;
>
> /*
More information about the igt-dev
mailing list