kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

Blame SOURCES/0001-renderer-native-Fallback-to-non-planar-API-if-gbm_bo.patch

776610
From 1276cc97d1e6437c7fbc43fdd5cbcea39f60acee Mon Sep 17 00:00:00 2001
776610
From: =?UTF-8?q?Alex=20Villac=C3=ADs=20Lasso?= <a_villacis@palosanto.com>
776610
Date: Fri, 27 Jul 2018 16:08:52 +0000
776610
Subject: [PATCH] renderer/native: Fallback to non-planar API if
776610
 gbm_bo_get_handle_for_plane fails
776610
776610
Commit c0d9b08ef9bf2be865aad9bf1bc74ba24c655d9f replaced the old GBM API calls
776610
with the multi-plane GBM API. However, the call to gbm_bo_get_handle_for_plane
776610
fails for some DRI drivers (in particular i915). Due to missing error checks,
776610
the subsequent call to drmModeAddFB[2] fails and the screen output locks up.
776610
776610
This commit adds the missing error checks and falls back to the old GBM API
776610
(non-planar) if necessary.
776610
776610
v5: test success of gbm_bo_get_handle_for_plane instead of errno
776610
776610
This commit adopts solution proposed by Daniel van Vugt to check the return
776610
value of gbm_bo_get_handle_for_plane on plane 0 and fall back to old
776610
non-planar method if the call fails. This removes the errno check (for
776610
ENOSYS) that could abort if mesa ever sets a different value.
776610
776610
Related to: https://gitlab.gnome.org/GNOME/mutter/issues/127
776610
776610
776610
(cherry picked from commit f7af32a3eaefabbea3ebbda3a93eff98dd105ab9)
776610
---
776610
 src/backends/native/meta-renderer-native.c | 21 ++++++++++++++++-----
776610
 1 file changed, 16 insertions(+), 5 deletions(-)
776610
776610
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
776610
index fc6b22302..59003b397 100644
776610
--- a/src/backends/native/meta-renderer-native.c
776610
+++ b/src/backends/native/meta-renderer-native.c
776610
@@ -1607,12 +1607,23 @@ gbm_get_next_fb_id (MetaGpuKms         *gpu_kms,
776610
       return FALSE;
776610
     }
776610
 
776610
-  for (i = 0; i < gbm_bo_get_plane_count (next_bo); i++)
776610
+  if (gbm_bo_get_handle_for_plane (next_bo, 0).s32 == -1)
776610
     {
776610
-      strides[i] = gbm_bo_get_stride_for_plane (next_bo, i);
776610
-      handles[i] = gbm_bo_get_handle_for_plane (next_bo, i).u32;
776610
-      offsets[i] = gbm_bo_get_offset (next_bo, i);
776610
-      modifiers[i] = gbm_bo_get_modifier (next_bo);
776610
+      /* Failed to fetch handle to plane, falling back to old method */
776610
+      strides[0] = gbm_bo_get_stride (next_bo);
776610
+      handles[0] = gbm_bo_get_handle (next_bo).u32;
776610
+      offsets[0] = 0;
776610
+      modifiers[0] = DRM_FORMAT_MOD_INVALID;
776610
+    }
776610
+  else
776610
+    {
776610
+      for (i = 0; i < gbm_bo_get_plane_count (next_bo); i++)
776610
+        {
776610
+          strides[i] = gbm_bo_get_stride_for_plane (next_bo, i);
776610
+          handles[i] = gbm_bo_get_handle_for_plane (next_bo, i).u32;
776610
+          offsets[i] = gbm_bo_get_offset (next_bo, i);
776610
+          modifiers[i] = gbm_bo_get_modifier (next_bo);
776610
+        }
776610
     }
776610
 
776610
   kms_fd = meta_gpu_kms_get_fd (gpu_kms);
776610
-- 
776610
2.19.0
776610