summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/igt_fb.c22
-rw-r--r--lib/igt_fb.h2
-rw-r--r--tests/kms_atomic.c2
-rw-r--r--tests/kms_render.c2
4 files changed, 17 insertions, 11 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 0462c35b..5f23136e 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1141,28 +1141,34 @@ const char *igt_format_str(uint32_t drm_format)
}
/**
- * igt_get_all_formats:
+ * igt_get_all_cairo_formats:
* @formats: pointer to pointer to store the allocated formats array
* @format_count: pointer to integer to store the size of the allocated array
*
- * This functions returns an array of all the drm fourcc codes supported by this
- * library.
+ * This functions returns an array of all the drm fourcc codes supported by
+ * cairo and this library.
*/
-void igt_get_all_formats(const uint32_t **formats, int *format_count)
+void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count)
{
static uint32_t *drm_formats;
+ static int n_formats;
if (!drm_formats) {
struct format_desc_struct *f;
uint32_t *format;
- drm_formats = calloc(ARRAY_SIZE(format_desc),
- sizeof(*drm_formats));
+ n_formats = 0;
+ for_each_format(f)
+ if (f->cairo_id != CAIRO_FORMAT_INVALID)
+ n_formats++;
+
+ drm_formats = calloc(n_formats, sizeof(*drm_formats));
format = &drm_formats[0];
for_each_format(f)
- *format++ = f->drm_id;
+ if (f->cairo_id != CAIRO_FORMAT_INVALID)
+ *format++ = f->drm_id;
}
*formats = drm_formats;
- *format_count = ARRAY_SIZE(format_desc);
+ *format_count = n_formats;
}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 064027cb..4e6a7694 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -117,7 +117,7 @@ int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
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_formats(const uint32_t **formats, int *format_count);
+void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count);
#endif /* __IGT_FB_H__ */
diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 501093cc..c8b8b78a 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -843,7 +843,7 @@ static uint32_t plane_get_igt_format(struct kms_atomic_plane_state *plane)
plane_kms = drmModeGetPlane(plane->state->desc->fd, plane->obj);
igt_assert(plane_kms);
- igt_get_all_formats(&igt_formats, &num_igt_formats);
+ igt_get_all_cairo_formats(&igt_formats, &num_igt_formats);
for (i = 0; i < num_igt_formats; i++) {
int j;
diff --git a/tests/kms_render.c b/tests/kms_render.c
index 467d71f6..e0a2b58f 100644
--- a/tests/kms_render.c
+++ b/tests/kms_render.c
@@ -173,7 +173,7 @@ static void test_connector(const char *test_name,
int format_count;
int i;
- igt_get_all_formats(&formats, &format_count);
+ igt_get_all_cairo_formats(&formats, &format_count);
for (i = 0; i < format_count; i++) {
if (intel_gen(intel_get_drm_devid(drm_fd)) < 4
&& formats[i] == DRM_FORMAT_XRGB2101010) {