summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2016-11-05 13:43:33 -0700
committerBen Widawsky <ben@bwidawsk.net>2017-04-14 14:14:07 -0700
commite5fb5659ebe11ad6c4e965495d8baced83c667f2 (patch)
treea6bbb0530c8132f7639deba9b0ef425d8320d61c /common.c
parent1d57afe6e3b83715ec824a625eebf876804b4883 (diff)
downloadkmscube-e5fb5659ebe11ad6c4e965495d8baced83c667f2.tar.gz
common: Use the create with modifiers interface
Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'common.c')
-rw-r--r--common.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/common.c b/common.c
index 4bf3c5a..6b8849d 100644
--- a/common.c
+++ b/common.c
@@ -31,10 +31,26 @@
static struct gbm gbm;
+#ifndef DRM_FORMAT_MOD_LINEAR
+#define DRM_FORMAT_MOD_LINEAR 0
+#endif
+
+#ifdef HAVE_GBM_MODIFIERS
+static int
+get_modifiers(uint64_t **mods)
+{
+ /* Assumed LINEAR is supported everywhere */
+ static uint64_t modifiers[] = {DRM_FORMAT_MOD_LINEAR};
+ *mods = modifiers;
+ return 1;
+}
+#endif
+
const struct gbm * init_gbm(int drm_fd, int w, int h)
{
gbm.dev = gbm_create_device(drm_fd);
+#ifndef HAVE_GBM_MODIFIERS
gbm.surface = gbm_surface_create(gbm.dev, w, h,
GBM_FORMAT_XRGB8888,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
@@ -42,6 +58,12 @@ const struct gbm * init_gbm(int drm_fd, int w, int h)
printf("failed to create gbm surface\n");
return NULL;
}
+#else
+ uint64_t *mods;
+ int count = get_modifiers(&mods);
+ gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
+ GBM_FORMAT_XRGB8888, mods, count);
+#endif
gbm.width = w;
gbm.height = h;