From 6c4ab48471ce82151a2d9b111000f66f0ea957ba Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 18 Dec 2020 17:50:02 +0300 Subject: [PATCH] SDL_kmsdrmvideo.c: check atomic modesetting in check_modesetting() .. so that KMSDRM_CreateDevice() can fail and SDL_VideoInit() would move on to next bootstrap member which is kmsdrm_legacy. hopefully fixes bug #5393. --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index dc8338b11..5411d2ebc 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -58,6 +58,14 @@ #define AMDGPU_COMPAT 1 +static int check_atomic_modesetting (int fd) +{ + if (KMSDRM_drmSetClientCap(fd, DRM_CLIENT_CAP_ATOMIC, 1)) { + return SDL_SetError("no atomic modesetting support."); + } + return 0; +} + static int check_modesetting(int devindex) { @@ -72,7 +80,7 @@ check_modesetting(int devindex) drm_fd = open(device, O_RDWR | O_CLOEXEC); if (drm_fd >= 0) { if (SDL_KMSDRM_LoadSymbols()) { - drmModeRes *resources = KMSDRM_drmModeGetResources(drm_fd); + drmModeRes *resources = (check_atomic_modesetting(drm_fd) < 0) ? NULL : KMSDRM_drmModeGetResources(drm_fd); if (resources) { SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%scard%d connector, encoder and CRTC counts are: %d %d %d", KMSDRM_DRI_PATH, devindex, @@ -1189,9 +1197,8 @@ KMSDRM_VideoInit(_THIS) /* Try ATOMIC compatibility */ - ret = KMSDRM_drmSetClientCap(viddata->drm_fd, DRM_CLIENT_CAP_ATOMIC, 1); + ret = check_atomic_modesetting(viddata->drm_fd); if (ret) { - ret = SDL_SetError("no atomic modesetting support."); goto cleanup; }