summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2020-02-07 16:17:19 +0900
committerINSUN PYO <insun.pyo@samsung.com>2020-02-07 16:17:19 +0900
commit54c09942d300d08b34f5ea1142ce11dfcd8cc938 (patch)
tree5b2673e9ce637a53892434cd80db9afc5d092a58
parent42006ef812e99880a0020cd124a9378fcf9396c4 (diff)
downloaddevice-manager-plugin-artik-tizen_6.0_hotfix.tar.gz
device-manager-plugin-artik-tizen_6.0_hotfix.tar.bz2
device-manager-plugin-artik-tizen_6.0_hotfix.zip
Change-Id: Ibdb713172b157e8063de24484a8b276522e40a7d
-rw-r--r--CMakeLists.txt2
-rw-r--r--hw/battery/CMakeLists.txt19
-rw-r--r--hw/battery/battery.c304
-rw-r--r--hw/external_connection/CMakeLists.txt19
-rw-r--r--hw/external_connection/external_connection.c216
5 files changed, 0 insertions, 560 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c5de95..01bda9c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,10 +5,8 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
-#ADD_SUBDIRECTORY(hw/battery)
ADD_SUBDIRECTORY(hw/board)
ADD_SUBDIRECTORY(hw/display)
-#ADD_SUBDIRECTORY(hw/external_connection)
ADD_SUBDIRECTORY(hw/led)
ADD_SUBDIRECTORY(hw/touchscreen)
ADD_SUBDIRECTORY(hw/usb_gadget)
diff --git a/hw/battery/CMakeLists.txt b/hw/battery/CMakeLists.txt
deleted file mode 100644
index 820c168..0000000
--- a/hw/battery/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(battery C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(battery_pkgs REQUIRED hwcommon dlog glib-2.0 libudev)
-
-FOREACH(flag ${battery_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE battery.c ../udev.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${battery_pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/battery/battery.c b/hw/battery/battery.c
deleted file mode 100644
index f16da48..0000000
--- a/hw/battery/battery.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * device-node
- *
- * Copyright (c) 2016 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 <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <linux/limits.h>
-#include <dirent.h>
-
-#include <hw/battery.h>
-#include <hw/shared.h>
-#include "../udev.h"
-
-#define BATTERY_ROOT_PATH "/sys/class/power_supply"
-
-static struct uevent_data {
- BatteryUpdated updated_cb;
- void *data;
-} udata = { 0, };
-
-static int get_power_source(char **src)
-{
- int ret, val;
-
- if (!src)
- return -EINVAL;
-
- ret = sys_get_int(BATTERY_ROOT_PATH"/rk-ac/online", &val);
- if (ret >= 0 && val > 0) {
- *src = POWER_SOURCE_AC;
- return 0;
- }
-
- *src = POWER_SOURCE_NONE;
-
- return 0;
-}
-
-static void remove_not_string(char *str)
-{
- char *t = str;
-
- while (*t != '\0') {
- if (*t == '\r' ||
- *t == '\n' ||
- *t == '\x0a')
- *t = '\0';
- else
- t++;
- }
-}
-
-static void uevent_delivered(struct udev_device *dev)
-{
- struct battery_info info;
- char *val;
- int ret;
-
- _I("POWER_SUPPLY uevent is delivered");
-
- if (!udata.updated_cb) {
- _E("POWER_SUPPLY callback is NULL");
- return;
- }
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_NAME");
- if (!val)
- return;
- info.name = val;
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_STATUS");
- if (!val)
- return;
- info.status = val;
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_HEALTH");
- if (!val)
- return;
- info.health = val;
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT");
- if (!val)
- return;
- info.present = atoi(val);
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE");
- if (val)
- info.online = atoi(val);
- else
- info.online = info.present;
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_CAPACITY");
- if (!val)
- return;
- info.capacity = atoi(val);
-
- ret = get_power_source(&val);
- if (ret < 0)
- return;
- info.power_source = val;
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_CURRENT_NOW");
- if (val)
- info.current_now = atoi(val); /* uA */
- else {
- if (strncmp(info.power_source, POWER_SOURCE_NONE, sizeof(POWER_SOURCE_NONE)))
- info.current_now = 1000; /* current entering the battery from charge source */
- else
- info.current_now = -1000; /* current discharging from the battery */
- }
-
- val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_CURRENT_AVG");
- if (val)
- info.current_average = atoi(val); /* uA */
- else
- info.current_average = info.current_now;
-
- udata.updated_cb(&info, udata.data);
-}
-
-static struct uevent_handler uh = {
- .subsystem = "power_supply",
- .uevent_func = uevent_delivered,
-};
-
-static int battery_register_changed_event(
- BatteryUpdated updated_cb, void *data)
-{
- int ret;
-
- ret = uevent_control_kernel_start();
- if (ret < 0) {
- _E("Failed to register uevent handler (%d)", ret);
- return ret;
- }
-
- ret = register_kernel_event_control(&uh);
- if (ret < 0)
- _E("Failed to register kernel event control (%d)", ret);
-
- if (udata.updated_cb == NULL) {
- udata.updated_cb = updated_cb;
- udata.data = data;
- } else
- _E("update callback is already registered");
-
- return ret;
-}
-
-static void battery_unregister_changed_event(
- BatteryUpdated updated_cb)
-{
- unregister_kernel_event_control(&uh);
- uevent_control_kernel_stop();
- udata.updated_cb = NULL;
- udata.data = NULL;
-}
-
-static int battery_get_current_state(
- BatteryUpdated updated_cb, void *data)
-{
- int ret, val;
- struct battery_info info;
- char *path;
- char status[32];
- char health[32];
- char *power_source;
-
- if (!updated_cb)
- return -EINVAL;
-
- info.name = BATTERY_HARDWARE_DEVICE_ID;
-
- path = BATTERY_ROOT_PATH"/rk-bat/status";
- ret = sys_get_str(path, status, sizeof(status));
- if (ret < 0) {
- _E("Failed to get value of (%s, %d)", path, ret);
- return ret;
- }
- remove_not_string(status);
- info.status = status;
-
- path = BATTERY_ROOT_PATH"/rk-bat/health";
- ret = sys_get_str(path, health, sizeof(health));
- if (ret < 0) {
- _E("Failed to get value of (%s, %d)", path, ret);
- return ret;
- }
- remove_not_string(health);
- info.health = health;
-
- ret = get_power_source(&power_source);
- if (ret < 0) {
- _E("Failed to get power source (%d)", ret);
- return ret;
- }
- remove_not_string(power_source);
- info.power_source = power_source;
-
- path = BATTERY_ROOT_PATH"/rk-bat/present";
- ret = sys_get_int(path, &val);
- if (ret < 0) {
- _E("Failed to get value of (%s, %d)", path, ret);
- return ret;
- }
- info.present = val;
-
- path = BATTERY_ROOT_PATH"/rk-bat/online";
- ret = sys_get_int(path, &val);
- if (ret == 0)
- info.online = val;
- else
- info.online = info.present;
-
- path = BATTERY_ROOT_PATH"/rk-bat/capacity";
- ret = sys_get_int(path, &val);
- if (ret < 0) {
- _E("Failed to get value of (%s, %d)", path, ret);
- return ret;
- }
- info.capacity = val;
-
- path = BATTERY_ROOT_PATH"/rk-bat/current_now";
- ret = sys_get_int(path, &val);
- if (ret == 0)
- info.current_now = val;
- else {
- if (strncmp(power_source, POWER_SOURCE_NONE, sizeof(POWER_SOURCE_NONE)))
- info.current_now = 1000; /* current entering the battery from charge source */
- else
- info.current_now = -1000; /* current discharging from the battery */
- }
-
- path = BATTERY_ROOT_PATH"/rk-bat/current_avg";
- ret = sys_get_int(path, &val);
- if (ret == 0)
- info.current_average = val;
- else
- info.current_average = info.current_now;
-
- updated_cb(&info, data);
-
- return 0;
-}
-
-static int battery_open(struct hw_info *info,
- const char *id, struct hw_common **common)
-{
- struct battery_device *battery_dev;
-
- if (!info || !common)
- return -EINVAL;
-
- battery_dev = calloc(1, sizeof(struct battery_device));
- if (!battery_dev)
- return -ENOMEM;
-
- battery_dev->common.info = info;
- battery_dev->register_changed_event
- = battery_register_changed_event;
- battery_dev->unregister_changed_event
- = battery_unregister_changed_event;
- battery_dev->get_current_state
- = battery_get_current_state;
-
- *common = (struct hw_common *)battery_dev;
- return 0;
-}
-
-static int battery_close(struct hw_common *common)
-{
- if (!common)
- return -EINVAL;
-
- free(common);
- return 0;
-}
-
-HARDWARE_MODULE_STRUCTURE = {
- .magic = HARDWARE_INFO_TAG,
- .hal_version = HARDWARE_INFO_VERSION,
- .device_version = BATTERY_HARDWARE_DEVICE_VERSION,
- .id = BATTERY_HARDWARE_DEVICE_ID,
- .name = "battery",
- .open = battery_open,
- .close = battery_close,
-};
diff --git a/hw/external_connection/CMakeLists.txt b/hw/external_connection/CMakeLists.txt
deleted file mode 100644
index b1f2f83..0000000
--- a/hw/external_connection/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(external_connection C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(external_connection_pkgs REQUIRED hwcommon dlog glib-2.0 libudev)
-
-FOREACH(flag ${external_connection_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE external_connection.c ../udev.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${external_connection_pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/external_connection/external_connection.c b/hw/external_connection/external_connection.c
deleted file mode 100644
index f49083b..0000000
--- a/hw/external_connection/external_connection.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * device-node
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <linux/limits.h>
-#include <dirent.h>
-
-#include <hw/external_connection.h>
-#include <hw/shared.h>
-#include "../udev.h"
-
-#define SWITCH_ROOT_PATH "/sys/devices/virtual/switch"
-
-static struct switch_device {
- char *type;
- char *name;
- int state;
-} switch_devices[] = {
- { EXTERNAL_CONNECTION_USB, "usb_cable", 0 },
- { EXTERNAL_CONNECTION_DOCK, "dock" , 0 },
- { EXTERNAL_CONNECTION_HEADPHONE, "earjack" , 0 },
-};
-
-static struct uevent_data {
- ConnectionUpdated updated_cb;
- void *data;
-} udata = { 0, };
-
-static void uevent_delivered(struct udev_device *dev)
-{
- struct connection_info info;
- char *name, *state;
- int i;
-
- _I("Switch uevent is delivered");
-
- name = (char *)udev_device_get_property_value(dev, "SWITCH_NAME");
- if (!name)
- return;
-
- state = (char *)udev_device_get_property_value(dev, "SWITCH_STATE");
- if (!state)
- return;
-
- for (i = 0 ; i < ARRAY_SIZE(switch_devices) ; i++) {
- if (strncmp(name, switch_devices[i].name, strlen(name) + 1))
- continue;
-
- switch_devices[i].state = atoi(state);
-
- info.name = switch_devices[i].type;
- info.state = state;
- info.flags = 0;
-
- if (udata.updated_cb)
- udata.updated_cb(&info, udata.data);
- else
- _E("callback is NULL");
- }
-}
-
-static struct uevent_handler uh = {
- .subsystem = "switch",
- .uevent_func = uevent_delivered,
-};
-
-static int external_connection_register_changed_event(
- ConnectionUpdated updated_cb, void *data)
-{
- int ret;
-
- ret = uevent_control_kernel_start();
- if (ret < 0) {
- _E("Failed to register uevent handler (%d)", ret);
- return ret;
- }
-
- ret = register_kernel_event_control(&uh);
- if (ret < 0)
- _E("Failed to register kernel event control (%d)", ret);
-
- if (udata.updated_cb == NULL) {
- udata.updated_cb = updated_cb;
- udata.data = data;
- } else
- _E("update callback is already registered");
-
- return ret;
-}
-
-static void external_connection_unregister_changed_event(
- ConnectionUpdated updated_cb)
-{
- unregister_kernel_event_control(&uh);
- uevent_control_kernel_stop();
- udata.updated_cb = NULL;
- udata.data = NULL;
-}
-
-static int read_switch_state(char *path)
-{
- char node[128], val[8];
- FILE *fp;
-
- if (!path)
- return -EINVAL;
-
- snprintf(node, sizeof(node), "%s/%s/state",
- SWITCH_ROOT_PATH, path);
-
- fp = fopen(node, "r");
- if (!fp) {
- _E("Failed to open (%s)", path);
- return -ENOMEM;
- }
-
- if (!fgets(val, sizeof(val), fp)) {
- _E("Failed to read (%s)", path);
- fclose(fp);
- return -ENOENT;
- }
-
- fclose(fp);
-
- return atoi(val);
-}
-
-static int external_connection_get_current_state(
- ConnectionUpdated updated_cb, void *data)
-{
- int ret, i;
- struct connection_info info;
- char buf[8];
-
- if (!updated_cb)
- return -EINVAL;
-
- for (i = 0 ; i < ARRAY_SIZE(switch_devices) ; i++) {
- ret = read_switch_state(switch_devices[i].name);
- if (ret < 0) {
- _E("Failed to get value of (%s, ret:%d)",
- switch_devices[i].name, ret);
- continue;
- }
-
- info.name = switch_devices[i].type;
- snprintf(buf, sizeof(buf), "%d", ret);
- info.state = buf;
-
- updated_cb(&info, data);
- }
-
- return 0;
-}
-
-static int external_connection_open(struct hw_info *info,
- const char *id, struct hw_common **common)
-{
- struct external_connection_device *external_connection_dev;
-
- if (!info || !common)
- return -EINVAL;
-
- external_connection_dev = calloc(1, sizeof(struct external_connection_device));
- if (!external_connection_dev)
- return -ENOMEM;
-
- external_connection_dev->common.info = info;
- external_connection_dev->register_changed_event
- = external_connection_register_changed_event;
- external_connection_dev->unregister_changed_event
- = external_connection_unregister_changed_event;
- external_connection_dev->get_current_state
- = external_connection_get_current_state;
-
- *common = (struct hw_common *)external_connection_dev;
- return 0;
-}
-
-static int external_connection_close(struct hw_common *common)
-{
- if (!common)
- return -EINVAL;
-
- free(common);
- return 0;
-}
-
-HARDWARE_MODULE_STRUCTURE = {
- .magic = HARDWARE_INFO_TAG,
- .hal_version = HARDWARE_INFO_VERSION,
- .device_version = EXTERNAL_CONNECTION_HARDWARE_DEVICE_VERSION,
- .id = EXTERNAL_CONNECTION_HARDWARE_DEVICE_ID,
- .name = "external_connection",
- .open = external_connection_open,
- .close = external_connection_close,
-};