summaryrefslogtreecommitdiff
path: root/lib/igt_kms.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-06-08 15:04:13 +0200
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-08-30 10:59:17 +0200
commit903366f8699d730345e560dcaf854da69150a8d9 (patch)
tree5ef957e94efbc8a78e000e46960c9809cbf4f6cc /lib/igt_kms.c
parent7beba5bd2f6a01127bccfe4158555a9874ab2860 (diff)
lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
We now have infrastructure for generic enum handling. This will make it easier to write new tests without defining all enum constants beforehand. Changes since v1: - Fix compile error, sent old version by accident. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Diffstat (limited to 'lib/igt_kms.c')
-rw-r--r--lib/igt_kms.c77
1 files changed, 9 insertions, 68 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e5272103..62d84684 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -196,61 +196,6 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
};
-static const char * const igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
- [IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
- [IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
- [IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
-};
-
-static const char * const igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
- [IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
- [IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
-};
-
-static void parse_enum_prop(drmModePropertyPtr prop,
- int num_enums,
- uint64_t values[],
- const char * const enum_names[])
-{
- igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
- DRM_MODE_PROP_ATOMIC)) == DRM_MODE_PROP_ENUM);
- igt_assert(prop->count_enums == prop->count_values);
- igt_assert(prop->count_enums >= 1);
- igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) == (prop->count_enums == 1));
-
- for (int i = 0; i < prop->count_enums; i++) {
- for (int j = 0; j < num_enums; j++) {
- if (strcmp(prop->enums[i].name, enum_names[j]))
- continue;
-
- values[j] = prop->enums[i].value;
- }
- }
-}
-
-static void
-parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr prop)
-{
- parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
- plane->color_encoding.values,
- igt_color_encoding_names);
-}
-
-static void
-parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
-{
- parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
- plane->color_range.values,
- igt_color_range_names);
-}
-
-typedef void (*parse_plane_prop_t)(igt_plane_t *plane, drmModePropertyPtr prop);
-
-static const parse_plane_prop_t igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
- [IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
- [IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
-};
-
/*
* Retrieve all the properies specified in props_name and store them into
* plane->props.
@@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
if (strcmp(prop->name, prop_names[j]) != 0)
continue;
- if (igt_parse_plane_prop[j])
- igt_parse_plane_prop[j](plane, prop);
-
plane->props[j] = props->props[i];
break;
}
@@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t *plane)
igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
- igt_plane_set_prop_value(plane, IGT_PLANE_COLOR_ENCODING,
- plane->color_encoding.values[IGT_COLOR_YCBCR_BT601]);
+ igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_ENCODING,
+ igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT601));
+
if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
- igt_plane_set_prop_value(plane, IGT_PLANE_COLOR_RANGE,
- plane->color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
+ igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_RANGE,
+ igt_color_range_to_str(IGT_COLOR_YCBCR_LIMITED_RANGE));
/* Use default rotation */
if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
@@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)
igt_fb_set_size(fb, plane, fb->width, fb->height);
if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
- igt_plane_set_prop_value(plane,
- IGT_PLANE_COLOR_ENCODING,
- plane->color_encoding.values[fb->color_encoding]);
+ igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_ENCODING,
+ igt_color_encoding_to_str(fb->color_encoding));
if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
- igt_plane_set_prop_value(plane,
- IGT_PLANE_COLOR_RANGE,
- plane->color_range.values[fb->color_range]);
+ igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_RANGE,
+ igt_color_range_to_str(fb->color_range));
} else {
igt_plane_set_size(plane, 0, 0);