modesetting: Check for GLAMOR instead of GLAMOR_HAS_GBM

Now gbm required for the modesetting driver.
`GLAMOR_HAS_GBM` is defined even if glamor isn't built.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
stefan11111
2026-02-06 23:10:33 +02:00
committed by Enrico Weigelt
parent 0a2568ab3a
commit b7bf58922f
8 changed files with 40 additions and 41 deletions

View File

@@ -44,7 +44,7 @@
#include "driver.h"
#include "dri2.h"
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
enum ms_dri2_frame_event_type {
MS_DRI2_QUEUE_SWAP,
@@ -1107,4 +1107,4 @@ ms_dri2_close_screen(ScreenPtr screen)
DRI2CloseScreen(screen);
}
#endif /* GLAMOR_HAS_GBM */
#endif /* GLAMOR */

View File

@@ -286,7 +286,7 @@ check_outputs(int fd, int *count)
*count = res->count_connectors;
ret = res->count_connectors > 0;
#if defined(GLAMOR_HAS_GBM_LINEAR)
#if defined(GLAMOR) && defined(GBM_BO_USE_LINEAR)
if (ret == FALSE) {
uint64_t value = 0;
if (drmGetCap(fd, DRM_CAP_PRIME, &value) == 0 &&
@@ -707,7 +707,7 @@ ms_tearfree_update_damages(ScreenPtr pScreen)
static void
ms_tearfree_do_flips(ScreenPtr pScreen)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
modesettingPtr ms = modesettingPTR(scrn);
@@ -824,7 +824,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty, int *timeout)
PixmapSyncDirtyHelper(dirty);
if (!screen->isGPU) {
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen));
/*
* When copying from the primary framebuffer to the shared pixmap,
@@ -1022,7 +1022,7 @@ FreeScreen(ScrnInfoPtr pScrn)
}
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
static Bool
load_glamor(ScrnInfoPtr pScrn)
@@ -1067,7 +1067,7 @@ try_enable_glamor(ScrnInfoPtr pScrn)
ms->drmmode.glamor = FALSE;
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
if (ms->drmmode.force_24_32) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Cannot use glamor with 24bpp packed fb\n");
return;
@@ -1349,7 +1349,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
if (ms->drmmode.glamor)
pScrn->capabilities |= RR_Capability_SinkOffload;
}
#ifdef GLAMOR_HAS_GBM_LINEAR
#if defined(GLAMOR) && defined(GBM_BO_USE_LINEAR)
if (value & DRM_PRIME_CAP_EXPORT && ms->drmmode.glamor)
pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SourceOffload;
#endif
@@ -1775,7 +1775,7 @@ modesetCreateScreenResources(ScreenPtr pScreen)
static Bool
msSharePixmapBacking(PixmapPtr ppix, ScreenPtr secondary, void **handle)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
modesettingPtr ms =
modesettingPTR(xf86ScreenToScrn(ppix->drawable.pScreen));
int ret;
@@ -1795,7 +1795,7 @@ msSharePixmapBacking(PixmapPtr ppix, ScreenPtr secondary, void **handle)
static Bool
msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
ScreenPtr screen = ppix->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
@@ -1947,7 +1947,6 @@ 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)
{
@@ -1961,7 +1960,6 @@ gbm_create_device_by_name(int fd, const char* name)
}
return ret;
}
#endif
static Bool
ScreenInit(ScreenPtr pScreen, int argc, char **argv)
@@ -1975,16 +1973,17 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
if (!SetMaster(pScrn))
return FALSE;
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
if (ms->drmmode.glamor) {
ms->drmmode.gbm = ms->glamor.egl_get_gbm_device(pScreen);
} else {
} else
#endif
{
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
if (!ms->drmmode.gbm) {
return FALSE;
@@ -2130,7 +2129,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
else
xf86DPMSInit(pScreen, xf86DPMSSet, 0);
#ifdef GLAMOR_HAS_GBM
#if defined(GLAMOR) && defined(XV)
if (ms->drmmode.glamor) {
XF86VideoAdaptorPtr glamor_adaptor;
@@ -2152,7 +2151,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
if (ms->drmmode.glamor) {
if (!(ms->drmmode.dri2_enable = ms_dri2_screen_init(pScreen))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -2287,7 +2286,7 @@ CloseScreen(ScreenPtr pScreen)
/* Clear mask of assigned crtc's in this generation */
ms_ent->assigned_crtcs = 0;
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
if (ms->drmmode.dri2_enable) {
ms_dri2_close_screen(pScreen);
}
@@ -2317,13 +2316,14 @@ CloseScreen(ScreenPtr pScreen)
drmmode_free_bos(pScrn, &ms->drmmode);
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
/* If we didn't get the gbm device from glamor, we have to free it ourserves */
if (!ms->drmmode.glamor) {
if (!ms->drmmode.glamor)
#endif
{
gbm_device_destroy(ms->drmmode.gbm);
ms->drmmode.gbm = NULL;
}
#endif
if (ms->drmmode.pageflip) {
miPointerScreenPtr PointPriv =

View File

@@ -39,12 +39,13 @@
#include <damage.h>
#include <X11/extensions/dpmsconst.h>
#include <shadow.h>
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
#define GLAMOR_FOR_XORG 1
#include "glamor.h"
#include <gbm.h>
#endif
#include <gbm.h>
#include "drmmode_display.h"
#define MS_LOGLEVEL_DEBUG 4
@@ -162,7 +163,7 @@ typedef struct _modesettingRec {
void (*UpdatePacked)(ScreenPtr, shadowBufPtr);
} shadow;
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
/* glamor API */
struct {
Bool (*back_pixmap_from_fd)(PixmapPtr, int, CARD16, CARD16, CARD16,
@@ -235,7 +236,7 @@ void ms_vblank_close_screen(ScreenPtr screen);
Bool ms_present_screen_init(ScreenPtr screen);
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
typedef void (*ms_pageflip_handler_proc)(modesettingPtr ms,
uint64_t frame,

View File

@@ -858,7 +858,7 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool test_only)
if (!drmmode_crtc_get_fb_id(crtc, &fb_id, &x, &y))
return 1;
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
/* Make sure any pending drawing will be visible in a new scanout buffer */
if (drmmode->glamor)
glamor_finish(crtc->scrn->pScreen);
@@ -1331,7 +1331,7 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
}
}
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
static PixmapPtr
create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int fbcon_id)
{
@@ -1376,7 +1376,7 @@ out_free_fb:
void
drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
PixmapPtr src, dst;
@@ -1426,7 +1426,6 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
void
drmmode_copy_damage(xf86CrtcPtr crtc, PixmapPtr dst, RegionPtr dmg, Bool empty)
{
#ifdef GLAMOR_HAS_GBM
ScreenPtr pScreen = xf86ScrnToScreen(crtc->scrn);
DrawableRec *src;
@@ -1443,6 +1442,7 @@ drmmode_copy_damage(xf86CrtcPtr crtc, PixmapPtr dst, RegionPtr dmg, Bool empty)
if (empty)
RegionEmpty(dmg);
#ifdef GLAMOR
/* Wait until the GC operations finish */
modesettingPTR(crtc->scrn)->glamor.finish(pScreen);
#endif
@@ -2179,7 +2179,7 @@ drmmode_clear_pixmap(PixmapPtr pixmap)
{
ScreenPtr screen = pixmap->drawable.pScreen;
GCPtr gc;
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen));
if (ms->drmmode.glamor) {
@@ -3858,7 +3858,7 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode, drmModeResPtr mode_re
static Bool
drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, struct gbm_bo *bo)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
ScrnInfoPtr scrn = drmmode->scrn;
modesettingPtr ms = modesettingPTR(scrn);
@@ -4185,7 +4185,7 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
Bool
drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
modesettingPtr ms = modesettingPTR(pScrn);

View File

@@ -78,7 +78,7 @@ ms_drain_drm_events(ScreenPtr screen)
ms_flush_drm_events_timeout(screen, -1);
}
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
/*
* Event data for an in progress flip.

View File

@@ -163,7 +163,7 @@ ms_present_abort_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
{
ScreenPtr screen = crtc->pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
xf86CrtcPtr xf86_crtc = crtc->devPrivate;
/* Check if this is a fake flip routed through TearFree and abort it */
@@ -180,7 +180,7 @@ ms_present_abort_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
static void
ms_present_flush(WindowPtr window)
{
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
ScreenPtr screen = window->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
@@ -190,7 +190,7 @@ ms_present_flush(WindowPtr window)
#endif
}
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
/**
* Callback for the DRM event queue when a flip has completed on all pipes
@@ -517,7 +517,7 @@ static present_screen_info_rec ms_present_screen_info = {
.flush = ms_present_flush,
.capabilities = PresentCapabilityNone,
#ifdef GLAMOR_HAS_GBM
#ifdef GLAMOR
.check_flip = NULL,
.check_flip2 = ms_present_check_flip,
.flip = ms_present_flip,