summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-06-10 10:46:41 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-06-10 11:05:13 +0000
commit80f92ee486dd98ec3b72a1ab3d77f7472f35323e (patch)
treeec08e0712c4f8eb3dd5d6a172295897676189afe /src
parenta91ba4e1a8f1d82015488c7775ddd812c0e6ce3d (diff)
e backlight - handle screens with no edid
this fixes backlight support on my pinephone... @fix
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_backlight.c31
-rw-r--r--src/bin/system/e_system_backlight.c4
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)
45 // and the delta between expected and val >= 0.05 45 // and the delta between expected and val >= 0.05
46 (fabs(bd->expected_val - bd->val) >= 0.05) && 46 (fabs(bd->expected_val - bd->val) >= 0.05) &&
47 // and we retried < 20 times 47 // and we retried < 20 times
48 (bd->retries < 20)) 48 (bd->retries < 10))
49 { // try again 49 { // try again
50 printf("RETRY backlight set as %1.2f != %1.2f (expected) try=%i\n", 50 printf("RETRY backlight set as %1.2f != %1.2f (expected) try=%i\n",
51 bd->val, bd->expected_val, bd->retries); 51 bd->val, bd->expected_val, bd->retries);
@@ -127,9 +127,10 @@ _backlight_devices_zone_device_find(E_Zone *zone)
127 Eina_List *l; 127 Eina_List *l;
128 Backlight_Device *bd; 128 Backlight_Device *bd;
129 char *tmp, *sep; 129 char *tmp, *sep;
130 const char *out, *edid; 130 const char *out, *edid, *id;
131 131
132 if (!zone->randr2_id) return NULL; 132 id = zone->randr2_id;
133 if (!id) id = "xxx/yyy";
133 tmp = strdup(zone->randr2_id); 134 tmp = strdup(zone->randr2_id);
134 if (!tmp) return NULL; 135 if (!tmp) return NULL;
135 sep = strchr(tmp, '/'); 136 sep = strchr(tmp, '/');
@@ -222,8 +223,8 @@ _backlight_devices_randr_output_get(Ecore_X_Window root, const char *output, con
222static void 223static void
223_backlight_devices_device_set(Backlight_Device *bd, double val) 224_backlight_devices_device_set(Backlight_Device *bd, double val)
224{ 225{
226 if (fabs(bd->expected_val - val) > DBL_EPSILON) bd->retries = 0;
225 bd->val = bd->expected_val = val; 227 bd->val = bd->expected_val = val;
226 bd->retries = 0;
227#ifndef HAVE_WAYLAND_ONLY 228#ifndef HAVE_WAYLAND_ONLY
228 if (!strcmp(bd->dev, "randr")) 229 if (!strcmp(bd->dev, "randr"))
229 { 230 {
@@ -344,12 +345,14 @@ _backlight_devices_screen_edid_get(const char *edid)
344{ 345{
345 Eina_List *l; 346 Eina_List *l;
346 E_Randr2_Screen *sc; 347 E_Randr2_Screen *sc;
348 const char *id;
347 349
348 if (!e_randr2) return NULL; 350 if (!e_randr2) return NULL;
349 EINA_LIST_FOREACH(e_randr2->screens, l, sc) 351 EINA_LIST_FOREACH(e_randr2->screens, l, sc)
350 { 352 {
351 if (!sc->info.edid) continue; 353 id = sc->info.edid;
352 if (!strncmp(sc->info.edid, edid, strlen(edid))) return sc; 354 if (!id) id = "xxx";
355 if (!strncmp(id, edid, strlen(edid))) return sc;
353 } 356 }
354 return NULL; 357 return NULL;
355} 358}
@@ -372,17 +375,20 @@ static void
372_backlight_devices_lid_register(const char *dev, Eina_Bool force) 375_backlight_devices_lid_register(const char *dev, Eina_Bool force)
373{ 376{
374 E_Randr2_Screen *sc = _backlight_devices_screen_lid_get(); 377 E_Randr2_Screen *sc = _backlight_devices_screen_lid_get();
375 Backlight_Device *bd; 378 Backlight_Device *bd = NULL;
379 const char *id;
380
376 if (!sc) return; 381 if (!sc) return;
377 if (!sc->info.edid) return; 382 id = sc->info.edid;
378 bd = _backlight_devices_edid_find(sc->info.edid); 383 if (!id) id = "xxx";
384 bd = _backlight_devices_edid_find(id);
379 if (!bd) 385 if (!bd)
380 { 386 {
381 E_Zone *zone; 387 E_Zone *zone;
382 388
383 bd = calloc(1, sizeof(Backlight_Device)); 389 bd = calloc(1, sizeof(Backlight_Device));
384 if (!bd) return; 390 if (!bd) return;
385 bd->edid = eina_stringshare_add(sc->info.edid); 391 bd->edid = eina_stringshare_add(id);
386 bd->output = eina_stringshare_add(sc->info.name); 392 bd->output = eina_stringshare_add(sc->info.name);
387 _devices = eina_list_append(_devices, bd); 393 _devices = eina_list_append(_devices, bd);
388 zone = _backlight_devices_device_zone_get(bd); 394 zone = _backlight_devices_device_zone_get(bd);
@@ -415,10 +421,13 @@ _backlight_devices_edid_register(const char *dev, const char *edid)
415 if (!bd) 421 if (!bd)
416 { 422 {
417 E_Zone *zone; 423 E_Zone *zone;
424 const char *id;
418 425
419 bd = calloc(1, sizeof(Backlight_Device)); 426 bd = calloc(1, sizeof(Backlight_Device));
420 if (!bd) return; 427 if (!bd) return;
421 bd->edid = eina_stringshare_add(sc->info.edid); 428 id = sc->info.edid;
429 if (!id) id = "xxx";
430 bd->edid = eina_stringshare_add(id);
422 bd->output = eina_stringshare_add(sc->info.name); 431 bd->output = eina_stringshare_add(sc->info.name);
423 _devices = eina_list_append(_devices, bd); 432 _devices = eina_list_append(_devices, bd);
424 zone = _backlight_devices_device_zone_get(bd); 433 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)
174static Eina_Bool 174static Eina_Bool
175_light_device_include(const char *dev) 175_light_device_include(const char *dev)
176{ // filter out known undesirable devices 176{ // filter out known undesirable devices
177 fprintf(stderr, "BL: found [%s]\n", dev);
177 if (strstr(dev, "::capslock")) return EINA_FALSE; 178 if (strstr(dev, "::capslock")) return EINA_FALSE;
178 if (strstr(dev, "::numlock")) return EINA_FALSE; 179 if (strstr(dev, "::numlock")) return EINA_FALSE;
179 if (strstr(dev, "::scrolllock")) return EINA_FALSE; 180 if (strstr(dev, "::scrolllock")) return EINA_FALSE;
@@ -198,12 +199,14 @@ _light_refresh_devices()
198 const char *s; 199 const char *s;
199 200
200 devs = eeze_udev_find_by_filter("backlight", NULL, NULL); 201 devs = eeze_udev_find_by_filter("backlight", NULL, NULL);
202 fprintf(stderr, "BL: backlight devices...\n");
201 EINA_LIST_FREE(devs, s) 203 EINA_LIST_FREE(devs, s)
202 { 204 {
203 if (_light_device_include(s)) _light_add(s); 205 if (_light_device_include(s)) _light_add(s);
204 eina_stringshare_del(s); 206 eina_stringshare_del(s);
205 } 207 }
206 devs = eeze_udev_find_by_filter("leds", NULL, NULL); 208 devs = eeze_udev_find_by_filter("leds", NULL, NULL);
209 fprintf(stderr, "BL: led devices...\n");
207 EINA_LIST_FREE(devs, s) 210 EINA_LIST_FREE(devs, s)
208 { 211 {
209 if (_light_device_include(s)) _light_add(s); 212 if (_light_device_include(s)) _light_add(s);
@@ -301,6 +304,7 @@ _cb_bklight_set(void *data EINA_UNUSED, const char *params)
301 if (!params) return; 304 if (!params) return;
302 if (sscanf(params, "%1023s %i", dev, &val) != 2) return; 305 if (sscanf(params, "%1023s %i", dev, &val) != 2) return;
303 eina_lock_take(&_devices_lock); 306 eina_lock_take(&_devices_lock);
307 fprintf(stderr, "BL: set [%s] -> %i\n", dev, val);
304 lig = _light_find(dev); 308 lig = _light_find(dev);
305 if (!lig) goto done; 309 if (!lig) goto done;
306 lig->val_set = val; 310 lig->val_set = val;