[igt-dev] [PATCH i-g-t v3 3/3] lib/kms: Optimize out redundant plane color encoding/range prop changes

Ville Syrjala ville.syrjala at linux.intel.com
Tue Apr 20 22:17:20 UTC 2021


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Skip updates to the plane color encoding/range props when changing
the fb, iff the prop values aren't changing.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_kms.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9aba7b6e4b40..41dbd8b8c3aa 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3117,9 +3117,9 @@ static bool igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t id, const c
 	return false;
 }
 
-bool igt_plane_try_prop_enum(igt_plane_t *plane,
-			     enum igt_atomic_plane_properties prop,
-			     const char *val)
+static bool _igt_plane_try_prop_enum(igt_plane_t *plane,
+				     enum igt_atomic_plane_properties prop,
+				     const char *val, bool force)
 {
 	igt_display_t *display = plane->pipe->display;
 	uint64_t uval;
@@ -3130,15 +3130,30 @@ bool igt_plane_try_prop_enum(igt_plane_t *plane,
 						 plane->props[prop], val, &uval))
 		return false;
 
-	igt_plane_set_prop_value(plane, prop, uval);
+	if (force || plane->values[prop] != uval)
+		igt_plane_set_prop_value(plane, prop, uval);
 	return true;
 }
 
+bool igt_plane_try_prop_enum(igt_plane_t *plane,
+			     enum igt_atomic_plane_properties prop,
+			     const char *val)
+{
+	return _igt_plane_try_prop_enum(plane, prop, val, 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_assert(_igt_plane_try_prop_enum(plane, prop, val, true));
+}
+
+static void igt_plane_set_prop_enum_if_changed(igt_plane_t *plane,
+					       enum igt_atomic_plane_properties prop,
+					       const char *val)
+{
+	igt_assert(_igt_plane_try_prop_enum(plane, prop, val, false));
 }
 
 /**
@@ -3979,11 +3994,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_enum(plane, IGT_PLANE_COLOR_ENCODING,
-				igt_color_encoding_to_str(fb->color_encoding));
+			igt_plane_set_prop_enum_if_changed(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_enum(plane, IGT_PLANE_COLOR_RANGE,
-				igt_color_range_to_str(fb->color_range));
+			igt_plane_set_prop_enum_if_changed(plane, IGT_PLANE_COLOR_RANGE,
+							   igt_color_range_to_str(fb->color_range));
 
 		/* Hack to prioritize the plane on the pipe that last set fb */
 		igt_plane_set_pipe(plane, pipe);
-- 
2.26.3



More information about the igt-dev mailing list