raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=80f92ee486dd98ec3b72a1ab3d77f7472f35323e

commit 80f92ee486dd98ec3b72a1ab3d77f7472f35323e
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Wed Jun 10 10:46:41 2020 +0000

    e backlight - handle screens with no edid
    
    this fixes backlight support on my pinephone...
    
    @fix
---
 src/bin/e_backlight.c               | 31 ++++++++++++++++++++-----------
 src/bin/system/e_system_backlight.c |  4 ++++
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/bin/e_backlight.c b/src/bin/e_backlight.c
index ee6c0db74..fd6bce157 100644
--- a/src/bin/e_backlight.c
+++ b/src/bin/e_backlight.c
@@ -45,7 +45,7 @@ _backlight_mismatch_retry(Backlight_Device *bd)
        // and the delta between expected and val >= 0.05
        (fabs(bd->expected_val - bd->val) >= 0.05) &&
        // and we retried < 20 times
-       (bd->retries < 20))
+       (bd->retries < 10))
      { // try again
         printf("RETRY backlight set as %1.2f != %1.2f (expected) try=%i\n",
                bd->val, bd->expected_val, bd->retries);
@@ -127,9 +127,10 @@ _backlight_devices_zone_device_find(E_Zone *zone)
    Eina_List *l;
    Backlight_Device *bd;
    char *tmp, *sep;
-   const char *out, *edid;
+   const char *out, *edid, *id;
 
-   if (!zone->randr2_id) return NULL;
+   id = zone->randr2_id;
+   if (!id) id = "xxx/yyy";
    tmp = strdup(zone->randr2_id);
    if (!tmp) return NULL;
    sep = strchr(tmp, '/');
@@ -222,8 +223,8 @@ _backlight_devices_randr_output_get(Ecore_X_Window root, 
const char *output, con
 static void
 _backlight_devices_device_set(Backlight_Device *bd, double val)
 {
+   if (fabs(bd->expected_val - val) > DBL_EPSILON) bd->retries = 0;
    bd->val = bd->expected_val = val;
-   bd->retries = 0;
 #ifndef HAVE_WAYLAND_ONLY
    if (!strcmp(bd->dev, "randr"))
      {
@@ -344,12 +345,14 @@ _backlight_devices_screen_edid_get(const char *edid)
 {
    Eina_List *l;
    E_Randr2_Screen *sc;
+   const char *id;
 
    if (!e_randr2) return NULL;
    EINA_LIST_FOREACH(e_randr2->screens, l, sc)
      {
-        if (!sc->info.edid) continue;
-        if (!strncmp(sc->info.edid, edid, strlen(edid))) return sc;
+        id = sc->info.edid;
+        if (!id) id = "xxx";
+        if (!strncmp(id, edid, strlen(edid))) return sc;
      }
    return NULL;
 }
@@ -372,17 +375,20 @@ static void
 _backlight_devices_lid_register(const char *dev, Eina_Bool force)
 {
    E_Randr2_Screen *sc = _backlight_devices_screen_lid_get();
-   Backlight_Device *bd;
+   Backlight_Device *bd = NULL;
+   const char *id;
+
    if (!sc) return;
-   if (!sc->info.edid) return;
-   bd = _backlight_devices_edid_find(sc->info.edid);
+   id = sc->info.edid;
+   if (!id) id = "xxx";
+   bd = _backlight_devices_edid_find(id);
    if (!bd)
      {
         E_Zone *zone;
 
         bd = calloc(1, sizeof(Backlight_Device));
         if (!bd) return;
-        bd->edid = eina_stringshare_add(sc->info.edid);
+        bd->edid = eina_stringshare_add(id);
         bd->output = eina_stringshare_add(sc->info.name);
         _devices = eina_list_append(_devices, bd);
         zone = _backlight_devices_device_zone_get(bd);
@@ -415,10 +421,13 @@ _backlight_devices_edid_register(const char *dev, const 
char *edid)
    if (!bd)
      {
         E_Zone *zone;
+        const char *id;
 
         bd = calloc(1, sizeof(Backlight_Device));
         if (!bd) return;
-        bd->edid = eina_stringshare_add(sc->info.edid);
+        id = sc->info.edid;
+        if (!id) id = "xxx";
+        bd->edid = eina_stringshare_add(id);
         bd->output = eina_stringshare_add(sc->info.name);
         _devices = eina_list_append(_devices, bd);
         zone = _backlight_devices_device_zone_get(bd);
diff --git a/src/bin/system/e_system_backlight.c 
b/src/bin/system/e_system_backlight.c
index 1c6c11765..053a5997c 100644
--- a/src/bin/system/e_system_backlight.c
+++ b/src/bin/system/e_system_backlight.c
@@ -174,6 +174,7 @@ _light_add(const char *dev)
 static Eina_Bool
 _light_device_include(const char *dev)
 { // filter out known undesirable devices
+   fprintf(stderr, "BL: found [%s]\n", dev);
    if (strstr(dev, "::capslock")) return EINA_FALSE;
    if (strstr(dev, "::numlock")) return EINA_FALSE;
    if (strstr(dev, "::scrolllock")) return EINA_FALSE;
@@ -198,12 +199,14 @@ _light_refresh_devices()
    const char *s;
 
    devs = eeze_udev_find_by_filter("backlight", NULL, NULL);
+   fprintf(stderr, "BL: backlight devices...\n");
    EINA_LIST_FREE(devs, s)
      {
         if (_light_device_include(s)) _light_add(s);
         eina_stringshare_del(s);
      }
    devs = eeze_udev_find_by_filter("leds", NULL, NULL);
+   fprintf(stderr, "BL: led devices...\n");
    EINA_LIST_FREE(devs, s)
      {
         if (_light_device_include(s)) _light_add(s);
@@ -301,6 +304,7 @@ _cb_bklight_set(void *data EINA_UNUSED, const char *params)
    if (!params) return;
    if (sscanf(params, "%1023s %i", dev, &val) != 2) return;
    eina_lock_take(&_devices_lock);
+   fprintf(stderr, "BL: set [%s] -> %i\n", dev, val);
    lig = _light_find(dev);
    if (!lig) goto done;
    lig->val_set = val;

-- 


Reply via email to