ecore-drm2: Add internal functions to get backlight values
authorChris Michael <cp.michael@samsung.com>
Tue, 6 Jun 2017 14:37:01 +0000 (10:37 -0400)
committerChris Michael <cp.michael@samsung.com>
Tue, 6 Jun 2017 14:37:01 +0000 (10:37 -0400)
Small patch to add an internal function which can be used to retrieve
backlight values on output creation.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_drm2/ecore_drm2_outputs.c

index 263fccd..4af7380 100644 (file)
@@ -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)