backlight - support backlight on non-lid panels and bl_power too

i didn't know bl_ppower existed... i found a device that exposes this
sysfs node and it seems it's a good idea to swizzle it too in addition
to brightness. so fix that and also fix e's backlight handling to find
backlight devices for non-lid panels marked to have a backlight ... i
have such a device here. this makes backlight controls work in this
case.
This commit is contained in:
Carsten Haitzler 2020-09-05 11:34:14 +01:00
parent 12311e63de
commit 63bc2a8093
2 changed files with 41 additions and 2 deletions

View File

@ -350,6 +350,10 @@ _backlight_devices_screen_lid_get(void)
{
if (sc->info.is_lid) return sc;
}
EINA_LIST_FOREACH(e_randr2->screens, l, sc)
{
if (sc->info.backlight) return sc;
}
return NULL;
}

View File

@ -21,8 +21,20 @@ _light_set(Light *lig, int val)
lig->val = nval;
#ifdef HAVE_EEZE
char buf[PATH_MAX];
int fd;
if (val == 0)
{
snprintf(buf, sizeof(buf), "%s/bl_power", lig->dev);
fd = open(buf, O_WRONLY);
if (fd >= 0)
{
if (write(fd, "4", 1) <= 0)
ERR("Write failed of [%s] to [%s]\n", "4", buf);
close(fd);
}
}
snprintf(buf, sizeof(buf), "%s/brightness", lig->dev);
int fd = open(buf, O_WRONLY);
fd = open(buf, O_WRONLY);
if (fd >= 0)
{
char buf2[32];
@ -31,6 +43,17 @@ _light_set(Light *lig, int val)
ERR("Write failed of [%s] to [%s]\n", buf2, buf);
close(fd);
}
if (val != 0)
{
snprintf(buf, sizeof(buf), "%s/bl_power", lig->dev);
fd = open(buf, O_WRONLY);
if (fd >= 0)
{
if (write(fd, "0", 1) <= 0)
ERR("Write failed of [%s] to [%s]\n", "0", buf);
close(fd);
}
}
#elif defined(__FreeBSD_kernel__)
sysctlbyname(lig->dev, NULL, NULL, &(lig->val), sizeof(lig->val));
#endif
@ -41,7 +64,19 @@ _light_get(Light *lig)
{
#ifdef HAVE_EEZE
const char *s;
s = eeze_udev_syspath_get_sysattr(lig->dev, "brightness");
s = eeze_udev_syspath_get_sysattr(lig->dev, "bl_power");
if (s)
{
if (atoi(s) != 0)
{
lig->val = 0;
eina_stringshare_del(s);
return;
}
eina_stringshare_del(s);
}
s = eeze_udev_syspath_get_sysattr(lig->dev, "actual_brightness");
if (!s) s = eeze_udev_syspath_get_sysattr(lig->dev, "brightness");
if (s)
{
lig->val = atoi(s);