Re: [PATCH v3 04/12] tests/kms_colorop_helper: Add helpers to get encoding/range from FIXED_MATRIX name
Alex Hung <[email protected]> Sat, 25 Jul 2026 01:04:10 -0600
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <[email protected]> |
On 6/23/26 11:57, Harry Wentland wrote: > Add fixed_matrix_type_to_encoding_range() to map a FIXED_MATRIX colorop's > DRM enum string name (e.g. "YCbCr 709 Limited to RGB") to the matching > igt_color_encoding and igt_color_range. This lets the tests derive the > encoding/range needed for the software reference CSC directly from the > colorop the hardware advertises. > > Assisted-by: Claude:claude-opus-4-6 > Signed-off-by: Harry Wentland <[email protected]> > --- > tests/kms_colorop_helper.c | 30 ++++++++++++++++++++++++++++++ > tests/kms_colorop_helper.h | 4 ++++ > 2 files changed, 34 insertions(+) > > diff --git a/tests/kms_colorop_helper.c b/tests/kms_colorop_helper.c > index d12584c9adb1..e589fa5c99a9 100644 > --- a/tests/kms_colorop_helper.c > +++ b/tests/kms_colorop_helper.c > @@ -473,3 +473,33 @@ void reset_colorops(kms_colorop_t *colorops[]) > for(i = 0; colorops[i]; i++) > reset_colorop(colorops[i]); > } > + > +static const struct { > + const char *name; > + enum igt_color_encoding encoding; > + enum igt_color_range range; > +} fixed_matrix_type_map[] = { > + { "YCbCr 601 Full to RGB", IGT_COLOR_YCBCR_BT601, IGT_COLOR_YCBCR_FULL_RANGE }, > + { "YCbCr 709 Full to RGB", IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_FULL_RANGE }, > + { "YCbCr 2020 Full to RGB NC", IGT_COLOR_YCBCR_BT2020, IGT_COLOR_YCBCR_FULL_RANGE }, > + { "YCbCr 601 Limited to RGB", IGT_COLOR_YCBCR_BT601, IGT_COLOR_YCBCR_LIMITED_RANGE }, > + { "YCbCr 709 Limited to RGB", IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE }, > + { "YCbCr 2020 Limited to RGB NC", IGT_COLOR_YCBCR_BT2020, IGT_COLOR_YCBCR_LIMITED_RANGE }, > +}; > + > +void fixed_matrix_type_to_encoding_range(const char *fixed_matrix_type_name, > + enum igt_color_encoding *encoding, > + enum igt_color_range *range) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(fixed_matrix_type_map); i++) { > + if (!strcmp(fixed_matrix_type_name, fixed_matrix_type_map[i].name)) { > + *encoding = fixed_matrix_type_map[i].encoding; > + *range = fixed_matrix_type_map[i].range; > + return; > + } > + } > + > + igt_assert_f(false, "Unknown Fixed Matrix type: %s\n", fixed_matrix_type_name); > +} Can "igt_color_encoding encoding" and "igt_color_range range" be included in kms_colorop_fixed_matrix_info_t like below? typedef struct kms_colorop_fixed_matrix_info { const char *fixed_matrix_type_name; + enum igt_color_encoding encoding; + enum igt_color_range range; } kms_colorop_fixed_matrix_info_t; and kms_colorop_t kms_colorop_bt709_full_ycbcr_to_rgb = { .type = KMS_COLOROP_FIXED_MATRIX, .fixed_matrix_info = { .fixed_matrix_type_name = "YCbCr 709 Full to RGB", + .encoding = IGT_COLOR_YCBCR_BT709, + .range = IGT_COLOR_YCBCR_FULL_RANGE, }, .name = "YCbCr BT.709 Full Range to RGB", .transform = NULL, }; then we don't need fixed_matrix_type_to_encoding_range() > diff --git a/tests/kms_colorop_helper.h b/tests/kms_colorop_helper.h > index 68ae1dd05c6f..539067b5a494 100644 > --- a/tests/kms_colorop_helper.h > +++ b/tests/kms_colorop_helper.h > @@ -115,4 +115,8 @@ void set_color_pipeline(igt_display_t *display, > void set_color_pipeline_bypass(igt_plane_t *plane); > void reset_colorops(kms_colorop_t *colorops[]); > > +void fixed_matrix_type_to_encoding_range(const char *fixed_matrix_type_name, > + enum igt_color_encoding *encoding, > + enum igt_color_range *range); > + > #endif /* __KMS_COLOROP_HELPER_H__ */