Allow RandR get output property to call into drivers

In order to report accurate values to users of the RandR property interface,
it's sometimes necessary to ask the driver to update the value (for example
when backlight brightness changes without the server's knowledge, due to hotkey
events or direct sysfs banging).

This patch wires up the core server code with a new xf86CrtcFuncs callback,
get_property, to allow for this.

The new code is available under the RANDR_13_INTERFACE define, which in turn
depends on the RANDR_12_INTERFACE code.
This commit is contained in:
Jesse Barnes 2008-03-06 13:47:44 -08:00
parent 34b69e3bc0
commit ca616b902b
5 changed files with 74 additions and 6 deletions

View File

@ -215,7 +215,14 @@ typedef struct _xf86CrtcFuncs {
Rotation rotation, int x, int y);
} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
#define XF86_CRTC_VERSION 1
struct _xf86Crtc {
/**
* ABI versioning
*/
int version;
/**
* Associated ScrnInfo
*/
@ -409,6 +416,14 @@ typedef struct _xf86OutputFuncs {
(*set_property)(xf86OutputPtr output,
Atom property,
RRPropertyValuePtr value);
#endif
#ifdef RANDR_13_INTERFACE
/**
* Callback to get an updated property value
*/
Bool
(*get_property)(xf86OutputPtr output,
Atom property);
#endif
/**
* Clean up driver-specific bits of the output
@ -417,7 +432,15 @@ typedef struct _xf86OutputFuncs {
(*destroy) (xf86OutputPtr output);
} xf86OutputFuncsRec, *xf86OutputFuncsPtr;
#define XF86_OUTPUT_VERSION 1
struct _xf86Output {
/**
* ABI versioning
*/
int version;
/**
* Associated ScrnInfo
*/

View File

@ -847,6 +847,20 @@ xf86RandR12OutputSetProperty (ScreenPtr pScreen,
return output->funcs->set_property(output, property, value);
}
static Bool
xf86RandR13OutputGetProperty (ScreenPtr pScreen,
RROutputPtr randr_output,
Atom property)
{
xf86OutputPtr output = randr_output->devPrivate;
if (output->funcs->get_property == NULL)
return TRUE;
/* Should be safe even w/o vtSema */
return output->funcs->get_property(output, property);
}
static Bool
xf86RandR12OutputValidateMode (ScreenPtr pScreen,
RROutputPtr randr_output,
@ -1126,6 +1140,9 @@ xf86RandR12Init12 (ScreenPtr pScreen)
rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma;
rp->rrOutputSetProperty = xf86RandR12OutputSetProperty;
rp->rrOutputValidateMode = xf86RandR12OutputValidateMode;
#if RANDR_13_INTERFACE
rp->rrOutputGetProperty = xf86RandR13OutputGetProperty;
#endif
rp->rrModeDestroy = xf86RandR12ModeDestroy;
rp->rrSetConfig = NULL;
pScrn->PointerMoved = xf86RandR12PointerMoved;

View File

@ -73,6 +73,14 @@ miRROutputSetProperty (ScreenPtr pScreen,
return TRUE;
}
Bool
miRROutputGetProperty (ScreenPtr pScreen,
RROutputPtr output,
Atom property)
{
return TRUE;
}
Bool
miRROutputValidateMode (ScreenPtr pScreen,
RROutputPtr output,
@ -116,6 +124,9 @@ miRandRInit (ScreenPtr pScreen)
pScrPriv->rrCrtcSet = miRRCrtcSet;
pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma;
pScrPriv->rrOutputSetProperty = miRROutputSetProperty;
#if RANDR_13_INTERFACE
pScrPriv->rrOutputGetProperty = miRROutputGetProperty;
#endif
pScrPriv->rrOutputValidateMode = miRROutputValidateMode;
pScrPriv->rrModeDestroy = miRRModeDestroy;

View File

@ -54,6 +54,7 @@
/* required for ABI compatibility for now */
#define RANDR_10_INTERFACE 1
#define RANDR_12_INTERFACE 1
#define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */
typedef XID RRMode;
typedef XID RROutput;
@ -175,6 +176,12 @@ typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen,
#endif
#if RANDR_13_INTERFACE
typedef Bool (*RROutputGetPropertyProcPtr) (ScreenPtr pScreen,
RROutputPtr output,
Atom property);
#endif /* RANDR_13_INTERFACE */
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
@ -220,6 +227,9 @@ typedef struct _rrScrPriv {
RROutputValidateModeProcPtr rrOutputValidateMode;
RRModeDestroyProcPtr rrModeDestroy;
#endif
#if RANDR_13_INTERFACE
RROutputGetPropertyProcPtr rrOutputGetProperty;
#endif
/*
* Private part of the structure; not considered part of the ABI

View File

@ -300,13 +300,21 @@ RRPropertyValuePtr
RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending)
{
RRPropertyPtr prop = RRQueryOutputProperty (output, property);
rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen);
if (!prop)
return NULL;
if (pending && prop->is_pending)
return &prop->pending;
else
else {
#if RANDR_13_INTERFACE
/* If we can, try to update the property value first */
if (pScrPriv->rrOutputGetProperty)
pScrPriv->rrOutputGetProperty(output->pScreen, output,
prop->propertyName);
#endif
return &prop->current;
}
}
int
@ -610,10 +618,9 @@ ProcRRGetOutputProperty (ClientPtr client)
if (prop->immutable && stuff->delete)
return BadAccess;
if (stuff->pending && prop->is_pending)
prop_value = &prop->pending;
else
prop_value = &prop->current;
prop_value = RRGetOutputProperty(output, stuff->property, stuff->pending);
if (!prop_value)
return BadAtom;
/* If the request type and actual type don't match. Return the
property information, but not the data. */