summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2017-08-03 14:49:45 +0100
committerJonas Ã…dahl <jadahl@gmail.com>2018-01-24 11:35:07 +0800
commitd99cd279d2b5434c51e7a45fd11b46c6c83e7843 (patch)
treeeb018bc689472d1062c017f20039f969034e38cf
parentd670a1aa78ff67358b483e411528df6ec466727b (diff)
downloadmutter-d99cd279d2b5434c51e7a45fd11b46c6c83e7843.tar.gz
renderer/native: Use drmModeAddFB2 where available
drmModeAddFB2 allows specifying multiple planes, as well as directly specifying the format, rather than relying on a depth/bpp -> format mapping. https://bugzilla.gnome.org/show_bug.cgi?id=785779
-rw-r--r--src/backends/native/meta-renderer-native.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 23d9fda26..968b9d44c 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -46,6 +46,7 @@
#include <sys/mman.h>
#include <unistd.h>
#include <xf86drm.h>
+#include <drm_fourcc.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-crtc.h"
@@ -1276,31 +1277,44 @@ gbm_get_next_fb_id (MetaGpuKms *gpu_kms,
struct gbm_bo **out_next_bo,
uint32_t *out_next_fb_id)
{
- uint32_t handle, stride;
struct gbm_bo *next_bo;
uint32_t next_fb_id;
int kms_fd;
+ uint32_t handles[4] = { 0, };
+ uint32_t strides[4] = { 0, };
+ uint32_t offsets[4] = { 0, };
/* Now we need to set the CRTC to whatever is the front buffer */
next_bo = gbm_surface_lock_front_buffer (gbm_surface);
- stride = gbm_bo_get_stride (next_bo);
- handle = gbm_bo_get_handle (next_bo).u32;
+ strides[0] = gbm_bo_get_stride (next_bo);
+ handles[0] = gbm_bo_get_handle (next_bo).u32;
kms_fd = meta_gpu_kms_get_fd (gpu_kms);
- if (drmModeAddFB (kms_fd,
- gbm_bo_get_width (next_bo),
- gbm_bo_get_height (next_bo),
- 24, /* depth */
- 32, /* bpp */
- stride,
- handle,
- &next_fb_id))
- {
- g_warning ("Failed to create new back buffer handle: %m");
- gbm_surface_release_buffer (gbm_surface, next_bo);
- return FALSE;
+ if (drmModeAddFB2 (kms_fd,
+ gbm_bo_get_width (next_bo),
+ gbm_bo_get_height (next_bo),
+ gbm_bo_get_format (next_bo),
+ handles,
+ strides,
+ offsets,
+ &next_fb_id,
+ 0))
+ {
+ if (drmModeAddFB (kms_fd,
+ gbm_bo_get_width (next_bo),
+ gbm_bo_get_height (next_bo),
+ 24, /* depth */
+ 32, /* bpp */
+ strides[0],
+ handles[0],
+ &next_fb_id))
+ {
+ g_warning ("Failed to create new back buffer handle: %m");
+ gbm_surface_release_buffer (gbm_surface, next_bo);
+ return FALSE;
+ }
}
*out_next_bo = next_bo;