Add code to update the value of the RandR "Backlight" property based on the

KMS connector property of the same name if such a property is present.

ok matthieu@
This commit is contained in:
kettenis 2017-07-12 20:08:07 +00:00
parent ea88c2222f
commit 11bfbfff1e

View File

@ -1133,6 +1133,8 @@ drmmode_property_ignore(drmModePropertyPtr prop)
return FALSE;
}
static Atom backlight_atom;
static void
drmmode_output_create_resources(xf86OutputPtr output)
{
@ -1229,6 +1231,9 @@ drmmode_output_create_resources(xf86OutputPtr output)
}
}
}
backlight_atom = MakeAtom(RR_PROPERTY_BACKLIGHT,
strlen(RR_PROPERTY_BACKLIGHT), FALSE);
}
static Bool
@ -1287,7 +1292,48 @@ drmmode_output_set_property(xf86OutputPtr output, Atom property,
static Bool
drmmode_output_get_property(xf86OutputPtr output, Atom property)
{
return TRUE;
drmmode_output_private_ptr drmmode_output = output->driver_private;
drmmode_ptr drmmode = drmmode_output->drmmode;
drmModeObjectPropertiesPtr props;
int i;
if (property != backlight_atom)
return TRUE;
props = drmModeObjectGetProperties(drmmode->fd, drmmode_output->output_id,
DRM_MODE_OBJECT_CONNECTOR);
if (!props)
return FALSE;
for (i = 0; i < drmmode_output->num_props; i++) {
drmmode_prop_ptr p = &drmmode_output->props[i];
int j;
if (p->atoms[0] != property)
continue;
for (j = 0; j < props->count_props; j++) {
if (props->props[j] == p->mode_prop->prop_id) {
INT32 value;
int err;
value = p->value = props->prop_values[j];
err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
XA_INTEGER, 32, PropModeReplace, 1,
&value, FALSE, TRUE);
if (err != 0) {
xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
"RRChangeOutputProperty error, %d\n", err);
}
drmModeFreeObjectProperties(props);
return TRUE;
}
}
}
drmModeFreeObjectProperties(props);
return FALSE;
}
static const xf86OutputFuncsRec drmmode_output_funcs = {