SET(SRCS ${SRCS}
src/led/led.c)
+SET(SRCS ${SRCS}
+ src/control/control.c)
+
# libdeviced
SET(DEVICED_SRCS
src/shared/battery.c
+ src/shared/control.c
src/shared/deviced-conf.c
src/shared/deviced-noti.c
src/shared/deviced-util.c
SET(DEVICED_HEADERS
src/deviced/dd-battery.h
+ src/deviced/dd-control.h
src/deviced/dd-deviced.h
src/deviced/dd-deviced-managed.h
src/deviced/dd-display.h
%files -n libdeviced-devel
%defattr(-,root,root,-)
%{_includedir}/deviced/dd-battery.h
+%{_includedir}/deviced/dd-control.h
%{_includedir}/deviced/dd-deviced.h
%{_includedir}/deviced/dd-deviced-managed.h
%{_includedir}/deviced/dd-display.h
--- /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 <sys/types.h>
+#include <dd-control.h>
+
+#include "core/log.h"
+#include "core/common.h"
+#include "core/devices.h"
+
+static const struct control_device {
+ const int id;
+ const struct device_ops *ops;
+} devices[] = {
+ /* code example
+ * { DEVICE_CONTROL_DISPLAY, &display_device_ops },
+ */
+ /* Add id & ops to provide start/stop control */
+};
+
+static int control_handler(int argc, char **argv)
+{
+ int i;
+ int pid;
+ int device;
+ bool enable;
+ int ret;
+
+ PRT_TRACE("argc : %d", argc);
+ for (i = 0; i < argc; ++i)
+ PRT_TRACE("[%2d] %s", i, argv[i]);
+
+ if (argc > 5) {
+ PRT_TRACE_ERR("Invalid argument");
+ errno = EINVAL;
+ return -1;
+ }
+
+ pid = atoi(argv[0]);
+ device = atoi(argv[1]);
+ enable = atoi(argv[2]);
+ PRT_TRACE("pid : %d, device : %d, enable :%d", pid, device, enable);
+
+ for (i = 0; i < ARRAY_SIZE(devices); i++)
+ if (devices[i].id == device)
+ break;
+
+ if (i >= ARRAY_SIZE(devices))
+ return -EINVAL;
+
+ if (enable)
+ ret = device_start(devices[i].ops);
+ else
+ ret = device_stop(devices[i].ops);
+
+ return ret;
+}
+
+static void control_init(void *data)
+{
+ ss_action_entry_add_internal(CONTROL_HANDLER_NAME, control_handler, NULL, NULL);
+}
+
+const struct device_ops control_device_ops = {
+ .init = control_init,
+};
+
/* The below devices don't have any init dependency */
&sysnoti_device_ops,
¬i_device_ops,
+ &control_device_ops,
&core_device_ops,
&signal_device_ops,
&predefine_device_ops,
extern const struct device_ops display_device_ops;
extern const struct device_ops sysnoti_device_ops;
extern const struct device_ops noti_device_ops;
+extern const struct device_ops control_device_ops;
extern const struct device_ops core_device_ops;
extern const struct device_ops signal_device_ops;
extern const struct device_ops predefine_device_ops;
--- /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 __DD_CONTROL_H__
+#define __DD_CONTROL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+
+/**
+ * @file dd-control.h
+ * @ingroup DEVICED_LIBRARY
+ * @brief This file provides to enable/disable devices
+ */
+
+#define CONTROL_HANDLER_NAME "control"
+
+enum control_device_type {
+ /* Add device define here */
+ /* DEVICE_CONTROL_DISPLAY, */
+ DEVICE_CONTROL_MAX,
+};
+
+/*
+ * Add new function to control in library.
+ */
+/*
+ * exmaple code
+ * int deviced_display_control(bool enable);
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /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 <vconf.h>
+#include <errno.h>
+#include <device-node.h>
+
+#include "log.h"
+#include "dd-control.h"
+
+static int deviced_control_common(int device, bool enable)
+{
+ char buf_pid[6];
+ char buf_dev[3];
+ char buf_enable[2];
+
+ snprintf(buf_pid, sizeof(buf_pid), "%d", getpid());
+ snprintf(buf_dev, sizeof(buf_dev), "%d", device);
+ snprintf(buf_enable, sizeof(buf_enable), "%d", enable);
+
+ return deviced_call_predef_action(CONTROL_HANDLER_NAME, 3, buf_pid,
+ buf_dev, buf_enable);
+}
+
+/*
+ * example of control api
+ * API int deviced_display_control(bool enable)
+ * {
+ * return deviced_control_common(DEVICE_CONTROL_DISPLAY, enable);
+ * }
+ */
+