From 583f61b202ce4fa092367837ef9d724f0dcd3ebb Mon Sep 17 00:00:00 2001 From: Sergey Zhuravlevich Date: Sat, 1 Dec 2018 16:31:56 -0500 Subject: [PATCH] kmsdrm: Check for resources when validating KMSDRM device in check_modesetting. Fixes Bugzilla #4403. --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 080ec667a..372e4bfd5 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -61,7 +61,13 @@ check_modestting(int devindex) if (SDL_KMSDRM_LoadSymbols()) { drmModeRes *resources = KMSDRM_drmModeGetResources(drm_fd); if (resources != NULL) { - available = SDL_TRUE; + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%scard%d connector, encoder and CRTC counts are: %d %d %d", + KMSDRM_DRI_PATH, devindex, + resources->count_connectors, resources->count_encoders, resources->count_crtcs); + + if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) { + available = SDL_TRUE; + } KMSDRM_drmModeFreeResources(resources); } SDL_KMSDRM_UnloadSymbols(); @@ -358,6 +364,7 @@ KMSDRM_VideoInit(_THIS) ret = SDL_OutOfMemory(); goto cleanup; } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device /dev/dri/card%d", vdata->devindex); SDL_snprintf(devname, 16, "/dev/dri/card%d", vdata->devindex); vdata->drm_fd = open(devname, O_RDWR | O_CLOEXEC); SDL_free(devname);