[igt-dev] [PATCH v5 07/13] fb: Add depth lookup function

Maxime Ripard maxime.ripard at bootlin.com
Fri Aug 24 08:04:13 UTC 2018


There is currently a function to lookup the bits per pixels for a given DRM
format, but not for the depth of that format. Add this function.

Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>
---
 lib/igt_fb.c | 18 ++++++++++++++++++
 lib/igt_fb.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index d98b733adecd..b712faa616a0 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2178,6 +2178,24 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format)
 }
 
 /**
+ * igt_drm_format_to_depth:
+ * @drm_format: drm fourcc pixel format code
+ *
+ * Returns:
+ * The bits per pixel for the given drm fourcc pixel format code. Fails hard if
+ * no match was found.
+ */
+uint32_t igt_drm_format_to_depth(uint32_t drm_format)
+{
+	struct format_desc_struct *f = lookup_drm_format(drm_format);
+
+	igt_assert_f(f, "can't find a depth for format %08x (%s)\n",
+		     drm_format, igt_format_str(drm_format));
+
+	return f->depth;
+}
+
+/**
  * igt_format_str:
  * @drm_format: drm fourcc pixel format code
  *
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index eb68b236530e..0273ad13899d 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -169,6 +169,7 @@ int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
 /* helpers to handle drm fourcc codes */
 uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
 uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
+uint32_t igt_drm_format_to_depth(uint32_t drm_format);
 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);
-- 
git-series 0.9.1


More information about the igt-dev mailing list