[igt-dev] [PATCH i-g-t 1/3] lib: Add igt_plane_has_format() etc. for pre-blobifier drivers

Ville Syrjala ville.syrjala at linux.intel.com
Fri Mar 16 17:47:57 UTC 2018


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

For drivers that don't support the IN_FORMATS blob we should just
consult the format list returned by getplane. Let's add a few helpers
to check a specific format against that list, and also let's make
the format+modifier use the same list. Since we can't tell which
modifiers are supported without IN_FORMATS we'll just assume that
linear should work, and everything else should not.

Cc: Ulrich Hecht <ulrich.hecht+renesas at gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_kms.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index cf6389f2474c..d894585fa6ba 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3901,11 +3901,31 @@ static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane
 	igt_assert_eq(idx, plane->format_mod_count);
 }
 
+bool igt_plane_has_format(igt_plane_t *plane, uint32_t format)
+{
+	drmModePlanePtr p = plane->drm_plane;
+
+	for (int i = 0; i < p->count_formats; i++) {
+		if (p->formats[i] == format)
+			return true;
+	}
+
+	return false;
+}
+
 bool igt_plane_has_format_mod(igt_plane_t *plane, uint32_t format,
 			      uint64_t modifier)
 {
 	int i;
 
+	if (plane->format_mod_count == 0) {
+		/* we can't tell what's supported so assume only linear */
+		if (modifier != DRM_FORMAT_MOD_LINEAR)
+			return false;
+
+		return igt_plane_has_format(plane, format);
+	}
+
 	for (i = 0; i < plane->format_mod_count; i++) {
 		if (plane->formats[i] == format &&
 		    plane->modifiers[i] == modifier)
@@ -3977,11 +3997,35 @@ static void igt_fill_display_format_mod(igt_display_t *display)
 	}
 }
 
+bool igt_display_has_format(igt_display_t *display, uint32_t format)
+{
+	enum pipe pipe;
+
+	for_each_pipe(display, pipe) {
+		igt_plane_t *plane;
+
+		for_each_plane_on_pipe(display, pipe, plane) {
+			if (igt_plane_has_format(plane, format))
+				return true;
+		}
+	}
+
+	return false;
+}
+
 bool igt_display_has_format_mod(igt_display_t *display, uint32_t format,
 				uint64_t modifier)
 {
 	int i;
 
+	if (display->format_mod_count == 0) {
+		/* we can't tell what's supported so assume only linear */
+		if (modifier != DRM_FORMAT_MOD_LINEAR)
+			return false;
+
+		return igt_display_has_format(display, format);
+	}
+
 	for (i = 0; i < display->format_mod_count; i++) {
 		if (display->formats[i] == format &&
 		    display->modifiers[i] == modifier)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 1ea3be991509..a59f80474ddd 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -680,7 +680,9 @@ bool igt_hotplug_detected(struct udev_monitor *mon,
 void igt_flush_hotplugs(struct udev_monitor *mon);
 void igt_cleanup_hotplug(struct udev_monitor *mon);
 
+bool igt_display_has_format(igt_display_t *display, uint32_t format);
 bool igt_display_has_format_mod(igt_display_t *display, uint32_t format, uint64_t modifier);
+bool igt_plane_has_format(igt_plane_t *plane, uint32_t format);
 bool igt_plane_has_format_mod(igt_plane_t *plane, uint32_t format, uint64_t modifier);
 
 #endif /* __IGT_KMS_H__ */
-- 
2.16.1



More information about the igt-dev mailing list