From 16fc7e2ab742c4a96972593e44507e3f14f1ef05 Mon Sep 17 00:00:00 2001 From: "jy910.yun" Date: Mon, 24 Jun 2013 21:50:35 +0900 Subject: [PATCH] support led indicator func libdeviced export led_set_mode, led_set_mode_with_color function. system server controls real operation regarding led mode. Change-Id: I2412fd4179230fceac49dfbcac4f4b47b2dde3a2 Signed-off-by: Krzysztof Sasiak --- CMakeLists.txt | 8 ++++++ src/core/data.h | 2 ++ src/core/predefine.c | 4 +++ src/led/led.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/led/led.h | 24 ++++++++++++++++++ src/shared/led.c | 22 +++++++++++------ 6 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 src/led/led.c create mode 100644 src/led/led.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bf95c6..68c97a1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(system_server C) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}") +SET(LIBDIR "\${prefix}/lib") + # deviced SET(DEVICED_NAME deviced) SET(VERSION 0.1.0) @@ -41,6 +46,9 @@ SET(SRCS ${SRCS} display/key-filter.c display/battery.c) +SET(SRCS ${SRCS} + src/led/led.c) + # libdeviced SET(DEVICED_SRCS src/shared/battery.c diff --git a/src/core/data.h b/src/core/data.h index bc6ecb2..f686e55 100644 --- a/src/core/data.h +++ b/src/core/data.h @@ -75,6 +75,8 @@ enum { #define PREDEF_CHECK_MMC "checkmmc" #define PREDEF_CHECK_MMC_PROC "checkmmcproc" +#define PREDEF_LED "led" + #define PREDEF_SET_MAX_FREQUENCY "set_max_frequency" #define PREDEF_SET_MIN_FREQUENCY "set_min_frequency" #define PREDEF_RELEASE_MAX_FREQUENCY "release_max_frequency" diff --git a/src/core/predefine.c b/src/core/predefine.c index addc991..e50045e 100644 --- a/src/core/predefine.c +++ b/src/core/predefine.c @@ -41,6 +41,7 @@ #include "core/data.h" #include "common.h" #include "display/poll.h" +#include "led/led.h" #define CALL_EXEC_PATH PREFIX"/bin/call" #define LOWMEM_EXEC_PATH PREFIX"/bin/lowmem-popup" @@ -904,6 +905,9 @@ void ss_predefine_internal_init(void) ss_action_entry_add_internal(PREDEF_HAPTIC, haptic_def_predefine_action, NULL, NULL); + ss_action_entry_add_internal(PREDEF_LED, + led_def_predefine_action, NULL, NULL); + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void *)poweroff_control_cb, NULL) < 0) { _E("Vconf notify key chaneged failed: KEY(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS); } diff --git a/src/led/led.c b/src/led/led.c new file mode 100644 index 0000000..db482c2 --- /dev/null +++ b/src/led/led.c @@ -0,0 +1,70 @@ +/* + * 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 "deviced/dd-led.h" +#include "core/log.h" + +enum { + SET_BRT = 0, +}; + +static int set_brightness(int val) +{ + int r; + + r = device_set_property(DEVICE_TYPE_LED, PROP_LED_BRIGHTNESS, val); + if (r < 0) + return r; + + return 0; +} + +int led_def_predefine_action(int argc, char **argv) +{ + int i; + int pid; + int prop; + + _D("argc : %d", argc); + for (i = 0; i < argc; ++i) + _D("[%2d] %s", i, argv[i]); + + if (argc > 4) { + _E("Invalid argument"); + errno = EINVAL; + return -1; + } + + pid = atoi(argv[0]); + prop = atoi(argv[1]); + _D("pid : %d, prop : %d", pid, prop); + + switch(prop) { + case SET_BRT: + return set_brightness(atoi(argv[2])); + default: + break; + } + + return -1; +} diff --git a/src/led/led.h b/src/led/led.h new file mode 100644 index 0000000..4cd49b5 --- /dev/null +++ b/src/led/led.h @@ -0,0 +1,24 @@ +/* + * 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 __LED_H__ +#define __LED_H__ + +int led_def_predefine_action(int argc, char **argv); + +#endif diff --git a/src/shared/led.c b/src/shared/led.c index af70de2..4da1d7d 100644 --- a/src/shared/led.c +++ b/src/shared/led.c @@ -6,7 +6,7 @@ * 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 + * 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, @@ -22,8 +22,15 @@ #include #include "log.h" +#include "dd-system.h" #include "dd-led.h" +#define PREDEF_LED "led" + +enum { + SET_BRT = 0, +}; + API int led_get_brightness(void) { int val; @@ -50,11 +57,12 @@ API int led_get_max_brightness(void) API int led_set_brightness(int val) { - int r; - - r = device_set_property(DEVICE_TYPE_LED, PROP_LED_BRIGHTNESS, val); - if (r < 0) - return r; + char buf_pid[32]; + char buf_prop[32]; + char buf_val[32]; - return 0; + snprintf(buf_pid, sizeof(buf_pid), "%d", getpid()); + snprintf(buf_prop, sizeof(buf_prop), "%d", SET_BRT); + snprintf(buf_val, sizeof(buf_val), "%d", val); + return system_call_predef_action(PREDEF_LED, 3, buf_pid, buf_prop, buf_val); } -- 2.7.4