modesetting: Create a gbm device even without glamor

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
stefan11111
2026-02-06 15:26:08 +02:00
committed by Enrico Weigelt
parent 8be62ebcae
commit 55eba2385c
2 changed files with 34 additions and 3 deletions

View File

@@ -35,6 +35,7 @@
#include "dix-config.h"
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <X11/extensions/randr.h>
@@ -1708,7 +1709,7 @@ modesetCreateScreenResources(ScreenPtr pScreen)
if (!ms->drmmode.sw_cursor)
drmmode_map_cursor_bos(pScrn, &ms->drmmode);
if (!ms->drmmode.gbm) {
if (!ms->drmmode.glamor) {
pixels = drmmode_map_front_bo(&ms->drmmode);
if (!pixels)
return FALSE;
@@ -1950,6 +1951,22 @@ modesetting_get_cursor_interleave(int fd)
return ret;
}
#ifdef GLAMOR_HAS_GBM
static struct gbm_device*
gbm_create_device_by_name(int fd, const char* name)
{
struct gbm_device* ret = NULL;
const char* old_backend = getenv("GBM_BACKEND");
setenv("GBM_BACKEND", name, 1);
ret = gbm_create_device(fd);
unsetenv("GBM_BACKEND");
if (old_backend) {
setenv("GBM_BACKEND", old_backend, 1);
}
return ret;
}
#endif
static Bool
ScreenInit(ScreenPtr pScreen, int argc, char **argv)
{
@@ -1963,8 +1980,14 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
return FALSE;
#ifdef GLAMOR_HAS_GBM
if (ms->drmmode.glamor)
if (ms->drmmode.glamor) {
ms->drmmode.gbm = ms->glamor.egl_get_gbm_device(pScreen);
} else {
ms->drmmode.gbm = gbm_create_device(ms->drmmode.fd);
if (!ms->drmmode.gbm) {
ms->drmmode.gbm = gbm_create_device_by_name(ms->drmmode.fd, "dumb");
}
}
#endif
/* HW dependent - FIXME */
@@ -2294,6 +2317,14 @@ CloseScreen(ScreenPtr pScreen)
drmmode_free_bos(pScrn, &ms->drmmode);
#ifdef GLAMOR_HAS_GBM
/* If we didn't get the gbm device from glamor, we have to free it ourserves */
if (!ms->drmmode.glamor && ms->drmmode.gbm) {
gbm_device_destroy(ms->drmmode.gbm);
ms->drmmode.gbm = NULL;
}
#endif
if (ms->drmmode.pageflip) {
miPointerScreenPtr PointPriv =
dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);

View File

@@ -4149,7 +4149,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
scrn->virtualY = height;
scrn->displayWidth = pitch / kcpp;
if (!drmmode->gbm) {
if (!drmmode->glamor) {
new_pixels = drmmode_map_front_bo(drmmode);
if (!new_pixels)
goto fail;