From d8702488cb1fa4cf5e8f6f85133f8bae5e0cbd26 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Thu, 10 Sep 2020 17:26:16 +0900 Subject: [PATCH 01/16] Fix battery link error when battery module is off - When battery_module option is off, there is link error about undefined function. - Get battery reference by battery plugin handle. Change-Id: I4b8649c98d52617bd98f97cfd37f52a355a1d565 Signed-off-by: Yunmi Ha --- plugins/iot/display/core.c | 20 ++++++++++++++++---- plugins/mobile/display/core.c | 20 ++++++++++++++++---- plugins/tv/display/core.c | 20 ++++++++++++++++---- plugins/wearable/display/core.c | 20 ++++++++++++++++---- plugins/wearable/display/device-interface.c | 27 ++++++++++++++++++++------- src/shared/plugin.c | 4 ++-- 6 files changed, 86 insertions(+), 25 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index b8aa6ee..f6b0c98 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -88,11 +89,12 @@ #define PM_SUSPEND 1 extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -1768,7 +1770,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2062,6 +2064,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2364,13 +2373,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** * @} diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 66f7bce..f7b3b4f 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -90,11 +91,12 @@ #define PM_SUSPEND 1 extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -1779,7 +1781,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2073,6 +2075,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2380,13 +2389,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** * @} diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 2db8f62..6ab5af1 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -88,11 +89,12 @@ #define PM_SUSPEND 1 extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -1769,7 +1771,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2064,6 +2066,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2366,13 +2375,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** * @} diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 6ba132b..586063a 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -96,11 +97,12 @@ #define UNKNOWN_STR "unknown" extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -2050,7 +2052,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2369,6 +2371,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2715,13 +2724,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index c803437..16f2257 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -47,6 +47,7 @@ #include "battery-monitor.h" #include "battery/power-supply.h" #include "power/power-control.h" +#include "shared/plugin.h" #define TOUCH_ON 1 #define TOUCH_OFF 0 @@ -73,6 +74,7 @@ static struct _backlight_ops backlight_ops; +static struct battery_plugin *battery_plgn; static bool custom_status; static int custom_brightness; static int force_brightness; @@ -85,6 +87,8 @@ static int aod_normal_level = -1; static int aod_min_level = -1; static int aod_charging_level = -1; static struct display_config *display_conf; +static struct battery_status *battery = NULL; +static struct battery_status* (*fp_get_var_battery_status)(void); inline struct _backlight_ops *get_backlight_ops(void) { @@ -647,11 +651,6 @@ static int backlight_transit_state(int state) int brt, val; int start, end; static int aod_brightness_level; - struct battery_status *battery = get_var_battery_status(); - if (!battery) { - _E("Failed to get battery status structure."); - return -EINVAL; - } backlight_ops.get_brightness(&brt); @@ -697,7 +696,7 @@ static int backlight_transit_state(int state) return 0; } - if (battery->charge_now == CHARGER_CHARGING) { + if (battery && battery->charge_now == CHARGER_CHARGING) { if (aod_charging_level > 0 && val >= aod_charging_level) aod_brightness_level = aod_charging_level; else if (aod_min_level > 0 && val >= aod_min_level) @@ -894,6 +893,17 @@ int init_sysfs(unsigned int flags) { register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); + if (battery_plgn->handle) { + fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); + if (fp_get_var_battery_status) { + battery = fp_get_var_battery_status(); + if (!battery) + _E("Failed to get battery status."); + } else + _E("Failed to obtain address of get_var_battery_status, %s.", dlerror()); + } else + _I("There is no battery module."); + return 0; } @@ -923,5 +933,8 @@ static void __CONSTRUCTOR__ initialize(void) display_conf = get_display_config(); if (!display_conf) _E("Failed to get display configuration."); -} + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); +} diff --git a/src/shared/plugin.c b/src/shared/plugin.c index d93087c..1df0e0a 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -112,9 +112,9 @@ void load_plugins() if (!load_plugin(ent->d_name, &handle)) { _I("Plugin(%s) is loaded. handle=%#x", ent->d_name, (unsigned int)((intptr_t)handle)); plgn_list = g_list_append(plgn_list, handle); - if (!strcmp(ent->d_name, "display")) + if (!strcmp(ent->d_name, "display.so")) disp_plgn.handle = handle; - else if (!strcmp(ent->d_name, "battery")) + else if (!strcmp(ent->d_name, "battery.so")) battery_plgn.handle = handle; } } -- 2.7.4 From e52d0afb372cf7d1d1f6be8f58afb38fe12ab202 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Mon, 14 Sep 2020 16:11:28 +0900 Subject: [PATCH 02/16] Replace function name to get variable pointer Change-Id: I8c057e2cf393636fcf439b0a6f9d62f5e7254992 Signed-off-by: Yunmi Ha --- plugins/iot/display/core.c | 14 ++-- plugins/iot/display/device-interface.c | 6 +- plugins/iot/display/key-filter.c | 12 ++-- plugins/mobile/battery/battery-notification.c | 4 +- plugins/mobile/display/core.c | 14 ++-- plugins/mobile/display/device-interface.c | 6 +- plugins/mobile/display/key-filter.c | 12 ++-- plugins/tv/display/core.c | 14 ++-- plugins/tv/display/device-interface.c | 6 +- plugins/tv/display/key-filter.c | 12 ++-- plugins/tv/display/state-tv.c | 11 ++- .../wearable/display/auto-brightness-sensorhub.c | 15 ++--- plugins/wearable/display/bezel.c | 7 +- plugins/wearable/display/core.c | 14 ++-- plugins/wearable/display/device-interface.c | 10 +-- plugins/wearable/display/display-handler.c | 4 +- plugins/wearable/display/enhance.c | 4 +- plugins/wearable/display/key-filter.c | 15 ++--- plugins/wearable/display/lbm.c | 4 +- plugins/wearable/display/powersaver.c | 4 +- plugins/wearable/display/swim.c | 11 ++- src/apps/apps.c | 7 +- src/battery/battery-time.c | 7 +- src/battery/lowbat-handler.c | 10 +-- src/battery/power-supply.c | 15 ++--- src/display/ambient-mode.c | 11 ++- src/display/auto-brightness.c | 8 +-- src/display/core.h | 2 +- src/display/device-interface.h | 2 +- src/display/display-dbus.c | 12 ++-- src/display/display-lock.c | 8 +-- src/display/display-signal.c | 7 +- src/display/input.c | 4 +- src/display/poll.c | 7 +- src/display/setting.c | 8 +-- src/extcon/cradle.c | 7 +- src/extcon/earjack.c | 7 +- src/extcon/hdmi.c | 7 +- src/led/touch-key.c | 7 +- src/power/boot.c | 7 +- src/power/power-handler.c | 7 +- src/shared/plugin.c | 4 +- src/shared/plugin.h | 4 +- src/time/time-handler.c | 7 +- src/touchscreen/touchscreen.c | 78 +++++++++++----------- src/usb/usb.c | 7 +- src/usbhost/usb-host.c | 7 +- 47 files changed, 216 insertions(+), 240 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index f6b0c98..6929c89 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -211,7 +211,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config* get_display_config() +inline struct display_config* get_var_display_config() { return &display_conf; } @@ -2372,17 +2372,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** * @} diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index 64e4f1e..eba4550 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -78,7 +78,7 @@ static struct display_device *display_dev; static guint release_timer; static struct display_config *display_conf; -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -841,8 +841,8 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/plugins/iot/display/key-filter.c b/plugins/iot/display/key-filter.c index 29d7de2..11821a6 100644 --- a/plugins/iot/display/key-filter.c +++ b/plugins/iot/display/key-filter.c @@ -432,9 +432,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -799,12 +799,12 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index 6b9c4b4..459f455 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -410,9 +410,9 @@ BATTERY_OPS_REGISTER(&battery_notification_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); battery = get_var_battery_status(); if (!battery) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index f7b3b4f..7d4c64b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -214,7 +214,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config* get_display_config() +inline struct display_config* get_var_display_config() { return &display_conf; } @@ -2388,17 +2388,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** * @} diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 9b37f8b..80b1d01 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -77,7 +77,7 @@ static struct display_device *display_dev; static guint release_timer; static struct display_config *display_conf; -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -856,8 +856,8 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 4aead39..7998b16 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -452,9 +452,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -826,12 +826,12 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 6ab5af1..1e1c176 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -212,7 +212,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config* get_display_config() +inline struct display_config* get_var_display_config() { return &display_conf; } @@ -2374,17 +2374,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** * @} diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 469b793..e7ab4df 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -78,7 +78,7 @@ static struct display_device *display_dev; static guint release_timer; static struct display_config *display_conf; -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -842,8 +842,8 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 24757b2..b28d7ec 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -432,9 +432,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if(!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -793,12 +793,12 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/tv/display/state-tv.c b/plugins/tv/display/state-tv.c index 3ce57d6..ceb85d0 100644 --- a/plugins/tv/display/state-tv.c +++ b/plugins/tv/display/state-tv.c @@ -571,12 +571,11 @@ void state_tv_deinit(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/auto-brightness-sensorhub.c b/plugins/wearable/display/auto-brightness-sensorhub.c index e5a5004..ee7ef57 100644 --- a/plugins/wearable/display/auto-brightness-sensorhub.c +++ b/plugins/wearable/display/auto-brightness-sensorhub.c @@ -43,9 +43,9 @@ static bool lbm, hbm, hold_brt, lowdim; static void change_brightness_transit(int start, int end) { - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if(!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ; } backlight_ops->transit_brt(start, end, @@ -373,12 +373,11 @@ void exit_level_handler(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/bezel.c b/plugins/wearable/display/bezel.c index bb22d8f..87bd336 100644 --- a/plugins/wearable/display/bezel.c +++ b/plugins/wearable/display/bezel.c @@ -318,8 +318,7 @@ DEVICE_OPS_REGISTER(&bezel_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 586063a..7e92237 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -234,7 +234,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config *get_display_config() +inline struct display_config *get_var_display_config() { return &display_conf; } @@ -2723,17 +2723,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 16f2257..2e5351c 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -90,7 +90,7 @@ static struct display_config *display_conf; static struct battery_status *battery = NULL; static struct battery_status* (*fp_get_var_battery_status)(void); -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -930,11 +930,11 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c index 27b97a8..ed2e9ba 100644 --- a/plugins/wearable/display/display-handler.c +++ b/plugins/wearable/display/display-handler.c @@ -224,7 +224,7 @@ DISPLAY_OPS_REGISTER(&display_handler_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/enhance.c b/plugins/wearable/display/enhance.c index 9fb32ea..0ac0b64 100644 --- a/plugins/wearable/display/enhance.c +++ b/plugins/wearable/display/enhance.c @@ -169,7 +169,7 @@ DISPLAY_OPS_REGISTER(&display_enhance_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 3cf379f..32691f8 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -429,9 +429,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -773,12 +773,11 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/lbm.c b/plugins/wearable/display/lbm.c index 79ec7cd..e10b09c 100644 --- a/plugins/wearable/display/lbm.c +++ b/plugins/wearable/display/lbm.c @@ -344,7 +344,7 @@ DISPLAY_OPS_REGISTER(&display_lbm_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/powersaver.c b/plugins/wearable/display/powersaver.c index 785acfa..e4ef88b 100644 --- a/plugins/wearable/display/powersaver.c +++ b/plugins/wearable/display/powersaver.c @@ -158,7 +158,7 @@ DEVICE_OPS_REGISTER(&powersaver_device_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index 2b093dc..eab5f88 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -141,12 +141,11 @@ DEVICE_OPS_REGISTER(&swim_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/src/apps/apps.c b/src/apps/apps.c index a192797..1debfa6 100644 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -175,8 +175,7 @@ int remove_notification(char *type, int id) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index eb61816..712824a 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -441,8 +441,7 @@ DEVICE_OPS_REGISTER(&battery_time_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index e0829b4..c8bb7c1 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -780,15 +780,15 @@ DEVICE_OPS_REGISTER(&lowbat_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); battery = get_var_battery_status(); if (!battery) - _E("Failed to get battery status structure."); + _E("Failed to get battery status structure variable."); } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 34722aa..c5109c5 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -1742,14 +1742,11 @@ DEVICE_OPS_REGISTER(&power_supply_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - battery_plgn = get_battery_plugin(); - if (!battery_plgn) { - _E("Failed to get battery plugin."); - } + battery_plgn = get_var_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin variable."); } - diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index 0e5e478..fdf58e4 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -307,12 +307,11 @@ DISPLAY_OPS_REGISTER(&ambient_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/src/display/auto-brightness.c b/src/display/auto-brightness.c index e8b1621..ac72807 100644 --- a/src/display/auto-brightness.c +++ b/src/display/auto-brightness.c @@ -684,11 +684,11 @@ DISPLAY_OPS_REGISTER(&display_autobrightness_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/src/display/core.h b/src/display/core.h index 5bfb1d1..00c3e27 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -145,7 +145,7 @@ struct display_config { * Global variables * display_conf : configuration of display */ -struct display_config* get_display_config(); +struct display_config* get_var_display_config(); /* * @brief Display Extension features diff --git a/src/display/device-interface.h b/src/display/device-interface.h index dec91c9..97121e3 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -91,7 +91,7 @@ struct _backlight_ops { void (*release_blink)(void); }; -struct _backlight_ops *get_backlight_ops(void); +struct _backlight_ops *get_var_backlight_ops(void); enum dpms_state { DPMS_ON, /* In use */ diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index e56c7f3..b8bf593 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -614,9 +614,9 @@ static GVariant *dbus_setrefreshrate(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int app, val, ret, control; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); ret = -EINVAL; goto error; } @@ -1307,12 +1307,12 @@ int init_pm_dbus(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/src/display/display-lock.c b/src/display/display-lock.c index b0d2568..6f04ec6 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -399,12 +399,12 @@ dd_list *get_cond_head(enum state_t s_index) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display config."); + _E("Failed to get display config variable."); } } diff --git a/src/display/display-signal.c b/src/display/display-signal.c index cf2cf83..67c3877 100644 --- a/src/display/display-signal.c +++ b/src/display/display-signal.c @@ -176,8 +176,7 @@ void set_process_active(bool flag, pid_t pid) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/display/input.c b/src/display/input.c index b985652..e372058 100644 --- a/src/display/input.c +++ b/src/display/input.c @@ -44,9 +44,9 @@ static inline void process_event(struct libinput_event *ev) struct libinput_event_keyboard *k; unsigned int time; int fd = 0; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if(!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return; } diff --git a/src/display/poll.c b/src/display/poll.c index c8a4a59..0e3ab28 100644 --- a/src/display/poll.c +++ b/src/display/poll.c @@ -184,8 +184,7 @@ void init_pm_internal() static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/display/setting.c b/src/display/setting.c index e493c7f..0b0ebb2 100644 --- a/src/display/setting.c +++ b/src/display/setting.c @@ -278,12 +278,12 @@ int exit_setting(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 1eeffa1..382dcde 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -148,8 +148,7 @@ EXTCON_OPS_REGISTER(cradle_extcon_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 1fb99c2..0b89fb5 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -97,8 +97,7 @@ EXTCON_OPS_REGISTER(earjack_extcon_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 6f38b31..c2cc3af 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -196,8 +196,7 @@ EXTCON_OPS_REGISTER(hdmi_extcon_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/led/touch-key.c b/src/led/touch-key.c index 6f679be..b5a4484 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -330,8 +330,7 @@ DEVICE_OPS_REGISTER(&touchled_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/power/boot.c b/src/power/boot.c index 24fc3ea..e49ca75 100644 --- a/src/power/boot.c +++ b/src/power/boot.c @@ -116,8 +116,7 @@ void add_booting_done_handler(void *data) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/power/power-handler.c b/src/power/power-handler.c index c00b17f..0a672c7 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -782,8 +782,7 @@ DEVICE_OPS_REGISTER(&power_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/shared/plugin.c b/src/shared/plugin.c index 1df0e0a..fc9b17b 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -43,12 +43,12 @@ static struct display_plugin disp_plgn; static struct battery_plugin battery_plgn; static GList *plgn_list; -inline struct display_plugin *get_display_plugin(void) +inline struct display_plugin *get_var_display_plugin(void) { return &disp_plgn; } -inline struct battery_plugin *get_battery_plugin(void) +inline struct battery_plugin *get_var_battery_plugin(void) { return &battery_plgn; } diff --git a/src/shared/plugin.h b/src/shared/plugin.h index 6eeb9d7..b79b690 100644 --- a/src/shared/plugin.h +++ b/src/shared/plugin.h @@ -22,8 +22,8 @@ #include "display/display-ops.h" #include "battery/battery-ops.h" -struct display_plugin *get_display_plugin(void); -struct battery_plugin *get_battery_plugin(void); +struct display_plugin *get_var_display_plugin(void); +struct battery_plugin *get_var_battery_plugin(void); int load_plugin(const char *id, void **h); int unload_plugin(void *h); diff --git a/src/time/time-handler.c b/src/time/time-handler.c index bac2374..9647f10 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -413,8 +413,7 @@ DEVICE_OPS_REGISTER(&time_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index b592bad..e3d2231 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -48,26 +48,26 @@ static int touchscreen_stop(enum device_flags flags); static int booting_done(void *data); -static struct display_config *_display_conf; -static struct _backlight_ops *_backlight_ops; +static struct display_config *display_conf; +static struct _backlight_ops *backlight_ops; static struct battery_status *battery = NULL; -static struct _backlight_ops* (*_get_var_backlight_ops)(void); -static struct display_config* (*_get_var_display_config)(void); -static struct battery_status* (*_get_var_battery_status)(void); +static struct _backlight_ops* (*fp_get_var_backlight_ops)(void); +static struct display_config* (*fp_get_var_display_config)(void); +static struct battery_status* (*fp_get_var_battery_status)(void); static void touchscreen_wakeup_status(keynode_t *key, void *data) { if (!key) return; - if (!_display_conf || !_backlight_ops) + if (!display_conf || !backlight_ops) return; - _display_conf->touch_wakeup = vconf_keynode_get_bool(key); + display_conf->touch_wakeup = vconf_keynode_get_bool(key); - if (_backlight_ops->get_lcd_power() != DPMS_ON) { - if (_display_conf->touch_wakeup) + if (backlight_ops->get_lcd_power() != DPMS_ON) { + if (display_conf->touch_wakeup) touchscreen_start(NORMAL_MODE); else touchscreen_stop(TOUCH_SCREEN_OFF_MODE); @@ -192,7 +192,7 @@ static int touchscreen_start(enum device_flags flags) if (touchscreen_enable != DEVICE_OPS_STATUS_START) return 0; - if (!_backlight_ops || !_backlight_ops->get_lcd_power) + if (!backlight_ops || !backlight_ops->get_lcd_power) return -ENOTSUP; /* Do not enable touchscreen during silent boot mode */ @@ -204,7 +204,7 @@ static int touchscreen_start(enum device_flags flags) */ ret = touchscreen_set_state(TOUCHSCREEN_ON); - state = _backlight_ops->get_lcd_power(); + state = backlight_ops->get_lcd_power(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); @@ -216,7 +216,7 @@ static int touchscreen_start(enum device_flags flags) static int touchscreen_stop(enum device_flags flags) { - if (!_display_conf || !_backlight_ops) { + if (!display_conf || !backlight_ops) { _I("Touchscreen is not initialized."); goto exit; } @@ -241,7 +241,7 @@ static int touchscreen_stop(enum device_flags flags) return touchscreen_powersaving(POWERSAVING_ON); } - if (_display_conf->touch_wakeup) { + if (display_conf->touch_wakeup) { _I("Touch wakeup enabled."); return touchscreen_powersaving(POWERSAVING_ON); } @@ -320,32 +320,32 @@ static void touchscreen_init(void *data) { int ret, val; - _get_var_display_config = dlsym(disp_plgn->handle, "get_display_config"); - if (_get_var_display_config) { - _display_conf = _get_var_display_config(); - if (!_display_conf) - _E("Failed to get display config."); + fp_get_var_display_config = dlsym(disp_plgn->handle, "get_var_display_config"); + if (fp_get_var_display_config) { + display_conf = fp_get_var_display_config(); + if (!display_conf) + _E("Failed to get display config variable."); } else - _E("Failed to obtain address of get_display_config, %s.", dlerror()); + _E("Failed to obtain address of get_var_display_config, %s.", dlerror()); /* 'backlight_ops' is declared static and used a lot of places with same name. * So it fails that fetching symbol directly with name 'backlight_ops'. - * To avoid this, fetches getter function 'get_backlight_ops' instead, and + * To avoid this, fetches getter function 'get_var_backlight_ops' instead, and * retrieve the 'backlight_ops' by using it */ - _get_var_backlight_ops = dlsym(disp_plgn->handle, "get_backlight_ops"); - if (_get_var_backlight_ops) { - _backlight_ops = _get_var_backlight_ops(); - if (!_backlight_ops) - _E("Failed to get backlight operator."); + fp_get_var_backlight_ops = dlsym(disp_plgn->handle, "get_var_backlight_ops"); + if (fp_get_var_backlight_ops) { + backlight_ops = fp_get_var_backlight_ops(); + if (!backlight_ops) + _E("Failed to get backlight operator variable."); } else - _E("Failed to obtain address of get_backlight_ops, %s.", dlerror()); + _E("Failed to obtain address of get_var_backlight_ops, %s.", dlerror()); if (battery_plgn->handle) { - _get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); - if (_get_var_battery_status) { - battery = _get_var_battery_status(); + fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); + if (fp_get_var_battery_status) { + battery = fp_get_var_battery_status(); if (!battery) - _E("Failed to get battery status."); + _E("Failed to get battery status variable"); } else _E("Failed to obtain address of get_var_battery_status, %s.", dlerror()); } else @@ -364,8 +364,8 @@ static void touchscreen_init(void *data) vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_WAKEUP_ENABLE, touchscreen_wakeup_status, NULL); ret = vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_WAKEUP_ENABLE, &val); - if (_display_conf && ret == 0) - _display_conf->touch_wakeup = val; + if (display_conf && ret == 0) + display_conf->touch_wakeup = val; ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_TOUCH, &dbus_interface); @@ -391,13 +391,11 @@ DEVICE_OPS_REGISTER(&touchscreen_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - battery_plgn = get_battery_plugin(); - if (!battery_plgn) { - _E("Failed to get battery plugin."); - } + battery_plgn = get_var_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin variable."); } diff --git a/src/usb/usb.c b/src/usb/usb.c index 0b24297..407edde 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -500,8 +500,7 @@ EXTCON_OPS_REGISTER(extcon_usb_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 91a5cf1..83dacf3 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -1207,8 +1207,7 @@ EXTCON_OPS_REGISTER(extcon_usbhost_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } -- 2.7.4 From 07bdb759b74a30a7a2a54ce03bab638a81173a72 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 15 Sep 2020 18:52:18 +0900 Subject: [PATCH 03/16] Deduplicate below functions ex) update_lock_timer process_background process_foreground Change-Id: I396f02f04943a27134c6b7a708f65d386c97edec Signed-off-by: lokilee73 --- plugins/iot/display/core.c | 48 ----------------------------------------- plugins/mobile/display/core.c | 48 ----------------------------------------- plugins/tv/display/core.c | 48 ----------------------------------------- plugins/wearable/display/core.c | 48 ----------------------------------------- src/display/display-lock.c | 48 +++++++++++++++++++++++++++++++++++++++++ src/display/display-lock.h | 3 +++ 6 files changed, 51 insertions(+), 192 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 6929c89..66d5169 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -967,22 +967,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -1953,38 +1937,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 7d4c64b..9ccf78b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -979,22 +979,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -1964,38 +1948,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 1e1c176..6f3667a 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -968,22 +968,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -1954,38 +1938,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 7e92237..8fc8ab3 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1225,22 +1225,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -2239,38 +2223,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/src/display/display-lock.c b/src/display/display-lock.c index 6f04ec6..f97b973 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -397,6 +397,54 @@ dd_list *get_cond_head(enum state_t s_index) return cond_head[s_index]; } +int process_background(void *data) +{ + pid_t pid; + PmLockNode *node; + + pid = *(pid_t *)data; + + node = find_node(S_NORMAL, pid); + if (node) { + node->background = true; + _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); + } + + return 0; +} + +int process_foreground(void *data) +{ + pid_t pid; + PmLockNode *node; + + pid = *(pid_t *)data; + + node = find_node(S_NORMAL, pid); + if (node) { + node->background = false; + _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); + } + + return 0; +} + +/* update transition condition for application requrements */ +void update_lock_timer(PMMsg *data, + PmLockNode *node, guint timeout_id) +{ + time_t now; + + if (data->timeout > 0) { + time(&now); + node->time = now; + } + + if (node->timeout_id) + g_source_remove(node->timeout_id); + node->timeout_id = timeout_id; +} + static void __CONSTRUCTOR__ initialize(void) { backlight_ops = get_var_backlight_ops(); diff --git a/src/display/display-lock.h b/src/display/display-lock.h index c52ac84..42c1853 100644 --- a/src/display/display-lock.h +++ b/src/display/display-lock.h @@ -62,6 +62,9 @@ void makeup_trans_condition(void); int check_processes(enum state_t prohibit_state); int get_trans_condition(void); dd_list *get_cond_head(enum state_t s_index); +int process_background(void *data); +int process_foreground(void *data); +void update_lock_timer(PMMsg *data, PmLockNode *node, guint timeout_id); extern int custom_holdkey_block; -- 2.7.4 From ed7715c95e96795ae169313e01007844e7ea265e Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 16 Sep 2020 20:16:20 +0900 Subject: [PATCH 04/16] Remove unused function ciritical_log ex) CRITICAL_LOG is used instead of critical_log Change-Id: Ib47f59e9d3425cd877f978286c4da3501bdb4866 Signed-off-by: lokilee73 --- src/core/device-notifier.c | 1 - src/core/device-notifier.h | 1 - src/core/log.c | 12 ------------ src/core/log.h | 3 --- 4 files changed, 17 deletions(-) diff --git a/src/core/device-notifier.c b/src/core/device-notifier.c index db104be..3f8d1b6 100644 --- a/src/core/device-notifier.c +++ b/src/core/device-notifier.c @@ -76,7 +76,6 @@ static const char *device_notifier_type_str[DEVICE_NOTIFIER_MAX] = { NOTIFY_STR(DEVICE_NOTIFIER_UPSM_OFF), NOTIFY_STR(DEVICE_NOTIFIER_BEZEL_WAKEUP), NOTIFY_STR(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS), - NOTIFY_STR(DEVICE_NOTIFIER_CRITICAL_LOG), NOTIFY_STR(DEVICE_NOTIFIER_ULTRAPOWERSAVING), }; diff --git a/src/core/device-notifier.h b/src/core/device-notifier.h index 98fca83..6362a82 100644 --- a/src/core/device-notifier.h +++ b/src/core/device-notifier.h @@ -59,7 +59,6 @@ enum device_notifier_type { DEVICE_NOTIFIER_BEZEL_WAKEUP, DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, DEVICE_NOTIFIER_ULTRAPOWERSAVING, - DEVICE_NOTIFIER_CRITICAL_LOG, DEVICE_NOTIFIER_EXTCON_COUNT, DEVICE_NOTIFIER_MAX, }; diff --git a/src/core/log.c b/src/core/log.c index 679eee8..fe0d3bf 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -39,15 +39,3 @@ void __cyg_profile_func_exit(void *func, void *caller) g_trace_depth--; } #endif - -void critical_log_internal(const char *func, const char *fmt, ...) -{ - va_list ap; - char buf[256]; - - va_start(ap, fmt); - vsnprintf(buf, 256, fmt, ap); - va_end(ap); - _I("%s:%s", func, buf); - device_notify(DEVICE_NOTIFIER_CRITICAL_LOG, (void *)buf); -} diff --git a/src/core/log.h b/src/core/log.h index 60c363e..395ab0e 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -39,6 +39,3 @@ #define __stringify_1(x...) #x #define __stringify(x...) __stringify_1(x) -void critical_log_internal(const char *caller, const char *fmt, ...); - -#define critical_log(fmt, arg...) critical_log_internal(__func__, fmt, ##arg) -- 2.7.4 From 49cf791bc4fce10046dab4cd1819a8e089742254 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 21 Sep 2020 20:55:01 +0900 Subject: [PATCH 05/16] Add logs to get pid information for below functions. ex) dbus_changestatebyreason dbus_customlcdon dbus_customlcdoff dbus_setbrightness dbus_holdbrightness dbus_releasebrightness dbus_lcdpaneloffmode dbus_dimstay_control dbus_staytouchscreenoff Change-Id: I3e692a5b2a407df04ec6e9aeab2f596b88fb7590 Signed-off-by: lokilee73 --- src/display/display-dbus.c | 63 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index b8bf593..bd0f59d 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -418,6 +418,7 @@ static GVariant *dbus_setbrightness(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int state, brt, autobrt, ret = 0, caps; + pid_t pid; caps = display_get_caps(DISPLAY_ACTOR_API); @@ -474,7 +475,8 @@ static GVariant *dbus_setbrightness(GDBusConnection *conn, } else ret = -EINVAL; - _I("set brightness %d, %d", brt, ret); + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Set brightness pid=%d brt=%d ret=%d", pid, brt, ret); error: return g_variant_new("(i)", ret); @@ -485,6 +487,7 @@ static GVariant *dbus_holdbrightness(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int brt, autobrt, ret, caps; + pid_t pid; caps = display_get_caps(DISPLAY_ACTOR_API); @@ -527,7 +530,8 @@ static GVariant *dbus_holdbrightness(GDBusConnection *conn, _E("Failed to set vconf value for automatic brightness: %d", vconf_get_ext_errno()); } - _I("hold brightness %d, %d", brt, ret); + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Hold brightness pid=%d brt=%d ret=%d", pid, brt, ret); error: return g_variant_new("(i)", ret); @@ -538,6 +542,10 @@ static GVariant *dbus_releasebrightness(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int bat, charger, changed, setting, brt, autobrt, ret = 0; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Release brightness pid=%d", pid); ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat); if (ret < 0) { @@ -816,6 +824,10 @@ static GVariant *dbus_customlcdon(GDBusConnection *conn, { int ret = 0; int timeout, lcdon_blocked; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Change state to S_LCDON pid=%d", pid); g_variant_get(param, "(i)", &timeout); @@ -836,7 +848,11 @@ static GVariant *dbus_customlcdoff(GDBusConnection *conn, { int ret = 0; enum device_flags flag; - char *reason_str; + char *reason_str = NULL; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Change state to S_LCDOFF pid=%d", pid); g_variant_get(param, "(s)", &reason_str); @@ -864,16 +880,27 @@ static GVariant *dbus_changestatebyreason(GDBusConnection *conn, { int ret = 0; int next_state, timeout; - char *reason; + char *reason = NULL, *state = NULL; + pid_t pid; g_variant_get(param, "(isi)", &next_state, &reason, &timeout); - if (next_state == DISPLAY_STATE_NORMAL) + if (next_state == DISPLAY_STATE_NORMAL) { + state = "S_LCDON"; ret = display_on_by_reason(reason, timeout); - else if (next_state == DISPLAY_STATE_SCREEN_OFF) + } else if (next_state == DISPLAY_STATE_SCREEN_OFF) { + state = "S_LCDOFF"; ret = display_off_by_reason(reason); - else + } else if (next_state == DISPLAY_STATE_SCREEN_DIM) { + state = "S_LCDDIM"; + ret = -EINVAL; + } else { + state = "unknown"; ret = -EINVAL; + } + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Change state pid=%d state=%s reason=%s ret=%d", pid, state, reason, ret); g_free(reason); return g_variant_new("(i)", ret); @@ -885,6 +912,10 @@ static GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, { int ret = 0; int val; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Stay touchscreen off pid=%d", pid); g_variant_get(param, "(i)", &val); @@ -899,6 +930,10 @@ static GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, { int ret = 0; int val; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Set lcd panel off mode pid=%d", pid); g_variant_get(param, "(i)", &val); @@ -1145,27 +1180,31 @@ static GVariant *dbus_dimstay_control(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int dimstay; + int dimstay, ret = 0; + pid_t pid; g_variant_get(param, "(i)", &dimstay); if (dimstay < 0) { _E("Invalid dimstay set value %d.", dimstay); - return g_variant_new("(i)", -EINVAL); + ret = -EINVAL; + goto out; } + pid = dbus_connection_get_sender_pid(conn, sender); if (dimstay) { - _I("Set DIM_FLAG."); + _I("Set DIM_FLAG pid=%d", pid); set_pm_status_flag(DIM_FLAG); } else { - _I("Unset DIM_FLAG."); + _I("Unset DIM_FLAG pid=%d", pid); clear_pm_status_flag(DIM_FLAG); } if (get_pm_cur_state() == S_NORMAL) backlight_ops->update(); - return g_variant_new("(i)", 0); +out: + return g_variant_new("(i)", ret); } static GVariant *dbus_getbrightnessinfo(GDBusConnection *conn, -- 2.7.4 From 2b68b75d3e98c80dab1f2a8185b7bb7ce694de23 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 29 Sep 2020 16:59:38 +0900 Subject: [PATCH 06/16] Add S_LCDDIM in process_background and process_foreground S_NORMAL is affected by signal, AppStatusChange. ex) lock status of process with the signal node->background: true, LOCK is ignored node->background: false, LOCK is valid Add S_LCDDIM to make it controlled by AppStatusChange as well. Change-Id: I4f97a07c39bc58c8599a8dae68601849bff12791 Signed-off-by: lokilee73 --- src/display/display-lock.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/display/display-lock.c b/src/display/display-lock.c index f97b973..c7d88c7 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -407,7 +407,13 @@ int process_background(void *data) node = find_node(S_NORMAL, pid); if (node) { node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); + _I("Process(%d) goes background. LCD_NORMAL will be unlocked.", pid); + } + + node = find_node(S_LCDDIM, pid); + if (node) { + node->background = true; + _I("Process(%d) goes background. LCD_DIM will be unlocked.", pid); } return 0; @@ -423,7 +429,13 @@ int process_foreground(void *data) node = find_node(S_NORMAL, pid); if (node) { node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); + _I("Process(%d) goes foreground. LCD_NORMAL will be locked.", pid); + } + + node = find_node(S_LCDDIM, pid); + if (node) { + node->background = false; + _I("Process(%d) goes foreground. LCD_DIM will be locked.", pid); } return 0; -- 2.7.4 From f524d9027ff454858aa3c3e791cb84abc4e52a98 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 5 Oct 2020 14:03:18 +0900 Subject: [PATCH 07/16] Do not handle LCD DIM, when display.Dimming is 0 LCD DIM lock/unlock is not supported in dbus_lockstate and dbus_unlockstate. Change-Id: I51e913b66adf55bb78124185ae5aca19b46ce1a2 Signed-off-by: lokilee73 (cherry picked from commit 8dbf5cc61905833fed475ef0f3bc720ffe0ddc07) --- src/display/display-dbus.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index bd0f59d..10564f2 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -140,9 +140,14 @@ static GVariant *dbus_lockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; - else if (!strcmp(state_str, PM_LCDDIM_STR)) + else if (!strcmp(state_str, PM_LCDDIM_STR)) { + if (!display_conf.dimming) { + _E("LCD_DIM lock is not supported."); + ret = -EINVAL; + goto out; + } state = LCD_DIM; - else if (!strcmp(state_str, PM_LCDOFF_STR)) + } else if (!strcmp(state_str, PM_LCDOFF_STR)) state = LCD_OFF; else { _E("%s state is invalid, dbus ignored.", state_str); @@ -225,9 +230,14 @@ static GVariant *dbus_unlockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; - else if (!strcmp(state_str, PM_LCDDIM_STR)) + else if (!strcmp(state_str, PM_LCDDIM_STR)) { + if (!display_conf.dimming) { + _E("LCD_DIM unlock is not supported."); + ret = -EINVAL; + goto out; + } state = LCD_DIM; - else if (!strcmp(state_str, PM_LCDOFF_STR)) + } else if (!strcmp(state_str, PM_LCDOFF_STR)) state = LCD_OFF; else { _E("%s state is invalid, dbus ignored!", state_str); -- 2.7.4 From 68a02f15db7a58e845d15f9e2ad5cd99213e4d5d Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 5 Oct 2020 20:30:36 +0900 Subject: [PATCH 08/16] Fix compile error display_conf->Dimming can be obtained via get_var_display_config() Change-Id: I846084962769e2b2e6846552f8724b6bd6d221d5 Signed-off-by: lokilee73 --- src/display/display-dbus.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 10564f2..f4f6317 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -70,6 +70,7 @@ static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct display_config *display_conf; static GVariant *dbus_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, @@ -141,7 +142,7 @@ static GVariant *dbus_lockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; else if (!strcmp(state_str, PM_LCDDIM_STR)) { - if (!display_conf.dimming) { + if (!display_conf->dimming) { _E("LCD_DIM lock is not supported."); ret = -EINVAL; goto out; @@ -231,7 +232,7 @@ static GVariant *dbus_unlockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; else if (!strcmp(state_str, PM_LCDDIM_STR)) { - if (!display_conf.dimming) { + if (!display_conf->dimming) { _E("LCD_DIM unlock is not supported."); ret = -EINVAL; goto out; @@ -632,12 +633,6 @@ static GVariant *dbus_setrefreshrate(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int app, val, ret, control; - struct display_config *display_conf = get_var_display_config(); - if (!display_conf) { - _E("Failed to get display configuration variable."); - ret = -EINVAL; - goto error; - } g_variant_get(param, "(ii)", &app, &val); @@ -1364,4 +1359,8 @@ static void __CONSTRUCTOR__ initialize(void) backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator variable."); + + display_conf = get_var_display_config(); + if (!display_conf) + _E("Failed to get display configuration variable."); } -- 2.7.4 From 2a6b0bfe9a7542993939ccf6173690612dd900bf Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 6 Oct 2020 20:33:36 +0900 Subject: [PATCH 09/16] Do not handle LCD DIM, when display.Dimming is 0 LCD DIM is not supported in dbus_changestate. Change-Id: Ie6d1ca66dcf5770492df3331fb71802a089df1af Signed-off-by: lokilee73 --- src/display/display-dbus.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index f4f6317..846c67e 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -301,9 +301,14 @@ static GVariant *dbus_changestate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; - else if (!strcmp(state_str, PM_LCDDIM_STR)) + else if (!strcmp(state_str, PM_LCDDIM_STR)) { + if (!display_conf->dimming) { + _E("LCD_DIM state is not supported."); + ret = -EINVAL; + goto out; + } state = LCD_DIM; - else if (!strcmp(state_str, PM_LCDOFF_STR)) + } else if (!strcmp(state_str, PM_LCDOFF_STR)) state = LCD_OFF; else if (!strcmp(state_str, PM_STANDBY_STR)) state = STANDBY; -- 2.7.4 From 6249588d0a71826adc34ee6585dc3a7b628009e2 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 7 Oct 2020 15:39:48 +0900 Subject: [PATCH 10/16] Add get_lcd_power_node() for direct accessing the lcd power node Change-Id: Id47db38af56b2f6b6e4be0e6b46acf79b0564d75 Signed-off-by: Hyotaek Shim --- plugins/iot/display/device-interface.c | 32 ++++++++++++++++------------- plugins/mobile/display/device-interface.c | 32 ++++++++++++++++------------- plugins/tv/display/device-interface.c | 32 ++++++++++++++++------------- plugins/wearable/display/device-interface.c | 32 ++++++++++++++++------------- 4 files changed, 72 insertions(+), 56 deletions(-) diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index eba4550..27fde01 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -124,25 +124,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -153,10 +150,17 @@ static int get_lcd_power(void) return DPMS_OFF; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 80b1d01..d9b5d3b 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -123,25 +123,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -152,10 +149,17 @@ static int get_lcd_power(void) return DPMS_OFF; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index e7ab4df..e264290 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -124,25 +124,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -153,10 +150,17 @@ static int get_lcd_power(void) return DPMS_OFF; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 2e5351c..e95977b 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -136,25 +136,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -167,10 +164,17 @@ static int get_lcd_power(void) return DPMS_DETACH; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) -- 2.7.4 From ce51a0a20b5a136a69c412e074860dc8455bf6f8 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 8 Oct 2020 17:18:22 +0900 Subject: [PATCH 11/16] silent reboot: Fix initial DPMS contol For silent reboot, don't do DPMS_ON, which was done at the end of init_dpms(). Change-Id: I3692503aa1b7a10085dcc19408148be440f382f7 Signed-off-by: Youngjae Cho --- plugins/iot/display/core.c | 3 ++- plugins/mobile/display/core.c | 3 ++- plugins/tv/display/core.c | 3 ++- plugins/wearable/display/core.c | 3 ++- src/display/display-dpms.c | 3 --- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 66d5169..228ac67 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -2151,9 +2151,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 9ccf78b..3a3b7ce 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -2162,9 +2162,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 6f3667a..94a6503 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -2153,9 +2153,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 8fc8ab3..3d13b4c 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -2496,9 +2496,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/src/display/display-dpms.c b/src/display/display-dpms.c index 81be588..265a07f 100644 --- a/src/display/display-dpms.c +++ b/src/display/display-dpms.c @@ -574,9 +574,6 @@ bool init_dpms(void) dpms_loop = g_main_loop_new(dpms_context, false); - /* Initiating enlightenment. */ - dpms_set_state(DPMS_ON); - return true; } -- 2.7.4 From cdf32833d23343df183324049c6aa49a04bc5d30 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 5 Oct 2020 17:09:04 +0900 Subject: [PATCH 12/16] Adopt a dpms cache In the previos structure, deviced sets dpms through Enlightenment, whereas gets dpms by reading the lcd power node directly. There is a possibility of a miasmatch between the actual dpms state and the lcd power node. The cached dpms value is alternatively used for this situation in replacement of the get_lcd_power(). Change-Id: Id0144cd76cb017694198856f6b40ff7162b61e64 Signed-off-by: Youngjae Cho Signed-off-by: Hyotaek Shim Signed-off-by: Youngjae Cho --- plugins/iot/display/device-interface.c | 1 + plugins/mobile/display/device-interface.c | 1 + plugins/tv/display/device-interface.c | 1 + plugins/wearable/display/device-interface.c | 1 + src/display/device-interface.h | 1 + src/display/display-dpms.c | 15 ++++++++++++++- src/display/display-dpms.h | 1 + src/touchscreen/touchscreen.c | 5 ++++- 8 files changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index 27fde01..06ca0ad 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -741,6 +741,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index d9b5d3b..b1a1356 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -740,6 +740,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index e264290..9a47571 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -741,6 +741,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index e95977b..d2ee406 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -806,6 +806,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/src/display/device-interface.h b/src/display/device-interface.h index 97121e3..4193de8 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -69,6 +69,7 @@ struct _backlight_ops { int (*set_default_brt)(int level); int (*get_default_brt)(void); int (*get_lcd_power)(void); + int (*get_lcd_power_cached)(void); int (*set_custom_status)(bool on); bool (*get_custom_status)(void); int (*save_custom_brightness)(void); diff --git a/src/display/display-dpms.c b/src/display/display-dpms.c index 265a07f..418274c 100644 --- a/src/display/display-dpms.c +++ b/src/display/display-dpms.c @@ -58,6 +58,8 @@ static GMainContext *dpms_context; static bool dpms_get_state_done; static bool dpms_set_state_done; +/* deviced-managing cache value */ +static int dpms_cache = -1; static void dpms_handle_set_state(void *data, struct tizen_dpms_manager *tz_dpms, uint32_t mode, uint32_t error) { @@ -75,7 +77,6 @@ static void dpms_handle_set_state(void *data, struct tizen_dpms_manager *tz_dpms } _D("Dpms_state_cb set - mode:%u, error:%u", mode, error); - dpms_client->dpms_mode = mode; dpms_set_state_done = true; if (g_main_loop_is_running(dpms_loop)) @@ -514,6 +515,8 @@ void dpms_set_state(int on) wait_response(DPMS_RESPONSE_TIMEOUT); + dpms_cache = on; + if (!dpms_set_state_done) { _E("No response for DPMS request(%d) for %d seconds.", mode, DPMS_RESPONSE_TIMEOUT); @@ -549,6 +552,16 @@ int dpms_get_state(void) } } +int dpms_get_cached_state(void) +{ + if (!dpms_is_available()) { + _E("Dpms is not available."); + return -1; + } + + return dpms_cache; +} + bool init_dpms(void) { if (dpms_client) diff --git a/src/display/display-dpms.h b/src/display/display-dpms.h index 4a936ee..b9ac040 100644 --- a/src/display/display-dpms.h +++ b/src/display/display-dpms.h @@ -21,6 +21,7 @@ void dpms_set_state(int on); int dpms_get_state(void); +int dpms_get_cached_state(void); bool init_dpms(void); void exit_dpms(void); void __register_dpms_checklist(int mode, void (*checker)(void), const char *caller); diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index e3d2231..b2c8182 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -104,6 +104,7 @@ static int touchscreen_powersaving(enum ps_mode mode) return 0; } + static int touchscreen_probe(void *data) { int ret; @@ -204,7 +205,9 @@ static int touchscreen_start(enum device_flags flags) */ ret = touchscreen_set_state(TOUCHSCREEN_ON); - state = backlight_ops->get_lcd_power(); + state = -1; + if (backlight_ops && backlight_ops->get_lcd_power_cached) + state = backlight_ops->get_lcd_power_cached(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); -- 2.7.4 From a3c2a44af4d13ae1bcc3de197f189187a5fabb21 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 12 Oct 2020 14:33:32 +0900 Subject: [PATCH 13/16] Fix dbus call of default_pmlock_check() For non-killable daemons, the return of resourced's CheckAppStatus is always ignored. Therefore, fix not to call CheckAppStatus when the pmlock_check is checking non-killable daemon, not app. Change-Id: Ifeef32754c9d94a18ad302b97927407de91b83d8 Signed-off-by: Youngjae Cho Signed-off-by: lokilee73 --- src/display/display-lock.c | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/display/display-lock.c b/src/display/display-lock.c index c7d88c7..2df1497 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -64,15 +64,34 @@ static void refresh_app_cond() trans_condition |= MASK_OFF; } +static void broadcast_pmlock_expired(pid_t pid, enum state_t state, const char* appid, time_t locktime) +{ + time_t now; + double diff; + int ret; + + time(&now); + diff = difftime(now, locktime); + + CRITICAL_LOG("%s(%d) has held %s lock for a long time(%.0f s).", + appid ? appid : "NULL", pid, state_st(state)->name + 2, diff); + + ret = dbus_handle_emit_dbus_signal(NULL, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + "pmlock_expired", + g_variant_new("(ii)", pid, (int)diff)); + if (ret < 0) + _E("Failed to send dbus pmlock_expired"); +} + static void default_pmlock_check_cb(GVariant *var, void *user_data, GError *err) { pid_t pid = 0; - int ret, detected = 0; + int detected = 0; char *app_id = NULL; enum state_t state = (enum state_t) user_data; PmLockNode *node; - time_t now; - double diff; if (!var) return; @@ -82,26 +101,14 @@ static void default_pmlock_check_cb(GVariant *var, void *user_data, GError *err) goto out; } - if (is_app(pid) == 1 && !detected) + if (!detected) goto out; node = find_node(state, pid); if (!node) goto out; - time(&now); - diff = difftime(now, node->time); - - CRITICAL_LOG("%s(%d) has held %s lock for a long time(%.0f s).", - app_id, pid, state_st(state)->name + 2, diff); - - ret = dbus_handle_emit_dbus_signal(NULL, - DEVICED_PATH_DISPLAY, - DEVICED_INTERFACE_DISPLAY, - "pmlock_expired", - g_variant_new("(ii)", pid, (int)diff)); - if (ret < 0) - _E("Failed to send dbus pmlock_expired"); + broadcast_pmlock_expired(pid, state, app_id, node->time); out: if (app_id) @@ -140,6 +147,13 @@ static gboolean default_pmlock_check(void *data) return G_SOURCE_REMOVE; } + if (!is_app(pid)) { + /* For (non-killable) daemon, + * no need to ask resourced if it is abnormal lock */ + broadcast_pmlock_expired(pid, state, NULL, node->time); + return G_SOURCE_CONTINUE; + } + snprintf(chr_pid, sizeof(chr_pid), "%d", pid); arr[0] = chr_pid; switch (state) { -- 2.7.4 From 5fc02e79c7be0e6cf372ecf8f09ccd2f67147519 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 13 Oct 2020 12:28:30 +0900 Subject: [PATCH 14/16] Apply dpms cache globally Existing get_lcd_power() accesses to node directly, but it now uses dpms_get_cached_state() instead. Accessing to the node is separated into another function, get_lcd_power_node(). Change-Id: Ic05ce15d0fd1ec603c88db470144631a7e1b3ebd Signed-off-by: Youngjae Cho --- plugins/iot/display/device-interface.c | 14 +++----------- plugins/mobile/display/device-interface.c | 14 +++----------- plugins/tv/display/device-interface.c | 14 +++----------- plugins/wearable/display/device-interface.c | 14 +++----------- src/display/device-interface.h | 2 +- src/touchscreen/touchscreen.c | 7 ++----- 6 files changed, 15 insertions(+), 50 deletions(-) diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index 06ca0ad..ea407fb 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -153,14 +153,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -357,7 +349,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -740,8 +732,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index b1a1356..d4ef77b 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -152,14 +152,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -356,7 +348,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -739,8 +731,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 9a47571..da6583c 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -153,14 +153,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -357,7 +349,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -740,8 +732,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index d2ee406..655a102 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -167,14 +167,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -368,7 +360,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -805,8 +797,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/src/display/device-interface.h b/src/display/device-interface.h index 4193de8..161c528 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -69,7 +69,7 @@ struct _backlight_ops { int (*set_default_brt)(int level); int (*get_default_brt)(void); int (*get_lcd_power)(void); - int (*get_lcd_power_cached)(void); + int (*get_lcd_power_node)(void); int (*set_custom_status)(bool on); bool (*get_custom_status)(void); int (*save_custom_brightness)(void); diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index b2c8182..5ec95d1 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -193,9 +193,6 @@ static int touchscreen_start(enum device_flags flags) if (touchscreen_enable != DEVICE_OPS_STATUS_START) return 0; - if (!backlight_ops || !backlight_ops->get_lcd_power) - return -ENOTSUP; - /* Do not enable touchscreen during silent boot mode */ if (silent_boot && !booting_done(NULL)) return -ENOTSUP; @@ -206,8 +203,8 @@ static int touchscreen_start(enum device_flags flags) ret = touchscreen_set_state(TOUCHSCREEN_ON); state = -1; - if (backlight_ops && backlight_ops->get_lcd_power_cached) - state = backlight_ops->get_lcd_power_cached(); + if (backlight_ops && backlight_ops->get_lcd_power) + state = backlight_ops->get_lcd_power(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); -- 2.7.4 From 1adb706ea7a06ac1eb879324442d6d498555a9f7 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 14 Sep 2020 11:49:48 +0900 Subject: [PATCH 15/16] Use definitions of libsyscommon instead of device api device api now uses libsyscommon library for dbus communication. To get in line with this change, Deviced is required to use the callback function of libsyscommon instead of that of api/device. Change-Id: I5c8f8025ba215ec2fb9a6722ee66ca4b2d8fbea2 Signed-off-by: Youngjae Cho --- src/auto-test/display.c | 2 +- src/auto-test/test.c | 2 +- src/auto-test/test.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auto-test/display.c b/src/auto-test/display.c index 0b92d84..df4631e 100644 --- a/src/auto-test/display.c +++ b/src/auto-test/display.c @@ -398,7 +398,7 @@ static bool set_display_brightness_state(display_state_e state, int brightness) return TRUE; } -static bool set_display_state_by_reason(display_state_e type, const char *reason, int timeout, device_dbus_pending_cb cb) +static bool set_display_state_by_reason(display_state_e type, const char *reason, int timeout, dbus_pending_cb cb) { int ret; diff --git a/src/auto-test/test.c b/src/auto-test/test.c index 6039944..0deda46 100644 --- a/src/auto-test/test.c +++ b/src/auto-test/test.c @@ -82,7 +82,7 @@ void test_exit(void *data) } } -void __cb(void *data, GVariant *result, GError *err) +void __cb(GVariant *result, void *data, GError *err) { int temp = 0; diff --git a/src/auto-test/test.h b/src/auto-test/test.h index 65dbd44..848a646 100644 --- a/src/auto-test/test.h +++ b/src/auto-test/test.h @@ -105,7 +105,7 @@ void remove_test(const struct test_ops *c); const struct test_ops *find_test(const char *name); void config_test(); void _R(const char *format, ...); -void __cb(void *data, GVariant *result, GError *err); +void __cb(GVariant *result, void *data, GError *err); bool capi_result(const char *method, int val); bool capi_reboot_result(const char *method, int val); #endif -- 2.7.4 From dbdb329932fd9c3ea7af71d09e1ead093789a1dc Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 13 Oct 2020 16:02:06 +0900 Subject: [PATCH 16/16] Skip running animation if option is silent Change-Id: Iaccd10955d02a129ad352b0a13192ed47042ffa9 Signed-off-by: lokilee73 (cherry picked from commit ca9d81149e324e49efc033810b25ce787f7c4c00) --- conf/power.conf | 1 + src/power/power-handler.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/conf/power.conf b/conf/power.conf index e99b94d..7a753c2 100644 --- a/conf/power.conf +++ b/conf/power.conf @@ -3,3 +3,4 @@ Option=recovery Option=download Option=wdownload Option=debug +Option=silent diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 0a672c7..342868e 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -502,7 +502,11 @@ static int power_execute_pid(const char *typename, const char *option) system_shutdown_send_system_event(); poweroff_send_broadcast(poweroff_opt.type); - poweroff_start_animation(); + /* Skip running animation if option is silent */ + if (poweroff_opt.option != NULL && !strcmp(poweroff_opt.option, "silent")) + _D("Skip running poweroff animation."); + else + poweroff_start_animation(); /* Spare time for AddPowerOffWait requests */ g_timeout_add_seconds(1, poweroff_start_timers, NULL); -- 2.7.4