* [igt-dev] [PATCH i-g-t 1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
@ 2018-07-25 11:38 Maarten Lankhorst
2018-07-25 11:38 ` [igt-dev] [PATCH i-g-t 2/2] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum Maarten Lankhorst
2018-07-25 12:22 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Patchwork
0 siblings, 2 replies; 3+ messages in thread
From: Maarten Lankhorst @ 2018-07-25 11:38 UTC (permalink / raw)
To: igt-dev
This adds the possibility to test arbitrary enumerations in IGT without
having to define mappings for each and every one.
Changes since v1:
- Add commit description.
- Add try_prop_enum, to allow handling unknown enumerations.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
lib/igt_kms.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_kms.h | 31 +++++++++++++++++-
2 files changed, 120 insertions(+), 1 deletion(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c9e00c3bd6a7..e5272103e243 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2891,6 +2891,48 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
plane->drm_plane->plane_id, plane->props[prop]);
}
+static bool igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t id, const char *str, uint64_t *val)
+{
+ drmModePropertyPtr prop = drmModeGetProperty(drm_fd, id);
+ int i;
+
+ igt_assert(id);
+ igt_assert(prop);
+
+ for (i = 0; i < prop->count_enums; i++)
+ if (!strcmp(str, prop->enums[i].name)) {
+ *val = prop->enums[i].value;
+ drmModeFreeProperty(prop);
+ return true;
+ }
+
+ return false;
+}
+
+bool igt_plane_try_prop_enum(igt_plane_t *plane,
+ enum igt_atomic_plane_properties prop,
+ const char *val)
+{
+ igt_display_t *display = plane->pipe->display;
+ uint64_t uval;
+
+ igt_assert(plane->props[prop]);
+
+ if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+ plane->props[prop], val, &uval))
+ return false;
+
+ igt_plane_set_prop_value(plane, prop, uval);
+ return true;
+}
+
+void igt_plane_set_prop_enum(igt_plane_t *plane,
+ enum igt_atomic_plane_properties prop,
+ const char *val)
+{
+ igt_assert(igt_plane_try_prop_enum(plane, prop, val));
+}
+
/**
* igt_plane_replace_prop_blob:
* @plane: plane to set property on.
@@ -2942,6 +2984,30 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
output->id, output->props[prop]);
}
+bool igt_output_try_prop_enum(igt_output_t *output,
+ enum igt_atomic_connector_properties prop,
+ const char *val)
+{
+ igt_display_t *display = output->display;
+ uint64_t uval;
+
+ igt_assert(output->props[prop]);
+
+ if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+ output->props[prop], val, &uval))
+ return false;
+
+ igt_output_set_prop_value(output, prop, uval);
+ return true;
+}
+
+void igt_output_set_prop_enum(igt_output_t *output,
+ enum igt_atomic_connector_properties prop,
+ const char *val)
+{
+ igt_assert(igt_output_try_prop_enum(output, prop, val));
+}
+
/**
* igt_output_replace_prop_blob:
* @output: output to set property on.
@@ -2993,6 +3059,30 @@ uint64_t igt_pipe_obj_get_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties
pipe->crtc_id, pipe->props[prop]);
}
+bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe_obj,
+ enum igt_atomic_crtc_properties prop,
+ const char *val)
+{
+ igt_display_t *display = pipe_obj->display;
+ uint64_t uval;
+
+ igt_assert(pipe_obj->props[prop]);
+
+ if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+ pipe_obj->props[prop], val, &uval))
+ return false;
+
+ igt_pipe_obj_set_prop_value(pipe_obj, prop, uval);
+ return true;
+}
+
+void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe_obj,
+ enum igt_atomic_crtc_properties prop,
+ const char *val)
+{
+ igt_assert(igt_pipe_obj_try_prop_enum(pipe_obj, prop, val));
+}
+
/**
* igt_pipe_obj_replace_prop_blob:
* @pipe: pipe to set property on.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4222a3418103..3a12f2782eed 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -574,6 +574,14 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
igt_plane_set_prop_changed(plane, prop); \
} while (0)
+extern bool igt_plane_try_prop_enum(igt_plane_t *plane,
+ enum igt_atomic_plane_properties prop,
+ const char *val);
+
+extern void igt_plane_set_prop_enum(igt_plane_t *plane,
+ enum igt_atomic_plane_properties prop,
+ const char *val);
+
extern void igt_plane_replace_prop_blob(igt_plane_t *plane,
enum igt_atomic_plane_properties prop,
const void *ptr, size_t length);
@@ -609,10 +617,17 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
igt_output_set_prop_changed(output, prop); \
} while (0)
+extern bool igt_output_try_prop_enum(igt_output_t *output,
+ enum igt_atomic_connector_properties prop,
+ const char *val);
+
+extern void igt_output_set_prop_enum(igt_output_t *output,
+ enum igt_atomic_connector_properties prop,
+ const char *val);
+
extern void igt_output_replace_prop_blob(igt_output_t *output,
enum igt_atomic_connector_properties prop,
const void *ptr, size_t length);
-
/**
* igt_pipe_obj_has_prop:
* @pipe: Pipe to check.
@@ -693,6 +708,20 @@ igt_pipe_has_prop(igt_display_t *display, enum pipe pipe,
#define igt_pipe_set_prop_value(display, pipe, prop, value) \
igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value)
+extern bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe,
+ enum igt_atomic_crtc_properties prop,
+ const char *val);
+
+extern void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe,
+ enum igt_atomic_crtc_properties prop,
+ const char *val);
+
+#define igt_pipe_try_prop_enum(display, pipe, prop, val) \
+ igt_pipe_obj_try_prop_enum(&(display)->pipes[(pipe)], prop, val)
+
+#define igt_pipe_set_prop_enum(display, pipe, prop, val) \
+ igt_pipe_obj_set_prop_enum(&(display)->pipes[(pipe)], prop, val)
+
extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe,
enum igt_atomic_crtc_properties prop,
const void *ptr, size_t length);
--
2.18.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [igt-dev] [PATCH i-g-t 2/2] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum
2018-07-25 11:38 [igt-dev] [PATCH i-g-t 1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Maarten Lankhorst
@ 2018-07-25 11:38 ` Maarten Lankhorst
2018-07-25 12:22 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Maarten Lankhorst @ 2018-07-25 11:38 UTC (permalink / raw)
To: igt-dev
We now have infrastructure for generic enum handling. This will make it easier
to write new tests without defining all enum constants beforehand.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
lib/igt_color_encoding.c | 19 ++++++++++
lib/igt_color_encoding.h | 3 ++
lib/igt_kms.c | 77 +++++-----------------------------------
3 files changed, 31 insertions(+), 68 deletions(-)
diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index f445dbbc0250..45b672d4c100 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -141,3 +141,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
return igt_matrix_multiply(&r, &c);
}
+
+const char *igt_color_encoding_to_str(enum igt_color_encoding encoding)
+{
+ switch (encoding) {
+ case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
+ case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
+ case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
+ default: igt_assert(0); return NULL;
+ }
+}
+
+const char *igt_color_range_to_str(enum igt_color_range range)
+{
+ switch (range) {
+ case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited range";
+ case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
+ default: igt_assert(0); return NULL;
+ }
+}
diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
index 0d8c819322af..3884e4939f4c 100644
--- a/lib/igt_color_encoding.h
+++ b/lib/igt_color_encoding.h
@@ -41,6 +41,9 @@ enum igt_color_range {
IGT_NUM_COLOR_RANGES,
};
+const char *igt_color_encoding_to_str(enum igt_color_encoding encoding);
+const char *igt_color_range_to_str(enum igt_color_range range);
+
struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding color_encoding,
enum igt_color_range color_range);
struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e5272103e243..62d8468415c6 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);
--
2.18.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
2018-07-25 11:38 [igt-dev] [PATCH i-g-t 1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Maarten Lankhorst
2018-07-25 11:38 ` [igt-dev] [PATCH i-g-t 2/2] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum Maarten Lankhorst
@ 2018-07-25 12:22 ` Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2018-07-25 12:22 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: igt-dev
== Series Details ==
Series: series starting with [i-g-t,1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
URL : https://patchwork.freedesktop.org/series/47206/
State : failure
== Summary ==
IGT patchset build failed on latest successful build
24c5e07783222b5d6cf86003e8e545033e09bb3c tests/kms_panel_fitting: Do not use scaling on gen7 and gen8, v2.
ninja: Entering directory `build'
[1/650] Generating version.h with a custom command.
[2/649] Linking static target lib/libigt-drmtest_c.a.
[3/649] Compiling C object 'lib/igt-igt_color_encoding_c@sta/igt_color_encoding.c.o'.
FAILED: lib/igt-igt_color_encoding_c@sta/igt_color_encoding.c.o
ccache cc -Ilib/igt-igt_color_encoding_c@sta -Ilib -I../lib -I. -I../ -I../include/drm-uapi -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/igt/include -I/opt/igt/include/libdrm -I/usr/include/x86_64-linux-gnu -I/usr/include -I/home/cidrm/kernel_headers/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -D_GNU_SOURCE -include config.h -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-clobbered -Wno-type-limits -Wimplicit-fallthrough=0 -fPIC -pthread '-DIGT_DATADIR="/opt/igt/share/igt-gpu-tools"' '-DIGT_SRCDIR="/home/cidrm/igt-gpu-tools/tests"' '-DIGT_LOG_DOMAIN="igt_color_encoding"' -MD -MQ 'lib/igt-igt_color_encoding_c@sta/igt_color_encoding.c.o' -MF 'lib/igt-igt_color_encoding_c@sta/igt_color_encoding.c.o.d' -o 'lib/igt-igt_color_encoding_c@sta/igt_color_encoding.c.o' -c ../lib/igt_color_encoding.c
../lib/igt_color_encoding.c: In function ‘igt_color_encoding_to_str’:
../lib/igt_color_encoding.c:151:11: warning: implicit declaration of function ‘igt_assert’ [-Wimplicit-function-declaration]
default: igt_assert(0); return NULL;
^~~~~~~~~~
../lib/igt_color_encoding.c:151:33: error: ‘NULL’ undeclared (first use in this function)
default: igt_assert(0); return NULL;
^~~~
../lib/igt_color_encoding.c:151:33: note: each undeclared identifier is reported only once for each function it appears in
../lib/igt_color_encoding.c: In function ‘igt_color_range_to_str’:
../lib/igt_color_encoding.c:160:33: error: ‘NULL’ undeclared (first use in this function)
default: igt_assert(0); return NULL;
^~~~
../lib/igt_color_encoding.c: In function ‘igt_color_encoding_to_str’:
../lib/igt_color_encoding.c:153:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
../lib/igt_color_encoding.c: In function ‘igt_color_range_to_str’:
../lib/igt_color_encoding.c:162:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
ninja: build stopped: subcommand failed.
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-25 12:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25 11:38 [igt-dev] [PATCH i-g-t 1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Maarten Lankhorst
2018-07-25 11:38 ` [igt-dev] [PATCH i-g-t 2/2] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum Maarten Lankhorst
2018-07-25 12:22 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).