summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-02-02 11:32:40 +0100
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-02-12 13:13:07 +0100
commitc60cf3b51244334117c69db1f4665ff52815de03 (patch)
treed7d9acfae339678c5f3bf659ae9cc343b0af5711 /lib
parentaa5068c58947f31252cad69d80686e40bbce29db (diff)
lib/igt_fb: Add igt_fb_supported_format()
This makes it possible to iterate whether a format is supported or not, without each driver having to open code it. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_fb.c18
-rw-r--r--lib/igt_fb.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 35a928b9..0389b1c1 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1719,3 +1719,21 @@ void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count)
*formats = drm_formats;
*format_count = n_formats;
}
+
+/**
+ * igt_fb_supported_format:
+ * @drm_format: drm fourcc to test.
+ *
+ * This functions returns whether @drm_format can be succesfully created by
+ * igt_create_fb() and drawn to by igt_get_cairo_ctx().
+ */
+bool igt_fb_supported_format(uint32_t drm_format)
+{
+ struct format_desc_struct *f;
+
+ for_each_format(f)
+ if (f->drm_id == drm_format)
+ return f->cairo_id != CAIRO_FORMAT_INVALID;
+
+ return false;
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 77fd88bb..a6ce0789 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -163,6 +163,7 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
const char *igt_format_str(uint32_t drm_format);
void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count);
+bool igt_fb_supported_format(uint32_t drm_format);
#endif /* __IGT_FB_H__ */