[PATCH i-g-t v2 2/4] lib/igt_fb: Expose lookup_drm_format to access format properties in tests

Louis Chauvet louis.chauvet at bootlin.com
Wed Mar 13 17:09:41 UTC 2024


Members of this struct are useful to configure tests when formats are discovered at runtime.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/igt_fb.c | 15 ++-------------
 lib/igt_fb.h | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index cc70cb91cef9..6cd299374d31 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -103,18 +103,7 @@
 #endif
 
 /* drm fourcc/cairo format maps */
-static const struct format_desc_struct {
-	const char *name;
-	uint32_t drm_id;
-	cairo_format_t cairo_id;
-	pixman_format_code_t pixman_id;
-	int depth;
-	int num_planes;
-	int plane_bpp[4];
-	uint8_t hsub;
-	uint8_t vsub;
-	bool convert;
-} format_desc[] = {
+static const struct format_desc_struct format_desc[] = {
 	{ .name = "ARGB1555", .depth = -1, .drm_id = DRM_FORMAT_ARGB1555,
 	  .cairo_id = CAIRO_FORMAT_ARGB32, .convert = true,
 	  .pixman_id = PIXMAN_a1r5g5b5,
@@ -371,7 +360,7 @@ static const struct format_desc_struct {
 #define for_each_format(f)	\
 	for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
 
-static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)
+const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)
 {
 	const struct format_desc_struct *format;
 
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 834aaef54dea..28c18b355d94 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -30,6 +30,7 @@
 #define __IGT_FB_H__
 
 #include <cairo.h>
+#include <pixman.h>
 #include <stddef.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -123,6 +124,32 @@ enum igt_text_align {
 	align_hcenter	= 0x08,
 };
 
+/**
+ * struct format_desc_struct - Description of a format in igt
+ *
+ * @name: Name of a format, used for lookup and printing
+ * @drm_id: Id of this format in DRM.
+ * @cairo_id: Id of the format used by IGT for software rendering. It can be different from @drm_id, the colors will be converted when writing to the DRM framebuffer.
+ * @pixman_id: When set, the conversion from @cairo_id to @drm_id will be done with pixman and this format. It should correspond to @drm_id.
+ * @depth: Number of bits used to represent a pixel
+ * @num_planes: Number of planes in this format
+ * @plane_bpp: Number of bit per pixels, per plane
+ * @hsub, @vsub: Subsampling of this format
+ * @convert: When set, the format must be converted using either pixman or a custom conversion function before writing to the DRM framebuffer.
+ */
+struct format_desc_struct {
+	const char *name;
+	uint32_t drm_id;
+	cairo_format_t cairo_id;
+	pixman_format_code_t pixman_id;
+	int depth;
+	int num_planes;
+	int plane_bpp[4];
+	uint8_t hsub;
+	uint8_t vsub;
+	bool convert;
+};
+
 void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
 			  unsigned *width_ret, unsigned *height_ret);
 void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t modifier,
@@ -215,6 +242,8 @@ const char *igt_format_str(uint32_t drm_format);
 bool igt_fb_supported_format(uint32_t drm_format);
 bool igt_format_is_yuv(uint32_t drm_format);
 bool igt_format_is_yuv_semiplanar(uint32_t format);
+const struct format_desc_struct *lookup_drm_format(uint32_t drm_format);
+
 
 uint32_t igt_drm_format_str_to_format(const char *drm_format);
 

-- 
2.43.0



More information about the igt-dev mailing list