[PATCH i-g-t 1/2] lib/igt_kms: Add set_prop_enum for mode objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
---
 lib/igt_kms.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h | 16 ++++++++++++++-
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index cb382c893c6c..9ac7ce73542a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2893,6 +2893,37 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
 					plane->drm_plane->plane_id, plane->props[prop]);
 }
 
+static uint64_t igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t id, const char *str)
+{
+	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)) {
+			uint64_t ret = prop->enums[i].value;
+			drmModeFreeProperty(prop);
+			return ret;
+		}
+
+	igt_assert_f(0, "Could not find property value for %s\n", str);
+	return 0;
+}
+
+void igt_plane_set_prop_enum(igt_plane_t *plane,
+			     enum igt_atomic_plane_properties prop,
+			     const char *val)
+{
+	igt_display_t *display = plane->display;
+	uint64_t uval =
+		igt_mode_object_get_prop_enum_value(display->drm_fd,
+						    plane->props[prop], val);
+
+	igt_plane_set_prop_value(plane, prop, uval);
+}
+
 /**
  * igt_plane_replace_prop_blob:
  * @plane: plane to set property on.
@@ -2944,6 +2975,18 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
 					output->id, output->props[prop]);
 }
 
+void igt_output_set_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_mode_object_get_prop_enum_value(display->drm_fd,
+						    output->props[prop], val);
+
+	igt_output_set_prop_value(output, prop, uval);
+}
+
 /**
  * igt_output_replace_prop_blob:
  * @output: output to set property on.
@@ -2995,6 +3038,19 @@ uint64_t igt_pipe_obj_get_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties
 					pipe->crtc_id, pipe->props[prop]);
 }
 
+void igt_pipe_obj_set_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_mode_object_get_prop_enum_value(display->drm_fd,
+						    pipe_obj->props[prop], val);
+
+	igt_pipe_obj_set_prop_value(pipe_obj, prop, uval);
+}
+
+
 /**
  * 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 8990a6fd6d12..b55881885b11 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -569,6 +569,10 @@ 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 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);
@@ -604,10 +608,13 @@ 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 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.
@@ -688,6 +695,13 @@ 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 void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe,
+				       enum igt_atomic_crtc_properties prop,
+				       const char *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.17.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux