summaryrefslogtreecommitdiff
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
parente3c3ba481127bcf03582794639f5b44dedece289 (diff)
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)
290 return mode; 290 return mode;
291} 291}
292 292
293static double
294_ecore_drm_output_brightness_get(Ecore_Drm_Backlight *backlight)
295{
296 const char *brightness = NULL;
297 double ret;
298
299 brightness = eeze_udev_syspath_get_sysattr(backlight->device, "brightness");
300 if (!brightness) return 0;
301
302 ret = strtod(brightness, NULL);
303 if (ret < 0)
304 ret = 0;
305
306 return ret;
307}
308
309static double
310_ecore_drm_output_actual_brightness_get(Ecore_Drm_Backlight *backlight)
311{
312 const char *brightness = NULL;
313 double ret;
314
315 brightness = eeze_udev_syspath_get_sysattr(backlight->device, "actual_brightness");
316 if (!brightness) return 0;
317
318 ret = strtod(brightness, NULL);
319 if (ret < 0)
320 ret = 0;
321
322 return ret;
323}
324
325static double
326_ecore_drm_output_max_brightness_get(Ecore_Drm_Backlight *backlight)
327{
328 const char *brightness = NULL;
329 double ret;
330
331 brightness = eeze_udev_syspath_get_sysattr(backlight->device, "max_brightness");
332 if (!brightness) return 0;
333
334 ret = strtod(brightness, NULL);
335 if (ret < 0)
336 ret = 0;
337
338 return ret;
339}
340
293static Ecore_Drm_Backlight * 341static Ecore_Drm_Backlight *
294_ecore_drm_backlight_init(Ecore_Drm_Device *dev EINA_UNUSED, uint32_t conn_type) 342_ecore_drm_output_backlight_init(Ecore_Drm_Output *output EINA_UNUSED, uint32_t conn_type)
295{ 343{
296 Ecore_Drm_Backlight *backlight = NULL; 344 Ecore_Drm_Backlight *backlight = NULL;
297 Ecore_Drm_Backlight_Type type = 0; 345 Ecore_Drm_Backlight_Type type = 0;
298 Eina_List *devs, *l; 346 Eina_List *devs, *l;
299 Eina_Bool found = EINA_FALSE; 347 Eina_Bool found = EINA_FALSE;
300 const char *device, *devtype, *tmpdevice; 348 const char *device, *devtype;
301 349
302 if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BACKLIGHT, NULL))) 350 if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BACKLIGHT, NULL)))
303 devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_LEDS, NULL); 351 devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_LEDS, NULL);
@@ -327,27 +375,20 @@ cont:
327 eina_stringshare_del(devtype); 375 eina_stringshare_del(devtype);
328 if (found) 376 if (found)
329 { 377 {
330 tmpdevice = eina_stringshare_add(device);
331 break; 378 break;
332 } 379 }
333 } 380 }
334 381
335 EINA_LIST_FREE(devs, device) 382 if (!found) goto out;
336 eina_stringshare_del(device);
337
338 if (!found) return NULL;
339 383
340 if ((backlight = calloc(1, sizeof(Ecore_Drm_Backlight)))) 384 if ((backlight = calloc(1, sizeof(Ecore_Drm_Backlight))))
341 { 385 {
342 backlight->type = type; 386 backlight->type = type;
343 /* NB: This sets backlight directory path to /dev/... 387 backlight->device = eina_stringshare_add(device);
344 * Am not sure yet if this is the desired path, or if we want the
345 * actual /sys path. If we want Just the syspath then 'tmpdevice' is
346 * already equal to that */
347 backlight->dir_path = eeze_udev_syspath_get_devpath(tmpdevice);
348 } 388 }
349 389out:
350 eina_stringshare_del(tmpdevice); 390 EINA_LIST_FREE(devs, device);
391 eina_stringshare_del(device);
351 392
352 return backlight; 393 return backlight;
353} 394}
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
103 103
104typedef struct _Ecore_Drm_Backlight 104typedef struct _Ecore_Drm_Backlight
105{ 105{
106 const char *dir_path; 106 const char *device;
107 int brightness_max; 107 double brightness_max;
108 int brightness; 108 double brightness_actual;
109 double brightness;
110
109 Ecore_Drm_Backlight_Type type; 111 Ecore_Drm_Backlight_Type type;
110} Ecore_Drm_Backlight; 112} Ecore_Drm_Backlight;
111 113