From: Wook Song Date: Mon, 21 Nov 2016 07:09:12 +0000 (+0900) Subject: pass: Remove led module X-Git-Tag: submit/tizen/20170328.004502~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94ebd91aee1011289560ed7c49b8f2e98d6e425f;p=platform%2Fcore%2Fsystem%2Fpass.git pass: Remove led module This patch removes the led moudule of deviced. Signed-off-by: Wook Song --- diff --git a/CMakeLists.txt b/CMakeLists.txt index de19eec..da7746a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,11 +80,6 @@ SET(SRCS src/proc/proc-handler.c ) -IF(LED_MODULE STREQUAL on) - ADD_SOURCE(src/led LED_SRCS) - SET(SRCS ${SRCS} ${LED_SRCS}) -ENDIF() - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced) diff --git a/src/led/noti.c b/src/led/noti.c deleted file mode 100644 index da9970b..0000000 --- a/src/led/noti.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include - -#include "core/log.h" -#include "core/edbus-handler.h" - -#define METHOD_TORCH_NOTI_ON "TorchNotiOn" -#define METHOD_TORCH_NOTI_OFF "TorchNotiOff" - -static int noti_h; - -int ongoing_show(void) -{ - int ret_val; - - if (noti_h > 0) { - _D("already ongoing noti show : handle(%d)", noti_h); - return 0; - } - - ret_val = dbus_method_sync(POPUP_BUS_NAME, - POPUP_PATH_LED, - POPUP_INTERFACE_LED, - METHOD_TORCH_NOTI_ON, - NULL, NULL); - - noti_h = ret_val; - _D("insert noti handle : %d", noti_h); - return (ret_val < 0) ? ret_val : 0; -} - -int ongoing_clear(void) -{ - char str_h[32]; - char *arr[1]; - int ret_val; - - if (noti_h <= 0) { - _D("already ongoing noti clear"); - return 0; - } - - snprintf(str_h, sizeof(str_h), "%d", noti_h); - arr[0] = str_h; - - ret_val = dbus_method_sync(POPUP_BUS_NAME, - POPUP_PATH_LED, - POPUP_INTERFACE_LED, - METHOD_TORCH_NOTI_OFF, - "i", arr); - - _D("delete noti handle : %d", noti_h); - noti_h = 0; - return ret_val; -} diff --git a/src/led/torch.c b/src/led/torch.c deleted file mode 100644 index 4bf581d..0000000 --- a/src/led/torch.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include -#include - -#include "core/log.h" -#include "core/edbus-handler.h" -#include "core/devices.h" -#include "torch.h" - -#define LED_MAX_BRIGHTNESS 100 -#define GET_BRIGHTNESS(x) (((x) >> 24) & 0xFF) - -#define SIGNAL_FLASH_STATE "ChangeFlashState" - -static struct led_device *led_dev; -static struct led_state led_state = { - .type = LED_TYPE_MANUAL, - .color = 0x0, - .duty_on = 0, - .duty_off = 0, -}; - -static void flash_state_broadcast(int val) -{ - char *arr[1]; - char str_state[32]; - - snprintf(str_state, sizeof(str_state), "%d", val); - arr[0] = str_state; - - broadcast_edbus_signal(DEVICED_PATH_LED, DEVICED_INTERFACE_LED, - SIGNAL_FLASH_STATE, "i", arr); -} - -static DBusMessage *edbus_get_brightness(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusMessageIter iter; - DBusMessage *reply; - int ret, alpha; - - if (!led_dev) { - _E("there is no led device"); - ret = -ENOENT; - goto error; - } - - alpha = GET_BRIGHTNESS(led_state.color); - ret = alpha * 100.f / 255; - if (alpha != 0 && alpha != 0xFF) - ret += 1; - _D("color : val(%d), color(%x)", ret, led_state.color); - -error: - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - return reply; -} - -static DBusMessage *edbus_get_max_brightness(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusMessageIter iter; - DBusMessage *reply; - int ret; - - ret = LED_MAX_BRIGHTNESS; - - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - return reply; -} - -static DBusMessage *edbus_set_brightness(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusMessageIter iter; - DBusMessage *reply; - int val, enable, ret; - struct led_state tmp = {0,}; - - ret = dbus_message_get_args(msg, NULL, - DBUS_TYPE_INT32, &val, - DBUS_TYPE_INT32, &enable, DBUS_TYPE_INVALID); - if (!ret) { - _I("there is no message"); - ret = -EINVAL; - goto error; - } - - if (!led_dev) { - _E("there is no led device"); - ret = -ENOENT; - goto error; - } - - tmp.color = (((int)(val * 255.f) / LED_MAX_BRIGHTNESS) & 0xFF) << 24; - _D("color : val(%d), color(%x)", val, tmp.color); - - ret = led_dev->set_state(&tmp); - if (ret < 0) - goto error; - - memcpy(&led_state, &tmp, sizeof(led_state)); - - /* flash status broadcast */ - flash_state_broadcast(val); - - /* if enable is ON, noti will be show or hide */ - if (enable) { - if (val) - ongoing_show(); - else - ongoing_clear(); - } - -error: - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - return reply; -} - -static const struct edbus_method edbus_methods[] = { - /** - * GetBrightnessForCamera is for camera library. - * Currently they do not have a daemon for camera, - * but they need to get camera brightness value without led priv. - * It's a temporary solution on Tizen 2.4 and will be removed asap. - */ - { "GetBrightnessForCamera", NULL, "i", edbus_get_brightness }, - { "GetBrightness", NULL, "i", edbus_get_brightness }, - { "GetMaxBrightness", NULL, "i", edbus_get_max_brightness }, - { "SetBrightness", "ii", "i", edbus_set_brightness }, - /* Add methods here */ -}; - -static int led_service_load(void) -{ - struct hw_info *info; - int r; - - r = hw_get_info(LED_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (r < 0) { - _E("fail to load led shared library : %d", r); - return -ENOENT; - } - - if (!info->open) { - _E("fail to open camera led device : open(NULL)"); - return -EPERM; - } - - r = info->open(info, LED_ID_CAMERA_BACK, - (struct hw_common **)&led_dev); - if (r < 0) { - _E("fail to get camera led device : %d", r); - return -EPERM; - } - - _D("camera led device structure load success"); - return 0; -} - -static int led_service_free(void) -{ - struct hw_info *info; - - if (!led_dev) - return -ENOENT; - - info = led_dev->common.info; - - assert(info); - - info->close((struct hw_common *)led_dev); - - return 0; -} - -static int torch_probe(void *data) -{ - /* load led device */ - return led_service_load(); -} - -static void torch_init(void *data) -{ - int ret; - - /* init dbus interface */ - ret = register_edbus_interface_and_method(DEVICED_PATH_LED, - DEVICED_INTERFACE_LED, - edbus_methods, ARRAY_SIZE(edbus_methods)); - if (ret < 0) - _E("fail to init edbus interface and method(%d)", ret); -} - -static void torch_exit(void *data) -{ - /* free led device */ - led_service_free(); -} - -static const struct device_ops torchled_device_ops = { - .name = "torchled", - .probe = torch_probe, - .init = torch_init, - .exit = torch_exit, -}; - -DEVICE_OPS_REGISTER(&torchled_device_ops) diff --git a/src/led/torch.h b/src/led/torch.h deleted file mode 100644 index 8a8a8d3..0000000 --- a/src/led/torch.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __TORCH_H__ -#define __TORCH_H__ - -int ongoing_show(void); -int ongoing_clear(void); - -int play_pattern(const char *path, int cnt); -int stop_pattern(void); - -#endif diff --git a/src/led/touch-key.c b/src/led/touch-key.c deleted file mode 100644 index f2b0ced..0000000 --- a/src/led/touch-key.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include - -#include "core/log.h" -#include "core/edbus-handler.h" -#include "core/devices.h" -#include "core/device-notifier.h" -#include "display/core.h" -#include "display/setting.h" -#include "touch-key.h" - -#define KEYBACKLIGHT_TIME_90 90 /* 1.5 second */ -#define KEYBACKLIGHT_TIME_360 360 /* 6 second */ -#define KEYBACKLIGHT_TIME_ALWAYS_ON -1 /* always on */ -#define KEYBACKLIGHT_TIME_ALWAYS_OFF 0 /* always off */ -#define KEYBACKLIGHT_BASE_TIME 60 /* 1min = 60sec */ -#define KEYBACKLIGHT_PRESSED_TIME 15 /* 15 second */ - -#ifndef VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION -#define VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION VCONFKEY_SETAPPL_PREFIX"/display/touchkey_light_duration" -#endif - -#define GET_BRIGHTNESS(val) (((val) >> 24) & 0xFF) -#define SET_BRIGHTNESS(val) (((val) & 0xFF) << 24) - -struct led_device *touchled_dev; -static Ecore_Timer *hardkey_timeout_id; -static int hardkey_duration; - -static int touchled_set_state(bool on) -{ - struct led_state tmp = {0,}; - int r; - - if (!touchled_dev || !touchled_dev->set_state) { - _E("there is no led device"); - return -ENOENT; - } - - if (on) - tmp.color = SET_BRIGHTNESS(255); - else - tmp.color = SET_BRIGHTNESS(0); - - r = touchled_dev->set_state(&tmp); - if (r < 0) { - _E("fail to set touch led state : %d", r); - return r; - } - - return 0; -} - -static Eina_Bool key_backlight_expired(void *data) -{ - hardkey_timeout_id = NULL; - - touchled_set_state(false); - - return ECORE_CALLBACK_CANCEL; -} - -static void process_touchkey_press(void) -{ - /* release existing timer */ - if (hardkey_timeout_id > 0) { - ecore_timer_del(hardkey_timeout_id); - hardkey_timeout_id = NULL; - } - /* if hardkey option is always off */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_OFF) - return; - /* turn on hardkey backlight */ - touchled_set_state(true); - /* start timer */ - hardkey_timeout_id = ecore_timer_add( - KEYBACKLIGHT_PRESSED_TIME, - key_backlight_expired, NULL); -} - -static void process_touchkey_release(void) -{ - float fduration; - - /* release existing timer */ - if (hardkey_timeout_id > 0) { - ecore_timer_del(hardkey_timeout_id); - hardkey_timeout_id = NULL; - } - /* if hardkey option is always on or off */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON || - hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_OFF) - return; - /* start timer */ - fduration = (float)hardkey_duration / KEYBACKLIGHT_BASE_TIME; - hardkey_timeout_id = ecore_timer_add( - fduration, - key_backlight_expired, NULL); -} - -static void process_touchkey_enable(bool enable) -{ - /* release existing timer */ - if (hardkey_timeout_id > 0) { - ecore_timer_del(hardkey_timeout_id); - hardkey_timeout_id = NULL; - } - - /* start timer in case of backlight enabled */ - if (enable) { - /* if hardkey option is always off */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_OFF) - return; - - /* turn on hardkey backlight */ - touchled_set_state(true); - - /* do not create turnoff timer in case of idle lock state */ - if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) - return; - - /* start timer */ - hardkey_timeout_id = ecore_timer_add( - KEYBACKLIGHT_PRESSED_TIME, - key_backlight_expired, NULL); - } else { - /* if hardkey option is always on */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON) - return; - - /* turn off hardkey backlight */ - touchled_set_state(false); - } -} - -static void hardkey_duration_cb(keynode_t *key, void *data) -{ - float duration; - - hardkey_duration = vconf_keynode_get_int(key); - - /* release existing timer */ - if (hardkey_timeout_id > 0) { - ecore_timer_del(hardkey_timeout_id); - hardkey_timeout_id = NULL; - } - - /* if hardkey option is always off */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_OFF) { - /* turn off hardkey backlight */ - touchled_set_state(false); - return; - } - - /* turn on hardkey backlight */ - touchled_set_state(true); - - /* if hardkey option is always on */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON) - return; - - /* start timer */ - duration = (float)hardkey_duration / KEYBACKLIGHT_BASE_TIME; - hardkey_timeout_id = ecore_timer_add( - duration, - key_backlight_expired, NULL); -} - -static int hardkey_lcd_changed_cb(void *data) -{ - int lcd_state; - - if (!data) - return 0; - - lcd_state = *(int*)data; - if (lcd_state == S_NORMAL - && hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON) { - touchled_set_state(true); - return 0; - } - - return 0; -} - -static int touchled_service_load(void) -{ - struct hw_info *info; - int r; - - r = hw_get_info(LED_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (r < 0) { - _E("fail to load led shared library : %d", r); - return -ENOENT; - } - - if (!info->open) { - _E("fail to open touch led device : open(NULL)"); - return -EPERM; - } - - r = info->open(info, LED_ID_TOUCH_KEY, - (struct hw_common **)&touchled_dev); - if (r < 0) { - _E("fail to get touch led device : %d", r); - return -EPERM; - } - - _D("touch led device structure load success"); - return 0; -} - -static int touchled_service_free(void) -{ - struct hw_info *info; - - if (!touchled_dev) - return -ENOENT; - - info = touchled_dev->common.info; - if (!info) { - free(touchled_dev); - touchled_dev = NULL; - return -EPERM; - } - - info->close((struct hw_common *)touchled_dev); - touchled_dev = NULL; - - return 0; -} - -static int touchled_probe(void *data) -{ - /* load led device */ - return touchled_service_load(); -} - -static void touchled_init(void *data) -{ - /* get touchkey light duration setting */ - if (vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &hardkey_duration) < 0) { - _W("Fail to get VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION!!"); - hardkey_duration = KEYBACKLIGHT_TIME_90; - } - - vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, hardkey_duration_cb, NULL); - - /* register notifier */ - register_notifier(DEVICE_NOTIFIER_LCD, hardkey_lcd_changed_cb); - - /* update touchkey light duration right now */ - if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON) - touchled_set_state(true); -} - -static void touchled_exit(void *data) -{ - /* unregister notifier */ - unregister_notifier(DEVICE_NOTIFIER_LCD, hardkey_lcd_changed_cb); - - vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, hardkey_duration_cb); - - /* free led device */ - touchled_service_free(); -} - -static int touchled_execute(void *data) -{ - int opt; - - if (!data) - return -EINVAL; - - opt = *(int *)data; - if (opt == TOUCHLED_PRESS) - process_touchkey_press(); - else if (opt == TOUCHLED_RELEASE) - process_touchkey_release(); - else if (opt == TOUCHLED_DIRECT_ON) - process_touchkey_enable(true); - else if (opt == TOUCHLED_DIRECT_OFF) - process_touchkey_enable(false); - else - return -EINVAL; - - return 0; -} - -static const struct device_ops touchled_device_ops = { - .name = TOUCHLED_NAME, - .probe = touchled_probe, - .init = touchled_init, - .exit = touchled_exit, - .execute = touchled_execute, -}; - -DEVICE_OPS_REGISTER(&touchled_device_ops) diff --git a/src/led/touch-key.h b/src/led/touch-key.h deleted file mode 100644 index 02af982..0000000 --- a/src/led/touch-key.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __TOUCH_KEY_H__ -#define __TOUCH_KEY_H__ - -#define TOUCHLED_NAME "touchled" - -enum touchled_opt { - TOUCHLED_PRESS, - TOUCHLED_RELEASE, - TOUCHLED_DIRECT_ON, - TOUCHLED_DIRECT_OFF, -}; - -#endif