From 2f10ce10559692b862316b8bda4ecbadb3086b47 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 6 Jun 2017 10:37:01 -0400 Subject: [PATCH] ecore-drm2: Add internal functions to get backlight values Small patch to add an internal function which can be used to retrieve backlight values on output creation. Signed-off-by: Chris Michael --- src/lib/ecore_drm2/ecore_drm2_outputs.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c index 263fccd..4af7380 100644 --- a/src/lib/ecore_drm2/ecore_drm2_outputs.c +++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c @@ -466,6 +466,23 @@ err: } #endif +static double +_output_backlight_value_get(Ecore_Drm2_Output *output, const char *attr) +{ + const char *b = NULL; + double ret = 0.0; + + if ((!output) || (!output->backlight.path)) return 0.0; + + b = eeze_udev_syspath_get_sysattr(output->backlight.path, attr); + if (!b) return 0.0; + + ret = strtod(b, NULL); + if (ret < 0) ret = 0.0; + + return ret; +} + static void _output_backlight_init(Ecore_Drm2_Output *output, unsigned int conn_type) { @@ -501,6 +518,10 @@ _output_backlight_init(Ecore_Drm2_Output *output, unsigned int conn_type) { output->backlight.type = type; output->backlight.path = eina_stringshare_add(dev); + output->backlight.max = + _output_backlight_value_get(output, "max_brightness"); + output->backlight.value = + _output_backlight_value_get(output, "brightness"); } EINA_LIST_FREE(devs, dev) -- 2.7.4