From f2dea5d1395093186165a4600838b195d873fada Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 9 Jan 2018 15:50:37 +0000 Subject: [PATCH] renderer-native: Remove no_add_fb2 drmModeAddFB2 allows userspace to specify a real format enum on non-ancient kernels, as an improvement over the legacy drmModeAddFB which derives format from a fixed depth/bpp mapping. As an optimisation, Weston used to decide at the first failure of drmModeAddFB2 that the ioctl was unavailable: as non-existent DRM ioctls return -EINVAL rather than -ENOSYS or similar, bad parameters are not distinguishable from the ioctl not being present. Mutter has also implemented the same optimisation for dumb framebuffers, which potentially papers over errors for the gain of avoiding one ioctl which will rapidly fail on ancient kernels. Remove the optimisation and always use AddFB2 where possible. Closes: #14 --- src/backends/native/meta-renderer-native.c | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 772ce07f1..c1a918efd 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -103,8 +103,6 @@ typedef struct _MetaRendererNativeGpuData MetaRendererNativeMode mode; - gboolean no_add_fb2; - EGLDisplay egl_display; /* @@ -2181,14 +2179,15 @@ init_dumb_fb (MetaDumbBuffer *dumb_fb, uint32_t format, GError **error) { - MetaRendererNative *renderer_native = meta_renderer_native_from_gpu (gpu_kms); - MetaRendererNativeGpuData *renderer_gpu_data; struct drm_mode_create_dumb create_arg; struct drm_mode_destroy_dumb destroy_arg; struct drm_mode_map_dumb map_arg; uint32_t fb_id = 0; void *map; int kms_fd; + uint32_t handles[4] = { 0, }; + uint32_t pitches[4] = { 0, }; + uint32_t offsets[4] = { 0, }; kms_fd = meta_gpu_kms_get_fd (gpu_kms); @@ -2206,25 +2205,18 @@ init_dumb_fb (MetaDumbBuffer *dumb_fb, goto err_ioctl; } - renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native, - gpu_kms); - if (!renderer_gpu_data->no_add_fb2) - { - uint32_t handles[4] = { create_arg.handle, }; - uint32_t pitches[4] = { create_arg.pitch, }; - uint32_t offsets[4] = { 0 }; + handles[0] = create_arg.handle; + pitches[0] = create_arg.pitch; - if (drmModeAddFB2 (kms_fd, width, height, format, - handles, pitches, offsets, - &fb_id, 0) != 0) - { - g_warning ("drmModeAddFB2 failed (%s), falling back to drmModeAddFB", - g_strerror (errno)); - renderer_gpu_data->no_add_fb2 = TRUE; - } + if (drmModeAddFB2 (kms_fd, width, height, format, + handles, pitches, offsets, + &fb_id, 0) != 0) + { + g_debug ("drmModeAddFB2 failed (%s), falling back to drmModeAddFB", + g_strerror (errno)); } - if (renderer_gpu_data->no_add_fb2) + if (fb_id == 0) { if (drmModeAddFB (kms_fd, width, height, 24 /* depth of RGBX8888 */,