KMSDRM: Add hint to enable the backend without DRM master

In some cases, it can be useful to have the KMSDRM backend even if it cannot
be used for rendering. An app may want to use SDL for input processing while
using another rendering API (such as an MMAL overlay on Raspberry Pi) or
using its own code to render to DRM overlays that SDL doesn't support.

This also moves the check for DRM master to an earlier point where we can fail
initialization of the backend, rather than allowing the backend to initialize
then failing the creation of a window later.
This commit is contained in:
Cameron Gutman
2021-02-25 19:22:31 -06:00
committed by Sam Lantinga
parent 8c5b7af2d2
commit dfa64eadd3
2 changed files with 31 additions and 6 deletions

View File

@@ -100,6 +100,14 @@ check_modestting(int devindex)
}
if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) {
if (SDL_GetHintBoolean(SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER, SDL_TRUE)) {
/* Skip this device if we can't obtain DRM master */
KMSDRM_drmSetMaster(drm_fd);
if (KMSDRM_drmAuthMagic(drm_fd, 0) == -EACCES) {
continue;
}
}
available = SDL_TRUE;
break;
}
@@ -773,12 +781,6 @@ KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata)
/* Set the FD we just opened as current DRM master. */
KMSDRM_drmSetMaster(viddata->drm_fd);
/* Check if we are the current DRM master. */
if (KMSDRM_drmAuthMagic(viddata->drm_fd, 0) == -EACCES) {
ret = SDL_SetError("DRM device is claimed by another program as master.");
return ret;
}
/* Create the GBM device. */
viddata->gbm_dev = KMSDRM_gbm_create_device(viddata->drm_fd);
if (!viddata->gbm_dev) {