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 <k.sasiak@samsung.com>
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)
display/key-filter.c
display/battery.c)
+SET(SRCS ${SRCS}
+ src/led/led.c)
+
# libdeviced
SET(DEVICED_SRCS
src/shared/battery.c
#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"
#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"
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);
}
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <errno.h>
+#include <assert.h>
+#include <device-node.h>
+
+#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;
+}
--- /dev/null
+/*
+ * 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
* 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,
#include <device-node.h>
#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;
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);
}