From d7bae4e2de2ca058b681b882466539af876988f9 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 3 Sep 2019 14:17:21 +0900 Subject: [PATCH 01/16] coverity fix Change-Id: Ic355e6fb4419394a443e995875cd818850a4a2c5 Signed-off-by: sanghyeok.oh --- plugins/iot/display/core.c | 6 ++++-- plugins/mobile/display/core.c | 4 +++- plugins/tv/display/core.c | 4 +++- plugins/wearable/display/core.c | 4 +++- src/display/display-dbus.c | 8 ++++++-- src/ir/ir.c | 7 ++++++- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 87ceda1..a93cf4b 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -2809,10 +2809,12 @@ static void display_init(void *data) _I("Start Power managing without noti"); if (power_ops.get_power_lock_support()) { broadcast_pm_wakeup(); - power_ops.power_lock(); + power_ops.power_lock(); } pm_cur_state = S_NORMAL; - vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + ret = vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + if (ret < 0) + _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); status = DEVICE_OPS_STATUS_START; if (display_conf.timeout_enable) { diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 30ca2bd..820aa9e 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -2824,7 +2824,9 @@ static void display_init(void *data) power_ops.power_lock(); } pm_cur_state = S_NORMAL; - vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + ret = vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + if (ret < 0) + _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); status = DEVICE_OPS_STATUS_START; if (display_conf.timeout_enable) { diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index dbd6954..0fa9df0 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -2812,7 +2812,9 @@ static void display_init(void *data) power_ops.power_lock(); } pm_cur_state = S_NORMAL; - vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + ret = vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + if (ret < 0) + _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); status = DEVICE_OPS_STATUS_START; if (display_conf.timeout_enable) { diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index f65f2a1..a72733c 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -2838,7 +2838,9 @@ static void display_init(void *data) power_ops.power_lock(); } pm_cur_state = S_NORMAL; - vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + ret = vconf_set_int(VCONFKEY_PM_STATE, pm_cur_state); + if (ret < 0) + _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); status = DEVICE_OPS_STATUS_START; if (display_conf.timeout_enable) { diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 773825f..d95e557 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -1157,8 +1157,12 @@ static void sim_signal_handler(GDBusConnection *conn, if (val != SIM_CARD_NOT_PRESENT) { state = true; - vconf_set_bool(VCONFKEY_LCD_BRIGHTNESS_INIT, state); - vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, PM_DEFAULT_BRIGHTNESS); + ret = vconf_set_bool(VCONFKEY_LCD_BRIGHTNESS_INIT, state); + if (ret < 0) + _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); + ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, PM_DEFAULT_BRIGHTNESS); + if (ret < 0) + _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); backlight_ops.set_brightness(PM_DEFAULT_BRIGHTNESS); _I("SIM card is inserted at first."); } diff --git a/src/ir/ir.c b/src/ir/ir.c index 3f69d31..1346ac5 100644 --- a/src/ir/ir.c +++ b/src/ir/ir.c @@ -75,6 +75,10 @@ static GVariant *dbus_ir_transmit(GDBusConnection *conn, size = g_variant_iter_n_children(iter); freq_pattern = (int*)malloc(sizeof(int) * size); + if (!freq_pattern) { + ret = -ENOMEM; + goto exit; + } while (g_variant_iter_next(iter, "i", &freq_pattern[i++])) ; @@ -86,7 +90,8 @@ static GVariant *dbus_ir_transmit(GDBusConnection *conn, ret = ir_dev->transmit(freq_pattern, size); exit: - free(freq_pattern); + if (freq_pattern) + free(freq_pattern); return g_variant_new("(i)", ret); } -- 2.7.4 From 969f118ba47bac5443fd048a278c72636148ce90 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 3 Sep 2019 15:14:36 +0900 Subject: [PATCH 02/16] usb-host-test: / remove at end of path CONFIGFS_PATH mount_check does not work properly with / at the end of path. Change-Id: I77700ff4074ce48b047851f7f5f5026ed20ee092 --- src/usb-host-test/usb-host-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb-host-test/usb-host-test.c b/src/usb-host-test/usb-host-test.c index a5ed283..256fd3f 100644 --- a/src/usb-host-test/usb-host-test.c +++ b/src/usb-host-test/usb-host-test.c @@ -41,7 +41,7 @@ #define SYSTEMD_UNIT_NAME "usb-host-test.socket" #define SYSTEMD_SERVICE_NAME "usb-host-ffs-test-daemon.service" #define UDC_NAME "dummy_udc.0" -#define CONFIGFS_PATH "/sys/kernel/config/" +#define CONFIGFS_PATH "/sys/kernel/config" #define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1" #define JOB_MANAGER_INTERFACE "org.freedesktop.systemd1.Manager" -- 2.7.4 From 4918525509e25f6e2e2f174f3fce465f4f9611d6 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 5 Sep 2019 21:25:51 +0900 Subject: [PATCH 03/16] Add SleepSupport field in display.conf Change-Id: I86f09c9fcfe0e1da0ab798242777c8fc5469c702 Signed-off-by: Hyotaek Shim --- plugins/iot/display/core.c | 10 +++++++--- plugins/mobile/display/core.c | 10 +++++++--- plugins/tv/display/core.c | 10 +++++++--- plugins/wearable/display/core.c | 10 +++++++--- src/display/core.h | 1 + 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index a93cf4b..260327d 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -226,7 +226,7 @@ struct display_config display_conf = { .lcdoff_timeout = LCDOFF_TIMEOUT, .brightness_change_step = BRIGHTNESS_CHANGE_STEP, .lcd_always_on = LCD_ALWAYS_ON, - .dimming = 1, + .dimming = 1, .framerate_app = {0, 0, 0, 0}, .control_display = 0, .powerkey_doublepress = 0, @@ -236,8 +236,9 @@ struct display_config display_conf = { .input_support = true, .lockcheck_timeout = 600, .aod_enter_level = 40, - .aod_tsp = true, + .aod_tsp = true, .touch_wakeup = false, + .sleep_support = true, }; struct display_function_info display_info = { @@ -1968,7 +1969,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP) { + if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); @@ -2608,6 +2609,9 @@ static int display_load_config(struct parse_result *result, void *user_data) } else if (MATCH(result->name, "AODTSP")) { c->aod_tsp = (MATCH(result->value, "yes") ? true : false); _D("TSP control at is %d at aod", c->aod_tsp); + } else if (MATCH(result->name, "SleepSupport")) { + c->sleep_support = (MATCH(result->value, "yes") ? true : false); + _D("SleepSupport is %d", c->sleep_support); } return 0; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 820aa9e..af2a4af 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -228,7 +228,7 @@ struct display_config display_conf = { .lcdoff_timeout = LCDOFF_TIMEOUT, .brightness_change_step = BRIGHTNESS_CHANGE_STEP, .lcd_always_on = LCD_ALWAYS_ON, - .dimming = 1, + .dimming = 1, .framerate_app = {0, 0, 0, 0}, .control_display = 0, .powerkey_doublepress = 0, @@ -238,8 +238,9 @@ struct display_config display_conf = { .input_support = true, .lockcheck_timeout = 600, .aod_enter_level = 40, - .aod_tsp = true, + .aod_tsp = true, .touch_wakeup = false, + .sleep_support = true, }; struct display_function_info display_info = { @@ -1980,7 +1981,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP) { + if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); @@ -2620,6 +2621,9 @@ static int display_load_config(struct parse_result *result, void *user_data) } else if (MATCH(result->name, "AODTSP")) { c->aod_tsp = (MATCH(result->value, "yes") ? true : false); _D("TSP control at is %d at aod", c->aod_tsp); + } else if (MATCH(result->name, "SleepSupport")) { + c->sleep_support = (MATCH(result->value, "yes") ? true : false); + _D("SleepSupport is %d", c->sleep_support); } return 0; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 0fa9df0..24bcb4b 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -226,7 +226,7 @@ struct display_config display_conf = { .lcdoff_timeout = LCDOFF_TIMEOUT, .brightness_change_step = BRIGHTNESS_CHANGE_STEP, .lcd_always_on = LCD_ALWAYS_ON, - .dimming = 1, + .dimming = 1, .framerate_app = {0, 0, 0, 0}, .control_display = 0, .powerkey_doublepress = 0, @@ -236,8 +236,9 @@ struct display_config display_conf = { .input_support = true, .lockcheck_timeout = 600, .aod_enter_level = 40, - .aod_tsp = true, + .aod_tsp = true, .touch_wakeup = false, + .sleep_support = true, }; struct display_function_info display_info = { @@ -1968,7 +1969,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP) { + if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); @@ -2608,6 +2609,9 @@ static int display_load_config(struct parse_result *result, void *user_data) } else if (MATCH(result->name, "AODTSP")) { c->aod_tsp = (MATCH(result->value, "yes") ? true : false); _D("TSP control at is %d at aod", c->aod_tsp); + } else if (MATCH(result->name, "SleepSupport")) { + c->sleep_support = (MATCH(result->value, "yes") ? true : false); + _D("SleepSupport is %d", c->sleep_support); } return 0; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index a72733c..1273f43 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -227,7 +227,7 @@ struct display_config display_conf = { .lcdoff_timeout = LCDOFF_TIMEOUT, .brightness_change_step = BRIGHTNESS_CHANGE_STEP, .lcd_always_on = LCD_ALWAYS_ON, - .dimming = 1, + .dimming = 1, .framerate_app = {0, 0, 0, 0}, .control_display = 0, .powerkey_doublepress = 0, @@ -237,8 +237,9 @@ struct display_config display_conf = { .input_support = true, .lockcheck_timeout = 600, .aod_enter_level = 40, - .aod_tsp = true, + .aod_tsp = true, .touch_wakeup = false, + .sleep_support = true, }; struct display_function_info display_info = { @@ -1990,7 +1991,7 @@ static int default_action(int timeout) return -EINVAL; } - if (pm_cur_state != S_SLEEP) { + if (pm_cur_state != S_SLEEP && !(pm_cur_state == S_LCDOFF && display_conf.sleep_support == false)) { if (pm_cur_state == S_NORMAL && lcdon_tv.tv_sec != 0) { gettimeofday(&now_tv, NULL); @@ -2634,6 +2635,9 @@ static int display_load_config(struct parse_result *result, void *user_data) } else if (MATCH(result->name, "AODTSP")) { c->aod_tsp = (MATCH(result->value, "yes") ? true : false); _D("TSP control at is %d at aod", c->aod_tsp); + } else if (MATCH(result->name, "SleepSupport")) { + c->sleep_support = (MATCH(result->value, "yes") ? true : false); + _D("SleepSupport is %d", c->sleep_support); } return 0; diff --git a/src/display/core.h b/src/display/core.h index 166eb2a..6ab0f09 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -140,6 +140,7 @@ struct display_config { bool timeout_enable; bool input_support; bool touch_wakeup; + bool sleep_support; }; /* -- 2.7.4 From 969526a490022ebd78a5013d6c89670e43c18b53 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 9 Sep 2019 11:04:28 +0900 Subject: [PATCH 04/16] Add SleepSupport=no for TV profile Change-Id: I3a637a43ce0aba64b50093b24d4e8a13a7b91f33 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 1 + conf/tv-display.conf | 37 +++++++++++++++++++++++++++++++++++++ packaging/deviced.spec | 2 ++ 3 files changed, 40 insertions(+) create mode 100644 conf/tv-display.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index e68f5bb..cb7cecf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,3 +309,4 @@ ADD_SUBDIRECTORY(plugins/iot/display) INSTALL_CONF(conf display) INSTALL_CONF(conf mobile-display) INSTALL_CONF(conf wearable-display) +INSTALL_CONF(conf tv-display) diff --git a/conf/tv-display.conf b/conf/tv-display.conf new file mode 100644 index 0000000..b289403 --- /dev/null +++ b/conf/tv-display.conf @@ -0,0 +1,37 @@ +[Display] +# deviced is pending lcd on until lock screen shows. +# This is the maximum pending time. +# LockScreenWaitingTime=0.3 (second) + +# Power-off popup is launched when power key is long pressed. +# This is duration of pressing power key. +# LongPressInterval=2 (second) + +# This is polling time of auto brightness. +# LightSensorSamplingInterval=1 (second) + +# display state is changed to SLEEP state after this time. +# If this value is large, it causes power consumption problem. +# LCDOffTimeout=500 (milli second) + +# This is n step of auto brightness. +# If brightness is change from a to b, brightness's changed n times from a to b. +# BrightnessChangeStep=10 + +# Just below application only allow to change display frame rate. +# refer to enum refresh_app +# ChangedFrameRateAllowed=setting (setting or all) +# ControlDisplay=(yes or no) + +# LCD is not turned off when this value is yes and key double pressed +# PowerKeyDoublePressSupport=(yes or no) + +# If this value is yes, LCD is always on except pressing power key. +# Default value is no, LCD is turned off by lcd timeout. +# LCDAlwaysOn=(yes or no) + +# If this value is yes, LCD is turned off by lcd timeout. +# If this value is no, LCD is turned off just by external requests. +# TimeoutEnable=(yes or no) + +SleepSupport=no diff --git a/packaging/deviced.spec b/packaging/deviced.spec index ea01b19..31adc79 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -226,6 +226,7 @@ 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 @@ -302,6 +303,7 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %manifest deviced.manifest %license LICENSE.Apache-2.0 %defattr(-,root,root,-) +%config %{_sysconfdir}/deviced/tv-display.conf %config %{_sysconfdir}/deviced/display.conf %{_libdir}/tv-display.so -- 2.7.4 From bd18592a61029923b321e4464fa8cf3263c8cc20 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 6 Sep 2019 13:15:49 +0900 Subject: [PATCH 05/16] Increase ALWAYS_ON_TIMEOUT from 1 hour to 100 hours Change-Id: I453debda0b4b1b344e0ca491ae0dea43bb089ac5 Signed-off-by: Hyotaek Shim --- plugins/iot/display/core.c | 4 ++-- plugins/mobile/display/core.c | 6 +++--- plugins/tv/display/core.c | 6 +++--- plugins/wearable/display/core.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 260327d..9850915 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -69,7 +69,7 @@ #define SET_BRIGHTNESS_IN_BOOTLOADER "/usr/bin/save_blenv SLP_LCD_BRIGHT" #define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 3600000 +#define ALWAYS_ON_TIMEOUT 360000000 #define LATE_LCD_TRANSIT 1 #define PID_MAX 6 @@ -83,7 +83,7 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -#define METHOD_APP_STATUS "CheckAppStatus" +#define METHOD_APP_STATUS "CheckAppStatus" #define PM_WAKEUP 0 #define PM_SUSPEND 1 diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index af2a4af..4a54229 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -71,8 +71,8 @@ #define SET_BRIGHTNESS_IN_BOOTLOADER "/usr/bin/save_blenv SLP_LCD_BRIGHT" #define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 3600000 -#define LATE_LCD_TRANSIT 1 +#define ALWAYS_ON_TIMEOUT 360000000 +#define LATE_LCD_TRANSIT 1 #define PID_MAX 6 @@ -85,7 +85,7 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -#define METHOD_APP_STATUS "CheckAppStatus" +#define METHOD_APP_STATUS "CheckAppStatus" #define PM_WAKEUP 0 #define PM_SUSPEND 1 diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 24bcb4b..4730754 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -69,8 +69,8 @@ #define SET_BRIGHTNESS_IN_BOOTLOADER "/usr/bin/save_blenv SLP_LCD_BRIGHT" #define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 3600000 -#define LATE_LCD_TRANSIT 1 +#define ALWAYS_ON_TIMEOUT 360000000 +#define LATE_LCD_TRANSIT 1 #define PID_MAX 6 @@ -83,7 +83,7 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -#define METHOD_APP_STATUS "CheckAppStatus" +#define METHOD_APP_STATUS "CheckAppStatus" #define PM_WAKEUP 0 #define PM_SUSPEND 1 diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 1273f43..c098a56 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -70,8 +70,8 @@ #define SET_BRIGHTNESS_IN_BOOTLOADER "/usr/bin/save_blenv SLP_LCD_BRIGHT" #define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 3600000 -#define LATE_LCD_TRANSIT 1 +#define ALWAYS_ON_TIMEOUT 360000000 +#define LATE_LCD_TRANSIT 1 #define PID_MAX 6 @@ -84,7 +84,7 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -#define METHOD_APP_STATUS "CheckAppStatus" +#define METHOD_APP_STATUS "CheckAppStatus" #define PM_WAKEUP 0 #define PM_SUSPEND 1 -- 2.7.4 From c1468c6d717784703b5ae1affa79995f376a97e6 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 9 Sep 2019 11:36:01 +0900 Subject: [PATCH 06/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 07/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 08/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 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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