From c1468c6d717784703b5ae1affa79995f376a97e6 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 9 Sep 2019 11:36:01 +0900 Subject: [PATCH 01/16] Minor fix to add SleepSupport=no for TV profile Change-Id: If8ec6b89f95de701778fca751cca28a2996eae64 Signed-off-by: Hyotaek Shim --- packaging/deviced.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 31adc79..83c8165 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -222,11 +222,11 @@ mkdir -p %{_libdir}/deviced mv %{_libdir}/wearable-display.so %{_libdir}/deviced/display.so %post plugin-profile-tv +mv %{_sysconfdir}/deviced/tv-display.conf %{_sysconfdir}/deviced/display.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/tv-display.so %{_libdir}/deviced/display.so %post plugin-profile-iot -mv %{_sysconfdir}/deviced/tv-display.conf %{_sysconfdir}/deviced/display.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so -- 2.7.4 From 2599a3645f7550b10cc6f0c0a1c7408c2309b148 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 4 Sep 2019 21:16:36 +0900 Subject: [PATCH 02/16] Add HBM, LBM module Change-Id: I64a3090092f622f879d2c754e71b5354682936c6 Signed-off-by: Youngjae Cho --- conf/org.tizen.system.deviced.conf | 1 + conf/wearable-display.conf | 7 +- .../wearable/display/auto-brightness-sensorhub.c | 202 ++++++++ .../wearable/display/auto-brightness-sensorhub.h | 30 ++ plugins/wearable/display/display-handler.c | 110 +++++ plugins/wearable/display/hbm.c | 510 +++++++++++++++++++++ plugins/wearable/display/hbm.h | 50 ++ plugins/wearable/display/lbm.c | 376 +++++++++++++++ plugins/wearable/display/lbm.h | 50 ++ plugins/wearable/display/weaks.h | 29 ++ 10 files changed, 1364 insertions(+), 1 deletion(-) create mode 100644 plugins/wearable/display/auto-brightness-sensorhub.c create mode 100644 plugins/wearable/display/auto-brightness-sensorhub.h create mode 100644 plugins/wearable/display/display-handler.c create mode 100644 plugins/wearable/display/hbm.c create mode 100644 plugins/wearable/display/hbm.h create mode 100644 plugins/wearable/display/lbm.c create mode 100644 plugins/wearable/display/lbm.h create mode 100644 plugins/wearable/display/weaks.h diff --git a/conf/org.tizen.system.deviced.conf b/conf/org.tizen.system.deviced.conf index 0fa137a..5ef074e 100644 --- a/conf/org.tizen.system.deviced.conf +++ b/conf/org.tizen.system.deviced.conf @@ -18,6 +18,7 @@ + diff --git a/conf/wearable-display.conf b/conf/wearable-display.conf index f17b4ca..a3393ea 100644 --- a/conf/wearable-display.conf +++ b/conf/wearable-display.conf @@ -40,4 +40,9 @@ ControlDisplay=no PowerKeyDoublePressSupport=yes AccelSensorOn=no ContinuousSampling=no -Dimming=no \ No newline at end of file +Dimming=no +LBMsupport=yes +Level=4 +BrtTable=1,20,40,50,60,70,80,90,95,100 +AodBrightnessLevel=40 + diff --git a/plugins/wearable/display/auto-brightness-sensorhub.c b/plugins/wearable/display/auto-brightness-sensorhub.c new file mode 100644 index 0000000..6e96daf --- /dev/null +++ b/plugins/wearable/display/auto-brightness-sensorhub.c @@ -0,0 +1,202 @@ +/* + * deviced + * + * Copyright (c) 2017 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 + +#include "hbm.h" +#include "lbm.h" +#include "auto-brightness-sensorhub.h" +#include "display/util.h" +#include "display/core.h" +#include "display/display-ops.h" +#include "core/device-notifier.h" +#include "battery/power-supply.h" + +#define SPECIFIC_MODE_OFF 0 +#define LBM_LEVEL 110 +#define HBM_LEVEL 120 + +#define LOWBATCAPACITY 5 + +static int auto_brightness_state = SETTING_BRIGHTNESS_AUTOMATIC_OFF; + +static void change_brightness_transit(int start, int end) +{ + backlight_ops.transit_brt(start, end, + display_conf.brightness_change_step); +} + +static void set_brightness_level(int level) +{ + int old_level = 0; + if (pm_cur_state != S_NORMAL) + return; +/* + if (battery.capacity <= LOWBATCAPACITY && battery.charge_now != CHARGER_CHARGING) + return; +*/ + _I("level changed! %d", level); + + if ((level > PM_MAX_BRIGHTNESS || level < PM_MIN_BRIGHTNESS) && + (level != LBM_LEVEL && level != HBM_LEVEL && level != SPECIFIC_MODE_OFF)) { + _E("Invalid level %d", level); + return; + } + + backlight_ops.get_brightness(&old_level); + + switch (level) { + case LBM_LEVEL: + /* + * received LBM enable + * change brightness to under LBM_BRIGHTNESS_LOW and set lbm state + */ + if (hbm_get_state()) { + hbm_set_state(false); + _I("HBM mode disabled."); + } + if (!lbm_get_state()) { + lbm_set_state(true); + _I("LBM mode enabled."); + } + break; + case HBM_LEVEL: + /* HBM must do not turn on at DIM_STY state. */ + if (pm_status_flag & DIM_MASK) + break; + + /* + * received HBM enable + * change brightness to MAX value and set hbm state + */ + if (lbm_get_state()) { + lbm_set_state(false); + _I("Disabling LBM before enabling HBM."); + } + + change_brightness_transit(old_level, PM_MAX_BRIGHTNESS); + hbm_set_state(true); + _I("HBM mode enabled."); + + break; + case SPECIFIC_MODE_OFF: + /* + * received HBM disable + * unset hbm state and change brightness to setting value + */ + + level = backlight_ops.get_default_brt(); + + if (hbm_get_state()) + hbm_set_state(false); + + if (lbm_get_state()) + lbm_set_state(false); + + change_brightness_transit(old_level, level); + + break; + default: + /* + * received automatic brightness by the light sensor + */ + if (auto_brightness_state != SETTING_BRIGHTNESS_AUTOMATIC_ON) + return; + + if (hbm_get_state()) + hbm_set_state(false); + + if (lbm_get_state()) + lbm_set_state(false); + + if (old_level != level) { + change_brightness_transit(old_level, level); + backlight_ops.set_default_brt(level); + } + + break; + } + + device_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL); +} + +static void set_default_brightness(void) +{ + int default_brt; + + default_brt = backlight_ops.get_default_brt(); + backlight_ops.set_default_brt(default_brt); + backlight_ops.update(); +} + +static void set_automatic_state_cb(keynode_t *key_nodes, void *data) +{ + if (key_nodes == NULL) { + _E("Wrong parameter, key_nodes is null."); + return; + } + auto_brightness_state = vconf_keynode_get_int(key_nodes); + + switch (auto_brightness_state) { + case SETTING_BRIGHTNESS_AUTOMATIC_OFF: + if (hbm_get_state()) + hbm_set_state(false); + /* escape dim state if it's in low battery.*/ + set_brightness_changed_state(); + set_default_brightness(); + break; + case SETTING_BRIGHTNESS_AUTOMATIC_PAUSE: + if (hbm_get_state()) + hbm_set_state(false); + break; + case SETTING_BRIGHTNESS_AUTOMATIC_ON: + set_brightness_changed_state(); + break; + default: + _E("Invalid value %d.", auto_brightness_state); + } +} + +int prepare_level_handler(void) +{ + int status, ret; + + display_info.set_brightness_level = set_brightness_level; + + ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &status); + if (ret >= 0) + auto_brightness_state = status; + + vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, + set_automatic_state_cb, NULL); + + return 0; +} + +void exit_level_handler(void) +{ + vconf_ignore_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, + set_automatic_state_cb); + set_default_brightness(); +} diff --git a/plugins/wearable/display/auto-brightness-sensorhub.h b/plugins/wearable/display/auto-brightness-sensorhub.h new file mode 100644 index 0000000..56243fb --- /dev/null +++ b/plugins/wearable/display/auto-brightness-sensorhub.h @@ -0,0 +1,30 @@ +/* + * deviced + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ + + +/** + * @file auto-brightness-sensorhub.h + * @brief auto-brightness-sensorhub header file + */ +#ifndef __AUTO_BRT_SENSORHUB_H__ +#define __AUTO_BRT_SENSORHUB_H__ + +int prepare_level_handler(void); +void exit_level_handler(void); + +#endif diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c new file mode 100644 index 0000000..11226c6 --- /dev/null +++ b/plugins/wearable/display/display-handler.c @@ -0,0 +1,110 @@ +/* + * deviced + * + * 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 +#include +#include +#include +#include + +#include "auto-brightness-sensorhub.h" +#include "core/device-notifier.h" +#include "display/util.h" +#include "display/core.h" +#include "display/poll.h" +#include "core/common.h" +#include "core/devices.h" +#include "display/display-actor.h" +#include "display/display-ops.h" +#include "display-info.h" + +#define CHARGER_LCD_NODE "/sys/class/power_supply/battery/lcd" + +enum charging_lcd_state { + CHARGING_LCD_OFF = 0, + CHARGING_LCD_ON = 1, +}; + +static GVariant *dbus_autobrightnesschanged(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + int ret = 0; + int level; + + g_variant_get(param, "(i)", &level); + + if (display_info.set_brightness_level) + display_info.set_brightness_level(level); + else + ret = -ENOTSUP; + + return g_variant_new("(i)", ret); +} + +static const dbus_method_s dbus_methods[] = { + { "AutoBrightnessChanged", "i", "i", dbus_autobrightnesschanged }, +}; + +static const dbus_interface_u dbus_interface = { + .oh = NULL, + .name = DEVICED_INTERFACE_DISPLAY, + .methods = dbus_methods, + .nr_methods = ARRAY_SIZE(dbus_methods), +}; + +static int display_state_changed(void *data) +{ + enum state_t state; + int ret = 0; + + state = DATA_VALUE_INT(data); + + if (state == S_LCDON) + ret = sys_set_int(CHARGER_LCD_NODE, CHARGING_LCD_ON); + else + ret = sys_set_int(CHARGER_LCD_NODE, CHARGING_LCD_OFF); + + if (ret < 0) + _E("Can't write %s node %d.", CHARGER_LCD_NODE, state); + + return 0; +} + +static void display_handler_init(void *data) +{ + int ret; + + prepare_level_handler(); + register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed); + + ret = sys_set_int(CHARGER_LCD_NODE, CHARGING_LCD_ON); + if (ret < 0) + _E("Can't write %s node.", CHARGER_LCD_NODE); + + ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface); + if (ret < 0) + _E("Failed to register dbus object."); +} + +static const struct display_ops display_handler_ops = { + .name = "dislay-handler", + .init = display_handler_init, +}; + +DISPLAY_OPS_REGISTER(&display_handler_ops) diff --git a/plugins/wearable/display/hbm.c b/plugins/wearable/display/hbm.c new file mode 100644 index 0000000..4d0fde5 --- /dev/null +++ b/plugins/wearable/display/hbm.c @@ -0,0 +1,510 @@ +/* + * deviced + * + * Copyright (c) 2017 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 "weaks.h" +#include "display-info.h" +#include "display/util.h" +#include "display/core.h" +#include "display/display-ops.h" +#include "core/common.h" +#include "core/device-notifier.h" +#include "core/config-parser.h" + +#define BOARD_CONF_FILE "/etc/deviced/display.conf" + +#define ON "on" +#define OFF "off" + +#define SIGNAL_HBM_ON "HBMOn" +#define SIGNAL_HBM_OFF "HBMOff" + +#define HBM_LEVEL 120 +#define DEFAULT_BRIGHTNESS_LEVEL 80 + +#define LCD_PATH "sys/class/lcd/" +#define HBM_PATH "/hbm" +#define DEVICE_PATH "/device" +#define PATH_BUFFER_MAX 256 + +static guint timer; +static struct timespec offtime; +static char *hbm_path; + +static void broadcast_hbm_state(char *state) +{ + dbus_handle_emit_dbus_signal(NULL, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + state, + NULL); +} + +static void hbm_set_offtime(int timeout) +{ + struct timespec now; + + if (timeout <= 0) { + offtime.tv_sec = 0; + return; + } + + clock_gettime(CLOCK_REALTIME, &now); + offtime.tv_sec = now.tv_sec + timeout; +} + +static gboolean hbm_off_cb(void *data) +{ + int ret; + + timer = 0; + + if (pm_cur_state != S_NORMAL) { + _D("Hbm timeout, but it's not display normal."); + return G_SOURCE_REMOVE; + } + hbm_set_offtime(0); + + ret = sys_set_str(hbm_path, OFF); + if (ret < 0) + _E("Failed to off hbm."); + + ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, + DEFAULT_BRIGHTNESS_LEVEL); + if (ret < 0) { + _E("Failed to set vconf value lcd brightness, %d.", ret); + return G_SOURCE_REMOVE; + } + backlight_ops.set_default_brt(DEFAULT_BRIGHTNESS_LEVEL); + backlight_ops.update(); + broadcast_hbm_state(SIGNAL_HBM_OFF); + + return G_SOURCE_REMOVE; +} + +static void hbm_start_timer(int timeout) +{ + if (timer) { + g_source_remove(timer); + timer = 0; + } + if (!timer) { + timer = g_timeout_add_seconds(timeout, hbm_off_cb, NULL); + } +} + +static void hbm_end_timer(void) +{ + if (timer) { + g_source_remove(timer); + timer = 0; + } +} + +int hbm_get_state(void) +{ + char state[5]; + int ret, hbm; + + if (!hbm_path) + return -ENODEV; + + ret = sys_get_str(hbm_path, state, sizeof(state)); + if (ret < 0) + return ret; + + if (!strncmp(state, ON, strlen(ON))) + hbm = true; + else if (!strncmp(state, OFF, strlen(OFF))) + hbm = false; + else + hbm = -EINVAL; + + return hbm; +} + +int hbm_set_state(int hbm) +{ + if (!hbm_path) + return -ENODEV; + + if (hbm) + broadcast_hbm_state(SIGNAL_HBM_ON); + else + broadcast_hbm_state(SIGNAL_HBM_OFF); + + return sys_set_str(hbm_path, (hbm ? ON : OFF)); +} + +static void hbm_turn_on(void) +{ + if (!hbm_get_state()) + hbm_set_state(true); +} + +static void hbm_turn_off(void) +{ + if (hbm_get_state()) + hbm_set_state(false); +} + +static int hbm_set_state_with_timeout(int hbm, int timeout) +{ + int ret; + + if (hbm && (timeout <= 0)) + return -EINVAL; + + ret = hbm_set_state(hbm); + if (ret < 0) + return ret; + + _D("timeout is %d", timeout); + + if (hbm) { + /* + * hbm is turned off after timeout. + */ + hbm_set_offtime(timeout); + hbm_start_timer(timeout); + } else { + hbm_set_offtime(0); + hbm_end_timer(); + broadcast_hbm_state(SIGNAL_HBM_OFF); + } + + return 0; +} + +void hbm_check_timeout(void) +{ + struct timespec now; + int ret; + + if (timer) { + g_source_remove(timer); + timer = 0; + } + + if (offtime.tv_sec == 0) { + if (hbm_get_state() == true) { + _E("It's invalid state. HBM is turned off."); + hbm_set_state(false); + } + return; + } + + clock_gettime(CLOCK_REALTIME, &now); + _D("now %ld, offtime %ld", now.tv_sec, offtime.tv_sec); + + /* check it's timeout */ + if (now.tv_sec >= offtime.tv_sec) { + hbm_set_offtime(0); + + ret = sys_set_str(hbm_path, OFF); + if (ret < 0) + _E("Failed to off HBM."); + backlight_ops.update(); + broadcast_hbm_state(SIGNAL_HBM_OFF); + } else { + _D("HBM state is restored."); + hbm_set_state(true); + hbm_start_timer(offtime.tv_sec - now.tv_sec); + } +} + +static void hbm_get_level(GVariant *var, void *user_data, GError *err) +{ + int level, brt; + + if (!var) { + _D("Invalid parameter."); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &level)) { + _E("Failed to get message, %s.", g_variant_get_type_string(var)); + goto out; + } + + if (level == HBM_LEVEL && hbm_get_state() == false) { + _I("Lux was high already, HBM enable"); + backlight_ops.get_brightness(&brt); + backlight_ops.transit_brt(brt, PM_MAX_BRIGHTNESS, + display_conf.brightness_change_step); + hbm_set_state(true); + } +out: + g_variant_unref(var); +} + +static gboolean hbm_check_handler(gpointer data) +{ + int ret; + + ret = dbus_handle_method_async_with_reply(COORD_BUS_NAME, + COORD_PATH_AUTOBRIGHTNESS, + COORD_INTERFACE_AUTOBRIGHTNESS, + "GetLevel", + NULL, + NULL, + hbm_get_level, + -1, + NULL); + + if (ret < 0) + _D("Failed to call coord.autobrightness.GetLevel method, %d", ret); + + return G_SOURCE_REMOVE; +} + +static int display_state_changed(void *data) +{ + int state; + int ret; + + state = DATA_VALUE_INT(data); + + if (get_outdoor_setting) + if (get_outdoor_setting()) + return 0; + + switch (state) { + case S_NORMAL: + /* + * outdoor-enhance-mode not supported + * : check & restore hbm always. + * outdoor-enhance-mode supported + * : check & restore hbm when old state is dim only. + */ + if (!get_outdoor_setting || pm_old_state == S_LCDDIM) + hbm_check_timeout(); + + (void) g_timeout_add(300, hbm_check_handler, NULL); + break; + case S_LCDDIM: + case S_LCDOFF: + case S_SLEEP: + if (hbm_get_state() == true) { + ret = hbm_set_state(false); + if (ret < 0) + _E("Failed to off hbm."); + } + hbm_end_timer(); + break; + } + + return 0; +} + +static int display_off_changed(void *data) +{ + int brt; + + if (hbm_get_state() == false) + return 0; + + hbm_turn_off(); + + brt = backlight_ops.get_default_brt(); + if (pm_status_flag & DIMSTAY_FLAG) + _D("skip auto change brightness"); + else + backlight_ops.transit_brt(PM_MAX_BRIGHTNESS, brt, display_conf.brightness_change_step); + + return 0; +} + +static GVariant *dbus_gethbm(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + return g_variant_new("(i)", hbm_get_state()); +} + +static GVariant *dbus_sethbm_timeout(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + int hbm, timeout, ret; + + g_variant_get(param, "(ii)", &hbm, &timeout); + + if (timeout <= 0) { + _E("Timeout can not be setting(%d).", timeout); + ret = -EINVAL; + goto out; + } + + ret = hbm_set_state_with_timeout(hbm, timeout); + + if (ret < 0) + _E("Failed to set HBM (ret=%d, hbm=%d, time=%d).", ret, hbm, timeout); + else + _I("Set hbm (ret=%d, hbm=%d, time=%d).", ret, hbm, timeout); + +out: + return g_variant_new("(i)", ret); +} + +static const dbus_method_s dbus_methods[] = { + { "GetHBM", NULL, "i", dbus_gethbm }, + { "SetHBMTimeout", "ii", "i", dbus_sethbm_timeout }, +}; + +static const dbus_interface_u dbus_interface = { + .oh = NULL, + .name = DEVICED_INTERFACE_DISPLAY, + .methods = dbus_methods, + .nr_methods = ARRAY_SIZE(dbus_methods), +}; + +static int hbm_func(unsigned int cmd, void *arg) +{ + int ret = 0; + int *on; + struct hbmsetstate *hss; + + switch (cmd) { + case HBM_GET_STATE: + ret = hbm_get_state(); + break; + case HBM_SET_STATE: + on = (int *)arg; + ret = hbm_set_state(*on); + break; + case HBM_TURN_ON: + hbm_turn_on(); + break; + case HBM_TURN_OFF: + hbm_turn_off(); + break; + case HBM_SET_TIMEOUT_STATE: + hss = (struct hbmsetstate *)arg; + ret = hbm_set_state_with_timeout(hss->hbm, hss->timeout); + break; + case HBM_TURN_OFF_STATE: + hbm_turn_off(); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static char *check_and_copy_path(char *path) +{ + int fd; + char *buf = NULL; + + fd = open(path, O_RDONLY); + if (fd >= 0) { + buf = strndup(path, strlen(path)); + close(fd); + } else { + _E("Failed to open HBM node."); + } + + return buf; +} + +static char *find_hbm_node() +{ + DIR *d; + struct dirent *dir; + char buf[PATH_BUFFER_MAX]; + char *result = NULL; + + d = opendir(LCD_PATH); + if (!d) + return NULL; + + while ((dir = readdir(d))) { + if (dir->d_name[0] == '.') + continue; + + snprintf(buf, sizeof(buf), "%s%s%s", LCD_PATH, + dir->d_name, HBM_PATH); + + result = check_and_copy_path(buf); + if (result) + break; + + snprintf(buf, sizeof(buf), "%s%s%s%s", LCD_PATH, + dir->d_name, DEVICE_PATH, HBM_PATH); + + result = check_and_copy_path(buf); + if (result) + break; + } + closedir(d); + + return result; +} + +static void hbm_init(void *data) +{ + int ret; + + hbm_path = find_hbm_node(); + + if (!hbm_path) { + _E("Failed to find HBM node."); + return; + } else { + _I("HBM node: %s.", hbm_path); + } + + ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface); + if (ret < 0) + _E("Failed to register dbus object."); + + /* register notifier */ + register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed); + register_notifier(DEVICE_NOTIFIER_LCD_OFF, display_off_changed); +} + +static void hbm_exit(void *data) +{ + /* unregister notifier */ + unregister_notifier(DEVICE_NOTIFIER_LCD_OFF, display_off_changed); + unregister_notifier(DEVICE_NOTIFIER_LCD, display_state_changed); + + /* + * set default brightness + * if display logic is stopped in hbm state. + */ + if (hbm_get_state() == true) { + hbm_set_offtime(0); + _I("set brightness to default value!"); + } +} + +static const struct display_ops display_hbm_ops = { + .name = "hbm", + .init = hbm_init, + .exit = hbm_exit, + .func = hbm_func, +}; + +DISPLAY_OPS_REGISTER(&display_hbm_ops) + diff --git a/plugins/wearable/display/hbm.h b/plugins/wearable/display/hbm.h new file mode 100644 index 0000000..d555152 --- /dev/null +++ b/plugins/wearable/display/hbm.h @@ -0,0 +1,50 @@ +/* + * deviced + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ + + +/** + * @file hbm.h + * @brief High Brightness Mode header file + */ +#ifndef __HBM_H__ +#define __HBM_H__ + +/* + * @brief Configuration structure + */ +struct hbm_config { + int on; + int off; + int on_count; + int off_count; +}; + +int hbm_get_state(void); +int hbm_set_state(int hbm); + +/* + * Global variables + * hbm_conf : configuration of hbm + */ +extern struct hbm_config hbm_conf; + +/** + * @} + */ + +#endif diff --git a/plugins/wearable/display/lbm.c b/plugins/wearable/display/lbm.c new file mode 100644 index 0000000..c098efd --- /dev/null +++ b/plugins/wearable/display/lbm.c @@ -0,0 +1,376 @@ +/* + * deviced + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. Ltd. All rights reserved. + * + * 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 "lbm.h" +#include "display-info.h" +#include "display/util.h" +#include "display/core.h" +#include "display/display-ops.h" +#include "core/common.h" +#include "core/config-parser.h" +#include "core/device-notifier.h" + +#define DISPLAY_CONF_FILE "/etc/deviced/display.conf" + +#define SIGNAL_LBM_ON "LBMOn" +#define SIGNAL_LBM_OFF "LBMOff" + +#define LCD_PHASED_DELAY 10000 /* microsecond */ + +#define LBM_TRANSIT_STEP 20 + +struct lbm_config lbm_conf = { + .support = 0, + .down_level = 0, + .brt_table_size = 0, + .brt_table = NULL, + .aod_brightness_level = 0, +}; + +static bool lbm_state; +static int lbm_setting_mode; +static int system_brightness; +static struct display_device *display_dev; + +static void broadcast_lbm_state(int state) +{ + char *str; + + if (state == 1) + str = SIGNAL_LBM_ON; + else + str = SIGNAL_LBM_OFF; + + dbus_handle_emit_dbus_signal(NULL, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + str, + NULL); +} + +static int get_level_by_brt(int brt) +{ + int iter; + for (iter = 0; iter < lbm_conf.brt_table_size; iter++) { + if (lbm_conf.brt_table[iter] == brt) + return iter; + } + return -EINVAL; +} + +static int lbm_down_brt(int brt) +{ + int level; + int down_level; + + if (lbm_conf.down_level == 0) { + _I("LBM down level setting is 0."); + return brt; + } + + if (lbm_conf.brt_table == NULL || lbm_setting_mode == 0) { + _I("LBM setting mode is %d.", lbm_setting_mode); + return brt; + } + + level = get_level_by_brt(brt); + down_level = level - lbm_conf.down_level; + + if (down_level < 0) + down_level = 0; + + return lbm_conf.brt_table[down_level]; +} + +int lbm_get_state(void) +{ + if (!lbm_conf.support) + return -ENODEV; + + return lbm_state; +} + +static int lbm_get_brightness(int *val) +{ + if (system_brightness == 0) + _E("Failed to get brightness."); + + *val = system_brightness; + + return 0; +} + +static int lbm_set_brightness(int val) +{ + int brt = 0; + + if (!display_dev || !display_dev->set_brightness) { + _E("There is no display device."); + return -ENOENT; + } + + if (pm_status_flag & DIM_MASK) + val = 0; + else + brt = lbm_down_brt(val); + + system_brightness = val; + + _I("Set brightness(LBM on) system=%d, real=%d.", val, brt); + device_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&val); + + return display_dev->set_brightness(brt); +} + +static void lbm_change_brightness(int start, int end, int step) +{ + int diff, val; + int ret = -1; + int prev; + + if (display_dimstay_check()) + return; + + ret = backlight_ops.get_brightness(&prev); + + if (ret < 0) { + _E("Failed to get brightness, %d.", ret); + return; + } + + if (prev == end) + return; + + if (pm_status_flag & DIM_MASK) + end = 0; + + _I("Start %d, end %d, step %d.", start, end, step); + + if (display_dev && display_dev->set_multi_brightness) { + diff = lbm_down_brt(end); + + ret = display_dev->set_multi_brightness(diff, step, LCD_PHASED_DELAY); + if (ret < 0) + _E("Failed to set_multi_brightness, %d.", ret); + + backlight_ops.set_brightness(end); + + return; + } + + diff = end - start; + + if (abs(diff) < step) + val = (diff > 0 ? 1 : -1); + else + val = (int)ceil((double)diff / step); + + while (start != end) { + if (val == 0) + break; + + start += val; + if ((val > 0 && start > end) || + (val < 0 && start < end)) + start = end; + + usleep(LCD_PHASED_DELAY); + backlight_ops.set_brightness(start); + } +} + +int lbm_set_state(int lbm) +{ + int brt; + _I("lbm_set_state"); + + if (lbm == lbm_state) { + _W("already lbm %s", (lbm_state ? "on" : "off")); + return 0; + } + + if (!lbm || lbm_setting_mode) { + lbm_state = lbm; + broadcast_lbm_state(lbm_state); + } + + brt = backlight_ops.get_default_brt(); + _I("Default brightness: %d", brt); + if (lbm && lbm_setting_mode) { + _I("Lowering Brightness."); + backlight_ops.transit_brt(brt, lbm_down_brt(brt), LBM_TRANSIT_STEP); + backlight_ops.get_brightness(&system_brightness); + backlight_ops.set_brightness = lbm_set_brightness; + backlight_ops.get_brightness = lbm_get_brightness; + backlight_ops.transit_brt = lbm_change_brightness; + } else { + system_brightness = 0; + backlight_ops.restore_brightness_func(); + backlight_ops.transit_brt(lbm_down_brt(brt), brt, display_conf.brightness_change_step); + } + + backlight_ops.set_brightness(brt); + + return 0; +} + +static void lbm_table_load(char *value, struct lbm_config *c) +{ + char *p, *saveptr; + int level_count = 1; + int i; + + if (value == '\0') + return; + + for (i = 0; *(value + i) != '\0'; i++) { + if (*(value + i) == ',') + level_count++; + } + + c->brt_table = malloc(sizeof(int) * level_count); + if (!c->brt_table) { + _E("Failed to allocate memory."); + return; + } + c->brt_table_size = level_count; + + i = 0; + p = strtok_r(value, ",", &saveptr); + if (p) + c->brt_table[i++] = atoi(p); + + while (p != NULL) { + p = strtok_r(NULL, ",", &saveptr); + if (p) + c->brt_table[i++] = atoi(p); + } +} + +static int lbm_load_config(struct parse_result *result, void *user_data) +{ + struct lbm_config *c = user_data; + + _D("%s,%s,%s.", result->section, result->name, result->value); + + if (!c) + return -EINVAL; + + if (!MATCH(result->section, "Display")) + return 0; + + if (MATCH(result->name, "LBMsupport")) { + c->support = (MATCH(result->value, "yes") ? 1 : 0); + _D("lbm support is %d", c->support); + } else if (MATCH(result->name, "Level")) { + SET_CONF(c->down_level, atoi(result->value)); + _D("lbm down level is %d", c->down_level); + } else if (MATCH(result->name, "BrtTable")) { + lbm_table_load(result->value, c); + _D("LBM table loaded."); + } + + return 0; +} + +static void lbm_mode_changed(keynode_t *key_nodes, void *data) +{ + int mode = vconf_keynode_get_bool(key_nodes); + + _I("LBM setting value is %s.", mode ? "enable" : "disable"); + + lbm_setting_mode = mode; + + if (lbm_get_state()) + lbm_set_state(false); +} + +static int display_off_changed(void *data) +{ + int brt; + + backlight_ops.get_brightness(&brt); + backlight_ops.restore_brightness_func(); + backlight_ops.set_brightness(brt); + + lbm_state = 0; + + return 0; +} + +static GVariant *dbus_getlbm(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + int lbm; + + lbm = lbm_get_state(); + if (lbm < 0) + _E("Failed to get low brightness mode %d.", lbm); + else + _D("Get low brightness mode %d.", lbm); + + return g_variant_new("(i)", lbm); +} + +static const dbus_method_s dbus_methods[] = { + { "GetLBM", NULL, "i", dbus_getlbm }, +}; + +static const dbus_interface_u dbus_interface = { + .oh = NULL, + .name = DEVICED_INTERFACE_DISPLAY, + .methods = dbus_methods, + .nr_methods = ARRAY_SIZE(dbus_methods), +}; +static void lbm_init(void *data) +{ + int ret; + + /* load configutation */ + ret = config_parse(DISPLAY_CONF_FILE, lbm_load_config, &lbm_conf); + if (ret < 0) + _W("Failed to load %s, %d. Use default value.", DISPLAY_CONF_FILE, ret); + + ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_AUTOMATIC_LOW_BRIGHTNESS, &lbm_setting_mode); + if (ret < 0) + _E("Failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_AUTOMATIC_LOW_BRIGHTNESS, %d.", ret); + + vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_AUTOMATIC_LOW_BRIGHTNESS, lbm_mode_changed, NULL); + + ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface); + if (ret < 0) + _E("Failed to init dbus method, %d.", ret); + + display_dev = display_dev_get(); + + _I("LBM setting value is %d.", lbm_setting_mode); + + /* register notifier */ + register_notifier(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, display_off_changed); +} + +static const struct display_ops display_lbm_ops = { + .name = "lbm", + .init = lbm_init, +}; + +DISPLAY_OPS_REGISTER(&display_lbm_ops) diff --git a/plugins/wearable/display/lbm.h b/plugins/wearable/display/lbm.h new file mode 100644 index 0000000..5b1e319 --- /dev/null +++ b/plugins/wearable/display/lbm.h @@ -0,0 +1,50 @@ +/* + * deviced + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ + +/** + * @file lbm.h + * @brief Low Brightness Mode header file + */ +#ifndef __LBM_H__ +#define __LBM_H__ + +/* + * @brief Configuration structure + */ +struct lbm_config { + int support; + int down_level; + int brt_table_size; + int *brt_table; + int aod_brightness_level; +}; + +/* + * Global variables + * lbm_conf : configuration of lbm + */ +struct lbm_config lbm_conf; + +int lbm_get_state(void); +int lbm_set_state(int lbm); + +/** + * @} + */ + +#endif diff --git a/plugins/wearable/display/weaks.h b/plugins/wearable/display/weaks.h new file mode 100644 index 0000000..e8c764e --- /dev/null +++ b/plugins/wearable/display/weaks.h @@ -0,0 +1,29 @@ +/* + * 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 __DISPLAY_WEAKS_H__ +#define __DISPLAY_WEAKS_H__ + +#include "core/common.h" +#include "display/core.h" + +bool __WEAK__ get_outdoor_setting(void); + +#endif + -- 2.7.4 From 58c3c57cf29e4794117e9f9183a7548901232181 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Tue, 10 Sep 2019 10:27:41 +0900 Subject: [PATCH 03/16] Fix add_device() not to remove added devices Change-Id: I7d6dbd9e240311b09fe251d492c11cb830c0eaef Signed-off-by: Hyotaek Shim --- src/core/devices.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/core/devices.c b/src/core/devices.c index 6d5480d..69e0106 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -38,12 +38,6 @@ dd_list *get_device_list_head(void) void add_device(const struct device_ops *dev) { - const struct device_ops *ops; - - ops = find_device(dev->name); - if (ops != &default_ops) - remove_device(dev); - if (dev->priority == DEVICE_PRIORITY_HIGH) DD_LIST_PREPEND(dev_head, dev); else -- 2.7.4 From 9b814cbf992ae0942cf075147287732c15b7ac2b Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 10 Sep 2019 16:29:04 +0900 Subject: [PATCH 04/16] Delete duplicate logs Change-Id: Ic53c99ff3225a1d2a15a2f34a5d9e32d8e84db0d --- src/usb/usb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/usb/usb.c b/src/usb/usb.c index 9eb86c9..65a33d0 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -379,17 +379,16 @@ static int usb_state_changed(int status) switch (status) { case USB_CONNECTED: - _I("USB cable is connected."); ret = usb_connected(); break; case USB_DISCONNECTED: - _I("USB cable is disconnected."); ret = usb_disconnected(); break; default: _E("Invalid USB state(%d).", status); return -EINVAL; } + if (ret < 0) _E("Failed to operate usb connection: %d", ret); else -- 2.7.4 From eafebf42bb9b34f2532c5841a5e063cc4a1a4df2 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 9 Sep 2019 14:02:04 +0900 Subject: [PATCH 05/16] Add ultrapowersaving module Change-Id: I65f7000fcd955197ce793b45b800e99161a8859d Signed-off-by: Youngjae Cho --- plugins/wearable/display/powersaver.c | 155 ++++++++++++++++++++++++++++++++++ plugins/wearable/display/powersaver.h | 29 +++++++ src/display/setting.h | 1 + 3 files changed, 185 insertions(+) create mode 100644 plugins/wearable/display/powersaver.c create mode 100644 plugins/wearable/display/powersaver.h diff --git a/plugins/wearable/display/powersaver.c b/plugins/wearable/display/powersaver.c new file mode 100644 index 0000000..5847afc --- /dev/null +++ b/plugins/wearable/display/powersaver.c @@ -0,0 +1,155 @@ +/* + * deviced + * + * Copyright (c) 2014 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 "core/common.h" +#include "core/devices.h" +#include "core/device-notifier.h" +#include "core/log.h" +#include "display/core.h" +#include "display/device-interface.h" +#include "display/display-ops.h" +#include "display-info.h" +#include "powersaver.h" +#include "setting.h" + +static int set_powersaver_mode(int mode) +{ + int timeout; + const struct display_ops *hbm_ops = NULL; + struct hbmsetstate hss; + bool pmqos = false; + + if (mode == POWERSAVER_ENHANCED) + pmqos = true; + _D("Powersaver mode %d pmqos %d.", mode, pmqos); + device_notify(DEVICE_NOTIFIER_ULTRAPOWERSAVING, (void *)&pmqos); + + backlight_ops.set_force_brightness(0); + set_force_lcdtimeout(0); + + FIND_DISPLAY(hbm_ops, "hbm"); + if (hbm_ops && hbm_ops->func(HBM_GET_STATE, 0)) { + hss.hbm = false; + hss.timeout = 0; + hbm_ops->func(HBM_SET_TIMEOUT_STATE, &hss); + } + + backlight_ops.update(); + get_run_timeout(&timeout); + states[S_NORMAL].timeout = timeout; + states[pm_cur_state].trans(EVENT_INPUT); + + return 0; +} + +static void powersaver_status_changed(keynode_t *key_nodes, void *data) +{ + int status, mode, ret; + + if (key_nodes == NULL) { + _E("Wrong parameter, key_nodes is null."); + return; + } + + status = vconf_keynode_get_int(key_nodes); + if (status == SETTING_PSMODE_NORMAL) + mode = POWERSAVER_OFF; + else if (status == SETTING_PSMODE_WEARABLE) + mode = POWERSAVER_BASIC; + else if (status == SETTING_PSMODE_WEARABLE_ENHANCED) + mode = POWERSAVER_ENHANCED; + else + return; + + ret = set_powersaver_mode(mode); + if (ret < 0) + _E("Failed to update powersaver state %d.", ret); +} + +static int booting_done(void *data) +{ + static int done; + int ret, status; + int mode = POWERSAVER_OFF; + bool pmqos = false; + + if (data == NULL) + goto out; + done = *(int *)data; + if (!done) + goto out; + _I("Booting done."); + + + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, + powersaver_status_changed, NULL); + if (ret != 0) + _E("Failed to vconf_notify_key_changed."); + + ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &status); + if (ret != 0) { + _E("Failed to vconf get bool."); + goto out; + } + + switch (status) { + case SETTING_PSMODE_WEARABLE: + mode = POWERSAVER_BASIC; + break; + case SETTING_PSMODE_WEARABLE_ENHANCED: + mode = POWERSAVER_ENHANCED; + pmqos = true; + break; + default: + goto out; + } + + _D("Powersaver mode on, %d.", mode); + device_notify(DEVICE_NOTIFIER_PMQOS_ULTRAPOWERSAVING, (void *)&pmqos); + ret = set_powersaver_mode(mode); + if (ret < 0) + _E("Failed to update powersaver state, %d.", ret); +out: + return done; +} + +static void powersaver_init(void *data) +{ + register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); +} + +static void powersaver_exit(void *data) +{ + int ret; + + ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE, + powersaver_status_changed); + if (ret != 0) + _E("Failed to vconf_ignore_key_changed."); +} + +static const struct device_ops powersaver_device_ops = { + DECLARE_NAME_LEN("powersaver"), + .init = powersaver_init, + .exit = powersaver_exit, +}; + +DEVICE_OPS_REGISTER(&powersaver_device_ops) diff --git a/plugins/wearable/display/powersaver.h b/plugins/wearable/display/powersaver.h new file mode 100644 index 0000000..84312c8 --- /dev/null +++ b/plugins/wearable/display/powersaver.h @@ -0,0 +1,29 @@ +/* + * deviced + * + * Copyright (c) 2014 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 __POWERSAVER_H__ +#define __POWERSAVER_H__ + +enum powersaver_state { + POWERSAVER_OFF, + POWERSAVER_ENHANCED, + POWERSAVER_BASIC, +}; + +#endif //__POWERSAVER_H__ diff --git a/src/display/setting.h b/src/display/setting.h index b34b21c..284fb62 100644 --- a/src/display/setting.h +++ b/src/display/setting.h @@ -49,6 +49,7 @@ enum { extern int (*update_pm_setting) (int key_idx, int val); +int set_force_lcdtimeout(int timeout); int get_setting_brightness(int *level); /* -- 2.7.4 From 5a9c8e78f3df3fd2d01ff6d6c61022a40792e0d6 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 16 Sep 2019 12:10:08 +0900 Subject: [PATCH 06/16] Fix SleepSupport Change-Id: Ic44b710acb3fe4a19238933c0b32e67bbca13387 Signed-off-by: Hyotaek Shim --- plugins/iot/display/core.c | 8 +++++++- plugins/mobile/display/core.c | 8 +++++++- plugins/tv/display/core.c | 10 ++++++++-- plugins/wearable/display/core.c | 8 +++++++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 9850915..18786fa 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -938,6 +938,9 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return; + _I("Reset timeout(%d ms).", timeout); if (timeout_src_id != 0) { g_source_remove(timeout_src_id); @@ -1893,6 +1896,9 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return 0; + st->action(st->timeout); } } @@ -1969,7 +1975,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { + if (pm_cur_state != S_SLEEP) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 4a54229..c7054a2 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -946,6 +946,9 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return; + _I("Reset timeout(%d ms).", timeout); if (timeout_src_id != 0) { g_source_remove(timeout_src_id); @@ -1905,6 +1908,9 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return 0; + st->action(st->timeout); } } @@ -1981,7 +1987,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { + if (pm_cur_state != S_SLEEP) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 4730754..dde0f6b 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -938,7 +938,10 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; - _I("Reset timeout(%d ms).", timeout); + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return; + + _I("Reset timeout(%d ms) pm_cur_state(%d).", timeout, pm_cur_state); if (timeout_src_id != 0) { g_source_remove(timeout_src_id); timeout_src_id = 0; @@ -1893,6 +1896,9 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return 0; + st->action(st->timeout); } } @@ -1969,7 +1975,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { + if (pm_cur_state != S_SLEEP) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index c098a56..60cb553 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -945,6 +945,9 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return; + _I("Reset timeout(%d ms).", timeout); if (timeout_src_id != 0) { g_source_remove(timeout_src_id); @@ -1915,6 +1918,9 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { + if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + return 0; + st->action(st->timeout); } } @@ -1991,7 +1997,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { + if (pm_cur_state != S_SLEEP) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); -- 2.7.4 From 69f08763e7e4f9db1ee58851bc607ee00a80ca1d Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 16 Sep 2019 18:09:57 +0900 Subject: [PATCH 07/16] Delete duplicated call for lcd_on_procedure() Change-Id: Ice42021b7accf261ec840cc977008ef565ad73fc Signed-off-by: Youngjae Cho --- plugins/iot/display/core.c | 13 ++----------- plugins/mobile/display/core.c | 13 ++----------- plugins/tv/display/core.c | 13 ++----------- plugins/wearable/display/core.c | 13 ++----------- 4 files changed, 8 insertions(+), 44 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 18786fa..f88f974 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -1943,21 +1943,12 @@ static void check_lock_screen(void) /* check state of lock */ ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) { - if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - goto lcd_on; - } + if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) + return; /* Use time to check lock is done. */ lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); - - return; - -lcd_on: - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); } /* default enter action function */ diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index c7054a2..5e5de90 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1955,21 +1955,12 @@ static void check_lock_screen(void) /* check state of lock */ ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) { - if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - goto lcd_on; - } + if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) + return; /* Use time to check lock is done. */ lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); - - return; - -lcd_on: - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); } /* default enter action function */ diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index dde0f6b..f5ed441 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1943,21 +1943,12 @@ static void check_lock_screen(void) /* check state of lock */ ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) { - if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - goto lcd_on; - } + if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) + return; /* Use time to check lock is done. */ lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); - - return; - -lcd_on: - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); } /* default enter action function */ diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 60cb553..9d5acc5 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1965,21 +1965,12 @@ static void check_lock_screen(void) /* check state of lock */ ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) { - if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - goto lcd_on; - } + if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) + return; /* Use time to check lock is done. */ lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); - - return; - -lcd_on: - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); } /* default enter action function */ -- 2.7.4 From 0d4017476c1b8098581eaac290e6dc946e092ada Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 18 Sep 2019 11:41:42 +0900 Subject: [PATCH 08/16] Fix SleepSupport not to step into default_action(S_SLEEP) Change-Id: I5d08b01bc2444c0985d474ed6f647e1496a7ad68 Signed-off-by: Hyotaek Shim --- plugins/iot/display/core.c | 2 +- plugins/mobile/display/core.c | 2 +- plugins/tv/display/core.c | 2 +- plugins/wearable/display/core.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index f88f974..180e0b0 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -1896,7 +1896,7 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) return 0; st->action(st->timeout); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 5e5de90..2cd6ddc 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1908,7 +1908,7 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) return 0; st->action(st->timeout); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index f5ed441..febc326 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1896,7 +1896,7 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) return 0; st->action(st->timeout); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 9d5acc5..3174ede 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1918,7 +1918,7 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) return 0; st->action(st->timeout); -- 2.7.4 From 78e3f841996ceaba7c960f2766b309aadf305e94 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 18 Sep 2019 18:33:28 +0900 Subject: [PATCH 09/16] Unmount rw partitions even for emulator environment Change-Id: Ie777afa9c3b8d9b69080f9bd340e85f24021a909 Signed-off-by: Hyotaek Shim --- src/power-shutdown/shutdown.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/power-shutdown/shutdown.c b/src/power-shutdown/shutdown.c index 7e4fa71..b292719 100644 --- a/src/power-shutdown/shutdown.c +++ b/src/power-shutdown/shutdown.c @@ -165,12 +165,11 @@ int main(int ac, char *av[]) (void)signal(SIGHUP, SIG_IGN); (void)signal(SIGTERM, SIG_IGN); - if (!is_emulator()) { - printf("%s: unmounting rw partitions\n", progname); - umount_partitions(); - } + printf("%s: unmounting rw partitions\n", progname); + + umount_partitions(); - printf("%s: flushing filesystems\n", progname); + printf("%s: rw partitions have been unmounted\n", progname); sync(); -- 2.7.4 From 5f348ae01c0ddc872b30e703552b86999a1c5228 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 18 Sep 2019 18:42:40 +0900 Subject: [PATCH 10/16] Do not enter S_SLEEP on emulator environment Change-Id: I9a0fba246cdb8403d03a16578b2c64efe5a8a9c1 Signed-off-by: Hyotaek Shim --- plugins/iot/display/core.c | 6 ++++-- plugins/mobile/display/core.c | 6 ++++-- plugins/tv/display/core.c | 6 ++++-- plugins/wearable/display/core.c | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 180e0b0..3b9cb2c 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -938,7 +938,8 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_LCDOFF + && (is_emulator() == true || display_conf.sleep_support == false)) return; _I("Reset timeout(%d ms).", timeout); @@ -1896,7 +1897,8 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP + && (is_emulator() == true || display_conf.sleep_support == false)) return 0; st->action(st->timeout); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 2cd6ddc..3d1e51b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -946,7 +946,8 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_LCDOFF + && (is_emulator() == true || display_conf.sleep_support == false)) return; _I("Reset timeout(%d ms).", timeout); @@ -1908,7 +1909,8 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP + && (is_emulator() == true || display_conf.sleep_support == false)) return 0; st->action(st->timeout); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index febc326..2942b96 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -938,7 +938,8 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_LCDOFF + && (is_emulator() == true || display_conf.sleep_support == false)) return; _I("Reset timeout(%d ms) pm_cur_state(%d).", timeout, pm_cur_state); @@ -1896,7 +1897,8 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP + && (is_emulator() == true || display_conf.sleep_support == false)) return 0; st->action(st->timeout); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 3174ede..4874e5f 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -945,7 +945,8 @@ void reset_timeout(int timeout) if (!display_conf.timeout_enable) return; - if (pm_cur_state == S_LCDOFF && display_conf.sleep_support == false) + if (pm_cur_state == S_LCDOFF + && (is_emulator() == true || display_conf.sleep_support == false)) return; _I("Reset timeout(%d ms).", timeout); @@ -1918,7 +1919,8 @@ static int default_trans(int evt) /* enter next state directly */ states[pm_cur_state].trans(EVENT_TIMEOUT); } else { - if (pm_cur_state == S_SLEEP && display_conf.sleep_support == false) + if (pm_cur_state == S_SLEEP + && (is_emulator() == true || display_conf.sleep_support == false)) return 0; st->action(st->timeout); -- 2.7.4 From 3de55bd6f100899a13329df73d3d614b495230d2 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 19 Sep 2019 11:06:22 +0900 Subject: [PATCH 11/16] Modify TV display configurations Change-Id: I9164660ca9c9e698855d4bd3fc1f53cc511d07e9 Signed-off-by: Hyotaek Shim --- conf/tv-display.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/tv-display.conf b/conf/tv-display.conf index b289403..4e14b86 100644 --- a/conf/tv-display.conf +++ b/conf/tv-display.conf @@ -34,4 +34,6 @@ # If this value is no, LCD is turned off just by external requests. # TimeoutEnable=(yes or no) +LCDAlwaysOn=yes +TimeoutEnable=no SleepSupport=no -- 2.7.4 From 48bad68e8a0bd4770324c4fa7b1ef2794a824809 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Thu, 19 Sep 2019 15:30:09 +0900 Subject: [PATCH 12/16] fix bug of macro ADD_SOURCE Change-Id: If68cd575a30886d75678edf82992c4e647d0c1e3 Signed-off-by: sanghyeok.oh --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb7cecf..b60f1aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,8 @@ ENDIF() ######################################################## MACRO(ADD_SOURCE DIR OUT) + SET(S_SRCS "") + SET(D_SRCS "") FILE(GLOB ALL_SRCS "${DIR}/*.c") FOREACH(SRC ${ALL_SRCS}) IF(NOT ${SRC} MATCHES "mobile|wearable|tv") -- 2.7.4 From 7a2442ad49e98d6da2a3b55e91ee552fc140c37c Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 19 Sep 2019 20:57:01 +0900 Subject: [PATCH 13/16] Fix library dependency in plugin modules Change-Id: Iaa5c932f025ab9e45bf8ada653a5e5d6819e6a4b Signed-off-by: Hyotaek Shim --- plugins/iot/display/CMakeLists.txt | 2 +- plugins/mobile/display/CMakeLists.txt | 2 +- plugins/tv/display/CMakeLists.txt | 2 +- plugins/wearable/display/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/iot/display/CMakeLists.txt b/plugins/iot/display/CMakeLists.txt index 206e95a..7af71d9 100644 --- a/plugins/iot/display/CMakeLists.txt +++ b/plugins/iot/display/CMakeLists.txt @@ -26,7 +26,7 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} shared) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME iot-display) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/plugins/mobile/display/CMakeLists.txt b/plugins/mobile/display/CMakeLists.txt index 071f366..4c2cfa3 100644 --- a/plugins/mobile/display/CMakeLists.txt +++ b/plugins/mobile/display/CMakeLists.txt @@ -26,7 +26,7 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} shared) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME mobile-display) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/plugins/tv/display/CMakeLists.txt b/plugins/tv/display/CMakeLists.txt index f996126..9b1ee5b 100644 --- a/plugins/tv/display/CMakeLists.txt +++ b/plugins/tv/display/CMakeLists.txt @@ -26,7 +26,7 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} shared) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME tv-display) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/plugins/wearable/display/CMakeLists.txt b/plugins/wearable/display/CMakeLists.txt index 391ec59..00290fc 100644 --- a/plugins/wearable/display/CMakeLists.txt +++ b/plugins/wearable/display/CMakeLists.txt @@ -26,7 +26,7 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} shared) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME wearable-display) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) -- 2.7.4 From bba927e580752d7016ffc3731f06594753dbe438 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 30 Sep 2019 21:14:09 +0900 Subject: [PATCH 14/16] Do not make caution of pmlock_expired for normal applications Change-Id: Id12492ee7d56a367318a590f4c0dc957c84f5c46 Signed-off-by: Hyotaek Shim --- plugins/iot/display/core.c | 3 +++ plugins/mobile/display/core.c | 3 +++ plugins/tv/display/core.c | 3 +++ plugins/wearable/display/core.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 3b9cb2c..50e45f6 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -853,6 +853,9 @@ static void pmlock_check_cb(GVariant *var, void *user_data, GError *err) goto out; } + if (!state) + return; + _W("%s(%d) was requested pmlock for a long time.", app_id, pid); ret = dbus_handle_emit_dbus_signal(NULL, DEVICED_PATH_DISPLAY, diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 3d1e51b..7726cb5 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -861,6 +861,9 @@ static void pmlock_check_cb(GVariant *var, void *user_data, GError *err) goto out; } + if (!state) + return; + _W("%s(%d) was requested pmlock for a long time.", app_id, pid); ret = dbus_handle_emit_dbus_signal(NULL, DEVICED_PATH_DISPLAY, diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 2942b96..35fb9e2 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -853,6 +853,9 @@ static void pmlock_check_cb(GVariant *var, void *user_data, GError *err) goto out; } + if (!state) + return; + _W("%s(%d) was requested pmlock for a long time.", app_id, pid); ret = dbus_handle_emit_dbus_signal(NULL, DEVICED_PATH_DISPLAY, diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 4874e5f..0b984da 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -860,6 +860,9 @@ static void pmlock_check_cb(GVariant *var, void *user_data, GError *err) goto out; } + if (!state) + return; + _W("%s(%d) was requested pmlock for a long time.", app_id, pid); ret = dbus_handle_emit_dbus_signal(NULL, DEVICED_PATH_DISPLAY, -- 2.7.4 From ab9c4f74e3296da343ab497c150090ff5b50f508 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Mon, 30 Sep 2019 15:24:59 +0900 Subject: [PATCH 15/16] Support USB tethering To enable USB tethering, you must run the following two commands after configuring the USB endpoint. 1. /sbin/ifconfig usb0 192.168.129.3 up 2. /Sbin/route add -net 192.168.129.0 netmask 255.255.255.0 dev usb0 These commands are not directly executed by deviced, but are delegated to rndis.service. The reason is to use the already implemented structure (sdbd.service and mtp-response.service). The patch has been split into deviced and libdeivce-node. The rndis.service is in deviced, and the code to run rndis.service is in libdevice-node. Connected patch: "Support USB tethering" commit on libdevice-node. Change-Id: I9fdc8424c94ee1f7e29a9a2cc37958d24373d74c --- CMakeLists.txt | 1 + packaging/deviced.spec | 1 + systemd/rndis.service | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 systemd/rndis.service diff --git a/CMakeLists.txt b/CMakeLists.txt index b60f1aa..10f7bb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,6 +284,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/org.tizen.system.deviced.servi INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/deviced.service DESTINATION /usr/lib/systemd/system) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/usb-host-ffs-test-daemon.service DESTINATION /usr/lib/systemd/system) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/usb-host-test.socket DESTINATION /usr/lib/systemd/system) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/rndis.service DESTINATION /usr/lib/systemd/system) IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/usb-host-ffs-test-daemon.service diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 83c8165..97033a8 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -290,6 +290,7 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %config %{_sysconfdir}/deviced/mobile-display.conf %config %{_sysconfdir}/deviced/critical-log.conf %{_libdir}/mobile-display.so +%{_unitdir}/rndis.service %files plugin-profile-wearable %manifest deviced.manifest diff --git a/systemd/rndis.service b/systemd/rndis.service new file mode 100644 index 0000000..747316d --- /dev/null +++ b/systemd/rndis.service @@ -0,0 +1,13 @@ +[Unit] +Description=rndis service + +[Service] +Type=oneshot +User=network_fw +Group=network_fw +SmackProcessLabel=System +ExecStart=/sbin/ifconfig usb0 192.168.129.3 up +ExecStart=/sbin/route add -net 192.168.129.0 netmask 255.255.255.0 dev usb0 +Capabilities=cap_net_admin=i +SecureBits=keep-caps +RemainAfterExit=yes -- 2.7.4 From 7c309dbf26fe2a7f560a5f9adef0b92b97eecb63 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 7 Oct 2019 14:47:29 +0900 Subject: [PATCH 16/16] Fix ASAN build errors [ 288s] CMakeFiles/deviced.dir/src/battery/lowbat-handler.c.o:(.bss+0x140): multiple definition of `old_battery' [ 288s] CMakeFiles/deviced.dir/src/battery/battery-time.c.o:(.bss+0x200): first defined here [ 288s] CMakeFiles/deviced.dir/src/battery/lowbat-handler.c.o: In function `lowbat_initialized': [ 288s] /home/abuild/rpmbuild/BUILD/deviced-5.5.0/src/battery/lowbat-handler.c:102: multiple definition of `battery' [ 288s] CMakeFiles/deviced.dir/src/battery/battery-time.c.o:/home/abuild/rpmbuild/BUILD/deviced-5.5.0/src/battery/battery-time.c:363: first defined here Change-Id: Ibf76f7265dfc1bf41c2b8e72de3dd6ed888ab7fc Signed-off-by: Hyotaek Shim --- plugins/wearable/display/lbm.h | 2 +- src/battery/power-supply.c | 2 ++ src/battery/power-supply.h | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/wearable/display/lbm.h b/plugins/wearable/display/lbm.h index 5b1e319..9401ac6 100644 --- a/plugins/wearable/display/lbm.h +++ b/plugins/wearable/display/lbm.h @@ -38,7 +38,7 @@ struct lbm_config { * Global variables * lbm_conf : configuration of lbm */ -struct lbm_config lbm_conf; +extern struct lbm_config lbm_conf; int lbm_get_state(void); int lbm_set_state(int lbm); diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 33e170f..f375b0a 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -100,6 +100,8 @@ static const struct uevent_handler uh = { .uevent_func = uevent_power_handler, }; +struct battery_status battery; +struct battery_status old_battery; static int noti_id; static int online_status; diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h index 8c62417..cd4d929 100644 --- a/src/battery/power-supply.h +++ b/src/battery/power-supply.h @@ -106,8 +106,8 @@ struct battery_status { char power_source_s[32]; }; -struct battery_status battery; -struct battery_status old_battery; +extern struct battery_status battery; +extern struct battery_status old_battery; int power_supply_broadcast(char *sig, int status); -- 2.7.4