X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbin%2Fe_backlight_main.c;h=ef764d2130962bfde6a94535a8e4ec42e429b8f0;hb=ac8fa492451a1268eec649ea98e67184842f11a0;hp=10e6bb857f5dfd7cf89187e1e49d962f80a914ed;hpb=71de741809b2c23779657ecda17a4ef900af62e1;p=framework%2Fuifw%2Fe17.git diff --git a/src/bin/e_backlight_main.c b/src/bin/e_backlight_main.c index 10e6bb8..ef764d2 100644 --- a/src/bin/e_backlight_main.c +++ b/src/bin/e_backlight_main.c @@ -22,35 +22,18 @@ _bl_write_file(const char *file, int val) perror("open"); return -1; } - snprintf(buf, sizeof(buf), "%i", val); + snprintf(buf, sizeof(buf), "%d", val); if (write(fd, buf, strlen(buf)) != (int)strlen(buf)) { perror("write"); close(fd); return -1; } + printf("BACKLIGHT: %s -> %i\n", file, val); close(fd); return 0; } -/* local subsystem globals */ -typedef struct _Bl_Entry -{ - char type; - const char *base; - const char *max; - const char *set; -} Bl_Entry; - -static const Bl_Entry search[] = -{ - { 'F', "/sys/devices/virtual/backlight/acpi_video0", "max_brightness", "brightness" }, - { 'D', "/sys/devices/virtual/backlight", "max_brightness", "brightness" }, - { 'F', "/sys/class/leds/lcd-backlight", "max_brightness", "brightness" }, - { 'F', "/sys/class/backlight/acpi_video0", "max_brightness", "brightness" }, - { 'D', "/sys/class/backlight", "max_brightness", "brightness" } -}; - /* externally accessible functions */ int main(int argc, char **argv) @@ -91,7 +74,31 @@ main(int argc, char **argv) eeze_init(); devs = eeze_udev_find_by_filter("backlight", NULL, NULL); - if (!devs) return -1; + if (!devs) + { + devs = eeze_udev_find_by_filter("leds", NULL, NULL); + if (!devs) return -1; + } + if (eina_list_count(devs) > 1) + { + const char *s = NULL; + Eina_List *l, *new = NULL; + Eina_Bool use = EINA_FALSE; + + /* prefer backlights of type "firmware" where available */ + EINA_LIST_FOREACH(devs, l, f) + { + s = eeze_udev_syspath_get_sysattr(f, "type"); + use = (s && (!strcmp(s, "firmware"))); + eina_stringshare_del(s); + if (!use) continue; + eina_list_move_list(&new, &devs, l); + EINA_LIST_FREE(devs, f) + eina_stringshare_del(f); + devs = new; + break; + } + } EINA_LIST_FREE(devs, f) { const char *str; @@ -118,6 +125,9 @@ main(int argc, char **argv) return _bl_write_file(buf, curlevel); } eina_stringshare_del(f); + /* Currently this will set brightness levels on ALL detected devices + If this is not desired, add a break here + */ } return -1;