[mutter] renderer/native: Use drmModeAddFB2 where available



commit d99cd279d2b5434c51e7a45fd11b46c6c83e7843
Author: Daniel Stone <daniels collabora com>
Date:   Thu Aug 3 14:49:45 2017 +0100

    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

 src/backends/native/meta-renderer-native.c |   42 ++++++++++++++++++---------
 1 files changed, 28 insertions(+), 14 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 23d9fda..968b9d4 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]