From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 03/25] lib/kms: Introduce struct igt_format_mods
Date: Tue, 12 May 2026 15:21:21 +0300 [thread overview]
Message-ID: <20260512122143.11013-4-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20260512122143.11013-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Wrap the forma+modifier arrays in a structure that can be passed
around. Having a real type for this will make the code less messy
and fragile, not to mention that it'll be easier to share all the
code that operates on these arrays.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_kms.c | 60 +++++++++++++-------------
lib/igt_kms.h | 19 ++++----
tests/chamelium/kms_chamelium_frames.c | 22 +++++-----
tests/intel/kms_flip_tiling.c | 12 +++---
tests/kms_async_flips.c | 26 +++++------
tests/kms_plane.c | 14 +++---
6 files changed, 76 insertions(+), 77 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 99fc9fa05c96..b60bfa033bcd 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -6225,19 +6225,19 @@ static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane
count = p->count_formats;
- 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);
+ plane->format_mods.count = count;
+ plane->format_mods.formats = calloc(count, sizeof(plane->format_mods.formats[0]));
+ igt_assert(plane->format_mods.formats);
+ plane->format_mods.modifiers = calloc(count, sizeof(plane->format_mods.modifiers[0]));
+ igt_assert(plane->format_mods.modifiers);
/*
* We don't know which modifiers are
* supported, so we'll assume linear only.
*/
for (int i = 0; i < count; i++) {
- plane->formats[i] = p->formats[i];
- plane->modifiers[i] = DRM_FORMAT_MOD_LINEAR;
+ plane->format_mods.formats[i] = p->formats[i];
+ plane->format_mods.modifiers[i] = DRM_FORMAT_MOD_LINEAR;
}
return;
@@ -6249,7 +6249,7 @@ static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane
return;
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);
+ igt_parse_format_mod_blob(blob_data, &plane->format_mods.formats, &plane->format_mods.modifiers, &plane->format_mods.count);
drmModeFreePropertyBlob(blob);
if (igt_plane_has_prop(plane, IGT_PLANE_IN_FORMATS_ASYNC)) {
@@ -6259,7 +6259,7 @@ static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane
return;
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);
+ igt_parse_format_mod_blob(blob_data, &plane->format_mods_async.formats, &plane->format_mods_async.modifiers, &plane->format_mods_async.count);
drmModeFreePropertyBlob(blob);
}
}
@@ -6277,9 +6277,9 @@ bool igt_plane_has_format_mod(igt_plane_t *plane, uint32_t format,
{
int i;
- for (i = 0; i < plane->format_mod_count; i++) {
- if (plane->formats[i] == format &&
- plane->modifiers[i] == modifier)
+ for (i = 0; i < plane->format_mods.count; i++) {
+ if (plane->format_mods.formats[i] == format &&
+ plane->format_mods.modifiers[i] == modifier)
return true;
}
@@ -6297,7 +6297,7 @@ static int igt_count_display_format_mod(igt_display_t *display)
for_each_plane_on_crtc(crtc,
plane) {
- count += plane->format_mod_count;
+ count += plane->format_mods.count;
}
}
@@ -6310,16 +6310,16 @@ igt_add_display_format_mod(igt_display_t *display, uint32_t format,
{
int i;
- for (i = 0; i < display->format_mod_count; i++) {
- if (display->formats[i] == format &&
- display->modifiers[i] == modifier)
+ for (i = 0; i < display->format_mods.count; i++) {
+ if (display->format_mods.formats[i] == format &&
+ display->format_mods.modifiers[i] == modifier)
return;
}
- display->formats[i] = format;
- display->modifiers[i] = modifier;
- display->format_mod_count++;
+ display->format_mods.formats[i] = format;
+ display->format_mods.modifiers[i] = modifier;
+ display->format_mods.count++;
}
static void igt_fill_display_format_mod(igt_display_t *display)
@@ -6330,21 +6330,21 @@ static void igt_fill_display_format_mod(igt_display_t *display)
if (!count)
return;
- display->formats = calloc(count, sizeof(display->formats[0]));
- igt_assert(display->formats);
- display->modifiers = calloc(count, sizeof(display->modifiers[0]));
- igt_assert(display->modifiers);
+ display->format_mods.formats = calloc(count, sizeof(display->format_mods.formats[0]));
+ igt_assert(display->format_mods.formats);
+ display->format_mods.modifiers = calloc(count, sizeof(display->format_mods.modifiers[0]));
+ igt_assert(display->format_mods.modifiers);
for_each_crtc(display, crtc) {
igt_plane_t *plane;
for_each_plane_on_crtc(crtc,
plane) {
- for (int i = 0; i < plane->format_mod_count; i++) {
+ for (int i = 0; i < plane->format_mods.count; i++) {
igt_add_display_format_mod(display,
- plane->formats[i],
- plane->modifiers[i]);
- igt_assert_lte(display->format_mod_count, count);
+ plane->format_mods.formats[i],
+ plane->format_mods.modifiers[i]);
+ igt_assert_lte(display->format_mods.count, count);
}
}
}
@@ -6363,9 +6363,9 @@ bool igt_display_has_format_mod(igt_display_t *display, uint32_t format,
{
int i;
- for (i = 0; i < display->format_mod_count; i++) {
- if (display->formats[i] == format &&
- display->modifiers[i] == modifier)
+ for (i = 0; i < display->format_mods.count; i++) {
+ if (display->format_mods.formats[i] == format &&
+ display->format_mods.modifiers[i] == modifier)
return true;
}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a58cb5cd3430..35923f94d7ff 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -423,6 +423,12 @@ typedef struct {
} igt_colorop_t;
+struct igt_format_mods {
+ uint64_t *modifiers;
+ uint32_t *formats;
+ int count;
+};
+
typedef struct _igt_plane {
/*< private >*/
igt_crtc_t *crtc;
@@ -453,13 +459,8 @@ typedef struct _igt_plane {
uint32_t props[IGT_NUM_PLANE_PROPS];
uint64_t values[IGT_NUM_PLANE_PROPS];
- uint64_t *modifiers;
- uint32_t *formats;
- int format_mod_count;
-
- uint64_t *async_modifiers;
- uint32_t *async_formats;
- int async_format_mod_count;
+ struct igt_format_mods format_mods;
+ struct igt_format_mods format_mods_async;
igt_colorop_t *color_pipelines[IGT_NUM_PLANE_COLOR_PIPELINES];
int num_color_pipelines;
@@ -533,9 +534,7 @@ struct _igt_display {
bool has_plane_color_pipeline;
bool first_commit;
- uint64_t *modifiers;
- uint32_t *formats;
- int format_mod_count;
+ struct igt_format_mods format_mods;
};
typedef struct {
diff --git a/tests/chamelium/kms_chamelium_frames.c b/tests/chamelium/kms_chamelium_frames.c
index 1cd3b34b9d65..3a59c2b51a9b 100644
--- a/tests/chamelium/kms_chamelium_frames.c
+++ b/tests/chamelium/kms_chamelium_frames.c
@@ -302,13 +302,13 @@ static void randomize_plane_setup(chamelium_data_t *data, igt_plane_t *plane,
uint64_t *modifier, bool allow_yuv)
{
int min_dim;
- uint32_t idx[plane->format_mod_count];
+ uint32_t idx[plane->format_mods.count];
unsigned int count = 0;
unsigned int i;
/* First pass to count the supported formats. */
- for (i = 0; i < plane->format_mod_count; i++) {
- uint32_t f = plane->formats[i];
+ for (i = 0; i < plane->format_mods.count; i++) {
+ uint32_t f = plane->format_mods.formats[i];
if (igt_fb_supported_format(f) &&
(allow_yuv || !igt_format_is_yuv(f)))
@@ -318,8 +318,8 @@ static void randomize_plane_setup(chamelium_data_t *data, igt_plane_t *plane,
igt_assert(count > 0);
i = idx[rand() % count];
- *format = plane->formats[i];
- *modifier = plane->modifiers[i];
+ *format = plane->format_mods.formats[i];
+ *modifier = plane->format_mods.modifiers[i];
update_tiled_modifier(plane, *width, *height, *format, modifier);
@@ -1041,9 +1041,9 @@ int igt_main()
output, DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);
- for (k = 0; k < primary->format_mod_count; k++) {
- uint32_t format = primary->formats[k];
- uint64_t modifier = primary->modifiers[k];
+ for (k = 0; k < primary->format_mods.count; k++) {
+ uint32_t format = primary->format_mods.formats[k];
+ uint64_t modifier = primary->format_mods.modifiers[k];
if (!igt_fb_supported_format(format))
continue;
@@ -1080,9 +1080,9 @@ int igt_main()
output, DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);
- for (k = 0; k < primary->format_mod_count; k++) {
- uint32_t format = primary->formats[k];
- uint64_t modifier = primary->modifiers[k];
+ for (k = 0; k < primary->format_mods.count; k++) {
+ uint32_t format = primary->format_mods.formats[k];
+ uint64_t modifier = primary->format_mods.modifiers[k];
if (!igt_fb_supported_format(format))
continue;
diff --git a/tests/intel/kms_flip_tiling.c b/tests/intel/kms_flip_tiling.c
index 14cc68c3b890..bccacfa7b229 100644
--- a/tests/intel/kms_flip_tiling.c
+++ b/tests/intel/kms_flip_tiling.c
@@ -244,16 +244,16 @@ int igt_main()
plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
- for (int i = 0; i < plane->format_mod_count; i++) {
- format[0] = plane->formats[i];
- modifier[0] = plane->modifiers[i];
+ for (int i = 0; i < plane->format_mods.count; i++) {
+ format[0] = plane->format_mods.formats[i];
+ modifier[0] = plane->format_mods.modifiers[i];
if (format[0] != data.testformat)
continue;
- for (int j = 0; j < plane->format_mod_count; j++) {
- format[1] = plane->formats[j];
- modifier[1] = plane->modifiers[j];
+ for (int j = 0; j < plane->format_mods.count; j++) {
+ format[1] = plane->format_mods.formats[j];
+ modifier[1] = plane->format_mods.modifiers[j];
if (format[1] != data.testformat)
continue;
diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 61cebf3ba6fe..6a56aaa48ecd 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -664,11 +664,11 @@ static void test_invalid(data_t *data)
flags = DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_PAGE_FLIP_EVENT;
- mod1 = data->plane->async_modifiers[0];
- mod2 = data->plane->async_modifiers[data->plane->async_format_mod_count - 1];
+ mod1 = data->plane->format_mods_async.modifiers[0];
+ mod2 = data->plane->format_mods_async.modifiers[data->plane->format_mods_async.count - 1];
/* Need at least 2 different modifiers to test invalid case */
- igt_require_f(data->plane->async_format_mod_count >= 2 && mod1 != mod2,
+ igt_require_f(data->plane->format_mods_async.count >= 2 && mod1 != mod2,
"Need at least 2 different async modifiers for invalid test\n");
igt_info("using modifier1 %s and modifier2 %s\n",
@@ -876,8 +876,8 @@ static void require_linear_modifier(data_t *data)
return;
}
- for (int i = 0; i < data->plane->async_format_mod_count; i++) {
- uint64_t modifier = data->plane->async_modifiers[i];
+ for (int i = 0; i < data->plane->format_mods_async.count; i++) {
+ uint64_t modifier = data->plane->format_mods_async.modifiers[i];
if (modifier == DRM_FORMAT_MOD_LINEAR) {
data->modifier = DRM_FORMAT_MOD_LINEAR;
@@ -968,13 +968,13 @@ static void run_test_with_async_format_modifiers(data_t *data, void (*test)(data
data->crtc = crtc;
test_init(data);
- igt_assert_f(data->plane->async_format_mod_count > 0,
+ igt_assert_f(data->plane->format_mods_async.count > 0,
"No async format/modifier supported\n");
- for (int i = 0; i < data->plane->async_format_mod_count; i++) {
+ for (int i = 0; i < data->plane->format_mods_async.count; i++) {
struct format_mod f = {
- .format = data->plane->async_formats[i],
- .modifier = data->plane->async_modifiers[i],
+ .format = data->plane->format_mods_async.formats[i],
+ .modifier = data->plane->format_mods_async.modifiers[i],
};
if (skip_async_format_mod(data, f.format, f.modifier, &tested_formats)) {
@@ -1022,12 +1022,12 @@ static void run_test_with_modifiers(data_t *data, void (*test)(data_t *))
data->crtc = crtc;
test_init(data);
- igt_require_f(data->plane->async_format_mod_count > 0,
+ igt_require_f(data->plane->format_mods_async.count > 0,
"No async format/modifier supported\n");
- for (int i = 0; i < data->plane->async_format_mod_count; i++) {
- uint64_t modifier = data->plane->async_modifiers[i];
- uint32_t format = data->plane->async_formats[i];
+ for (int i = 0; i < data->plane->format_mods_async.count; i++) {
+ uint64_t modifier = data->plane->format_mods_async.modifiers[i];
+ uint32_t format = data->plane->format_mods_async.formats[i];
if (format != DRM_FORMAT_XRGB8888)
continue;
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 0e00db014426..5990adabf175 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -1126,8 +1126,8 @@ static void test_format_plane(data_t *data, igt_crtc_t *crtc,
bool result = true;
bool found = false;
- for (int i = 0; i < plane->format_mod_count; i++) {
- uint64_t modifier = plane->modifiers[i];
+ for (int i = 0; i < plane->format_mods.count; i++) {
+ uint64_t modifier = plane->format_mods.modifiers[i];
if (data->mod == modifier) {
found = true;
@@ -1192,9 +1192,9 @@ static void test_format_plane(data_t *data, igt_crtc_t *crtc,
*/
igt_require(num_unique_crcs(ref_crc[MULTIPLE_CRC_SET], data->num_colors) > 1);
- for (int i = 0; i < plane->format_mod_count; i++) {
- uint32_t format = plane->formats[i];
- uint64_t modifier = plane->modifiers[i];
+ for (int i = 0; i < plane->format_mods.count; i++) {
+ uint32_t format = plane->format_mods.formats[i];
+ uint64_t modifier = plane->format_mods.modifiers[i];
struct format_mod f = {
.format = format,
.modifier = modifier,
@@ -1264,8 +1264,8 @@ static bool skip_plane(data_t *data, igt_plane_t *plane)
int index = plane->index;
int i;
- for (i = 0; i < plane->format_mod_count; i++) {
- uint64_t modifier = plane->modifiers[i];
+ for (i = 0; i < plane->format_mods.count; i++) {
+ uint64_t modifier = plane->format_mods.modifiers[i];
if (IS_AMD_FMT_MOD(modifier) &&
(AMD_FMT_MOD_GET(DCC, modifier) ||
--
2.52.0
next prev parent reply other threads:[~2026-05-12 12:22 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 12:21 [PATCH i-g-t 00/25] lib/kms: Clean up format+mod stuff Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 01/25] tests/kms_async_flips: Use correct format_mod list Ville Syrjala
2026-05-13 5:12 ` B, Jeevan
2026-05-12 12:21 ` [PATCH i-g-t 02/25] test/kms: Introduce a few extra format/modifier variables Ville Syrjala
2026-05-13 5:17 ` B, Jeevan
2026-05-12 12:21 ` Ville Syrjala [this message]
2026-05-13 5:23 ` [PATCH i-g-t 03/25] lib/kms: Introduce struct igt_format_mods B, Jeevan
2026-05-12 12:21 ` [PATCH i-g-t 04/25] lib/kms: Pass struct igt_format_mods to igt_parse_format_mod_blob() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 05/25] lib/kms: Extract format_mods_alloc() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 06/25] lib/kms: Extract fill_plane_default_format_mods() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 07/25] lib/kms: Extract igt_format_mods_has_format_with_modifier() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 08/25] lib/kms: Pass target format_mods to igt_add_display_format_mod() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 09/25] lib/kms: Extract format_mods_union() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 10/25] lib/kms: Extract display_format_mods_union() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 11/25] lib/kms: Move and rename igt_count_display_format_mod() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 12/25] lib/kms: Make igt_fill_display_format_mod() more flexible Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 13/25] lib/kms: Add display->format_mods_async Ville Syrjala
2026-05-14 4:35 ` Reddy Guddati, Santhosh
2026-05-12 12:21 ` [PATCH i-g-t 14/25] lib/kms: Fill plane->format_mods_async for planes without IN_FORMATS Ville Syrjala
2026-05-14 4:59 ` Reddy Guddati, Santhosh
2026-05-12 12:21 ` [PATCH i-g-t 15/25] lib/kms: Encourage drivers to expose IN_FORMATS_ASYNC Ville Syrjala
2026-05-14 5:15 ` Reddy Guddati, Santhosh
2026-05-12 12:21 ` [PATCH i-g-t 16/25] lib/kms: Introduce igt_format_mods iterators Ville Syrjala
2026-05-13 3:17 ` [PATCH i-g-t v2 " Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 17/25] lib/kms: Add helpers to query igt_format_mods Ville Syrjala
2026-05-13 3:17 ` [PATCH i-g-t v2 " Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 18/25] tests/chamelium/kms_chamelium_frames: Use for_each_format_and_modifier() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 19/25] tests/kms_plane: Use igt_format_mods_has_modifier() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 20/25] tests/kms_plane: Use for_each_format_and_modifier() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 21/25] tests/kms_async_flips: Remove the IN_FORMAT_ASYNC check Ville Syrjala
2026-05-14 5:18 ` Reddy Guddati, Santhosh
2026-05-12 12:21 ` [PATCH i-g-t 22/25] tests/kms_async_flips: Use igt_format_mods_has_modifier() Ville Syrjala
2026-05-14 4:27 ` Reddy Guddati, Santhosh
2026-05-12 12:21 ` [PATCH i-g-t 23/25] tests/kms_async_flips: Use for_each_format_and_modifier() and for_each_modifier_with_format() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 24/25] tests/intel/kms_flip_tiling: Use for_each_modifier_with_format() Ville Syrjala
2026-05-12 12:21 ` [PATCH i-g-t 25/25] tests/chamelium/kms_chamelium_frames: Use for_each_format_with_modifier() Ville Syrjala
2026-05-12 22:00 ` ✗ i915.CI.BAT: failure for lib/kms: Clean up format+mod stuff Patchwork
2026-05-13 0:10 ` ✗ Xe.CI.BAT: " Patchwork
2026-05-13 4:25 ` ✓ i915.CI.BAT: success for lib/kms: Clean up format+mod stuff (rev3) Patchwork
2026-05-13 4:34 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-13 17:00 ` ✗ Xe.CI.FULL: failure for lib/kms: Clean up format+mod stuff Patchwork
2026-05-14 0:12 ` ✗ Xe.CI.FULL: failure for lib/kms: Clean up format+mod stuff (rev3) Patchwork
2026-05-14 2:27 ` ✗ i915.CI.Full: " 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=20260512122143.11013-4-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.