aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2014-09-24 09:58:57 -0400
committerChris Michael <cp.michael@samsung.com>2014-09-24 10:02:37 -0400
commitaf6cb4e84a92de053aa347c7d06e2c53c0f2fce4 (patch)
tree19a225285724581ceb7bf089cf6f6152b7ff9bf0
parentecore-drm: Remove need to use an extra variable for storing device. (diff)
downloadefl-af6cb4e84a92de053aa347c7d06e2c53c0f2fce4.tar.gz
ecore-drm: Added private functions to get brightness levels in backlight
Summary: Added private internal functions to get various brightness levels 1) Added _ecore_drm_actual_brightness_get to get Actual brightness 2) Added _ecore_drm_max_brightness_get to get Max brightness 3) Added _ecore_drm_brightness_get to get Brightness These functions will eventually be exposed with an API for ecore-drm to get/set the backlight level for an output. @feature Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1482
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c69
-rw-r--r--src/lib/ecore_drm/ecore_drm_private.h8
2 files changed, 60 insertions, 17 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index 8f85f8bf7e..6fce00467f 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -290,14 +290,62 @@ _ecore_drm_output_mode_add(Ecore_Drm_Output *output, drmModeModeInfo *info)
return mode;
}
+static double
+_ecore_drm_output_brightness_get(Ecore_Drm_Backlight *backlight)
+{
+ const char *brightness = NULL;
+ double ret;
+
+ brightness = eeze_udev_syspath_get_sysattr(backlight->device, "brightness");
+ if (!brightness) return 0;
+
+ ret = strtod(brightness, NULL);
+ if (ret < 0)
+ ret = 0;
+
+ return ret;
+}
+
+static double
+_ecore_drm_output_actual_brightness_get(Ecore_Drm_Backlight *backlight)
+{
+ const char *brightness = NULL;
+ double ret;
+
+ brightness = eeze_udev_syspath_get_sysattr(backlight->device, "actual_brightness");
+ if (!brightness) return 0;
+
+ ret = strtod(brightness, NULL);
+ if (ret < 0)
+ ret = 0;
+
+ return ret;
+}
+
+static double
+_ecore_drm_output_max_brightness_get(Ecore_Drm_Backlight *backlight)
+{
+ const char *brightness = NULL;
+ double ret;
+
+ brightness = eeze_udev_syspath_get_sysattr(backlight->device, "max_brightness");
+ if (!brightness) return 0;
+
+ ret = strtod(brightness, NULL);
+ if (ret < 0)
+ ret = 0;
+
+ return ret;
+}
+
static Ecore_Drm_Backlight *
-_ecore_drm_backlight_init(Ecore_Drm_Device *dev EINA_UNUSED, uint32_t conn_type)
+_ecore_drm_output_backlight_init(Ecore_Drm_Output *output EINA_UNUSED, uint32_t conn_type)
{
Ecore_Drm_Backlight *backlight = NULL;
Ecore_Drm_Backlight_Type type = 0;
Eina_List *devs, *l;
Eina_Bool found = EINA_FALSE;
- const char *device, *devtype, *tmpdevice;
+ const char *device, *devtype;
if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BACKLIGHT, NULL)))
devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_LEDS, NULL);
@@ -327,27 +375,20 @@ cont:
eina_stringshare_del(devtype);
if (found)
{
- tmpdevice = eina_stringshare_add(device);
break;
}
}
- EINA_LIST_FREE(devs, device)
- eina_stringshare_del(device);
-
- if (!found) return NULL;
+ if (!found) goto out;
if ((backlight = calloc(1, sizeof(Ecore_Drm_Backlight))))
{
backlight->type = type;
- /* NB: This sets backlight directory path to /dev/...
- * Am not sure yet if this is the desired path, or if we want the
- * actual /sys path. If we want Just the syspath then 'tmpdevice' is
- * already equal to that */
- backlight->dir_path = eeze_udev_syspath_get_devpath(tmpdevice);
+ backlight->device = eina_stringshare_add(device);
}
-
- eina_stringshare_del(tmpdevice);
+out:
+ EINA_LIST_FREE(devs, device);
+ eina_stringshare_del(device);
return backlight;
}
diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h
index 2f0904dd66..da84614024 100644
--- a/src/lib/ecore_drm/ecore_drm_private.h
+++ b/src/lib/ecore_drm/ecore_drm_private.h
@@ -103,9 +103,11 @@ typedef enum _Ecore_Drm_Backlight_Type
typedef struct _Ecore_Drm_Backlight
{
- const char *dir_path;
- int brightness_max;
- int brightness;
+ const char *device;
+ double brightness_max;
+ double brightness_actual;
+ double brightness;
+
Ecore_Drm_Backlight_Type type;
} Ecore_Drm_Backlight;