(submit/vrr-driver-api) dix: add generic Xinerama capable VRR infrastructure

We don't have a standard protocol for enabling VRR yet, but some time ago an
ad-hoc had been made in the amdgpu driver (later also copied to modsetting),
which works by client setting the _VARIABLE_REFRESH window property.

The way it's currently done - driver is highjacking the X_ChangeProperty and
X_DeleteProperty request handlers - is pretty fragile, and is also a violation
of layers: drivers never should be twisted with core protocol details. (And in
the future, this should be done by some suitable extension).

Another problem is Xinerama: when it's enabled, this only works on the first
screen - the others won't ever see this signal, no matter on which one(s) the
Window is physically placed (for the wire protocol, all windows are on screen 0,
unless the client explicitly creates them on another one)

This commit adds a generic Screen proc for telling the DDX, whether the VRR mode
shall be changed (for now, it's only DISABLED and ENABLED). Drivers can hook into
here in order to receive this signal, w/o having to highjack any core request
handlers. Catching the property change is now entirely done in the DIX.

The (non-standard) status qou of (ab)using window properties is kept, but it's
now also easy to add a new signaling mechanism, in case a standard is agreed on.

Yet a quite naive implementation (eg. not acting on moving windows between screens),
but enough to fix the most pressing problems supporting extra screens in general,
as well as stopping the highjacking of core request handlers by drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-22 15:59:41 +02:00
parent 2e847c7b23
commit a5c42ba050
3 changed files with 62 additions and 1 deletions

View File

@ -61,6 +61,11 @@ SOFTWARE.
#include "swaprep.h" #include "swaprep.h"
#include "xace.h" #include "xace.h"
#ifdef PANORAMIX
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#endif
/***************************************************************** /*****************************************************************
* Property Stuff * Property Stuff
* *
@ -109,6 +114,46 @@ dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom propertyName,
return rc; return rc;
} }
static void
setVRRMode(WindowPtr pWin, WindowVRRMode mode)
{
SetWindowVRRModeProcPtr proc = pWin->drawable.pScreen->SetWindowVRRMode;
if (proc != NULL)
proc(pWin, mode);
}
static void
notifyVRRMode(ClientPtr pClient, WindowPtr pWindow, int state, PropertyPtr pProp)
{
const char *pName = NameForAtom(pProp->propertyName);
if (pName == NULL || strcmp(pName, "_VARIABLE_REFRESH") || pProp->format != 32 || pProp->size != 1)
return;
WindowVRRMode mode = (WindowVRRMode)(state == PropertyNewValue ? (*((uint32_t*)pProp->data)) : 0);
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
PanoramiXRes *win;
int rc, j;
rc = dixLookupResourceByType((void **) &win, pWindow->drawable.id, XRT_WINDOW,
pClient, DixWriteAccess);
if (rc != Success)
goto no_panoramix;
FOR_NSCREENS_BACKWARD(j) {
WindowPtr pWin;
rc = dixLookupWindow(&pWin, win->info[j].id, pClient, DixSetPropAccess);
if (rc == Success)
setVRRMode(pWin, mode);
}
}
return;
no_panoramix:
#endif
setVRRMode(pWindow, mode);
}
CallbackListPtr PropertyStateCallback; CallbackListPtr PropertyStateCallback;
static void static void
@ -189,6 +234,7 @@ ProcRotateProperties(ClientPtr client)
for (i = 0; i < stuff->nAtoms; i++) { for (i = 0; i < stuff->nAtoms; i++) {
j = (i + delta) % stuff->nAtoms; j = (i + delta) % stuff->nAtoms;
deliverPropertyNotifyEvent(pWin, PropertyNewValue, props[i]); deliverPropertyNotifyEvent(pWin, PropertyNewValue, props[i]);
notifyVRRMode(client, pWin, PropertyNewValue, props[i]);
/* Preserve name and devPrivates */ /* Preserve name and devPrivates */
props[j]->type = saved[i].type; props[j]->type = saved[i].type;
@ -368,8 +414,10 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
else else
return rc; return rc;
if (sendevent) if (sendevent) {
deliverPropertyNotifyEvent(pWin, PropertyNewValue, pProp); deliverPropertyNotifyEvent(pWin, PropertyNewValue, pProp);
notifyVRRMode(pClient, pWin, PropertyNewValue, pProp);
}
return Success; return Success;
} }
@ -399,6 +447,7 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
} }
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp); deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
notifyVRRMode(client, pWin, PropertyDelete, pProp);
free(pProp->data); free(pProp->data);
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
} }
@ -535,7 +584,10 @@ ProcGetProperty(ClientPtr client)
}; };
if (stuff->delete && (reply.bytesAfter == 0)) if (stuff->delete && (reply.bytesAfter == 0))
{
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp); deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
notifyVRRMode(client, pWin, PropertyDelete, pProp);
}
WriteReplyToClient(client, sizeof(xGenericReply), &reply); WriteReplyToClient(client, sizeof(xGenericReply), &reply);
if (len) { if (len) {

View File

@ -324,6 +324,7 @@ conf_data.set('SYSCONS_SUPPORT', supports_syscons ? '1' : false)
conf_data.set('WSCONS_SUPPORT', supports_wscons ? '1' : false) conf_data.set('WSCONS_SUPPORT', supports_wscons ? '1' : false)
conf_data.set('XSERVER_LIBPCIACCESS', get_option('pciaccess') ? '1' : false) conf_data.set('XSERVER_LIBPCIACCESS', get_option('pciaccess') ? '1' : false)
conf_data.set('XSERVER_PLATFORM_BUS', build_udev_kms ? '1' : false) conf_data.set('XSERVER_PLATFORM_BUS', build_udev_kms ? '1' : false)
conf_data.set('XSERVER_SCREEN_VRR', '1')
configure_file(output : 'dix-config.h', configure_file(output : 'dix-config.h',
configuration : conf_data) configuration : conf_data)

View File

@ -90,6 +90,11 @@ typedef struct _ScreenSaverStuff {
Bool /*force */ ); Bool /*force */ );
} ScreenSaverStuffRec; } ScreenSaverStuffRec;
typedef enum {
WINDOW_VRR_DISABLED = 0,
WINDOW_VRR_ENABLED,
} WindowVRRMode;
/* /*
* There is a typedef for each screen function pointer so that code that * There is a typedef for each screen function pointer so that code that
* needs to declare a screen function pointer (e.g. in a screen private * needs to declare a screen function pointer (e.g. in a screen private
@ -177,6 +182,8 @@ typedef void (*ClipNotifyProcPtr) (WindowPtr /*pWindow */ ,
int /*dx */ , int /*dx */ ,
int /*dy */ ); int /*dy */ );
typedef void (*SetWindowVRRModeProcPtr) (WindowPtr pWindow, WindowVRRMode mode);
/* pixmap will exist only for the duration of the current rendering operation */ /* pixmap will exist only for the duration of the current rendering operation */
#define CREATE_PIXMAP_USAGE_SCRATCH 1 #define CREATE_PIXMAP_USAGE_SCRATCH 1
/* pixmap will be the backing pixmap for a redirected window */ /* pixmap will be the backing pixmap for a redirected window */
@ -545,6 +552,7 @@ typedef struct _Screen {
ClipNotifyProcPtr ClipNotify; ClipNotifyProcPtr ClipNotify;
RestackWindowProcPtr RestackWindow; RestackWindowProcPtr RestackWindow;
PaintWindowProcPtr PaintWindow; PaintWindowProcPtr PaintWindow;
SetWindowVRRModeProcPtr SetWindowVRRMode;
/* Pixmap procedures */ /* Pixmap procedures */