Browse Source

KMSDRM: fix unsupported modifiers

Substring 9 months ago
parent
commit
9548bba63a

+ 1 - 0
src/video/kmsdrm/SDL_kmsdrmsym.h

@@ -129,6 +129,7 @@ SDL_KMSDRM_SYM(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo))
 SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
 SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
 SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
+SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane);)
 
 #undef SDL_KMSDRM_MODULE
 #undef SDL_KMSDRM_SYM

+ 15 - 2
src/video/kmsdrm/SDL_kmsdrmvideo.c

@@ -383,16 +383,29 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo)
     num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
     for (int i = 0; i < num_planes; i++) {
         strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
-        handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
+        handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32;
         offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
         modifiers[i] = modifiers[0];
     }
 
-    if (modifiers[0]) {
+    if (modifiers[0] && modifiers[0] != DRM_FORMAT_MOD_INVALID) {
         flags = DRM_MODE_FB_MODIFIERS;
     }
 
     ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
+
+    if (ret) {
+        handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32;
+        strides[0] = KMSDRM_gbm_bo_get_stride(bo);
+        offsets[0] = 0;
+        for (int i = 1; i<4; i++) {
+            handles[i] = 0;
+            strides[i] = 0;
+            offsets[i] = 0;
+        }
+        ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, w, h, format, handles, strides, offsets, &fb_info->fb_id, 0);
+    }
+
     if (ret) {
         SDL_free(fb_info);
         return NULL;

+ 4 - 0
src/video/kmsdrm/SDL_kmsdrmvideo.h

@@ -33,6 +33,10 @@
 #include <gbm.h>
 #include <EGL/egl.h>
 
+#ifndef DRM_FORMAT_MOD_INVALID
+#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
+#endif
+
 #ifndef DRM_MODE_FB_MODIFIERS
 #define DRM_MODE_FB_MODIFIERS	2
 #endif