summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2014-09-23 15:45:53 -0400
committerChris Michael <cp.michael@samsung.com>2014-09-23 15:47:04 -0400
commite19fbbcd457d26bb3c110cf7699216874b24ab4b (patch)
tree7a3229ed107d5c50e1764ac0a3b805a0d2cb21c0
parenta0395b07c5b51fff61ec4b2e62bbe12fd2badd8f (diff)
ecore-drm: Port ecore_drm_output backlight init code to use Eeze
Summary: This ports the current backlight_init code to use Eeze library instead of udev functions directly. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index 105440e101..8f85f8bf7e 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -291,69 +291,63 @@ _ecore_drm_output_mode_add(Ecore_Drm_Output *output, drmModeModeInfo *info)
291} 291}
292 292
293static Ecore_Drm_Backlight * 293static Ecore_Drm_Backlight *
294_ecore_drm_backlight_init(Ecore_Drm_Device *dev, uint32_t conn_type) 294_ecore_drm_backlight_init(Ecore_Drm_Device *dev EINA_UNUSED, uint32_t conn_type)
295{ 295{
296 Ecore_Drm_Backlight *backlight = NULL; 296 Ecore_Drm_Backlight *backlight = NULL;
297 Ecore_Drm_Backlight_Type type = 0; 297 Ecore_Drm_Backlight_Type type = 0;
298 struct udev_enumerate *enumerate; 298 Eina_List *devs, *l;
299 struct udev_device *device; 299 Eina_Bool found = EINA_FALSE;
300 struct udev_list_entry *item, *first; 300 const char *device, *devtype, *tmpdevice;
301 const char *dev_type, *backlight_path; 301
302 int ret; 302 if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BACKLIGHT, NULL)))
303 303 devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_LEDS, NULL);
304 enumerate = udev_enumerate_new(udev);
305 if (!enumerate) return NULL;
306
307 udev_enumerate_add_match_subsystem(enumerate, "backlight");
308 ret = udev_enumerate_scan_devices(enumerate);
309 if (ret < 0)
310 {
311 udev_enumerate_add_match_subsystem(enumerate, "leds");
312 ret = udev_enumerate_scan_devices(enumerate);
313 if (ret < 0)
314 {
315 udev_enumerate_unref(enumerate);
316 return NULL;
317 }
318 }
319 304
320 first = udev_enumerate_get_list_entry(enumerate); 305 if (!devs) return NULL;
321 udev_list_entry_foreach(item, first) 306
307 EINA_LIST_FOREACH(devs, l, device)
322 { 308 {
323 backlight_path = udev_list_entry_get_name(item); 309 if (!(devtype = eeze_udev_syspath_get_sysattr(device, "type")))
324 device = udev_device_new_from_syspath(udev, backlight_path); 310 continue;
325 311
326 dev_type = udev_device_get_sysattr_value(device, "type"); 312 if (!strcmp(devtype, "raw"))
327 if (!dev_type)
328 {
329 udev_device_unref(device);
330 udev_enumerate_unref(enumerate);
331 return NULL;
332 }
333 if (!strcmp(dev_type, "raw"))
334 type = ECORE_DRM_BACKLIGHT_RAW; 313 type = ECORE_DRM_BACKLIGHT_RAW;
335 else if (!strcmp(dev_type, "platform")) 314 else if (!strcmp(devtype, "platform"))
336 type = ECORE_DRM_BACKLIGHT_PLATFORM; 315 type = ECORE_DRM_BACKLIGHT_PLATFORM;
337 else if (!strcmp(dev_type, "firmware")) 316 else if (!strcmp(devtype, "firmware"))
338 type = ECORE_DRM_BACKLIGHT_FIRMWARE; 317 type = ECORE_DRM_BACKLIGHT_FIRMWARE;
339 318
340 if (conn_type != DRM_MODE_CONNECTOR_LVDS && 319 if ((conn_type != DRM_MODE_CONNECTOR_LVDS) &&
341 conn_type != DRM_MODE_CONNECTOR_eDP) 320 (conn_type != DRM_MODE_CONNECTOR_eDP))
342 { 321 {
343 if (type != ECORE_DRM_BACKLIGHT_RAW) 322 if (type != ECORE_DRM_BACKLIGHT_RAW) goto cont;
344 { 323 }
345 udev_device_unref(device); 324
346 udev_enumerate_unref(enumerate); 325 found = EINA_TRUE;
347 return NULL; 326cont:
348 } 327 eina_stringshare_del(devtype);
328 if (found)
329 {
330 tmpdevice = eina_stringshare_add(device);
331 break;
349 } 332 }
350 udev_device_unref(device);
351 } 333 }
352 udev_enumerate_unref(enumerate);
353 334
354 backlight = (Ecore_Drm_Backlight *)malloc(sizeof(Ecore_Drm_Backlight)); 335 EINA_LIST_FREE(devs, device)
355 backlight->type = type; 336 eina_stringshare_del(device);
356 backlight->dir_path = eina_stringshare_add(backlight_path); 337
338 if (!found) return NULL;
339
340 if ((backlight = calloc(1, sizeof(Ecore_Drm_Backlight))))
341 {
342 backlight->type = type;
343 /* NB: This sets backlight directory path to /dev/...
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 }
349
350 eina_stringshare_del(tmpdevice);
357 351
358 return backlight; 352 return backlight;
359} 353}