From aac80675e25ec20b90e439cf7f240258488272c0 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 21 Mar 2023 14:48:56 +0900 Subject: [PATCH 01/16] display: Move plugin display.c to core The list lcdon_ops has been renamed to display_dependent_device_ops and related operation has been added. - display_start_dependent_device() - display_stop_dependent_device() - display_register_dependent_device() - display_unregister_dependent_device() Each operation replaces the previous lcdon_ops code. The enum brightness_request_e has been moved to display-ops.h that contains operation of auto_brightness_control. Change-Id: I04b2b28d42938743fcbe0654461274127b95f010 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 24 +--- plugins/iot-headed/display/device-interface.c | 1 - plugins/mobile/display/core.c | 24 +--- plugins/mobile/display/device-interface.c | 1 - plugins/tv/display/core.c | 24 +--- plugins/tv/display/device-interface.c | 1 - .../wearable/display/auto-brightness-sensorhub.h | 1 + plugins/wearable/display/core.c | 24 +--- plugins/wearable/display/device-interface.c | 3 +- src/display/display.c | 122 +++++++++++++++++++++ src/display/{plugin-common => }/display.h | 48 +++----- src/display/plugin-common/core.h | 3 +- src/display/plugin-common/display-dbus.c | 2 +- src/display/plugin-common/display-lock.c | 2 +- src/display/plugin-common/display-ops.h | 27 ++++- src/display/plugin-common/display-panel.c | 2 +- src/display/plugin-common/display.c | 112 ------------------- 17 files changed, 191 insertions(+), 230 deletions(-) rename src/display/{plugin-common => }/display.h (66%) delete mode 100644 src/display/plugin-common/display.c diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 57dbfbe..a280885 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -109,7 +109,6 @@ static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; static int lcd_paneloff_mode = false; static int stay_touchscreen_off = false; -GList *lcdon_ops; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -304,8 +303,6 @@ static gboolean late_transit_on(void *data) void lcd_on_procedure(int state, enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_on_flags(); flags |= flag; @@ -348,8 +345,7 @@ void lcd_on_procedure(int state, enum device_flags flag) else if (state == LCD_DIM) set_setting_pmstate(S_LCDDIM); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->start(flags); + display_start_dependent_device(flags); if (!lcdon_broadcast) { broadcast_lcd_on(SIGNAL_POST, flags); @@ -382,8 +378,6 @@ static unsigned long get_lcd_off_flags(void) inline void lcd_off_procedure(enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_off_flags(); flags |= flag; @@ -426,8 +420,7 @@ inline void lcd_off_procedure(enum device_flags flag) if (flags & LCD_PHASED_TRANSIT_MODE) display_backlight_change_brightness_by_dpms_state(DPMS_OFF); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->stop(flags); + display_stop_dependent_device(flags); if (flags & AMBIENT_MODE) { broadcast_lcd_off_late(flags); @@ -1737,25 +1730,20 @@ static void init_lcd_operation(void) ops = find_device("display"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchkey"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchscreen"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); } static void exit_lcd_operation(void) { - GList *l = NULL; - GList *l_next = NULL; - const struct device_ops *ops = NULL; - - SYS_G_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops) - SYS_G_LIST_REMOVE_LIST(lcdon_ops, l); + display_unregister_dependent_device(); } enum { diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index 43fe79e..2a2c497 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -43,7 +43,6 @@ #include "vconf.h" #include "core.h" #include "display-dpms.h" -#include "display.h" #include "display-lock.h" #include "display-backlight.h" #include "display-panel.h" diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 87bb9ac..0949e9b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -111,7 +111,6 @@ static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; static int lcd_paneloff_mode = false; static int stay_touchscreen_off = false; -GList *lcdon_ops; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -311,8 +310,6 @@ static gboolean late_transit_on(void *data) void lcd_on_procedure(int state, enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_on_flags(); flags |= flag; @@ -355,8 +352,7 @@ void lcd_on_procedure(int state, enum device_flags flag) else if (state == LCD_DIM) set_setting_pmstate(S_LCDDIM); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->start(flags); + display_start_dependent_device(flags); if (!lcdon_broadcast) { broadcast_lcd_on(SIGNAL_POST, flags); @@ -389,8 +385,6 @@ static unsigned long get_lcd_off_flags(void) inline void lcd_off_procedure(enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_off_flags(); flags |= flag; @@ -433,8 +427,7 @@ inline void lcd_off_procedure(enum device_flags flag) if (flags & LCD_PHASED_TRANSIT_MODE) display_backlight_change_brightness_by_dpms_state(DPMS_OFF); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->stop(flags); + display_stop_dependent_device(flags); if (flags & AMBIENT_MODE) { broadcast_lcd_off_late(flags); @@ -1747,25 +1740,20 @@ static void init_lcd_operation(void) ops = find_device("display"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchkey"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchscreen"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); } static void exit_lcd_operation(void) { - GList *l = NULL; - GList *l_next = NULL; - const struct device_ops *ops = NULL; - - SYS_G_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops) - SYS_G_LIST_REMOVE_LIST(lcdon_ops, l); + display_unregister_dependent_device(); } enum { diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index b4b0496..8726b08 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -42,7 +42,6 @@ #include "vconf.h" #include "core.h" #include "display-dpms.h" -#include "display.h" #include "display-lock.h" #include "display-backlight.h" #include "display-panel.h" diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 956cc53..c4a34d3 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -109,7 +109,6 @@ static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; static int lcd_paneloff_mode = false; static int stay_touchscreen_off = false; -GList *lcdon_ops; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -304,8 +303,6 @@ static gboolean late_transit_on(void *data) void lcd_on_procedure(int state, enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_on_flags(); flags |= flag; @@ -348,8 +345,7 @@ void lcd_on_procedure(int state, enum device_flags flag) else if (state == LCD_DIM) set_setting_pmstate(S_LCDDIM); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->start(flags); + display_start_dependent_device(flags); if (!lcdon_broadcast) { broadcast_lcd_on(SIGNAL_POST, flags); @@ -382,8 +378,6 @@ static unsigned long get_lcd_off_flags(void) inline void lcd_off_procedure(enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_off_flags(); flags |= flag; @@ -426,8 +420,7 @@ inline void lcd_off_procedure(enum device_flags flag) if (flags & LCD_PHASED_TRANSIT_MODE) display_backlight_change_brightness_by_dpms_state(DPMS_OFF); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->stop(flags); + display_stop_dependent_device(flags); if (flags & AMBIENT_MODE) { broadcast_lcd_off_late(flags); @@ -1737,25 +1730,20 @@ static void init_lcd_operation(void) ops = find_device("display"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchkey"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchscreen"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); } static void exit_lcd_operation(void) { - GList *l = NULL; - GList *l_next = NULL; - const struct device_ops *ops = NULL; - - SYS_G_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops) - SYS_G_LIST_REMOVE_LIST(lcdon_ops, l); + display_unregister_dependent_device(); } enum { diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index b607cc3..10dc227 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -43,7 +43,6 @@ #include "core.h" #include "display-dpms.h" #include "display-panel.h" -#include "display.h" #include "display-backlight.h" #include "power/power-suspend.h" #include "display-lock.h" diff --git a/plugins/wearable/display/auto-brightness-sensorhub.h b/plugins/wearable/display/auto-brightness-sensorhub.h index 7f26c4a..a3d401f 100644 --- a/plugins/wearable/display/auto-brightness-sensorhub.h +++ b/plugins/wearable/display/auto-brightness-sensorhub.h @@ -29,6 +29,7 @@ #define HBM_LEVEL 120 #include "display.h" +#include "display-ops.h" int prepare_level_handler(void); void exit_level_handler(void); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 904ca95..cf41068 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -121,7 +121,6 @@ static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; static int lcd_paneloff_mode = false; static int stay_touchscreen_off = false; -GList *lcdon_ops; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -515,8 +514,6 @@ static gboolean late_transit_on(void *data) void lcd_on_procedure(int state, enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_on_flags(); flags |= flag; int ret; @@ -567,8 +564,7 @@ void lcd_on_procedure(int state, enum device_flags flag) else if (state == LCD_DIM) set_setting_pmstate(S_LCDDIM); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->start(flags); + display_start_dependent_device(flags); if (!lcdon_broadcast) { broadcast_lcd_on(SIGNAL_POST, flags); @@ -598,8 +594,6 @@ static unsigned long get_lcd_off_flags(void) inline void lcd_off_procedure(enum device_flags flag) { - GList *l = NULL; - const struct device_ops *ops = NULL; unsigned long flags = get_lcd_off_flags(); flags |= flag; @@ -645,8 +639,7 @@ inline void lcd_off_procedure(enum device_flags flag) if (flags & LCD_PHASED_TRANSIT_MODE) display_backlight_change_brightness_by_dpms_state(DPMS_OFF); - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->stop(flags); + display_stop_dependent_device(flags); if (flags & AMBIENT_MODE) { broadcast_lcd_off_late(flags); @@ -2005,25 +1998,20 @@ static void init_lcd_operation(void) ops = find_device("display"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("touchscreen"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); ops = find_device("bezel"); if (!check_default(ops)) - SYS_G_LIST_APPEND(lcdon_ops, ops); + display_register_dependent_device(ops); } static void exit_lcd_operation(void) { - GList *l = NULL; - GList *l_next = NULL; - const struct device_ops *ops = NULL; - - SYS_G_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops) - SYS_G_LIST_REMOVE_LIST(lcdon_ops, l); + display_unregister_dependent_device(); } enum { diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 3f57023..0054982 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -42,11 +42,10 @@ #include "vconf.h" #include "core.h" #include "display-dpms.h" -#include "display.h" #include "display-lock.h" #include "display-backlight.h" #include "display-panel.h" -#include "display-config.h" +#include "display/display-config.h" #include "battery-monitor.h" #include "battery/power-supply.h" #include "power/power-suspend.h" diff --git a/src/display/display.c b/src/display/display.c index a8f72ed..32dd285 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -16,9 +16,131 @@ * limitations under the License. */ +#include #include +#include "display/display.h" +#include "shared/log.h" + static const struct device_ops *display_plugin_device_ops; +static int pm_cur_state; +static int pm_old_state; +static unsigned int pm_status_flag; +static enum display_init_direction_e g_display_init_direction; +static bool g_display_hal_backend_available; +static GList *display_dependent_device_ops; + +inline int get_pm_cur_state(void) +{ + return pm_cur_state; +} + +inline void set_pm_cur_state(int cur_state) +{ + pm_cur_state = cur_state; +} + +inline int get_pm_old_state(void) +{ + return pm_old_state; +} + +inline void set_pm_old_state(int old_state) +{ + pm_old_state = old_state; +} + +inline unsigned int get_pm_status_flag(void) +{ + return pm_status_flag; +} + +inline void set_pm_status_flag(unsigned int status_flag) +{ + pm_status_flag |= status_flag; +} + +inline void clear_pm_status_flag(unsigned int status_flag) +{ + pm_status_flag &= ~status_flag; +} + +inline enum display_init_direction_e get_display_init_direction(void) +{ + return g_display_init_direction; +} + +inline void set_display_init_direction(enum display_init_direction_e display_init_direction) +{ + g_display_init_direction = display_init_direction; +} + +/* FIXME: The first parameter was type enum dpms_state. + * After extracting display-dpms from plugin, restore its type to enum dpms_state. */ +void lcd_direct_control(int dpms_state, int flags) +{ + const struct device_ops *ops = NULL; + GList *l = NULL; + + switch (dpms_state) { + case 0: /* FIXME: DPMS_ON */ + SYS_G_LIST_FOREACH(display_dependent_device_ops, l, ops) + ops->start(flags); + break; + case 3: /* FIXME: DPMS_OFF */ + SYS_G_LIST_FOREACH(display_dependent_device_ops, l, ops) + ops->stop(flags); + break; + default: + _E("state is wrong value %d", dpms_state); + break; + } +} + +/* FIXME: This function is for temporary use, should be fixed after plugin refactoring */ +void display_set_hal_backend_available(bool display_hal_backend_available) +{ + g_display_hal_backend_available = display_hal_backend_available; +} + +/* FIXME: This function is for temporary use, should be fixed after plugin refactoring */ +bool display_is_hal_backend_available(void) +{ + return g_display_hal_backend_available; +} + +void display_start_dependent_device(unsigned long flags) +{ + const struct device_ops *ops = NULL; + GList *l; + + SYS_G_LIST_FOREACH(display_dependent_device_ops, l, ops) + ops->start(flags); +} + +void display_stop_dependent_device(unsigned long flags) +{ + const struct device_ops *ops = NULL; + GList *l; + + SYS_G_LIST_FOREACH(display_dependent_device_ops, l, ops) + ops->stop(flags); +} + +void display_register_dependent_device(const struct device_ops *ops) +{ + SYS_G_LIST_APPEND(display_dependent_device_ops, ops); +} + +void display_unregister_dependent_device(void) +{ + GList *l = NULL; + GList *l_next = NULL;; + const struct device_ops *ops = NULL; + + SYS_G_LIST_FOREACH_SAFE(display_dependent_device_ops, l, l_next, ops) + SYS_G_LIST_REMOVE_LIST(display_dependent_device_ops, l); +} static int display_probe(void *data) { diff --git a/src/display/plugin-common/display.h b/src/display/display.h similarity index 66% rename from src/display/plugin-common/display.h rename to src/display/display.h index 90c4764..c947535 100644 --- a/src/display/plugin-common/display.h +++ b/src/display/display.h @@ -16,14 +16,18 @@ * limitations under the License. */ - #ifndef __DISPLAY_H__ #define __DISPLAY_H__ -#include -#include "device-interface.h" +#include +#include "shared/devices.h" -void lcd_direct_control(enum dpms_state state, int flags); +enum display_init_direction_e { + DISPLAY_INIT_DIRECTION_HORIZONTAL, + DISPLAY_INIT_DIRECTION_VERTICAL, +}; + +void lcd_direct_control(int dpms_state, int flags); /* FIXME: The first parameter was type enum dpms_state */ int get_pm_cur_state(void); int get_pm_old_state(void); void set_pm_cur_state(int cur_state); @@ -35,35 +39,9 @@ enum display_init_direction_e get_display_init_direction(void); void set_display_init_direction(enum display_init_direction_e display_init_direction); void display_set_hal_backend_available(bool display_hal_backend_available); bool display_is_hal_backend_available(void); +void display_start_dependent_device(unsigned long flags); +void display_stop_dependent_device(unsigned long flags); +void display_register_dependent_device(const struct device_ops *ops); +void display_unregister_dependent_device(void); -enum brightness_request_e { - BR_MIN = 0, - /* entering request */ - BR_LBM_ON, - BR_HBM_ON, - BR_HOLD_BRIGHTNESS, - BR_LOWDIM_ON, /* low battery dim */ - - /* exiting request */ - BR_LBM_OFF, - BR_HBM_OFF, - BR_RELEASE_BRIGHTNESS, - BR_LOWDIM_OFF, /* low battery dim off */ - - /* special */ - BR_SET_BRIGHTNESS, - - BR_MAX, -}; - -enum display_init_direction_e { - DISPLAY_INIT_DIRECTION_HORIZONTAL, - DISPLAY_INIT_DIRECTION_VERTICAL, -}; - -/* request for brightness that managed internally. - * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness - * for request, but explicitly request for a brightness value */ -#define BR_IMPLICIT (-1) - -#endif +#endif //__DISPLAY_H__ diff --git a/src/display/plugin-common/core.h b/src/display/plugin-common/core.h index fce9961..0d83d1a 100644 --- a/src/display/plugin-common/core.h +++ b/src/display/plugin-common/core.h @@ -28,6 +28,7 @@ #include "device-interface.h" #include "setting.h" #include "display-dpms.h" +#include "display.h" #include "display-config.h" #define WITHOUT_STARTNOTI 0x1 @@ -119,7 +120,6 @@ struct display_keyfilter_ops { }; extern const struct display_keyfilter_ops *keyfilter_ops; -extern GList *lcdon_ops; typedef struct { pid_t pid; @@ -159,7 +159,6 @@ void set_lcd_paneloff_mode(int val); void lcd_on_direct(enum device_flags flags); void lcd_on_procedure(int state, enum device_flags flag); void lcd_off_procedure(enum device_flags flag); -void lcd_direct_control(enum dpms_state state, int flags); bool touch_event_blocked(void); void broadcast_lcd_off_late(enum device_flags flags); void set_dim_state(bool on); diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 88a3ee6..fa77a7c 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -41,10 +41,10 @@ #include "dd-display.h" #include "display-actor.h" #include "display-ops.h" -#include "display.h" #include "shared/plugin.h" #include "display-lock.h" #include "display-panel.h" +//#include "display/display.h" #include "display-backlight.h" #define AUL_APPSTATUS_PATH "/Org/Tizen/Aul/AppStatus" diff --git a/src/display/plugin-common/display-lock.c b/src/display/plugin-common/display-lock.c index 4223b2f..ad7c2f7 100644 --- a/src/display/plugin-common/display-lock.c +++ b/src/display/plugin-common/display-lock.c @@ -24,7 +24,7 @@ #include "shared/common.h" #include "device-interface.h" #include "poll.h" -#include "display.h" +//#include "display.h" #include "display-signal.h" #include "lock-detector.h" #include "display-lock.h" diff --git a/src/display/plugin-common/display-ops.h b/src/display/plugin-common/display-ops.h index 7fd6d42..70eba16 100644 --- a/src/display/plugin-common/display-ops.h +++ b/src/display/plugin-common/display-ops.h @@ -23,7 +23,7 @@ #include #include "shared/common.h" #include "shared/devices.h" -#include "display.h" +//#include "display.h" struct display_ops { char *name; @@ -59,6 +59,31 @@ const struct display_ops *find_display_feature(const char *name); #define DISPLAY_FUNC(a, b) (((a) << 16) | (b)) +enum brightness_request_e { + BR_MIN = 0, + /* entering request */ + BR_LBM_ON, + BR_HBM_ON, + BR_HOLD_BRIGHTNESS, + BR_LOWDIM_ON, /* low battery dim */ + + /* exiting request */ + BR_LBM_OFF, + BR_HBM_OFF, + BR_RELEASE_BRIGHTNESS, + BR_LOWDIM_OFF, /* low battery dim off */ + + /* special */ + BR_SET_BRIGHTNESS, + + BR_MAX, +}; + +/* request for brightness that managed internally. + * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness + * for request, but explicitly request for a brightness value */ +#define BR_IMPLICIT (-1) + struct display_plugin { void *handle; int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout); diff --git a/src/display/plugin-common/display-panel.c b/src/display/plugin-common/display-panel.c index be401df..f968332 100644 --- a/src/display/plugin-common/display-panel.c +++ b/src/display/plugin-common/display-panel.c @@ -19,7 +19,7 @@ #include "shared/log.h" #include "power/power-suspend.h" #include "ambient-mode.h" -#include "display.h" +//#include "display.h" #include "display-backlight.h" #include "display-dpms.h" #include "display-panel.h" diff --git a/src/display/plugin-common/display.c b/src/display/plugin-common/display.c deleted file mode 100644 index 977252a..0000000 --- a/src/display/plugin-common/display.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2019 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include - -#include "util.h" -#include "core.h" -#include "display-dpms.h" -#include "display-ops.h" -#include "dd-display.h" -#include "shared/common.h" - -static int pm_cur_state; -static int pm_old_state; -static unsigned int pm_status_flag; -static enum display_init_direction_e g_display_init_direction; -static bool g_display_hal_backend_available; - -inline int get_pm_cur_state(void) -{ - return pm_cur_state; -} - -inline void set_pm_cur_state(int cur_state) -{ - pm_cur_state = cur_state; -} - -inline int get_pm_old_state(void) -{ - return pm_old_state; -} - -inline void set_pm_old_state(int old_state) -{ - pm_old_state = old_state; -} - -inline unsigned int get_pm_status_flag(void) -{ - return pm_status_flag; -} - -inline void set_pm_status_flag(unsigned int status_flag) -{ - pm_status_flag |= status_flag; -} - -inline void clear_pm_status_flag(unsigned int status_flag) -{ - pm_status_flag &= ~status_flag; -} - -inline enum display_init_direction_e get_display_init_direction(void) -{ - return g_display_init_direction; -} - -inline void set_display_init_direction(enum display_init_direction_e display_init_direction) -{ - g_display_init_direction = display_init_direction; -} - -void lcd_direct_control(enum dpms_state state, int flags) -{ - const struct device_ops *ops = NULL; - GList *l = NULL; - - switch (state) { - case DPMS_ON: - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->start(flags); - break; - case DPMS_OFF: - SYS_G_LIST_FOREACH(lcdon_ops, l, ops) - ops->stop(flags); - break; - default: - _E("state is wrong value %d", state); - break; - } -} - -/* FIXME: This function is for temporary use, should be fixed after plugin refactoring */ -void display_set_hal_backend_available(bool display_hal_backend_available) -{ - g_display_hal_backend_available = display_hal_backend_available; -} - -/* FIXME: This function is for temporary use, should be fixed after plugin refactoring */ -bool display_is_hal_backend_available(void) -{ - return g_display_hal_backend_available; -} -- 2.7.4 From 5c624f2e0582f024806f21b78174f39a27608e51 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 21 Mar 2023 16:38:50 +0900 Subject: [PATCH 02/16] display: Move plugin display_dimstay_check() to core The display_dimstay_check() has bee relocated: - plugins/*/display/device-interface.c => src/display/display.c Change-Id: Ifd8a23ab255d091495d6de25a8d35c933b9c8b39 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/device-interface.c | 11 ----------- plugins/mobile/display/device-interface.c | 11 ----------- plugins/tv/display/device-interface.c | 11 ----------- plugins/wearable/display/device-interface.c | 8 -------- src/display/display.c | 13 +++++++++++++ src/display/display.h | 12 ++++++++++++ src/display/plugin-common/core.h | 11 ----------- src/display/plugin-common/device-interface.h | 1 - src/display/plugin-common/display-backlight.c | 2 -- 9 files changed, 25 insertions(+), 55 deletions(-) diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index 2a2c497..011d6ef 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -79,17 +79,6 @@ bool display_dev_ready(void) return display_dev_available; } -bool display_dimstay_check(void) -{ - if (get_pm_status_flag() & DIM_FLAG) - return true; - - if ((get_pm_status_flag() & PWRSV_FLAG) && !(get_pm_status_flag() & BRTCH_FLAG)) - return true; - - return false; -} - static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = NULL, diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 8726b08..3e450dc 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -78,17 +78,6 @@ bool display_dev_ready(void) return display_dev_available; } -bool display_dimstay_check(void) -{ - if (get_pm_status_flag() & DIM_FLAG) - return true; - - if ((get_pm_status_flag() & PWRSV_FLAG) && !(get_pm_status_flag() & BRTCH_FLAG)) - return true; - - return false; -} - static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = NULL, diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 10dc227..a8f98e8 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -79,17 +79,6 @@ bool display_dev_ready(void) return display_dev_available; } -bool display_dimstay_check(void) -{ - if (get_pm_status_flag() & DIM_FLAG) - return true; - - if ((get_pm_status_flag() & PWRSV_FLAG) && !(get_pm_status_flag() & BRTCH_FLAG)) - return true; - - return false; -} - static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = NULL, diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 0054982..929be3d 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -92,14 +92,6 @@ bool display_dev_ready(void) return display_dev_available; } -bool display_dimstay_check(void) -{ - if (get_pm_status_flag() & DIM_FLAG) - return true; - - return false; -} - static int set_brightness(int val) { int max, ret; diff --git a/src/display/display.c b/src/display/display.c index 32dd285..9bb1789 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -142,6 +142,19 @@ void display_unregister_dependent_device(void) SYS_G_LIST_REMOVE_LIST(display_dependent_device_ops, l); } +/* FIXME: display_dimstay_check function should be changed to plugin api call. + * Only the wearable profile had the first condition only, checking DIM_FLAG. */ +bool display_dimstay_check(void) +{ + if (pm_status_flag & DIM_FLAG) + return true; + + if ((pm_status_flag & PWRSV_FLAG) && !(pm_status_flag & BRTCH_FLAG)) + return true; + + return false; +} + static int display_probe(void *data) { display_plugin_device_ops = find_device("display-plugin"); diff --git a/src/display/display.h b/src/display/display.h index c947535..3ad974a 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -22,6 +22,17 @@ #include #include "shared/devices.h" +#define VCALL_FLAG 0x00000001 +#define LOWBT_FLAG 0x00000100 +#define CHRGR_FLAG 0x00000200 +#define PWRSV_FLAG 0x00000400 +#define BRTCH_FLAG 0x00002000 +#define PWROFF_FLAG 0x00004000 +#define DIMSTAY_FLAG 0x00008000 +#define DIM_FLAG 0x00010000 +#define BATTERY_FLAG 0x00020000 +#define COOLDOWN_FLAG 0x00040000 + enum display_init_direction_e { DISPLAY_INIT_DIRECTION_HORIZONTAL, DISPLAY_INIT_DIRECTION_VERTICAL, @@ -43,5 +54,6 @@ void display_start_dependent_device(unsigned long flags); void display_stop_dependent_device(unsigned long flags); void display_register_dependent_device(const struct device_ops *ops); void display_unregister_dependent_device(void); +bool display_dimstay_check(void); #endif //__DISPLAY_H__ diff --git a/src/display/plugin-common/core.h b/src/display/plugin-common/core.h index 0d83d1a..5bd9836 100644 --- a/src/display/plugin-common/core.h +++ b/src/display/plugin-common/core.h @@ -37,17 +37,6 @@ #define MASK_DIM 0x2 /* 010 */ #define MASK_OFF 0x4 /* 100 */ -#define VCALL_FLAG 0x00000001 -#define LOWBT_FLAG 0x00000100 -#define CHRGR_FLAG 0x00000200 -#define PWRSV_FLAG 0x00000400 -#define BRTCH_FLAG 0x00002000 -#define PWROFF_FLAG 0x00004000 -#define DIMSTAY_FLAG 0x00008000 -#define DIM_FLAG 0x00010000 -#define BATTERY_FLAG 0x00020000 -#define COOLDOWN_FLAG 0x00040000 - #define DEFAULT_NORMAL_TIMEOUT 30 #define DIM_MASK 0x000f0000 diff --git a/src/display/plugin-common/device-interface.h b/src/display/plugin-common/device-interface.h index 6fb6581..a069429 100644 --- a/src/display/plugin-common/device-interface.h +++ b/src/display/plugin-common/device-interface.h @@ -80,7 +80,6 @@ enum dpms_state { }; bool display_dev_ready(void); -bool display_dimstay_check(void); void dpms_set_running_state(int val); enum lcdon_block_state { diff --git a/src/display/plugin-common/display-backlight.c b/src/display/plugin-common/display-backlight.c index c65e2bb..51fe33c 100644 --- a/src/display/plugin-common/display-backlight.c +++ b/src/display/plugin-common/display-backlight.c @@ -320,7 +320,6 @@ int display_backlight_set_brightness_by_dim_brightness(void) return ret; } -/* FIXME: display_dimstay_check function should be changed to plugin api call */ int display_backlight_update_by_default_brightness(void) { int ret = 0; @@ -349,7 +348,6 @@ void display_backlight_set_custom_brightness(int brightness) custom_brightness = brightness; } -/* FIXME: display_dimstay_check function should be changed to plugin api call */ int display_backlight_update_by_custom_brightness(void) { int ret = 0; -- 2.7.4 From ec707d53e741aae6ea108a7bf9c16d72d2acc7b3 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 23 Mar 2023 09:54:16 +0900 Subject: [PATCH 03/16] display: Move plugin struct display_plugin to core The struct display_plugin has been relocated: - src/display/plugin-common/display-ops.h => src/display/display-plugin.h Added wrapper for each member variable/function of the structure. Those wrapper access/invoke matching plugin variable/function if exist. - display_plugin_handle() - display_plugin_pm_lock_internal() - display_plugin_pm_unlock_internal() - display_plugin_pm_change_internal() - display_plugin_update_pm_setting() - display_plugin_get_lock_screen_state() - display_plugin_get_system_wakeup_flag() - display_plugin_set_system_wakeup_flag() - display_plugin_device_flags_to_string() - display_plugin_auto_brightness_control() The structure's member would grow as more plugin code will move to the display core. Later, this struct display_plugin and wrapper can be replaced by plugin-api-deviced. Change-Id: I2ebc6b77b647764cbc1d4ceb55d17fdc2fee6af1 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 5 +- plugins/mobile/display/core.c | 5 +- plugins/tv/display/core.c | 5 +- plugins/wearable/display/core.c | 5 +- src/battery/battery-time.c | 16 ++-- src/battery/lowbat-handler.c | 23 ++---- src/battery/power-supply.c | 44 ++++------- src/display/display-plugin.c | 96 ++++++++++++++++++++++++ src/display/display-plugin.h | 77 +++++++++++++++++++ src/display/display.c | 4 +- src/display/plugin-common/display-ops.h | 38 +--------- src/display/plugin-common/poll.c | 17 ++--- src/display/plugin-common/poll.h | 2 + src/extcon/cradle.c | 21 ++---- src/extcon/earjack.c | 12 +-- src/led/touch-key.c | 11 +-- src/shared/apps.c | 14 +--- src/shared/plugin.c | 7 +- src/time/time-handler.c | 23 ++---- src/touchscreen/touchscreen.c | 11 +-- src/usb-gadget/usb-gadget.c | 18 +---- src/usb-host/usb-host.c | 19 ++--- tests/deviced-common-private-test/CMakeLists.txt | 1 + tests/deviced-common-private-test/test-mock.c | 12 +++ 24 files changed, 273 insertions(+), 213 deletions(-) create mode 100644 src/display/display-plugin.c create mode 100644 src/display/display-plugin.h diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index a280885..8c68386 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -46,6 +46,7 @@ #include "ambient-mode.h" #include "util.h" #include "core.h" +#include "poll.h" #include "lock-detector.h" #include "display-ops.h" #include "shared/devices.h" @@ -60,6 +61,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "display-plugin.h" #include "display-dpms.h" #include "display-signal.h" #include "display-lock.h" @@ -87,7 +89,6 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -extern void init_pm_internal(); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; @@ -1936,7 +1937,7 @@ static int display_probe(void *data) return ret; /* display_plugin instance initialization */ - init_pm_internal(); + init_pm_internal(data); disp_plgn->device_flags_to_string = __device_flags_to_string; if (battery_plgn->handle) { diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 0949e9b..90a7c9b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -45,6 +45,7 @@ #include "ambient-mode.h" #include "util.h" #include "core.h" +#include "poll.h" #include "lock-detector.h" #include "display-ops.h" #include "shared/devices.h" @@ -59,6 +60,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "display-plugin.h" #include "display-dpms.h" #include "proximity.h" #include "display-info.h" @@ -88,7 +90,6 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -extern void init_pm_internal(); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; @@ -1942,7 +1943,7 @@ static int display_probe(void *data) return ret; /* display_plugin instance initialization */ - init_pm_internal(); + init_pm_internal(data); disp_plgn->device_flags_to_string = __device_flags_to_string; if (battery_plgn->handle) { diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index c4a34d3..0299f83 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -45,6 +45,7 @@ #include "ambient-mode.h" #include "util.h" #include "core.h" +#include "poll.h" #include "lock-detector.h" #include "display-ops.h" #include "shared/devices.h" @@ -59,6 +60,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "display-plugin.h" #include "display-dpms.h" #include "display-signal.h" #include "display-lock.h" @@ -86,7 +88,6 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -extern void init_pm_internal(); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; @@ -1933,7 +1934,7 @@ static int display_probe(void *data) return ret; /* display_plugin instance initialization */ - init_pm_internal(); + init_pm_internal(data); disp_plgn->device_flags_to_string = __device_flags_to_string; if (battery_plgn->handle) { diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index cf41068..b692b00 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -46,6 +46,7 @@ #include "ambient-mode.h" #include "util.h" #include "core.h" +#include "poll.h" #include "lock-detector.h" #include "display-ops.h" #include "shared/devices.h" @@ -60,6 +61,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "display-plugin.h" #include "display-dpms.h" #include "display-info.h" #include "battery-monitor.h" @@ -98,7 +100,6 @@ #define DISPLAY_DETACH_STR "display_detach" #define UNKNOWN_STR "unknown" -extern void init_pm_internal(); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; @@ -2221,7 +2222,7 @@ static int display_probe(void *data) return ret; /* display_plugin instance initialization */ - init_pm_internal(); + init_pm_internal(data); disp_plgn->device_flags_to_string = __device_flags_to_string; if (battery_plgn->handle) { diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index 72ff11e..54c8c10 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -28,6 +28,7 @@ #include "shared/devices.h" #include "core/log.h" #include "display-ops.h" +#include "display-plugin.h" #include "power-supply.h" #include "shared/plugin.h" @@ -61,8 +62,6 @@ enum state_a { A_END = 2 }; -static struct display_plugin *disp_plgn; - static guint timeout_id; static struct Batt_node *batt_head[B_END]; @@ -262,6 +261,7 @@ static int battinfo_calculation(void) int capacity = 0; int estimated_time = 0; int tmp = 0; + bool system_wakeup_flag; struct battery_status *battery; battery = get_var_battery_status(); @@ -305,9 +305,10 @@ static int battinfo_calculation(void) update_time(A_TIMETOFULL, estimated_time); } else { del_all_batt_node(B_CHARGING); - if (disp_plgn->system_wakeup_flag == true) { + display_plugin_get_system_wakeup_flag(&system_wakeup_flag); + if (system_wakeup_flag == true) { del_all_batt_node(B_UNCHARGING); - disp_plgn->system_wakeup_flag = false; + display_plugin_set_system_wakeup_flag(false); } if (batt_head[B_UNCHARGING] == NULL) { add_batt_node(B_UNCHARGING, clock, capacity); @@ -437,10 +438,3 @@ static const struct device_ops battery_time_device_ops = { }; DEVICE_OPS_REGISTER(&battery_time_device_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - 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 93f4ec8..d4a7b70 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -42,6 +42,7 @@ #include "setting.h" #include "poll.h" #include "display-ops.h" +#include "display-plugin.h" #include "power/power.h" #include "power/power-off.h" #include "power-supply.h" @@ -66,7 +67,6 @@ struct lowbat_process_entry { int (*func) (void *data); }; -static struct display_plugin *disp_plgn; static struct battery_plugin *battery_plgn; static struct battery_status *battery; @@ -253,11 +253,9 @@ direct_launch: if (lowbat_popup_option == BAT_OPT_ERR_TEMP_LOW || lowbat_popup_option == BAT_OPT_ERR_TEMP_HIGH || lowbat_popup_option == BAT_OPT_ERR_CF_OPEN) { - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_DIM); + display_plugin_pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_DIM); } else { - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); + display_plugin_pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); } if (lowbat_popup_option == BAT_OPT_ERR_TEMP_LOW || lowbat_popup_option == BAT_OPT_ERR_TEMP_HIGH || @@ -303,15 +301,15 @@ int battery_charge_err_cf_act(void *data) int battery_charge_err_low_act(void *data) { - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_OVERCOOL, LCD_OFF, STAY_CUR_STATE, 60000); + display_plugin_pm_lock_internal(INTERNAL_LOCK_OVERCOOL, LCD_OFF, STAY_CUR_STATE, 60000); + return lowbat_popup(BAT_OPT_ERR_TEMP_LOW); } int battery_charge_err_high_act(void *data) { - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_OVERHEAT, LCD_OFF, STAY_CUR_STATE, 60000); + display_plugin_pm_lock_internal(INTERNAL_LOCK_OVERHEAT, LCD_OFF, STAY_CUR_STATE, 60000); + return lowbat_popup(BAT_OPT_ERR_TEMP_HIGH); } @@ -535,8 +533,7 @@ static int lowbat_process(int bat_percent, void *ad) if (status != -1) { result = status; - if (disp_plgn->update_pm_setting) - disp_plgn->update_pm_setting(SETTING_LOW_BATT, status); + display_plugin_update_pm_setting(SETTING_LOW_BATT, status); } else result = vconf_state; @@ -764,10 +761,6 @@ DEVICE_OPS_REGISTER(&lowbat_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); - battery_plgn = get_var_battery_plugin(); if (!battery_plgn) _E("Failed to get battery plugin variable."); diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 82e1ad8..a91bae0 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -83,7 +83,6 @@ #define BATTERY_CHECK_TIMER_INTERVAL 500 /* 0.5 second */ #define LCD_DIM_TIME_IN_BATTERY_HEALTH 10000 /* ms */ -static struct display_plugin *disp_plgn; static struct battery_plugin *battery_plgn; static struct battery_status battery; @@ -372,8 +371,7 @@ static void noti_batt_full(void) static void check_power_supply(int state) { pm_check_and_change(state); - if (disp_plgn->update_pm_setting) - disp_plgn->update_pm_setting(SETTING_CHARGING, state); + display_plugin_update_pm_setting(SETTING_CHARGING, state); } static void charger_state_send_system_event(int state) @@ -409,13 +407,11 @@ static void update_present(enum battery_noti_status status) if (status == DEVICE_NOTI_ON) { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); } else { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); } if (battery_plgn->changed_battery_cf) battery_plgn->changed_battery_cf(battery.present); @@ -431,10 +427,8 @@ static void launch_health_popup(void) device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); + display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); if (battery.health == HEALTH_LOW) battery_charge_err_low_act(NULL); else if (battery.health == HEALTH_HIGH) @@ -465,10 +459,8 @@ static void update_health(enum battery_noti_status status) } else { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); - if (disp_plgn->pm_unlock_internal) { - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); - } + display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); health_status_broadcast(); if (abnormal_health_popup_timer) { CRITICAL_LOG("Battery health returned to normal. Stop abnormal popup."); @@ -490,10 +482,8 @@ void relaunch_health_popup(void) if (abnormal_health_popup_timer) g_source_remove(abnormal_health_popup_timer); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); + display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); if (battery.health == HEALTH_LOW) battery_charge_err_low_act(NULL); else if (battery.health == HEALTH_HIGH) @@ -624,8 +614,7 @@ static void process_power_supply(void *data) int ret_lock = -1; int ret_val; - if (disp_plgn->pm_lock_internal) - ret_lock = disp_plgn->pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0); + ret_lock = display_plugin_pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0); if (old_battery.charge_now != battery.charge_now || battery.charge_now == CHARGER_ABNORMAL) { ret_val = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, battery.charge_now); @@ -734,10 +723,8 @@ static void process_power_supply(void *data) old_battery.charge_now = battery.charge_now; } - if (disp_plgn->pm_unlock_internal) { - if (ret_lock == 0) { - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN); - } + if (ret_lock == 0) { + display_plugin_pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN); } } @@ -1312,8 +1299,7 @@ int battery_pm_change_internal(int pid, int s_bits) if (battery_do_not_disturb()) return 0; - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(pid, s_bits); + display_plugin_pm_change_internal(pid, s_bits); return 0; } @@ -1470,10 +1456,6 @@ DEVICE_OPS_REGISTER(&power_supply_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); - battery_plgn = get_var_battery_plugin(); if (!battery_plgn) _E("Failed to get battery plugin variable."); diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c new file mode 100644 index 0000000..06055d1 --- /dev/null +++ b/src/display/display-plugin.c @@ -0,0 +1,96 @@ +/* + * deviced + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "display-plugin.h" + +struct display_plugin g_display_plugin; + +void* display_plugin_handle(void) +{ + return g_display_plugin.handle; +} + +int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout) +{ + if (g_display_plugin.pm_lock_internal) + return g_display_plugin.pm_lock_internal(pid, s_bits, flags, timeout); + + return 0; +} + +int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags) +{ + if (g_display_plugin.pm_unlock_internal) + return g_display_plugin.pm_unlock_internal(pid, s_bits, flags); + + return 0; +} + +int display_plugin_pm_change_internal(pid_t pid, int s_bits) +{ + if (g_display_plugin.pm_change_internal) + return g_display_plugin.pm_change_internal(pid, s_bits); + + return 0; +} + +int display_plugin_update_pm_setting(int key_idx, int val) +{ + if (g_display_plugin.update_pm_setting) + return g_display_plugin.update_pm_setting(key_idx, val); + + return 0; +} + +int display_plugin_get_lock_screen_state(void) +{ + if (g_display_plugin.get_lock_screen_state) + return g_display_plugin.get_lock_screen_state(); + + return 0; +} + +int display_plugin_get_system_wakeup_flag(bool *flag) +{ + *flag = g_display_plugin.system_wakeup_flag; + + return 0; +} + +int display_plugin_set_system_wakeup_flag(bool flag) +{ + g_display_plugin.system_wakeup_flag = flag; + + return 0; +} + +const char* display_plugin_device_flags_to_string(enum device_flags flags) +{ + if (g_display_plugin.device_flags_to_string) + return g_display_plugin.device_flags_to_string(flags); + + return NULL; +} + +int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness) +{ + if (g_display_plugin.auto_brightness_control) + return g_display_plugin.auto_brightness_control(request, set_brightness); + + return 0; +} diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h new file mode 100644 index 0000000..28411bb --- /dev/null +++ b/src/display/display-plugin.h @@ -0,0 +1,77 @@ +/* + * deviced + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DISPLAY_PLUGIN_H__ +#define __DISPLAY_PLUGIN_H__ + +#include +#include + +#include "shared/devices.h" + +/* FIXME: Currently because of display_plugin.auto_brightness_control(), + * it is here. Please relocate it to proper place later. */ +enum brightness_request_e { + BR_MIN = 0, + /* entering request */ + BR_LBM_ON, + BR_HBM_ON, + BR_HOLD_BRIGHTNESS, + BR_LOWDIM_ON, /* low battery dim */ + + /* exiting request */ + BR_LBM_OFF, + BR_HBM_OFF, + BR_RELEASE_BRIGHTNESS, + BR_LOWDIM_OFF, /* low battery dim off */ + + /* special */ + BR_SET_BRIGHTNESS, + + BR_MAX, +}; + +/* request for brightness that managed internally. + * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness + * for request, but explicitly request for a brightness value */ +#define BR_IMPLICIT (-1) + +struct display_plugin { + void *handle; + int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout); + int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag); + int (*pm_change_internal) (pid_t pid, int s_bits); + int (*update_pm_setting) (int key_idx, int val); + int (*get_lock_screen_state) (void); + bool system_wakeup_flag; + const char* (*device_flags_to_string) (enum device_flags flags); + int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness); +}; + +void* display_plugin_handle(void); +int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout); +int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags); +int display_plugin_pm_change_internal(pid_t pid, int s_bits); +int display_plugin_update_pm_setting(int key_idx, int val); +int display_plugin_get_lock_screen_state(void); +int display_plugin_get_system_wakeup_flag(bool *flag); +int display_plugin_set_system_wakeup_flag(bool flag); +const char* display_plugin_device_flags_to_string(enum device_flags flags); +int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness); + +#endif //__DISPLAY_PLUGIN_H__ diff --git a/src/display/display.c b/src/display/display.c index 9bb1789..def14e7 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -19,10 +19,12 @@ #include #include +#include "display-plugin.h" #include "display/display.h" #include "shared/log.h" static const struct device_ops *display_plugin_device_ops; +extern struct display_plugin g_display_plugin; static int pm_cur_state; static int pm_old_state; static unsigned int pm_status_flag; @@ -161,7 +163,7 @@ static int display_probe(void *data) if (!display_plugin_device_ops || !display_plugin_device_ops->probe) return 0; - return display_plugin_device_ops->probe(data); + return display_plugin_device_ops->probe(&g_display_plugin); } static void display_init(void *data) diff --git a/src/display/plugin-common/display-ops.h b/src/display/plugin-common/display-ops.h index 70eba16..119c72d 100644 --- a/src/display/plugin-common/display-ops.h +++ b/src/display/plugin-common/display-ops.h @@ -21,6 +21,7 @@ #define __DISPLAY_OPS_H__ #include +#include "display-plugin.h" #include "shared/common.h" #include "shared/devices.h" //#include "display.h" @@ -59,41 +60,4 @@ const struct display_ops *find_display_feature(const char *name); #define DISPLAY_FUNC(a, b) (((a) << 16) | (b)) -enum brightness_request_e { - BR_MIN = 0, - /* entering request */ - BR_LBM_ON, - BR_HBM_ON, - BR_HOLD_BRIGHTNESS, - BR_LOWDIM_ON, /* low battery dim */ - - /* exiting request */ - BR_LBM_OFF, - BR_HBM_OFF, - BR_RELEASE_BRIGHTNESS, - BR_LOWDIM_OFF, /* low battery dim off */ - - /* special */ - BR_SET_BRIGHTNESS, - - BR_MAX, -}; - -/* request for brightness that managed internally. - * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness - * for request, but explicitly request for a brightness value */ -#define BR_IMPLICIT (-1) - -struct display_plugin { - void *handle; - int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout); - int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag); - int (*pm_change_internal) (pid_t pid, int s_bits); - int (*update_pm_setting) (int key_idx, int val); - int (*get_lock_screen_state) (); - bool system_wakeup_flag; - const char* (*device_flags_to_string) (enum device_flags flags); - int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness); -}; - #endif diff --git a/src/display/plugin-common/poll.c b/src/display/plugin-common/poll.c index 9a82c4c..17d1114 100644 --- a/src/display/plugin-common/poll.c +++ b/src/display/plugin-common/poll.c @@ -28,6 +28,7 @@ #include "core.h" #include "poll.h" #include "display-ops.h" +#include "display-plugin.h" #include "shared/plugin.h" #define SHIFT_UNLOCK 4 @@ -38,7 +39,6 @@ #define __HOLDKEY_BLOCK_BIT 0x1 #define HOLDKEY_BLOCK_BIT (__HOLDKEY_BLOCK_BIT << LOCK_FLAG_SHIFT) -static struct display_plugin *disp_plgn; static PMMsg recv_data; int check_dimstay(int next_state, int flag) @@ -166,16 +166,11 @@ static int __pm_change_internal(pid_t pid, int s_bits) return 0; } -void init_pm_internal() +void init_pm_internal(void *data) { - disp_plgn->pm_lock_internal = __pm_lock_internal; - disp_plgn->pm_unlock_internal = __pm_unlock_internal; - disp_plgn->pm_change_internal = __pm_change_internal; -} + struct display_plugin *dp = (struct display_plugin *) data; -static void __CONSTRUCTOR__ initialize(void) -{ - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); + dp->pm_lock_internal = __pm_lock_internal; + dp->pm_unlock_internal = __pm_unlock_internal; + dp->pm_change_internal = __pm_change_internal; } diff --git a/src/display/plugin-common/poll.h b/src/display/plugin-common/poll.h index 5e03f6a..2b9bda2 100644 --- a/src/display/plugin-common/poll.h +++ b/src/display/plugin-common/poll.h @@ -141,6 +141,8 @@ enum cond_flags_e { #define RESET_TIMER_STR "resettimer" #define KEEP_TIMER_STR "keeptimer" +void init_pm_internal(void *data); + /** * @} */ diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index b1ca644..ee1c5f4 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -26,13 +26,13 @@ #include "core/udev.h" #include "core.h" #include "display-ops.h" +#include "display-plugin.h" #include "extcon/extcon.h" #include "shared/plugin.h" #define METHOD_GET_CRADLE "GetCradle" #define SIGNAL_CRADLE_STATE "ChangedCradle" -static struct display_plugin *disp_plgn; static struct extcon_ops cradle_extcon_ops; static void cradle_send_broadcast(int status) @@ -60,8 +60,7 @@ static int cradle_update(const char *index, int status) int ret; _I("Cradle changed. status=%d", status); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL); + display_plugin_pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL); cradle_send_broadcast(status); ret = vconf_set_int(VCONFKEY_SYSMAN_CRADLE_STATUS, status); if (ret < 0) { @@ -70,11 +69,9 @@ static int cradle_update(const char *index, int status) } if (status == DOCK_SOUND) { - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); + display_plugin_pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); } else if (status == DOCK_NONE) { - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN); } return 0; @@ -94,8 +91,7 @@ static int display_changed(void *data) cradle = cradle_extcon_ops.status; if (cradle == DOCK_SOUND) { - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); + display_plugin_pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); _I("Sound dock is connected. Dim lock is on."); } @@ -145,10 +141,3 @@ static struct extcon_ops cradle_extcon_ops = { }; EXTCON_OPS_REGISTER(cradle_extcon_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - 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 3cc6bdb..ae44eaa 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -25,13 +25,13 @@ #include "core/log.h" #include "poll.h" #include "display-ops.h" +#include "display-plugin.h" #include "extcon/extcon.h" #include "shared/plugin.h" #define SIGNAL_EARJACK_STATE "ChangedEarjack" #define GET_EARJACK_STATE "Earjack" -static struct display_plugin *disp_plgn; static void earjack_send_broadcast(int status) { static int old = 0; @@ -79,8 +79,7 @@ static int earjack_update(const char *index, int status) earjack_send_broadcast(status); earjack_send_system_event(status); if (status != EARJACK_DICONNECTED) { - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); + display_plugin_pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); } return 0; @@ -92,10 +91,3 @@ static struct extcon_ops earjack_extcon_ops = { }; EXTCON_OPS_REGISTER(earjack_extcon_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - 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 7727ac3..ff9db34 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -28,6 +28,7 @@ #include "core.h" #include "setting.h" #include "display-ops.h" +#include "display-plugin.h" #include "touch-key.h" #include "shared/plugin.h" @@ -45,7 +46,6 @@ #define GET_BRIGHTNESS(val) (((val) >> 24) & 0xFF) #define SET_BRIGHTNESS(val) (((val) & 0xFF) << 24) -static struct display_plugin *disp_plgn; static bool touchkey_dev_available = false; static guint hardkey_timeout_id; static int hardkey_duration; @@ -141,7 +141,7 @@ static void process_touchkey_enable(bool enable) touchled_set_state(true); /* do not create turnoff timer in case of idle lock state */ - if (disp_plgn->get_lock_screen_state && disp_plgn->get_lock_screen_state() == VCONFKEY_IDLE_LOCK) + if (display_plugin_get_lock_screen_state() == VCONFKEY_IDLE_LOCK) return; /* start timer */ @@ -307,10 +307,3 @@ static const struct device_ops touchled_device_ops = { }; DEVICE_OPS_REGISTER(&touchled_device_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); -} diff --git a/src/shared/apps.c b/src/shared/apps.c index 10e53a0..caa6155 100644 --- a/src/shared/apps.c +++ b/src/shared/apps.c @@ -22,13 +22,12 @@ #include "core/log.h" #include "shared/common.h" #include "apps.h" -#include "shared/plugin.h" +#include "display-plugin.h" #include "shared/bitmap.h" #define POPUP_METHOD "PopupLaunch" #define BUFF_MAX 255 -static struct display_plugin *disp_plgn; static struct dd_bitmap *bm_background; static int pid_max; @@ -104,8 +103,7 @@ int launch_system_app(char *type, int num, ...) va_end(args); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + display_plugin_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); return ret; } @@ -124,8 +122,8 @@ int launch_message_post(char *type) g_variant_new("(s)", type), __cb, -1, NULL); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + display_plugin_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + return ret; } @@ -197,10 +195,6 @@ void set_app_state(pid_t pid, enum application_state as) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); - init_bm_background(); } diff --git a/src/shared/plugin.c b/src/shared/plugin.c index db8725c..aff5f8f 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -30,6 +30,7 @@ #include "plugin.h" #include "common.h" +#include "display-plugin.h" #include "core/log.h" #ifndef LIBPATH @@ -37,13 +38,13 @@ #endif #define MODULE_PATH LIBPATH"/deviced/" -static struct display_plugin disp_plgn; +extern struct display_plugin g_display_plugin; static struct battery_plugin battery_plgn; static GList *plgn_list; inline struct display_plugin *get_var_display_plugin(void) { - return &disp_plgn; + return &g_display_plugin; } inline struct battery_plugin *get_var_battery_plugin(void) @@ -111,7 +112,7 @@ void load_plugins(void) _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.so")) - disp_plgn.handle = handle; + g_display_plugin.handle = handle; else if (!strcmp(ent->d_name, "battery.so")) battery_plgn.handle = handle; } diff --git a/src/time/time-handler.c b/src/time/time-handler.c index 7daa9ed..46b80ec 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -38,6 +38,7 @@ #include "poll.h" #include "core.h" #include "display-ops.h" +#include "display-plugin.h" #include "shared/common.h" #include "shared/device-notifier.h" #include "shared/plugin.h" @@ -66,7 +67,6 @@ #define TIME_CHANGE_SIGNAL "STimeChanged" -static struct display_plugin *disp_plgn; static const time_t default_time = 2147483645; /* max(32bit) -3sec */ static guint tfdh; /* tfd change noti */ static int tfd = -1; @@ -191,13 +191,11 @@ int set_datetime_action(int argc, char **argv) else pm_state = 0x4; - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + display_plugin_pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); ret = handle_date(argv[0]); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); return ret; } @@ -220,13 +218,11 @@ int set_timezone_action(int argc, char **argv) else pm_state = 0x4; - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + display_plugin_pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); ret = handle_timezone(argv[0]); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); return ret; } @@ -399,7 +395,7 @@ static void time_init(void *data) _E("Failed system time change detector init."); register_notifier(DEVICE_NOTIFIER_LCD, time_lcd_changed_cb); - get_cond_head = dlsym(disp_plgn->handle, "get_cond_head"); + get_cond_head = dlsym(display_plugin_handle(), "get_cond_head"); if (!get_cond_head) _E("Failed to load symbol get_cond_head(), %s.", dlerror()); } @@ -410,10 +406,3 @@ static const struct device_ops time_device_ops = { }; DEVICE_OPS_REGISTER(&time_device_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - 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 5f334cf..4b9d5bb 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -29,6 +29,7 @@ #include "battery/power-supply.h" #include "core.h" #include "display-ops.h" +#include "display-plugin.h" #include "power/power-boot.h" #include "shared/plugin.h" @@ -37,7 +38,6 @@ enum ps_mode { POWERSAVING_ON, }; -static struct display_plugin *disp_plgn; static struct battery_plugin *battery_plgn; static bool touchscreen_dev_available = false; static int touchscreen_enable = DEVICE_OPS_STATUS_START; @@ -313,8 +313,9 @@ static int delayed_init_done(void *data) static void touchscreen_init(void *data) { int ret, val; + void *handle = display_plugin_handle(); - fp_get_var_display_config = dlsym(disp_plgn->handle, "get_var_display_config"); + fp_get_var_display_config = dlsym(handle, "get_var_display_config"); if (fp_get_var_display_config) { display_conf = fp_get_var_display_config(); if (!display_conf) @@ -326,7 +327,7 @@ static void touchscreen_init(void *data) * So it fails that fetching symbol directly with name 'backlight_ops'. * To avoid this, fetches getter function 'get_var_backlight_ops' instead, and * retrieve the 'backlight_ops' by using it */ - fp_get_var_backlight_ops = dlsym(disp_plgn->handle, "get_var_backlight_ops"); + fp_get_var_backlight_ops = dlsym(handle, "get_var_backlight_ops"); if (fp_get_var_backlight_ops) { backlight_ops = fp_get_var_backlight_ops(); if (!backlight_ops) @@ -384,10 +385,6 @@ DEVICE_OPS_REGISTER(&touchscreen_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); - battery_plgn = get_var_battery_plugin(); if (!battery_plgn) _E("Failed to get battery plugin variable."); diff --git a/src/usb-gadget/usb-gadget.c b/src/usb-gadget/usb-gadget.c index 341d934..009fa59 100644 --- a/src/usb-gadget/usb-gadget.c +++ b/src/usb-gadget/usb-gadget.c @@ -24,6 +24,7 @@ #include "core/udev.h" #include "poll.h" #include "display-ops.h" +#include "display-plugin.h" #include "shared/plugin.h" #include "usb-gadget.h" @@ -33,8 +34,6 @@ static int usb_change_gadget(unsigned mode); -static struct display_plugin *disp_plgn; - static int usb_config_init(void) { unsigned int mode = usb_state_get_selected_mode(); @@ -105,8 +104,7 @@ static int usb_connected(void) int ret; unsigned int mode = usb_state_get_selected_mode(); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); + display_plugin_pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); usb_state_set_connection(USB_CONNECTED); send_usb_state_changed_event(VCONFKEY_SYSMAN_USB_CONNECTED); @@ -131,11 +129,10 @@ static int usb_disconnected(void) ret = usb_disable(); if(ret < 0) { _E("Failed to disable USB gadget: %d", ret); - /* Important: You have to keep going to unlock disp_plgn->pm_unlock_internal */ + /* Important: You have to keep going to unlock display_plugin_pm_unlock_internal */ } - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); + display_plugin_pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); return ret; } @@ -344,10 +341,3 @@ static struct extcon_ops extcon_usb_ops = { }; EXTCON_OPS_REGISTER(extcon_usb_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); -} diff --git a/src/usb-host/usb-host.c b/src/usb-host/usb-host.c index f4057ef..c5c8668 100644 --- a/src/usb-host/usb-host.c +++ b/src/usb-host/usb-host.c @@ -32,6 +32,7 @@ #include "core/udev.h" #include "extcon/extcon.h" #include "display-ops.h" +#include "display-plugin.h" #include "core.h" #include "dd-usbhost.h" #include "shared/plugin.h" @@ -53,7 +54,6 @@ #define ROOTPATH tzplatform_getenv(TZ_SYS_VAR) #define POLICY_FILENAME "usbhost-policy" -static struct display_plugin *disp_plgn; static struct display_config *disp_conf; static struct display_config* (*fp_get_var_display_config)(void); static bool display_on_usb_conn_changed = true; @@ -244,8 +244,8 @@ static int add_usbhost_list(struct udev_device *dev, const char *devpath) broadcast_usbhost_signal(USB_HOST_ADDED, usbhost); - if (display_on_usb_conn_changed && disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); + if (display_on_usb_conn_changed) + display_plugin_pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); /* for debugging */ _I("USB HOST Added."); @@ -273,8 +273,8 @@ static int remove_usbhost_list(const char *devpath) broadcast_usbhost_signal(USB_HOST_REMOVED, usbhost); - if (display_on_usb_conn_changed && disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); + if (display_on_usb_conn_changed) + display_plugin_pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); /* for debugging */ _I("USB HOST Removed."); @@ -1132,7 +1132,7 @@ static void usbhost_init(void *data) { int ret; - fp_get_var_display_config = dlsym(disp_plgn->handle, "get_var_display_config"); + fp_get_var_display_config = dlsym(display_plugin_handle(), "get_var_display_config"); if (fp_get_var_display_config) { disp_conf = fp_get_var_display_config(); if (!disp_conf) @@ -1215,10 +1215,3 @@ static struct extcon_ops extcon_usbhost_ops = { }; EXTCON_OPS_REGISTER(extcon_usbhost_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); -} diff --git a/tests/deviced-common-private-test/CMakeLists.txt b/tests/deviced-common-private-test/CMakeLists.txt index 7c3323d..212a7f3 100644 --- a/tests/deviced-common-private-test/CMakeLists.txt +++ b/tests/deviced-common-private-test/CMakeLists.txt @@ -14,6 +14,7 @@ PKG_CHECK_MODULES(ORIG_REQUIRED_PKGS REQUIRED SET(WRAP_FLAGS "-Wl,--wrap=dlopen") SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=access") +SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=display_plugin_pm_change_internal") FILE(GLOB ORIG_SRCS "${CMAKE_SOURCE_DIR}/src/shared/*.c") ADD_LIBRARY(test-shared SHARED ${ORIG_SRCS}) diff --git a/tests/deviced-common-private-test/test-mock.c b/tests/deviced-common-private-test/test-mock.c index 63ea2cd..c3eba7e 100644 --- a/tests/deviced-common-private-test/test-mock.c +++ b/tests/deviced-common-private-test/test-mock.c @@ -1,8 +1,15 @@ #include +#include +#include + +/* FIXME: This would be replaced to plugin-api-deviced */ +#include "display-plugin.h" #include "test-main.h" #include "test-mock.h" +struct display_plugin g_display_plugin; + int __wrap_access(const char *pathname, int mode) { return mock_type(int); @@ -18,3 +25,8 @@ void *__wrap_dlopen(const char *filename, int flags) return ret; } + +int __wrap_display_plugin_pm_change_internal(pid_t pid, int s_bits) +{ + return 0; +} -- 2.7.4 From e0de9aa48fa8b4afb72be7482669609e13627644 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 22 Mar 2023 13:22:41 +0900 Subject: [PATCH 04/16] display: Move plugin get_var_display_conf() to core Instead of get_var_display_config(), declare 'g_display_plugin.config'. - plugin/*/display/core.c: get_var_display_config() => src/display/display-config.c: g_display_plugin.config Fixed existing code into two way in case of 'g_display_plugin.config' has not been initialized: - If there has been logic that handling (g_display_plugin.config == NULL), then followed that logic. - Otherwise, added assert(g_display_plugin.config). It can spot error that could be derived from later patches. This only has been applied to those code that will be a part of display core, that is, codes under src/display/plugin-common. The codes that stays in plugin work the way they used to. Change-Id: I7f65d149298358e2c9116a504fdda952fb9c3963 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 4 +++ plugins/mobile/display/core.c | 4 +++ plugins/tv/display/core.c | 4 +++ plugins/wearable/display/core.c | 4 +++ src/display/display-config.c | 1 - src/display/display-config.h | 2 ++ src/display/display-plugin.h | 4 +++ src/display/display.c | 4 +-- src/display/plugin-common/auto-brightness.c | 47 +++++++++++++++------------ src/display/plugin-common/display-backlight.c | 26 +++++++-------- src/display/plugin-common/display-dbus.c | 27 ++++++++------- src/display/plugin-common/display-dpms.c | 6 ++-- src/display/plugin-common/display-input.c | 6 ++-- src/display/plugin-common/display-lock.c | 18 +++------- src/display/plugin-common/setting.c | 11 +++---- src/touchscreen/touchscreen.c | 25 +++++--------- src/usb-host/usb-host.c | 15 ++------- 17 files changed, 104 insertions(+), 104 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 8c68386..4a65ba7 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -1922,6 +1922,10 @@ static void add_timer_for_dpms_init(void) static int display_probe(void *data) { int ret; + struct display_plugin *dp = (struct display_plugin *) data; + assert(dp); + + dp->config = &display_conf; /* check display feature */ if (!is_feature_display_supported()) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 90a7c9b..2169da1 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1932,6 +1932,10 @@ static void add_timer_for_dpms_init(void) static int display_probe(void *data) { int ret; + struct display_plugin *dp = (struct display_plugin *) data; + assert(dp); + + dp->config = &display_conf; /** * load display service diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 0299f83..f2834b8 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1923,6 +1923,10 @@ static void add_timer_for_dpms_init(void) static int display_probe(void *data) { int ret; + struct display_plugin *dp = (struct display_plugin *) data; + assert(dp); + + dp->config = &display_conf; /** * load display service diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index b692b00..8a7a220 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -2211,6 +2211,10 @@ static void add_timer_for_dpms_init(void) static int display_probe(void *data) { int ret; + struct display_plugin *dp = (struct display_plugin *) data; + assert(dp); + + dp->config = &display_conf; /** * load display service diff --git a/src/display/display-config.c b/src/display/display-config.c index 2dac564..9c57647 100644 --- a/src/display/display-config.c +++ b/src/display/display-config.c @@ -109,4 +109,3 @@ int display_load_config(struct display_config *config) { return config_parse(DISPLAY_CONF_FILE, display_config_parse, config); } - diff --git a/src/display/display-config.h b/src/display/display-config.h index 1d2cdfe..9c90bb2 100644 --- a/src/display/display-config.h +++ b/src/display/display-config.h @@ -19,6 +19,8 @@ #ifndef __DISPLAY_CONFIG_H__ #define __DISPLAY_CONFIG_H__ +#include + #define DISPLAY_CONF_FILE "/etc/deviced/display.conf" /* * @brief Configuration structure diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 28411bb..d67ebc2 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -22,6 +22,7 @@ #include #include +#include "display-config.h" #include "shared/devices.h" /* FIXME: Currently because of display_plugin.auto_brightness_control(), @@ -61,7 +62,10 @@ struct display_plugin { bool system_wakeup_flag; const char* (*device_flags_to_string) (enum device_flags flags); int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness); + + struct display_config *config; }; +extern struct display_plugin g_display_plugin; void* display_plugin_handle(void); int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout); diff --git a/src/display/display.c b/src/display/display.c index def14e7..8798d7d 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -19,12 +19,12 @@ #include #include +#include "display.h" #include "display-plugin.h" -#include "display/display.h" +#include "display-config.h" #include "shared/log.h" static const struct device_ops *display_plugin_device_ops; -extern struct display_plugin g_display_plugin; static int pm_cur_state; static int pm_old_state; static unsigned int pm_status_flag; diff --git a/src/display/plugin-common/auto-brightness.c b/src/display/plugin-common/auto-brightness.c index a5f75ef..4d594ad 100644 --- a/src/display/plugin-common/auto-brightness.c +++ b/src/display/plugin-common/auto-brightness.c @@ -23,16 +23,17 @@ #include #include #include +#include #include #include #include #include - #include "util.h" #include "core.h" #include "display-ops.h" #include "display-backlight.h" +#include "display-config.h" #include "setting.h" #include "shared/device-notifier.h" #include @@ -73,7 +74,6 @@ static char *min_brightness_name = 0; /* light sensor */ static float lmax, lmin; -static const struct display_config *display_conf; static bool update_working_position(void) { @@ -81,7 +81,9 @@ static bool update_working_position(void) int ret; float x, y, z, pitch, realg; - if (!display_conf->accel_sensor_on) + assert(g_display_plugin.config); + + if (!g_display_plugin.config->accel_sensor_on) return false; ret = sensor_listener_read_data(accel_listener, &data); @@ -109,6 +111,8 @@ static void alc_set_brightness(int setting, int value, float light) static float old; int position, tmp_value = 0, ret; + assert(g_display_plugin.config); + ret = display_backlight_get_brightness_by_plugin_profile(&tmp_value); if (ret < 0) { _E("Failed to get display brightness."); @@ -120,7 +124,7 @@ static void alc_set_brightness(int setting, int value, float light) if (tmp_value != value) { if (!setting && min_brightness == PM_MIN_BRIGHTNESS && - display_conf->accel_sensor_on == true) { + g_display_plugin.config->accel_sensor_on == true) { position = update_working_position(); if (!position && (old > light)) { _D("It's not working position, " @@ -131,11 +135,11 @@ static void alc_set_brightness(int setting, int value, float light) int diff, step; diff = value - tmp_value; - if (abs(diff) < display_conf->brightness_change_step) + if (abs(diff) < g_display_plugin.config->brightness_change_step) step = (diff > 0 ? 1 : -1); else step = (int)ceil(diff / - (float)display_conf->brightness_change_step); + (float)g_display_plugin.config->brightness_change_step); _D("%d", step); while (tmp_value != value) { @@ -179,6 +183,8 @@ static bool alc_update_brt(bool setting) int index; float light; + assert(g_display_plugin.config); + ret = sensor_listener_read_data(light_listener, &light_data); if (ret != SENSOR_ERROR_NONE) { _E("Failed to read light sensor data: %d", ret); @@ -206,7 +212,7 @@ static bool alc_update_brt(bool setting) fault_count = 0; - if (display_conf->continuous_sampling && + if (g_display_plugin.config->continuous_sampling && !check_brightness_changed(value) && !setting) return true; @@ -253,12 +259,14 @@ static gboolean alc_handler(void *data) static int alc_action(int timeout) { + assert(g_display_plugin.config); + /* sampling timer add */ if (alc_timeout_id == 0 && !(get_pm_status_flag() & PWRSV_FLAG)) { display_info.update_auto_brightness(true); alc_timeout_id = - g_timeout_add_seconds(display_conf->lightsensor_interval, + g_timeout_add_seconds(g_display_plugin.config->lightsensor_interval, alc_handler, NULL); } @@ -276,6 +284,8 @@ static int connect_sensor(void) sensor_h *list = NULL; int cnt = 0; + assert(g_display_plugin.config); + _I("Connect with sensor fw."); /* light sensor */ ret = sensor_get_sensor_list(SENSOR_LIGHT, &list, &cnt); @@ -320,7 +330,7 @@ static int connect_sensor(void) goto error; } - if (!display_conf->accel_sensor_on) + if (!g_display_plugin.config->accel_sensor_on) goto success; /* accelerometer sensor */ @@ -353,7 +363,7 @@ error: sensor_destroy_listener(light_listener); light_listener = 0; } - if (display_conf->accel_sensor_on && accel_listener > 0) { + if (g_display_plugin.config->accel_sensor_on && accel_listener > 0) { sensor_listener_stop(accel_listener); sensor_destroy_listener(accel_listener); accel_listener = 0; @@ -363,6 +373,8 @@ error: static int disconnect_sensor(void) { + assert(g_display_plugin.config); + _I("Disconnect with sensor fw."); /* light sensor*/ if (light_listener > 0) { @@ -372,7 +384,7 @@ static int disconnect_sensor(void) } /* accelerometer sensor*/ - if (display_conf->accel_sensor_on && accel_listener > 0) { + if (g_display_plugin.config->accel_sensor_on && accel_listener > 0) { sensor_listener_stop(accel_listener); sensor_destroy_listener(accel_listener); accel_listener = 0; @@ -405,6 +417,8 @@ static int set_autobrightness_state(int status) int brt = -1; int default_brt = -1; + assert(g_display_plugin.config); + if (status == SETTING_BRIGHTNESS_AUTOMATIC_ON) { if (connect_sensor() < 0) return -1; @@ -420,7 +434,7 @@ static int set_autobrightness_state(int status) display_info.update_auto_brightness(true); alc_timeout_id = - g_timeout_add_seconds(display_conf->lightsensor_interval, + g_timeout_add_seconds(g_display_plugin.config->lightsensor_interval, alc_handler, NULL); } else if (status == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) { _I("Auto brightness paused."); @@ -433,7 +447,7 @@ static int set_autobrightness_state(int status) ret = get_setting_brightness(&default_brt); if (ret != 0 || (default_brt < PM_MIN_BRIGHTNESS || default_brt > PM_MAX_BRIGHTNESS)) { _I("Failed to read vconf value for brightness."); - brt = display_conf->pm_default_brightness; + brt = g_display_plugin.config->pm_default_brightness; if (default_brt < PM_MIN_BRIGHTNESS || default_brt > PM_MAX_BRIGHTNESS) { ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt); if (ret < 0) @@ -681,10 +695,3 @@ static const struct display_ops display_autobrightness_ops = { }; DISPLAY_OPS_REGISTER(&display_autobrightness_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - display_conf = get_var_display_config(); - if (!display_conf) - _E("Failed to get display configuration variable."); -} diff --git a/src/display/plugin-common/display-backlight.c b/src/display/plugin-common/display-backlight.c index 51fe33c..062315f 100644 --- a/src/display/plugin-common/display-backlight.c +++ b/src/display/plugin-common/display-backlight.c @@ -27,11 +27,11 @@ #include "display.h" #include "display-backlight.h" #include "display-dpms.h" +#include "display-plugin.h" #define DUMP_MODE_WAITING_TIME 600000 /* milisecond */ #define LCD_PHASED_DELAY 10000 /* microsecond */ -static const struct display_config *display_conf; static struct _backlight_ops *backlight_ops; static int default_brightness; @@ -249,6 +249,8 @@ int display_backlight_change_brightness_by_dpms_state(enum dpms_state state) int start, end; int default_brightness; + assert(g_display_plugin.config); + display_backlight_get_default_brightness(&default_brightness); if (backlight_ops && backlight_ops->transit_state) @@ -258,7 +260,7 @@ int display_backlight_change_brightness_by_dpms_state(enum dpms_state state) if (state == DPMS_OFF) { start = brt; - end = display_conf->aod_enter_level; + end = g_display_plugin.config->aod_enter_level; /* * The value of display_backlight_get_brightness is system brightness. @@ -267,19 +269,19 @@ int display_backlight_change_brightness_by_dpms_state(enum dpms_state state) */ display_backlight_get_brightness(&val); - if (val > display_conf->aod_enter_level) - display_backlight_change_brightness(start, end, display_conf->brightness_change_step); + if (val > g_display_plugin.config->aod_enter_level) + display_backlight_change_brightness(start, end, g_display_plugin.config->brightness_change_step); } else { /* prevent transit effect when another effect is already executed */ - if (brt != display_conf->aod_enter_level) { + if (brt != g_display_plugin.config->aod_enter_level) { _W("effect is already executed brt(%d) aod_level(%d)", - brt, display_conf->aod_enter_level); + brt, g_display_plugin.config->aod_enter_level); return 0; } - start = display_conf->aod_enter_level; + start = g_display_plugin.config->aod_enter_level; end = default_brightness; - display_backlight_change_brightness(start, end, display_conf->brightness_change_step); + display_backlight_change_brightness(start, end, g_display_plugin.config->brightness_change_step); } return 0; @@ -288,8 +290,8 @@ int display_backlight_change_brightness_by_dpms_state(enum dpms_state state) int display_backlight_set_default_brightness(int brightness) { if (brightness < PM_MIN_BRIGHTNESS || brightness > PM_MAX_BRIGHTNESS) { - if (display_conf) - brightness = display_conf->pm_default_brightness; + if (g_display_plugin.config) + brightness = g_display_plugin.config->pm_default_brightness; else return -EPERM; } @@ -488,10 +490,6 @@ void display_backlight_get_force_brightness(int *brightness) /* FIXME: This code structure should be changed to plugin api call, after plugin refactoting*/ static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_var_display_config(); - if (!display_conf) - _W("Failed to get display configuration variable."); - backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _W("Failed to get backlight operator variable."); diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index fa77a7c..3e198ef 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include "shared/plugin.h" #include "display-lock.h" #include "display-panel.h" +#include "display-config.h" //#include "display/display.h" #include "display-backlight.h" @@ -73,7 +75,6 @@ #define EXPIRED_POPUP_ID "_REQUEST_ID_" static struct display_plugin *disp_plgn; -static const struct display_config *display_conf; static GVariant *dbus_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, @@ -124,6 +125,8 @@ static GVariant *dbus_lockstate(GDBusConnection *conn, int ret = 0; unsigned int caps; + assert(g_display_plugin.config); + g_variant_get(param, "(sssi)", &state_str, &option1_str, &option2_str, &timeout); if (!state_str || timeout < 0) { @@ -145,7 +148,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 (!g_display_plugin.config->dimming) { _E("LCD_DIM lock is not supported."); ret = -EINVAL; goto out; @@ -214,6 +217,8 @@ static GVariant *dbus_unlockstate(GDBusConnection *conn, int flag; int ret = 0; + assert(g_display_plugin.config); + g_variant_get(param, "(ss)", &state_str, &option_str); if (!state_str) { @@ -235,7 +240,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 (!g_display_plugin.config->dimming) { _E("LCD_DIM unlock is not supported."); ret = -EINVAL; goto out; @@ -278,6 +283,8 @@ static GVariant *dbus_changestate(GDBusConnection *conn, int ret = 0, len, lcdon_blocked; unsigned int caps; + assert(g_display_plugin.config); + g_variant_get(param, "(s)", &state_str); if (!state_str) { @@ -305,7 +312,7 @@ static GVariant *dbus_changestate(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 (!g_display_plugin.config->dimming) { _E("LCD_DIM state is not supported."); ret = -EINVAL; goto out; @@ -642,20 +649,22 @@ static GVariant *dbus_setrefreshrate(GDBusConnection *conn, { int app, val, ret, control; + assert(g_display_plugin.config); + g_variant_get(param, "(ii)", &app, &val); - if (app < 0 || app >= ARRAY_SIZE(display_conf->framerate_app) || val < 0) { + if (app < 0 || app >= ARRAY_SIZE(g_display_plugin.config->framerate_app) || val < 0) { ret = -EINVAL; goto error; } - if (!display_conf->framerate_app[app]) { + if (!g_display_plugin.config->framerate_app[app]) { _I("This case(%d) is not support in this target", app); ret = -EPERM; goto error; } - control = display_conf->control_display; + control = g_display_plugin.config->control_display; if (control) display_panel_set_panel_state_by_off_state(NORMAL_MODE); @@ -1471,8 +1480,4 @@ static void __CONSTRUCTOR__ initialize(void) if (!disp_plgn) { _E("Failed to get display plugin variable."); } - - display_conf = get_var_display_config(); - if (!display_conf) - _E("Failed to get display configuration variable."); } diff --git a/src/display/plugin-common/display-dpms.c b/src/display/plugin-common/display-dpms.c index e9bf433..4124ef7 100644 --- a/src/display/plugin-common/display-dpms.c +++ b/src/display/plugin-common/display-dpms.c @@ -31,6 +31,7 @@ #include "device-interface.h" #include "util.h" #include "display-dpms.h" +#include "display-plugin.h" #include "device-interface.h" #include "core.h" @@ -646,13 +647,12 @@ int dpms_get_cached_state(void) bool dpms_init(void) { - const struct display_config *display_conf = get_var_display_config(); - if (!display_conf) { + if (!g_display_plugin.config) { _E("Failed to get display configuration"); return false; } - switch (display_conf->display_dpms_type) { + switch (g_display_plugin.config->display_dpms_type) { case DISPLAY_DPMS_TYPE_WINDOW_MANAGER: g_dpms_ops.set_state = wm_dpms_set_state; g_dpms_ops.get_state = wm_dpms_get_state; diff --git a/src/display/plugin-common/display-input.c b/src/display/plugin-common/display-input.c index df63a54..3b608a3 100644 --- a/src/display/plugin-common/display-input.c +++ b/src/display/plugin-common/display-input.c @@ -27,6 +27,7 @@ #include "core.h" #include "poll.h" #include "ambient-mode.h" +#include "display-plugin.h" #define SEAT_NAME "seat0" @@ -38,8 +39,7 @@ static void process_input(struct libinput_event *ev) struct libinput_event_keyboard *k; unsigned int time; int fd = 0; - const struct display_config *display_conf = get_var_display_config(); - if(!display_conf) { + if(!g_display_plugin.config) { _E("Failed to get display configuration variable."); return; } @@ -88,7 +88,7 @@ static void process_input(struct libinput_event *ev) break; case LIBINPUT_EVENT_TOUCH_MOTION: case LIBINPUT_EVENT_TOUCH_FRAME: - if (touch_event_blocked() && !ambient_get_state() && !display_conf->touch_wakeup) + if (touch_event_blocked() && !ambient_get_state() && !g_display_plugin.config->touch_wakeup) return; input.type = EV_ABS; input.value = KEY_BEING_PRESSED; diff --git a/src/display/plugin-common/display-lock.c b/src/display/plugin-common/display-lock.c index ad7c2f7..901f58c 100644 --- a/src/display/plugin-common/display-lock.c +++ b/src/display/plugin-common/display-lock.c @@ -42,8 +42,6 @@ static GList *cond_head[S_END]; static int trans_condition; -static const struct display_config *display_conf; - bool check_lock_state(int state) { GList *elem; @@ -248,7 +246,7 @@ PmLockNode *add_node(enum state_t s_index, pid_t pid, guint timeout_id, PmLockNode *n; time_t now; - assert(display_conf); + assert(g_display_plugin.config); n = (PmLockNode *) calloc(1, sizeof(PmLockNode)); if (n == NULL) { @@ -274,12 +272,12 @@ PmLockNode *add_node(enum state_t s_index, pid_t pid, guint timeout_id, /* check if this lock node needs custom-defined lock checker. * n->warning_id would be 0 if fails to register the checker, * or there is no need to use that checker */ - if (display_conf->pmlock_check) - n->warning_id = display_conf->pmlock_check(n); + if (g_display_plugin.config->pmlock_check) + n->warning_id = g_display_plugin.config->pmlock_check(n); /* use default lock checker */ if (!n->warning_id) - n->warning_id = g_timeout_add_seconds(display_conf->lockcheck_timeout, + n->warning_id = g_timeout_add_seconds(g_display_plugin.config->lockcheck_timeout, default_pmlock_check, (gpointer)n); } @@ -564,11 +562,3 @@ void update_lock_timer(PMMsg *data, g_source_remove(node->timeout_id); node->timeout_id = timeout_id; } - -static void __CONSTRUCTOR__ initialize(void) -{ - display_conf = get_var_display_config(); - if (!display_conf) { - _E("Failed to get display config variable."); - } -} diff --git a/src/display/plugin-common/setting.c b/src/display/plugin-common/setting.c index cc695ff..e652a9c 100644 --- a/src/display/plugin-common/setting.c +++ b/src/display/plugin-common/setting.c @@ -48,7 +48,6 @@ static int force_lcdtimeout = 0; static int custom_on_timeout = 0; static int custom_normal_timeout = 0; static int custom_dim_timeout = 0; -static const struct display_config *display_conf; int (*update_pm_setting) (int key_idx, int val); @@ -143,12 +142,14 @@ void get_dim_timeout(int *dim_timeout) { int vconf_timeout, on_timeout, val, ret; + assert(g_display_plugin.config); + if (custom_dim_timeout > 0) { *dim_timeout = custom_dim_timeout; return; } - if (!display_conf->dimming || ambient_get_condition()) { + if (!g_display_plugin.config->dimming || ambient_get_condition()) { *dim_timeout = LCD_MIN_DIM_TIMEOUT; return; } @@ -215,7 +216,7 @@ int set_custom_lcdon_timeout(int timeout) return changed; } - if (display_conf->dimming) + if (g_display_plugin.config && g_display_plugin.config->dimming) custom_dim_timeout = (double)timeout * LCD_DIM_RATIO; else custom_dim_timeout = LCD_MIN_DIM_TIMEOUT; @@ -282,8 +283,4 @@ static void __CONSTRUCTOR__ initialize(void) if (!disp_plgn) { _E("Failed to get display plugin variable."); } - - display_conf = get_var_display_config(); - if (!display_conf) - _E("Failed to get display configuration variable."); } diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index 4b9d5bb..2b3b66e 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -30,6 +30,7 @@ #include "core.h" #include "display-ops.h" #include "display-plugin.h" +#include "display-config.h" #include "power/power-boot.h" #include "shared/plugin.h" @@ -48,12 +49,10 @@ static int touchscreen_stop(enum device_flags flags); static int delayed_init_done(void *data); -static struct display_config *display_conf; static struct _backlight_ops *backlight_ops; static struct battery_status *battery = NULL; 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) @@ -61,10 +60,10 @@ static void touchscreen_wakeup_status(keynode_t *key, void *data) if (!key) return; - if (!display_conf || !backlight_ops) + if (!g_display_plugin.config || !backlight_ops) return; - display_conf->touch_wakeup = vconf_keynode_get_bool(key); + g_display_plugin.config->touch_wakeup = vconf_keynode_get_bool(key); /** * FIXME: backlight_ops->get_lcd_power() should be changed to @@ -72,7 +71,7 @@ static void touchscreen_wakeup_status(keynode_t *key, void *data) * After deviding src/display module and plugin display module from build. */ if (backlight_ops->get_lcd_power() != DPMS_ON) { - if (display_conf->touch_wakeup) + if (g_display_plugin.config->touch_wakeup) touchscreen_start(NORMAL_MODE); else touchscreen_stop(TOUCH_SCREEN_OFF_MODE); @@ -208,7 +207,7 @@ static int touchscreen_start(enum device_flags flags) static int touchscreen_stop(enum device_flags flags) { - if (!display_conf || !backlight_ops) { + if (!g_display_plugin.config || !backlight_ops) { _I("Touchscreen is not initialized."); goto exit; } @@ -233,7 +232,7 @@ static int touchscreen_stop(enum device_flags flags) return touchscreen_powersaving(POWERSAVING_ON); } - if (display_conf->touch_wakeup) { + if (g_display_plugin.config->touch_wakeup) { _I("Touch wakeup enabled."); return touchscreen_powersaving(POWERSAVING_ON); } @@ -315,14 +314,6 @@ static void touchscreen_init(void *data) int ret, val; void *handle = display_plugin_handle(); - fp_get_var_display_config = dlsym(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_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_var_backlight_ops' instead, and @@ -358,8 +349,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 (g_display_plugin.config && ret == 0) + g_display_plugin.config->touch_wakeup = val; ret = gdbus_add_object(NULL, DEVICED_PATH_TOUCH, &dbus_interface); diff --git a/src/usb-host/usb-host.c b/src/usb-host/usb-host.c index c5c8668..68a5b8c 100644 --- a/src/usb-host/usb-host.c +++ b/src/usb-host/usb-host.c @@ -33,6 +33,7 @@ #include "extcon/extcon.h" #include "display-ops.h" #include "display-plugin.h" +#include "display-config.h" #include "core.h" #include "dd-usbhost.h" #include "shared/plugin.h" @@ -54,8 +55,6 @@ #define ROOTPATH tzplatform_getenv(TZ_SYS_VAR) #define POLICY_FILENAME "usbhost-policy" -static struct display_config *disp_conf; -static struct display_config* (*fp_get_var_display_config)(void); static bool display_on_usb_conn_changed = true; static char *POLICY_FILEPATH; @@ -1132,16 +1131,8 @@ static void usbhost_init(void *data) { int ret; - fp_get_var_display_config = dlsym(display_plugin_handle(), "get_var_display_config"); - if (fp_get_var_display_config) { - disp_conf = fp_get_var_display_config(); - if (!disp_conf) - _E("Failed to get display config variable."); - else - display_on_usb_conn_changed = disp_conf->display_on_usb_conn_changed; - } else { - _E("Failed to obtain address of get_var_display_config, %s.", dlerror()); - } + if (g_display_plugin.config) + display_on_usb_conn_changed = g_display_plugin.config->display_on_usb_conn_changed; /* register usbhost uevent */ ret = register_kernel_uevent_control(&uh); -- 2.7.4 From e8328112a22e381833d7704703f13a93e697b78b Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 23 Mar 2023 14:49:47 +0900 Subject: [PATCH 05/16] display: Move plugin display-backlight.c to core The source code display-backlight.c has been relocated: - src/display/plugin-common/display-backlight.c => src/display/display-backlight.c The struct _backlight_ops has been relocated: - src/display/plugin-common/device-interface.h: struct _backlight_ops => src/display/display-backlight.h: struct display_backlight_ops Currently, the display_backlight_ops is utilized by plugin and it is registered to display_plugin. Add wrapper for each member function so that the deviced core can invoke matching plugin function if exist. - display_plugin_backlight_get_lcd_power() - display_plugin_backlight_set_brightness() - display_plugin_backlight_get_brightness() - display_plugin_backlight_transit_state() - display_plugin_backlight_transit_brightness() Change-Id: Ieb93fd50bd9df968d6a3a77556134ea297e60d42 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 4 +- plugins/iot-headed/display/device-interface.c | 13 +++++-- plugins/iot-headed/display/key-filter.c | 2 +- plugins/mobile/display/core.c | 4 +- plugins/mobile/display/device-interface.c | 13 +++++-- plugins/mobile/display/key-filter.c | 2 +- plugins/tv/display/core.c | 4 +- plugins/tv/display/device-interface.c | 13 +++++-- plugins/tv/display/key-filter.c | 2 +- .../wearable/display/auto-brightness-sensorhub.c | 2 +- plugins/wearable/display/core.c | 4 +- plugins/wearable/display/device-interface.c | 13 +++++-- plugins/wearable/display/display-handler.c | 2 +- plugins/wearable/display/enhance.c | 2 +- plugins/wearable/display/key-filter.c | 2 +- plugins/wearable/display/lbm.c | 2 +- plugins/wearable/display/powersaver.c | 2 +- plugins/wearable/display/swim.c | 2 +- .../{plugin-common => }/display-backlight.c | 39 +++++++++----------- .../{plugin-common => }/display-backlight.h | 13 +++++-- src/display/display-plugin.c | 43 ++++++++++++++++++++++ src/display/display-plugin.h | 8 ++++ src/display/plugin-common/device-interface.h | 13 ++----- src/touchscreen/touchscreen.c | 28 +++----------- 24 files changed, 151 insertions(+), 81 deletions(-) rename src/display/{plugin-common => }/display-backlight.c (93%) rename src/display/{plugin-common => }/display-backlight.h (83%) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 4a65ba7..c27e1f6 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -61,6 +61,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "device-interface.h" #include "display-plugin.h" #include "display-dpms.h" #include "display-signal.h" @@ -92,7 +93,7 @@ extern void init_save_userlock(void); static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_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); @@ -1926,6 +1927,7 @@ static int display_probe(void *data) assert(dp); dp->config = &display_conf; + setup_display_plugin_backlight_ops(dp); /* check display feature */ if (!is_feature_display_supported()) diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index 011d6ef..beaa035 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -65,11 +65,11 @@ #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" -static struct _backlight_ops backlight_ops; +static struct display_backlight_ops backlight_ops; static bool display_dev_available = false; static const struct display_config *display_conf; -inline struct _backlight_ops *get_var_backlight_ops(void) +inline struct display_backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -79,7 +79,7 @@ bool display_dev_ready(void) return display_dev_available; } -static struct _backlight_ops backlight_ops = { +static struct display_backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = NULL, .get_brightness = NULL, @@ -120,6 +120,13 @@ int is_lcdon_blocked(void) return LCDON_BLOCK_NONE; } +void setup_display_plugin_backlight_ops(struct display_plugin *dp) +{ + assert(dp); + + dp->backlight = &backlight_ops; +} + int init_sysfs(unsigned int flags) { register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index e054c2f..0d8067b 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -92,7 +92,7 @@ enum combination_process { }; static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct timeval pressed_time; static guint longkey_timeout_id = 0; static guint longkey_restore_id = 0; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 2169da1..61e551c 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -60,6 +60,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "device-interface.h" #include "display-plugin.h" #include "display-dpms.h" #include "proximity.h" @@ -93,7 +94,7 @@ extern void init_save_userlock(void); static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct battery_plugin *battery_plgn; static int (*fp_get_charging_status) (int *val); @@ -1936,6 +1937,7 @@ static int display_probe(void *data) assert(dp); dp->config = &display_conf; + setup_display_plugin_backlight_ops(dp); /** * load display service diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 3e450dc..7834acb 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -64,11 +64,11 @@ #define PALM_STR "palm" #define UNKNOWN_STR "unknown" -static struct _backlight_ops backlight_ops; +static struct display_backlight_ops backlight_ops; static bool display_dev_available = false; static const struct display_config *display_conf; -inline struct _backlight_ops *get_var_backlight_ops(void) +inline struct display_backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -78,7 +78,7 @@ bool display_dev_ready(void) return display_dev_available; } -static struct _backlight_ops backlight_ops = { +static struct display_backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = NULL, .get_brightness = NULL, @@ -134,6 +134,13 @@ int is_lcdon_blocked(void) return LCDON_BLOCK_NONE; } +void setup_display_plugin_backlight_ops(struct display_plugin *dp) +{ + assert(dp); + + dp->backlight = &backlight_ops; +} + int init_sysfs(unsigned int flags) { register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 6fdc5c5..c5bcb9e 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -92,7 +92,7 @@ enum combination_process { }; static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct timeval pressed_time; static guint longkey_timeout_id = 0; static guint longkey_restore_id = 0; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index f2834b8..817e868 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -60,6 +60,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "device-interface.h" #include "display-plugin.h" #include "display-dpms.h" #include "display-signal.h" @@ -91,7 +92,7 @@ extern void init_save_userlock(void); static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct battery_plugin *battery_plgn; static int (*fp_get_charging_status) (int *val); @@ -1927,6 +1928,7 @@ static int display_probe(void *data) assert(dp); dp->config = &display_conf; + setup_display_plugin_backlight_ops(dp); /** * load display service diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index a8f98e8..d56931b 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -65,11 +65,11 @@ #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" -static struct _backlight_ops backlight_ops; +static struct display_backlight_ops backlight_ops; static bool display_dev_available = false; static const struct display_config *display_conf; -inline struct _backlight_ops *get_var_backlight_ops(void) +inline struct display_backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -79,7 +79,7 @@ bool display_dev_ready(void) return display_dev_available; } -static struct _backlight_ops backlight_ops = { +static struct display_backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = NULL, .get_brightness = NULL, @@ -120,6 +120,13 @@ int is_lcdon_blocked(void) return LCDON_BLOCK_NONE; } +void setup_display_plugin_backlight_ops(struct display_plugin *dp) +{ + assert(dp); + + dp->backlight = &backlight_ops; +} + int init_sysfs(unsigned int flags) { register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index dcbced5..6ea8b30 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -92,7 +92,7 @@ enum combination_process { }; static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct timeval pressed_time; static guint longkey_timeout_id = 0; static guint longkey_restore_id = 0; diff --git a/plugins/wearable/display/auto-brightness-sensorhub.c b/plugins/wearable/display/auto-brightness-sensorhub.c index 1815253..9d9a8cb 100644 --- a/plugins/wearable/display/auto-brightness-sensorhub.c +++ b/plugins/wearable/display/auto-brightness-sensorhub.c @@ -39,7 +39,7 @@ #define LOWBATCAPACITY 5 static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static int auto_brightness_state = SETTING_BRIGHTNESS_AUTOMATIC_OFF; static bool lbm, hbm, hold_brt, lowdim; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 8a7a220..55db6fd 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -61,6 +61,7 @@ #include "power/power-suspend.h" #include "power/power-boot.h" #include "power/power-doze.h" +#include "device-interface.h" #include "display-plugin.h" #include "display-dpms.h" #include "display-info.h" @@ -103,7 +104,7 @@ extern void init_save_userlock(void); static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct battery_plugin *battery_plgn; static int (*fp_get_charging_status) (int *val); @@ -2215,6 +2216,7 @@ static int display_probe(void *data) assert(dp); dp->config = &display_conf; + setup_display_plugin_backlight_ops(dp); /** * load display service diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 929be3d..8f2a9c8 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -71,7 +71,7 @@ #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" -static struct _backlight_ops backlight_ops; +static struct display_backlight_ops backlight_ops; static struct battery_plugin *battery_plgn; static bool display_dev_available = false; static int aod_max_level = -1; @@ -82,7 +82,7 @@ static const 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_var_backlight_ops(void) +inline struct display_backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -224,7 +224,7 @@ static int backlight_transit_state(int state) return 0; } -static struct _backlight_ops backlight_ops = { +static struct display_backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, .set_brightness = set_brightness, .get_brightness = NULL, @@ -269,6 +269,13 @@ int is_lcdon_blocked(void) return LCDON_BLOCK_NONE; } +void setup_display_plugin_backlight_ops(struct display_plugin *dp) +{ + assert(dp); + + dp->backlight = &backlight_ops; +} + int init_sysfs(unsigned int flags) { register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c index 5fabbfb..b544866 100644 --- a/plugins/wearable/display/display-handler.c +++ b/plugins/wearable/display/display-handler.c @@ -44,7 +44,7 @@ enum charging_lcd_state { CHARGING_LCD_ON = 1, }; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static guint autobrt_timer; static int autobrtlevel; diff --git a/plugins/wearable/display/enhance.c b/plugins/wearable/display/enhance.c index 769f91d..d5d8fd5 100644 --- a/plugins/wearable/display/enhance.c +++ b/plugins/wearable/display/enhance.c @@ -34,7 +34,7 @@ #define VCONF_HIGH_CONTRAST VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST #define VCONF_GREYSCALE VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static bool negative_status; static bool greyscale_status; static bool greysacle_setting; diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 574466b..1a219c6 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -92,7 +92,7 @@ enum combination_process { }; static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static struct timeval pressed_time; static guint longkey_timeout_id = 0; static guint longkey_restore_id = 0; diff --git a/plugins/wearable/display/lbm.c b/plugins/wearable/display/lbm.c index dbf3838..af706b1 100644 --- a/plugins/wearable/display/lbm.c +++ b/plugins/wearable/display/lbm.c @@ -46,7 +46,7 @@ static struct lbm_config lbm_conf = { .aod_brightness_level = 0, }; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static int lbm_setting_mode; static int system_brightness; static bool display_dev_available = false; diff --git a/plugins/wearable/display/powersaver.c b/plugins/wearable/display/powersaver.c index 2fa86bc..713e955 100644 --- a/plugins/wearable/display/powersaver.c +++ b/plugins/wearable/display/powersaver.c @@ -31,7 +31,7 @@ #include "powersaver.h" #include "setting.h" -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static int set_powersaver_mode(int mode) { diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index e54cfd1..f8b3b57 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -32,7 +32,7 @@ #define DBUS_SWIMMODE_MEMBER_STATUS "status" static struct display_plugin *disp_plgn; -static struct _backlight_ops *backlight_ops; +static struct display_backlight_ops *backlight_ops; static const struct device_ops *touchscreen_ops; static int swimmode_status; diff --git a/src/display/plugin-common/display-backlight.c b/src/display/display-backlight.c similarity index 93% rename from src/display/plugin-common/display-backlight.c rename to src/display/display-backlight.c index 062315f..f60dadb 100644 --- a/src/display/plugin-common/display-backlight.c +++ b/src/display/display-backlight.c @@ -32,8 +32,6 @@ #define DUMP_MODE_WAITING_TIME 600000 /* milisecond */ #define LCD_PHASED_DELAY 10000 /* microsecond */ -static struct _backlight_ops *backlight_ops; - static int default_brightness; static int custom_brightness; static bool g_custom_status; @@ -115,8 +113,9 @@ int display_backlight_set_brightness(int brightness) display_backlight_get_default_brightness(&default_brightness); display_backlight_get_force_brightness(&force_brightness); - if (backlight_ops && backlight_ops->set_brightness) - return backlight_ops->set_brightness(brightness); + ret = display_plugin_backlight_set_brightness(brightness); + if (ret == 0) + return 0; if (!display_is_hal_backend_available()) { _E("There is no display device."); @@ -178,8 +177,11 @@ int display_backlight_get_brightness(int *brightness) /* FIXME: this function is only for wearable plugin, it should changed or removed after refactoring */ int display_backlight_get_brightness_by_plugin_profile(int *brightness) { - if (backlight_ops && backlight_ops->get_brightness) - return backlight_ops->get_brightness(brightness); + int ret; + + ret = display_plugin_backlight_get_brightness(brightness); + if (ret == 0) + return 0; return display_backlight_get_brightness(brightness); } @@ -190,8 +192,9 @@ void display_backlight_change_brightness(int start, int end, int step) int ret = -1; int prev; - if (backlight_ops && backlight_ops->transit_brt) - return backlight_ops->transit_brt(start, end, step); + ret = display_plugin_backlight_transit_brightness(start, end, step); + if (ret == 0) + return; if (display_dimstay_check()) return; @@ -242,19 +245,22 @@ void display_backlight_change_brightness(int start, int end, int step) } /* FIXME: display_backlight_get_brightness is duplicated, this code structure should be changed */ -/* It was operated only AOD enter & leave */ -int display_backlight_change_brightness_by_dpms_state(enum dpms_state state) +/* It was operated only AOD enter & leave. + * Change its parameter type to enum dpms_state when the display-dpms comes into the core. */ +int display_backlight_change_brightness_by_dpms_state(int state) { int brt, val; int start, end; int default_brightness; + int ret; assert(g_display_plugin.config); display_backlight_get_default_brightness(&default_brightness); - if (backlight_ops && backlight_ops->transit_state) - return backlight_ops->transit_state((int)state); + ret = display_plugin_backlight_transit_state((int) state); + if (ret == 0) + return 0; display_backlight_get_brightness(&brt); @@ -486,12 +492,3 @@ void display_backlight_get_force_brightness(int *brightness) { *brightness = force_brightness; } - -/* FIXME: This code structure should be changed to plugin api call, after plugin refactoting*/ -static void __CONSTRUCTOR__ initialize(void) -{ - backlight_ops = get_var_backlight_ops(); - if (!backlight_ops) - _W("Failed to get backlight operator variable."); - -} diff --git a/src/display/plugin-common/display-backlight.h b/src/display/display-backlight.h similarity index 83% rename from src/display/plugin-common/display-backlight.h rename to src/display/display-backlight.h index 8a5855c..69e9ec0 100644 --- a/src/display/plugin-common/display-backlight.h +++ b/src/display/display-backlight.h @@ -19,7 +19,13 @@ #ifndef __DISPLAY_BACKLIGHT_H__ #define __DISPLAY_BACKLIGHT_H__ -#include "shared/devices.h" +struct display_backlight_ops { + int (*get_lcd_power)(void); + int (*set_brightness)(int val); + int (*get_brightness)(int *val); + int (*transit_state)(int state); + void (*transit_brt)(int start, int end, int step); +}; int display_backlight_get_max_brightness(int *max_brightness); int display_backlight_get_normalized_brightness(int raw_brightness, @@ -28,7 +34,8 @@ int display_backlight_set_brightness(int brightness); int display_backlight_get_brightness(int *brightness); int display_backlight_get_brightness_by_plugin_profile(int *brightness); void display_backlight_change_brightness(int start, int end, int step); -int display_backlight_change_brightness_by_dpms_state(enum dpms_state state); +/* FIXME: The parameter was originally type of enum dpms_state */ +int display_backlight_change_brightness_by_dpms_state(int state); int display_backlight_set_default_brightness(int brightness); int display_backlight_get_default_brightness(int *brightness); int display_backlight_update_by_default_brightness(void); @@ -45,4 +52,4 @@ int display_backlight_set_force_brightness(int brightness); void display_backlight_get_force_brightness(int *brightness); int display_backlight_set_brightness_with_delay(int brightness, int delay); -#endif /* __DISPLAY_BACKLIGHT_H__ */ \ No newline at end of file +#endif /* __DISPLAY_BACKLIGHT_H__ */ diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 06055d1..95f8f07 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -16,6 +16,7 @@ * limitations under the License. */ +#include #include "display-plugin.h" struct display_plugin g_display_plugin; @@ -94,3 +95,45 @@ int display_plugin_auto_brightness_control(enum brightness_request_e request, in return 0; } + +int display_plugin_backlight_get_lcd_power(void) +{ + if (g_display_plugin.backlight && g_display_plugin.backlight->get_lcd_power) + return g_display_plugin.backlight->get_lcd_power(); + + return -EOPNOTSUPP; +} + +int display_plugin_backlight_set_brightness(int brightness) +{ + if (g_display_plugin.backlight && g_display_plugin.backlight->set_brightness) + return g_display_plugin.backlight->set_brightness(brightness); + + return -EOPNOTSUPP; +} + +int display_plugin_backlight_get_brightness(int *brightness) +{ + if (g_display_plugin.backlight && g_display_plugin.backlight->get_brightness) + return g_display_plugin.backlight->get_brightness(brightness); + + return -EOPNOTSUPP; +} + +int display_plugin_backlight_transit_state(int state) +{ + if (g_display_plugin.backlight && g_display_plugin.backlight->transit_state) + return g_display_plugin.backlight->transit_state(state); + + return -EOPNOTSUPP; +} + +int display_plugin_backlight_transit_brightness(int start, int end, int step) +{ + if (g_display_plugin.backlight && g_display_plugin.backlight->transit_brt) { + g_display_plugin.backlight->transit_brt(start, end, step); + return 0; + } + + return -EOPNOTSUPP; +} diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index d67ebc2..ba981a9 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -23,6 +23,7 @@ #include #include "display-config.h" +#include "display-backlight.h" #include "shared/devices.h" /* FIXME: Currently because of display_plugin.auto_brightness_control(), @@ -64,6 +65,7 @@ struct display_plugin { int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness); struct display_config *config; + struct display_backlight_ops *backlight; }; extern struct display_plugin g_display_plugin; @@ -78,4 +80,10 @@ int display_plugin_set_system_wakeup_flag(bool flag); const char* display_plugin_device_flags_to_string(enum device_flags flags); int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness); +int display_plugin_backlight_get_lcd_power(void); +int display_plugin_backlight_set_brightness(int brightness); +int display_plugin_backlight_get_brightness(int *brightness); +int display_plugin_backlight_transit_state(int state); +int display_plugin_backlight_transit_brightness(int start, int end, int step); + #endif //__DISPLAY_PLUGIN_H__ diff --git a/src/display/plugin-common/device-interface.h b/src/display/plugin-common/device-interface.h index a069429..8393ddd 100644 --- a/src/display/plugin-common/device-interface.h +++ b/src/display/plugin-common/device-interface.h @@ -27,6 +27,8 @@ #include #include #include "shared/devices.h" +#include "display-backlight.h" +#include "display-plugin.h" #define FLAG_X_DPMS 0x2 @@ -60,15 +62,7 @@ int exit_sysfs(void); int display_service_load(void); int display_service_free(void); -struct _backlight_ops { - int (*get_lcd_power)(void); - int (*set_brightness)(int val); - int (*get_brightness)(int *val); - int (*transit_state)(int state); - void (*transit_brt)(int start, int end, int step); -}; - -struct _backlight_ops *get_var_backlight_ops(void); +struct display_backlight_ops *get_var_backlight_ops(void); enum dpms_state { DPMS_ON, /* In use */ @@ -88,6 +82,7 @@ enum lcdon_block_state { LCDON_BLOCK_DURING_SILENT_BOOT, }; int is_lcdon_blocked(void); +void setup_display_plugin_backlight_ops(struct display_plugin *dp); #endif diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index 2b3b66e..9a67045 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -49,10 +49,8 @@ static int touchscreen_stop(enum device_flags flags); static int delayed_init_done(void *data); -static struct _backlight_ops *backlight_ops; static struct battery_status *battery = NULL; -static struct _backlight_ops* (*fp_get_var_backlight_ops)(void); static struct battery_status* (*fp_get_var_battery_status)(void); static void touchscreen_wakeup_status(keynode_t *key, void *data) @@ -60,17 +58,17 @@ static void touchscreen_wakeup_status(keynode_t *key, void *data) if (!key) return; - if (!g_display_plugin.config || !backlight_ops) + if (!g_display_plugin.config) return; g_display_plugin.config->touch_wakeup = vconf_keynode_get_bool(key); /** - * FIXME: backlight_ops->get_lcd_power() should be changed to + * FIXME: display_plugin_backlight_get_lcd_power() should be changed to * dpms_get_cached_state() function. * After deviding src/display module and plugin display module from build. */ - if (backlight_ops->get_lcd_power() != DPMS_ON) { + if (display_plugin_backlight_get_lcd_power() != DPMS_ON) { if (g_display_plugin.config->touch_wakeup) touchscreen_start(NORMAL_MODE); else @@ -190,12 +188,11 @@ static int touchscreen_start(enum device_flags flags) state = -1; /** - * FIXME: backlight_ops->get_lcd_power() should be changed to + * FIXME: display_plugin_backlight_get_lcd_power() should be changed to * dpms_get_cached_state() function. * After deviding src/display module and plugin display module from build. */ - if (backlight_ops && backlight_ops->get_lcd_power) - state = backlight_ops->get_lcd_power(); + state = display_plugin_backlight_get_lcd_power(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); @@ -207,7 +204,7 @@ static int touchscreen_start(enum device_flags flags) static int touchscreen_stop(enum device_flags flags) { - if (!g_display_plugin.config || !backlight_ops) { + if (!g_display_plugin.config) { _I("Touchscreen is not initialized."); goto exit; } @@ -312,19 +309,6 @@ static int delayed_init_done(void *data) static void touchscreen_init(void *data) { int ret, val; - void *handle = display_plugin_handle(); - - /* '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_var_backlight_ops' instead, and - * retrieve the 'backlight_ops' by using it */ - fp_get_var_backlight_ops = dlsym(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_var_backlight_ops, %s.", dlerror()); if (battery_plgn->handle) { fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); -- 2.7.4 From 121214c318609282f287f4d0dc6298eee304bfb4 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 24 Mar 2023 09:48:44 +0900 Subject: [PATCH 06/16] display: Move plugin display-dpms.c to core The source code display-dpms.c has been relocated: - src/display/plugin-common/display-dpms.c => src/display/display-dpms.c The enum dpms_state has been relocated: - src/display/plugin-common/device-interface.h => src/display/display-dpms.h Change-Id: I194b04061a7f404951f564e13cabdc7ca30a6296 Signed-off-by: Youngjae Cho --- src/display/display-backlight.c | 5 ++--- src/display/display-backlight.h | 5 +++-- src/display/display-config.h | 4 ++-- src/display/{plugin-common => }/display-dpms.c | 0 src/display/{plugin-common => }/display-dpms.h | 19 ++++++++++++++----- src/display/display.c | 8 +++----- src/display/display.h | 3 ++- src/display/plugin-common/device-interface.h | 9 --------- 8 files changed, 26 insertions(+), 27 deletions(-) rename src/display/{plugin-common => }/display-dpms.c (100%) rename src/display/{plugin-common => }/display-dpms.h (81%) diff --git a/src/display/display-backlight.c b/src/display/display-backlight.c index f60dadb..96fd72c 100644 --- a/src/display/display-backlight.c +++ b/src/display/display-backlight.c @@ -245,9 +245,8 @@ void display_backlight_change_brightness(int start, int end, int step) } /* FIXME: display_backlight_get_brightness is duplicated, this code structure should be changed */ -/* It was operated only AOD enter & leave. - * Change its parameter type to enum dpms_state when the display-dpms comes into the core. */ -int display_backlight_change_brightness_by_dpms_state(int state) +/* It was operated only AOD enter & leave. */ +int display_backlight_change_brightness_by_dpms_state(enum dpms_state state) { int brt, val; int start, end; diff --git a/src/display/display-backlight.h b/src/display/display-backlight.h index 69e9ec0..914193c 100644 --- a/src/display/display-backlight.h +++ b/src/display/display-backlight.h @@ -19,6 +19,8 @@ #ifndef __DISPLAY_BACKLIGHT_H__ #define __DISPLAY_BACKLIGHT_H__ +#include "display-dpms.h" + struct display_backlight_ops { int (*get_lcd_power)(void); int (*set_brightness)(int val); @@ -34,8 +36,7 @@ int display_backlight_set_brightness(int brightness); int display_backlight_get_brightness(int *brightness); int display_backlight_get_brightness_by_plugin_profile(int *brightness); void display_backlight_change_brightness(int start, int end, int step); -/* FIXME: The parameter was originally type of enum dpms_state */ -int display_backlight_change_brightness_by_dpms_state(int state); +int display_backlight_change_brightness_by_dpms_state(enum dpms_state state); int display_backlight_set_default_brightness(int brightness); int display_backlight_get_default_brightness(int *brightness); int display_backlight_update_by_default_brightness(void); diff --git a/src/display/display-config.h b/src/display/display-config.h index 9c90bb2..77361c4 100644 --- a/src/display/display-config.h +++ b/src/display/display-config.h @@ -20,6 +20,7 @@ #define __DISPLAY_CONFIG_H__ #include +#include "display-dpms.h" #define DISPLAY_CONF_FILE "/etc/deviced/display.conf" /* @@ -56,8 +57,7 @@ struct display_config { bool touch_wakeup; bool display_on_usb_conn_changed; - /* FIXME: After extrancting display-dpms from plugin, restore its type to enum display_dpms_type */ - int display_dpms_type; + enum display_dpms_type display_dpms_type; }; int display_load_config(struct display_config *config); diff --git a/src/display/plugin-common/display-dpms.c b/src/display/display-dpms.c similarity index 100% rename from src/display/plugin-common/display-dpms.c rename to src/display/display-dpms.c diff --git a/src/display/plugin-common/display-dpms.h b/src/display/display-dpms.h similarity index 81% rename from src/display/plugin-common/display-dpms.h rename to src/display/display-dpms.h index f1a970e..b7b89f7 100644 --- a/src/display/plugin-common/display-dpms.h +++ b/src/display/display-dpms.h @@ -19,6 +19,20 @@ #ifndef __DISPLAY_DPMS_H__ #define __DISPLAY_DPMS_H__ +enum dpms_state { + DPMS_ON, /* In use */ + DPMS_STANDBY, /* Blanked, low power */ + DPMS_SUSPEND, /* Blanked, lower power */ + DPMS_OFF, /* Shut off, awaiting activity */ + DPMS_FORCE_OFF,/* Force Shut off */ + DPMS_DETACH, /* Display detached */ +}; + +enum display_dpms_type { + DISPLAY_DPMS_TYPE_NONE, + DISPLAY_DPMS_TYPE_WINDOW_MANAGER, +}; + void dpms_set_state(int on); int dpms_get_state(void); int dpms_get_cached_state(void); @@ -27,9 +41,4 @@ void dpms_exit(void); void __register_dpms_checklist(int mode, void (*checker)(void), const char *caller); #define register_dpms_checklist(mode, checker) __register_dpms_checklist(mode, checker, __func__) -enum display_dpms_type { - DISPLAY_DPMS_TYPE_NONE, - DISPLAY_DPMS_TYPE_WINDOW_MANAGER, -}; - #endif /* __DISPLAY_DPMS_H__ */ diff --git a/src/display/display.c b/src/display/display.c index 8798d7d..469bc7f 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -77,19 +77,17 @@ inline void set_display_init_direction(enum display_init_direction_e display_ini g_display_init_direction = display_init_direction; } -/* FIXME: The first parameter was type enum dpms_state. - * After extracting display-dpms from plugin, restore its type to enum dpms_state. */ -void lcd_direct_control(int dpms_state, int flags) +void lcd_direct_control(enum dpms_state dpms_state, int flags) { const struct device_ops *ops = NULL; GList *l = NULL; switch (dpms_state) { - case 0: /* FIXME: DPMS_ON */ + case DPMS_ON: SYS_G_LIST_FOREACH(display_dependent_device_ops, l, ops) ops->start(flags); break; - case 3: /* FIXME: DPMS_OFF */ + case DPMS_OFF: SYS_G_LIST_FOREACH(display_dependent_device_ops, l, ops) ops->stop(flags); break; diff --git a/src/display/display.h b/src/display/display.h index 3ad974a..4c48cfe 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -20,6 +20,7 @@ #define __DISPLAY_H__ #include +#include "display-dpms.h" #include "shared/devices.h" #define VCALL_FLAG 0x00000001 @@ -38,7 +39,7 @@ enum display_init_direction_e { DISPLAY_INIT_DIRECTION_VERTICAL, }; -void lcd_direct_control(int dpms_state, int flags); /* FIXME: The first parameter was type enum dpms_state */ +void lcd_direct_control(enum dpms_state dpms_state, int flags); int get_pm_cur_state(void); int get_pm_old_state(void); void set_pm_cur_state(int cur_state); diff --git a/src/display/plugin-common/device-interface.h b/src/display/plugin-common/device-interface.h index 8393ddd..f286464 100644 --- a/src/display/plugin-common/device-interface.h +++ b/src/display/plugin-common/device-interface.h @@ -64,15 +64,6 @@ int display_service_free(void); struct display_backlight_ops *get_var_backlight_ops(void); -enum dpms_state { - DPMS_ON, /* In use */ - DPMS_STANDBY, /* Blanked, low power */ - DPMS_SUSPEND, /* Blanked, lower power */ - DPMS_OFF, /* Shut off, awaiting activity */ - DPMS_FORCE_OFF,/* Force Shut off */ - DPMS_DETACH, /* Display detached */ -}; - bool display_dev_ready(void); void dpms_set_running_state(int val); -- 2.7.4 From 34958bb68a13fc9edaf8793f8985956288337070 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 24 Mar 2023 10:19:48 +0900 Subject: [PATCH 07/16] display: Move plugin display-panel.c to core The source code display-panel.c has been relocated: - src/display/plugin-common/display-panel.c => src/display/display-panel.c Change-Id: I2798e3645e99ee7dd62a14b69ea4be11ab3b12e9 Signed-off-by: Youngjae Cho --- src/display/{plugin-common => }/display-panel.c | 9 +++++++-- src/display/{plugin-common => }/display-panel.h | 0 2 files changed, 7 insertions(+), 2 deletions(-) rename src/display/{plugin-common => }/display-panel.c (95%) rename src/display/{plugin-common => }/display-panel.h (100%) diff --git a/src/display/plugin-common/display-panel.c b/src/display/display-panel.c similarity index 95% rename from src/display/plugin-common/display-panel.c rename to src/display/display-panel.c index f968332..a05cd06 100644 --- a/src/display/plugin-common/display-panel.c +++ b/src/display/display-panel.c @@ -196,8 +196,13 @@ int display_panel_get_dpms_state(void) if (ret < 0) return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + /** + * FIXME: Ambient mode is currently not the display core feature but wearable profile exclusive + * feature. Therefore exclude this condition statement from the display core logic. + * Please consider this condition statement when the ambient feature comes into the display core. + */ + //if (val == DISPLAY_ON && ambient_get_state()) + // return DPMS_OFF; if (dpms_running_state != DPMS_SETTING_DONE) return dpms_running_state; diff --git a/src/display/plugin-common/display-panel.h b/src/display/display-panel.h similarity index 100% rename from src/display/plugin-common/display-panel.h rename to src/display/display-panel.h -- 2.7.4 From ba9c0e286a49739fbd68e7a3bd3b13cdb890889c Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 24 Mar 2023 13:04:30 +0900 Subject: [PATCH 08/16] display: Provide DPMS wrapper via display-panel Technically DPMS is subject to display-panel. Therefore added wrapper for DPMS at display-panel.c. - dpms_get_cached_state() => display_panel_get_dpms_cached_state() - dpms_init() => display_panel_init_dpms() - dpms_exit() => display_panel_exit_dpms() - register_dpms_checklist() => display_panel_register_dpms_checklist() And those existing DPMS functions have been restricted that it is unable to be accessed from external object file. Plugins who want deviced service for DPMS must not use DPMS function directly but use wrapper provided by display-panel.h. Change-Id: I8359b9b60981be14a03f8b7f89284f0b93596a24 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 29 ++++++++++++------------- plugins/iot-headed/display/device-interface.c | 5 ++--- plugins/iot-headed/display/key-filter.c | 7 +++--- plugins/mobile/display/core.c | 29 ++++++++++++------------- plugins/mobile/display/device-interface.c | 5 ++--- plugins/mobile/display/key-filter.c | 13 +++++------ plugins/tv/display/core.c | 29 ++++++++++++------------- plugins/tv/display/device-interface.c | 5 ++--- plugins/tv/display/key-filter.c | 7 +++--- plugins/wearable/display/core.c | 31 +++++++++++++-------------- plugins/wearable/display/device-interface.c | 7 +++--- plugins/wearable/display/display-handler.c | 3 ++- plugins/wearable/display/hbm.c | 4 ++-- plugins/wearable/display/key-filter.c | 7 +++--- plugins/wearable/display/swim.c | 3 ++- src/display/display-backlight.c | 2 +- src/display/display-backlight.h | 2 +- src/display/display-config.c | 2 +- src/display/display-config.h | 2 +- src/display/display-dpms.c | 8 ++++++- src/display/display-dpms.h | 3 +-- src/display/display-panel.c | 22 +++++++++++++++++-- src/display/display-panel.h | 10 ++++++++- src/display/display.h | 2 +- src/display/plugin-common/ambient-mode.c | 4 ++-- src/display/plugin-common/core.h | 1 - src/display/plugin-common/display-lock.c | 3 ++- src/power/power-suspend.c | 1 - src/shared/common.h | 4 ++++ src/touchscreen/touchscreen.c | 19 +++++----------- 30 files changed, 146 insertions(+), 123 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index c27e1f6..64c3bcf 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -63,7 +63,6 @@ #include "power/power-doze.h" #include "device-interface.h" #include "display-plugin.h" -#include "display-dpms.h" #include "display-signal.h" #include "display-lock.h" #include "display-backlight.h" @@ -325,7 +324,7 @@ void lcd_on_procedure(int state, enum device_flags flag) _I("[lcdstep] 0x%lx", flags); if (flags & AMBIENT_MODE) { - if (ambient_get_state() == false && dpms_get_cached_state() == DPMS_ON) + if (ambient_get_state() == false && display_panel_get_dpms_cached_state() == DPMS_ON) return; ambient_set_state(false); } @@ -687,7 +686,7 @@ void lcd_on_direct(enum device_flags flags) static inline bool check_lcd_is_on(void) { - if (dpms_get_cached_state() != DPMS_ON) + if (display_panel_get_dpms_cached_state() != DPMS_ON) return false; return true; @@ -760,7 +759,7 @@ int custom_lcdoff(enum device_flags flag) } _I("custom lcd off by flag(%d)", flag); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) @@ -848,7 +847,7 @@ int display_off_by_reason(const char *reason) } _I("platform lcd off by %s", reason); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); /* state transition */ @@ -898,7 +897,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) default_proc_change_state_action(next, -1); break; case S_LCDOFF: - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) update_display_time(); @@ -1444,11 +1443,11 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { stop_lock_timer(); /* lcd off state : turn off the backlight */ - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } - if (dpms_get_cached_state() == DPMS_ON + if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; @@ -1457,7 +1456,7 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) stop_lock_timer(); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { @@ -1644,7 +1643,7 @@ static int update_setting(int key_idx, int val) /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && val == VCONFKEY_IDLE_LOCK && - dpms_get_cached_state() != DPMS_ON && + display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); @@ -1872,7 +1871,7 @@ static int battery_health_changed(void *data) set_pm_status_flag(DIMSTAY_FLAG); } - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) display_backlight_update_by_default_brightness(); return 0; @@ -1882,7 +1881,7 @@ static gboolean delayed_dpms_init_done(gpointer data) { int timeout; - if (!dpms_init()) + if (!display_panel_init_dpms()) return G_SOURCE_CONTINUE; switch (get_pm_cur_state()) { @@ -1913,7 +1912,7 @@ static void add_timer_for_dpms_init(void) { guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL); if (id == 0) - _E("Failed to add dpms_init timeout."); + _E("Failed to add display_panel_init_dpms timeout."); } /** @@ -2100,7 +2099,7 @@ static void display_init(void *data) check_seed_status(); /* In smd test, TSP should be turned off if display panel is not existed. */ - if (dpms_get_cached_state() == -ENOENT) { + if (display_panel_get_dpms_cached_state() == -ENOENT) { _I("Display panel is not existed."); lcd_direct_control(DPMS_OFF, NORMAL_MODE); exit_lcd_operation(); @@ -2110,7 +2109,7 @@ static void display_init(void *data) * since display manager can be launched later than deviced. * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); - if (dpms_init()) { + if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); else diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index beaa035..95a4e79 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -42,7 +42,6 @@ #include "device-interface.h" #include "vconf.h" #include "core.h" -#include "display-dpms.h" #include "display-lock.h" #include "display-backlight.h" #include "display-panel.h" @@ -80,7 +79,7 @@ bool display_dev_ready(void) } static struct display_backlight_ops backlight_ops = { - .get_lcd_power = dpms_get_cached_state, + .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = NULL, .get_brightness = NULL, .transit_state = NULL, @@ -140,7 +139,7 @@ int exit_sysfs(void) display_backlight_update_by_default_brightness(); - dpms_exit(); + display_panel_exit_dpms(); ops = find_device("touchscreen"); if (!check_default(ops)) diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 0d8067b..8b9b03e 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -32,6 +32,7 @@ #include "core.h" #include "poll.h" #include "display-actor.h" +#include "display-panel.h" #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" @@ -211,7 +212,7 @@ static inline bool switch_on_lcd(enum device_flags flags) if (current_state_in_on()) return false; - if (dpms_get_cached_state() == DPMS_ON) { + if (display_panel_get_dpms_cached_state() == DPMS_ON) { if (ambient_get_state() == false) return false; } @@ -231,7 +232,7 @@ static inline void switch_off_lcd(void) if (!current_state_in_on()) return; - if (dpms_get_cached_state() == DPMS_OFF) + if (display_panel_get_dpms_cached_state() == DPMS_OFF) return; broadcast_lcdoff_by_powerkey(); @@ -358,7 +359,7 @@ static int decide_lcdoff(void) { /* It's not needed if it's already LCD off state */ if (!current_state_in_on() && - dpms_get_cached_state() != DPMS_ON) + display_panel_get_dpms_cached_state() != DPMS_ON) return false; /* diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 61e551c..cd5a1d5 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -62,7 +62,6 @@ #include "power/power-doze.h" #include "device-interface.h" #include "display-plugin.h" -#include "display-dpms.h" #include "proximity.h" #include "display-info.h" #include "display-signal.h" @@ -332,7 +331,7 @@ void lcd_on_procedure(int state, enum device_flags flag) _I("[lcdstep] 0x%lx", flags); if (flags & AMBIENT_MODE) { - if (ambient_get_state() == false && dpms_get_cached_state() == DPMS_ON) + if (ambient_get_state() == false && display_panel_get_dpms_cached_state() == DPMS_ON) return; ambient_set_state(false); } @@ -694,7 +693,7 @@ void lcd_on_direct(enum device_flags flags) static inline bool check_lcd_is_on(void) { - if (dpms_get_cached_state() != DPMS_ON) + if (display_panel_get_dpms_cached_state() != DPMS_ON) return false; return true; @@ -767,7 +766,7 @@ int custom_lcdoff(enum device_flags flag) } _I("custom lcd off by flag(%d)", flag); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) @@ -855,7 +854,7 @@ int display_off_by_reason(const char *reason) } _I("platform lcd off by %s", reason); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); /* state transition */ @@ -905,7 +904,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) default_proc_change_state_action(next, -1); break; case S_LCDOFF: - if (dpms_get_cached_state() == DPMS_ON) { + if (display_panel_get_dpms_cached_state() == DPMS_ON) { if (get_proximity_state() == SENSOR_PROXIMITY_NEAR) lcd_off_procedure(LCD_OFF_BY_PROXIMITY); else @@ -1454,11 +1453,11 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { stop_lock_timer(); /* lcd off state : turn off the backlight */ - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } - if (dpms_get_cached_state() == DPMS_ON + if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; @@ -1467,7 +1466,7 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) stop_lock_timer(); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { @@ -1654,7 +1653,7 @@ static int update_setting(int key_idx, int val) /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && val == VCONFKEY_IDLE_LOCK && - dpms_get_cached_state() != DPMS_ON && + display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); @@ -1882,7 +1881,7 @@ static int battery_health_changed(void *data) set_pm_status_flag(DIMSTAY_FLAG); } - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) display_backlight_update_by_default_brightness(); return 0; @@ -1892,7 +1891,7 @@ static gboolean delayed_dpms_init_done(gpointer data) { int timeout; - if (!dpms_init()) + if (!display_panel_init_dpms()) return G_SOURCE_CONTINUE; switch (get_pm_cur_state()) { @@ -1923,7 +1922,7 @@ static void add_timer_for_dpms_init(void) { guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL); if (id == 0) - _E("Failed to add dpms_init timeout."); + _E("Failed to add display_panel_init_dpms timeout."); } /** @@ -2106,7 +2105,7 @@ static void display_init(void *data) check_seed_status(); /* In smd test, TSP should be turned off if display panel is not existed. */ - if (dpms_get_cached_state() == -ENOENT) { + if (display_panel_get_dpms_cached_state() == -ENOENT) { _I("Display panel is not existed."); lcd_direct_control(DPMS_OFF, NORMAL_MODE); exit_lcd_operation(); @@ -2116,7 +2115,7 @@ static void display_init(void *data) * since display manager can be launched later than deviced. * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); - if (dpms_init()) { + if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); else diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 7834acb..aa1bc85 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -41,7 +41,6 @@ #include "device-interface.h" #include "vconf.h" #include "core.h" -#include "display-dpms.h" #include "display-lock.h" #include "display-backlight.h" #include "display-panel.h" @@ -79,7 +78,7 @@ bool display_dev_ready(void) } static struct display_backlight_ops backlight_ops = { - .get_lcd_power = dpms_get_cached_state, + .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = NULL, .get_brightness = NULL, .transit_state = NULL, @@ -155,7 +154,7 @@ int exit_sysfs(void) display_backlight_update_by_default_brightness(); - dpms_exit(); + display_panel_exit_dpms(); ops = find_device("touchscreen"); if (!check_default(ops)) diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index c5bcb9e..85437e4 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -32,6 +32,7 @@ #include "core.h" #include "poll.h" #include "display-actor.h" +#include "display-panel.h" #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" @@ -200,7 +201,7 @@ static inline bool switch_on_lcd(enum device_flags flags) if (current_state_in_on()) return false; - if (dpms_get_cached_state() == DPMS_ON) { + if (display_panel_get_dpms_cached_state() == DPMS_ON) { if (ambient_get_state() == false) return false; } @@ -220,7 +221,7 @@ static inline void switch_off_lcd(void) if (!current_state_in_on()) return; - if (dpms_get_cached_state() == DPMS_OFF) + if (display_panel_get_dpms_cached_state() == DPMS_OFF) return; broadcast_lcdoff_by_powerkey(); @@ -347,7 +348,7 @@ static int decide_lcdoff(void) { /* It's not needed if it's already LCD off state */ if (!current_state_in_on() && - dpms_get_cached_state() != DPMS_ON) + display_panel_get_dpms_cached_state() != DPMS_ON) return false; /* @@ -410,7 +411,7 @@ static bool key_check_display_on(void) if (current_state_in_on()) return false; - if (dpms_get_cached_state() == DPMS_ON) { + if (display_panel_get_dpms_cached_state() == DPMS_ON) { _W("display power was on"); return false; } @@ -424,7 +425,7 @@ static gboolean display_on_cb(void *data) return G_SOURCE_REMOVE; displayon_by_powerkey_timeout_id = 0; - if (dpms_get_cached_state() != DPMS_ON || + if (display_panel_get_dpms_cached_state() != DPMS_ON || current_state_in_on() == false) { broadcast_lcdon_by_powerkey(); lcd_on_direct(LCD_ON_BY_POWER_KEY); @@ -497,7 +498,7 @@ static int process_power_key(struct input_event *pinput) ignore = true; if (!displayon_by_powerkey_timeout_id && - dpms_get_cached_state() != DPMS_ON && + display_panel_get_dpms_cached_state() != DPMS_ON && key_combination != COMBINATION_TORCH) { displayon_by_powerkey_timeout_id = g_timeout_add( 100, diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 817e868..04adbff 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -62,7 +62,6 @@ #include "power/power-doze.h" #include "device-interface.h" #include "display-plugin.h" -#include "display-dpms.h" #include "display-signal.h" #include "display-lock.h" #include "display-backlight.h" @@ -325,7 +324,7 @@ void lcd_on_procedure(int state, enum device_flags flag) _I("[lcdstep] 0x%lx", flags); if (flags & AMBIENT_MODE) { - if (ambient_get_state() == false && dpms_get_cached_state() == DPMS_ON) + if (ambient_get_state() == false && display_panel_get_dpms_cached_state() == DPMS_ON) return; ambient_set_state(false); } @@ -687,7 +686,7 @@ void lcd_on_direct(enum device_flags flags) static inline bool check_lcd_is_on(void) { - if (dpms_get_cached_state() != DPMS_ON) + if (display_panel_get_dpms_cached_state() != DPMS_ON) return false; return true; @@ -760,7 +759,7 @@ int custom_lcdoff(enum device_flags flag) } _I("custom lcd off by flag(%d)", flag); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) @@ -848,7 +847,7 @@ int display_off_by_reason(const char *reason) } _I("platform lcd off by %s", reason); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); /* state transition */ @@ -898,7 +897,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) default_proc_change_state_action(next, -1); break; case S_LCDOFF: - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) update_display_time(); @@ -1444,11 +1443,11 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { stop_lock_timer(); /* lcd off state : turn off the backlight */ - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } - if (dpms_get_cached_state() == DPMS_ON + if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; @@ -1457,7 +1456,7 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) stop_lock_timer(); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { @@ -1644,7 +1643,7 @@ static int update_setting(int key_idx, int val) /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && val == VCONFKEY_IDLE_LOCK && - dpms_get_cached_state() != DPMS_ON && + display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); @@ -1872,7 +1871,7 @@ static int battery_health_changed(void *data) set_pm_status_flag(DIMSTAY_FLAG); } - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) display_backlight_update_by_default_brightness(); return 0; @@ -1882,7 +1881,7 @@ static gboolean delayed_dpms_init_done(gpointer data) { int timeout; - if (!dpms_init()) + if (!display_panel_init_dpms()) return G_SOURCE_CONTINUE; switch (get_pm_cur_state()) { @@ -1913,7 +1912,7 @@ static void add_timer_for_dpms_init(void) { guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL); if (id == 0) - _E("Failed to add dpms_init timeout."); + _E("Failed to add display_panel_init_dpms timeout."); } /** @@ -2097,7 +2096,7 @@ static void display_init(void *data) check_seed_status(); /* In smd test, TSP should be turned off if display panel is not existed. */ - if (dpms_get_cached_state() == -ENOENT) { + if (display_panel_get_dpms_cached_state() == -ENOENT) { _I("Display panel is not existed."); lcd_direct_control(DPMS_OFF, NORMAL_MODE); exit_lcd_operation(); @@ -2107,7 +2106,7 @@ static void display_init(void *data) * since display manager can be launched later than deviced. * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); - if (dpms_init()) { + if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); else diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index d56931b..c9d13b7 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -41,7 +41,6 @@ #include "device-interface.h" #include "vconf.h" #include "core.h" -#include "display-dpms.h" #include "display-panel.h" #include "display-backlight.h" #include "power/power-suspend.h" @@ -80,7 +79,7 @@ bool display_dev_ready(void) } static struct display_backlight_ops backlight_ops = { - .get_lcd_power = dpms_get_cached_state, + .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = NULL, .get_brightness = NULL, .transit_state = NULL, @@ -140,7 +139,7 @@ int exit_sysfs(void) display_backlight_update_by_default_brightness(); - dpms_exit(); + display_panel_exit_dpms(); ops = find_device("touchscreen"); if (!check_default(ops)) diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 6ea8b30..d758a95 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -32,6 +32,7 @@ #include "core.h" #include "poll.h" #include "display-actor.h" +#include "display-panel.h" #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" @@ -211,7 +212,7 @@ static inline bool switch_on_lcd(enum device_flags flags) if (current_state_in_on()) return false; - if (dpms_get_cached_state() == DPMS_ON) { + if (display_panel_get_dpms_cached_state() == DPMS_ON) { if (ambient_get_state() == false) return false; } @@ -231,7 +232,7 @@ static inline void switch_off_lcd(void) if (!current_state_in_on()) return; - if (dpms_get_cached_state() == DPMS_OFF) + if (display_panel_get_dpms_cached_state() == DPMS_OFF) return; broadcast_lcdoff_by_powerkey(); @@ -358,7 +359,7 @@ static int decide_lcdoff(void) { /* It's not needed if it's already LCD off state */ if (!current_state_in_on() && - dpms_get_cached_state() != DPMS_ON) + display_panel_get_dpms_cached_state() != DPMS_ON) return false; /* diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 55db6fd..4e82dfa 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -63,7 +63,6 @@ #include "power/power-doze.h" #include "device-interface.h" #include "display-plugin.h" -#include "display-dpms.h" #include "display-info.h" #include "battery-monitor.h" #include "display-signal.h" @@ -544,7 +543,7 @@ void lcd_on_procedure(int state, enum device_flags flag) _I("[lcdstep] 0x%lx", flags); if (flags & AMBIENT_MODE) { - if (ambient_get_state() == false && dpms_get_cached_state() == DPMS_ON) + if (ambient_get_state() == false && display_panel_get_dpms_cached_state() == DPMS_ON) return; ambient_set_state(false); } @@ -906,7 +905,7 @@ void lcd_on_direct(enum device_flags flags) static inline bool check_lcd_is_on(void) { - if (dpms_get_cached_state() != DPMS_ON) + if (display_panel_get_dpms_cached_state() != DPMS_ON) return false; return true; @@ -1007,7 +1006,7 @@ int custom_lcdoff(enum device_flags flag) } _I("custom lcd off by flag(%d)", flag); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) @@ -1100,7 +1099,7 @@ int display_off_by_reason(const char *reason) } _I("platform lcd off by %s", reason); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(flag); /* state transition */ @@ -1150,7 +1149,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) default_proc_change_state_action(next, -1); break; case S_LCDOFF: - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) update_display_time(); @@ -1716,11 +1715,11 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { stop_lock_timer(); /* lcd off state : turn off the backlight */ - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } - if (dpms_get_cached_state() == DPMS_ON + if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; @@ -1729,7 +1728,7 @@ static int default_action(int timeout) if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) stop_lock_timer(); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { @@ -1912,7 +1911,7 @@ static int update_setting(int key_idx, int val) /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && val == VCONFKEY_IDLE_LOCK && - dpms_get_cached_state() != DPMS_ON && + display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); @@ -2135,12 +2134,12 @@ static int battery_health_changed(void *data) if (health == HEALTH_GOOD) { clear_pm_status_flag(BATTERY_FLAG); clear_pm_status_flag(DIMSTAY_FLAG); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) auto_brightness_restore(); } else if (health == HEALTH_LOW || health == HEALTH_HIGH || health == HEALTH_OVP) { set_pm_status_flag(BATTERY_FLAG); set_pm_status_flag(DIMSTAY_FLAG); - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) display_backlight_update_by_default_brightness(); } @@ -2171,7 +2170,7 @@ static gboolean delayed_dpms_init_done(gpointer data) { int timeout; - if (!dpms_init()) + if (!display_panel_init_dpms()) return G_SOURCE_CONTINUE; switch (get_pm_cur_state()) { @@ -2202,7 +2201,7 @@ static void add_timer_for_dpms_init(void) { guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL); if (id == 0) - _E("Failed to add dpms_init timeout."); + _E("Failed to add display_panel_init_dpms timeout."); } /** @@ -2423,7 +2422,7 @@ static void display_init(void *data) check_seed_status(); /* In smd test, TSP should be turned off if display panel is not existed. */ - if (dpms_get_cached_state() == -ENOENT) { + if (display_panel_get_dpms_cached_state() == -ENOENT) { _I("Display panel is not existed."); lcd_direct_control(DPMS_OFF, NORMAL_MODE); exit_lcd_operation(); @@ -2433,7 +2432,7 @@ static void display_init(void *data) * since display manager can be launched later than deviced. * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); - if (dpms_init()) { + if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); else diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 8f2a9c8..2e06e43 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -41,7 +41,6 @@ #include "device-interface.h" #include "vconf.h" #include "core.h" -#include "display-dpms.h" #include "display-lock.h" #include "display-backlight.h" #include "display-panel.h" @@ -225,7 +224,7 @@ static int backlight_transit_state(int state) } static struct display_backlight_ops backlight_ops = { - .get_lcd_power = dpms_get_cached_state, + .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = set_brightness, .get_brightness = NULL, .transit_state = backlight_transit_state, @@ -261,7 +260,7 @@ int display_service_free(void) int is_lcdon_blocked(void) { - int state = dpms_get_cached_state(); + int state = display_panel_get_dpms_cached_state(); if ((state == DPMS_DETACH) || (state == -EINVAL)) return LCDON_BLOCK_WHEN_DISPLAY_DETACHED; @@ -300,7 +299,7 @@ int exit_sysfs(void) display_backlight_update_by_default_brightness(); - dpms_exit(); + display_panel_exit_dpms(); ops = find_device("touchscreen"); if (!check_default(ops)) diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c index b544866..04e63c0 100644 --- a/plugins/wearable/display/display-handler.c +++ b/plugins/wearable/display/display-handler.c @@ -30,6 +30,7 @@ #include "shared/common.h" #include "shared/devices.h" #include "display-actor.h" +#include "display-panel.h" #include "display-backlight.h" #include "display-ops.h" #include "display-info.h" @@ -57,7 +58,7 @@ static gboolean lcdon_from_aod_cb(gpointer data) autobrt_timer = 0; /* If it is still not turned on, do not apply auto brightness */ - if (dpms_get_cached_state() != DPMS_ON) + if (display_panel_get_dpms_cached_state() != DPMS_ON) return G_SOURCE_REMOVE; display_backlight_change_brightness_by_dpms_state(DPMS_ON); diff --git a/plugins/wearable/display/hbm.c b/plugins/wearable/display/hbm.c index f670d2f..2c6e9b5 100644 --- a/plugins/wearable/display/hbm.c +++ b/plugins/wearable/display/hbm.c @@ -26,7 +26,7 @@ #include "util.h" #include "core.h" #include "display-ops.h" -#include "display-dpms.h" +#include "display-panel.h" #include "shared/common.h" #include "shared/device-notifier.h" @@ -408,7 +408,7 @@ static void hbm_init(void *data) register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed); /* double check to guarantee HBMOFF before DPMS OFF */ - register_dpms_checklist(DPMS_OFF, dpms_check_hbm_off); + display_panel_register_dpms_checklist(DPMS_OFF, dpms_check_hbm_off); } static void hbm_exit(void *data) diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 1a219c6..4c0ca45 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -33,6 +33,7 @@ #include "poll.h" #include "display-actor.h" #include "display-ops.h" +#include "display-panel.h" #include "display-backlight.h" #include "display-config.h" #include "shared/common.h" @@ -207,7 +208,7 @@ static inline bool switch_on_lcd(enum device_flags flags) if (current_state_in_on()) return false; - if (dpms_get_cached_state() == DPMS_ON) { + if (display_panel_get_dpms_cached_state() == DPMS_ON) { if (ambient_get_state() == false) return false; } @@ -227,7 +228,7 @@ static inline void switch_off_lcd(void) if (!current_state_in_on()) return; - if (dpms_get_cached_state() == DPMS_OFF) + if (display_panel_get_dpms_cached_state() == DPMS_OFF) return; broadcast_lcdoff_by_powerkey(); @@ -354,7 +355,7 @@ static int decide_lcdoff(void) { /* It's not needed if it's already LCD off state */ if (!current_state_in_on() && - dpms_get_cached_state() != DPMS_ON) + display_panel_get_dpms_cached_state() != DPMS_ON) return false; /* diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index f8b3b57..92dc037 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -23,6 +23,7 @@ #include "core.h" #include "util.h" #include "display-ops.h" +#include "display-panel.h" #include "shared/plugin.h" #include @@ -91,7 +92,7 @@ static void swimmode_signal_handler(GDBusConnection *conn, _I("Request swim mode state %d by %d", val, pid); - if (dpms_get_cached_state() != DPMS_ON) { + if (display_panel_get_dpms_cached_state() != DPMS_ON) { if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_SWIM, S_NORMAL); lcd_state = true; diff --git a/src/display/display-backlight.c b/src/display/display-backlight.c index 96fd72c..8af9e77 100644 --- a/src/display/display-backlight.c +++ b/src/display/display-backlight.c @@ -26,7 +26,7 @@ #include "core.h" #include "display.h" #include "display-backlight.h" -#include "display-dpms.h" +#include "display-panel.h" #include "display-plugin.h" #define DUMP_MODE_WAITING_TIME 600000 /* milisecond */ diff --git a/src/display/display-backlight.h b/src/display/display-backlight.h index 914193c..7d35d19 100644 --- a/src/display/display-backlight.h +++ b/src/display/display-backlight.h @@ -19,7 +19,7 @@ #ifndef __DISPLAY_BACKLIGHT_H__ #define __DISPLAY_BACKLIGHT_H__ -#include "display-dpms.h" +#include "display-panel.h" struct display_backlight_ops { int (*get_lcd_power)(void); diff --git a/src/display/display-config.c b/src/display/display-config.c index 9c57647..1025b6c 100644 --- a/src/display/display-config.c +++ b/src/display/display-config.c @@ -19,7 +19,7 @@ #include #include -#include "display-dpms.h" +#include "display-panel.h" #include "display.h" #include "deviced/dd-display.h" diff --git a/src/display/display-config.h b/src/display/display-config.h index 77361c4..71c060b 100644 --- a/src/display/display-config.h +++ b/src/display/display-config.h @@ -20,7 +20,7 @@ #define __DISPLAY_CONFIG_H__ #include -#include "display-dpms.h" +#include "display-panel.h" #define DISPLAY_CONF_FILE "/etc/deviced/display.conf" /* diff --git a/src/display/display-dpms.c b/src/display/display-dpms.c index 4124ef7..8e69b9a 100644 --- a/src/display/display-dpms.c +++ b/src/display/display-dpms.c @@ -460,7 +460,8 @@ static void check_dpms_checklist(int mode) checker(); } -void __register_dpms_checklist(int mode, void (*checker)(void), const char *caller) +DD_INTERNAL +void register_dpms_checklist(int mode, void (*checker)(void), const char *caller) { if (!checker) return; @@ -625,12 +626,14 @@ static int none_dpms_get_cached_state(void) { return dpms_cache; } static bool none_dpms_init(void) { return true; } static void none_dpms_exit(void) {} +DD_INTERNAL void dpms_set_state(int on) { if (g_dpms_ops.set_state) g_dpms_ops.set_state(on); } +DD_INTERNAL int dpms_get_state(void) { if (g_dpms_ops.get_state) @@ -638,6 +641,7 @@ int dpms_get_state(void) return -EINVAL; } +DD_INTERNAL int dpms_get_cached_state(void) { if (g_dpms_ops.get_cached_state) @@ -645,6 +649,7 @@ int dpms_get_cached_state(void) return -EINVAL; } +DD_INTERNAL bool dpms_init(void) { if (!g_display_plugin.config) { @@ -678,6 +683,7 @@ bool dpms_init(void) return false; } +DD_INTERNAL void dpms_exit(void) { if (g_dpms_ops.exit) diff --git a/src/display/display-dpms.h b/src/display/display-dpms.h index b7b89f7..2c8802b 100644 --- a/src/display/display-dpms.h +++ b/src/display/display-dpms.h @@ -38,7 +38,6 @@ int dpms_get_state(void); int dpms_get_cached_state(void); bool dpms_init(void); void dpms_exit(void); -void __register_dpms_checklist(int mode, void (*checker)(void), const char *caller); -#define register_dpms_checklist(mode, checker) __register_dpms_checklist(mode, checker, __func__) +void register_dpms_checklist(int mode, void (*checker)(void), const char *caller); #endif /* __DISPLAY_DPMS_H__ */ diff --git a/src/display/display-panel.c b/src/display/display-panel.c index a05cd06..66ea2c0 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -19,9 +19,7 @@ #include "shared/log.h" #include "power/power-suspend.h" #include "ambient-mode.h" -//#include "display.h" #include "display-backlight.h" -#include "display-dpms.h" #include "display-panel.h" #define MAX_WHITE_BALANCE_GAIN 2047 @@ -223,6 +221,26 @@ int display_panel_get_dpms_state(void) } } +int display_panel_get_dpms_cached_state(void) +{ + return dpms_get_cached_state(); +} + +bool display_panel_init_dpms(void) +{ + return dpms_init(); +} + +void display_panel_exit_dpms(void) +{ + dpms_exit(); +} + +void __display_panel_register_dpms_checklist(int mode, void (*checker)(void), const char *caller) +{ + register_dpms_checklist(mode, checker, caller); +} + /* FIXME: This function is used for only wearable profile, should be fixed after plugin refactoring */ int display_panel_set_image_effect(enum display_image_effect effect) { diff --git a/src/display/display-panel.h b/src/display/display-panel.h index 795962c..c00ae6e 100644 --- a/src/display/display-panel.h +++ b/src/display/display-panel.h @@ -21,6 +21,7 @@ #include +#include "display-dpms.h" #include "shared/devices.h" int display_panel_set_dpms_state(int dpms_on, enum device_flags flags); @@ -37,6 +38,13 @@ int display_panel_get_panel_mode(enum display_panel_mode *mode); int display_panel_set_frame_rate(int frame_rate); int display_panel_get_frame_rate(int *frame_rate); int display_panel_get_dpms_state(void); + +int display_panel_get_dpms_cached_state(void); +bool display_panel_init_dpms(void); +void display_panel_exit_dpms(void); +void __display_panel_register_dpms_checklist(int mode, void (*checker)(void), const char *caller); +#define display_panel_register_dpms_checklist(mode, checker) __display_panel_register_dpms_checklist(mode, checker, __func__) + void display_panel_set_dpms_running_state(int val); -#endif /* __DISPLAY_PANEL_H__ */ \ No newline at end of file +#endif /* __DISPLAY_PANEL_H__ */ diff --git a/src/display/display.h b/src/display/display.h index 4c48cfe..c8943dc 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -20,7 +20,7 @@ #define __DISPLAY_H__ #include -#include "display-dpms.h" +#include "display-panel.h" #include "shared/devices.h" #define VCALL_FLAG 0x00000001 diff --git a/src/display/plugin-common/ambient-mode.c b/src/display/plugin-common/ambient-mode.c index 581d9b3..5f464b4 100644 --- a/src/display/plugin-common/ambient-mode.c +++ b/src/display/plugin-common/ambient-mode.c @@ -87,7 +87,7 @@ static void ambient_set_condition(keynode_t *key_nodes, void *data) val = vconf_keynode_get_bool(key_nodes); if (val != ambient_condition) { - if (dpms_get_cached_state() != DPMS_ON) + if (display_panel_get_dpms_cached_state() != DPMS_ON) if (disp_plgn->pm_lock_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); } @@ -139,7 +139,7 @@ void ambient_check_invalid_state(pid_t pid) if (is_emulator()) { /* In emulator, deviced does not turn off the display. */ - if (dpms_get_cached_state() == DPMS_ON) + if (display_panel_get_dpms_cached_state() == DPMS_ON) return; } diff --git a/src/display/plugin-common/core.h b/src/display/plugin-common/core.h index 5bd9836..c112da5 100644 --- a/src/display/plugin-common/core.h +++ b/src/display/plugin-common/core.h @@ -27,7 +27,6 @@ #include "poll.h" #include "device-interface.h" #include "setting.h" -#include "display-dpms.h" #include "display.h" #include "display-config.h" diff --git a/src/display/plugin-common/display-lock.c b/src/display/plugin-common/display-lock.c index 901f58c..747b876 100644 --- a/src/display/plugin-common/display-lock.c +++ b/src/display/plugin-common/display-lock.c @@ -28,6 +28,7 @@ #include "display-signal.h" #include "lock-detector.h" #include "display-lock.h" +#include "display-panel.h" #include "display-config.h" #include "shared/log-macro.h" #include "shared/apps.h" @@ -179,7 +180,7 @@ static gboolean default_pmlock_check(void *data) state = node->state; pid = node->pid; - if (state == S_LCDOFF && dpms_get_cached_state() == DPMS_ON) { + if (state == S_LCDOFF && display_panel_get_dpms_cached_state() == DPMS_ON) { _D("Lcd state is PM_LCD_POWER_ON"); return G_SOURCE_CONTINUE; } diff --git a/src/power/power-suspend.c b/src/power/power-suspend.c index f1d97ef..12ec794 100644 --- a/src/power/power-suspend.c +++ b/src/power/power-suspend.c @@ -38,7 +38,6 @@ #include "shared/device-notifier.h" #include "shared/time.h" #include "vconf.h" -#include "display-dpms.h" #include "display.h" #include "power.h" #include "power-boot.h" diff --git a/src/shared/common.h b/src/shared/common.h index 1d2cdb0..627700c 100644 --- a/src/shared/common.h +++ b/src/shared/common.h @@ -35,6 +35,10 @@ extern "C" { #define API __attribute__ ((visibility("default"))) #endif +#ifndef DD_INTERNAL +#define DD_INTERNAL __attribute__ ((visibility("hidden"))) +#endif + #ifndef DEPRECATED #define DEPRECATED __attribute__ ((deprecated)) #endif diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index 9a67045..90a34cc 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -29,6 +29,7 @@ #include "battery/power-supply.h" #include "core.h" #include "display-ops.h" +#include "display-panel.h" #include "display-plugin.h" #include "display-config.h" #include "power/power-boot.h" @@ -63,12 +64,7 @@ static void touchscreen_wakeup_status(keynode_t *key, void *data) g_display_plugin.config->touch_wakeup = vconf_keynode_get_bool(key); - /** - * FIXME: display_plugin_backlight_get_lcd_power() should be changed to - * dpms_get_cached_state() function. - * After deviding src/display module and plugin display module from build. - */ - if (display_plugin_backlight_get_lcd_power() != DPMS_ON) { + if (display_panel_get_dpms_cached_state() != DPMS_ON) { if (g_display_plugin.config->touch_wakeup) touchscreen_start(NORMAL_MODE); else @@ -172,7 +168,8 @@ static int touchscreen_execute(void *data) static int touchscreen_start(enum device_flags flags) { - int state, ret; + int state = -1; + int ret; if (touchscreen_enable != DEVICE_OPS_STATUS_START) return 0; @@ -186,13 +183,7 @@ static int touchscreen_start(enum device_flags flags) */ ret = touchscreen_set_state(TOUCHSCREEN_ON); - state = -1; - /** - * FIXME: display_plugin_backlight_get_lcd_power() should be changed to - * dpms_get_cached_state() function. - * After deviding src/display module and plugin display module from build. - */ - state = display_plugin_backlight_get_lcd_power(); + state = display_panel_get_dpms_cached_state(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); -- 2.7.4 From dd0200ffc360d6738c5cef93d60a290030255389 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 28 Mar 2023 14:39:41 +0900 Subject: [PATCH 09/16] power: Rename enable/disable autosleep to init/exit The functions below has been renamed: - power_enable_autosleep() => power_init_autosleep() - power_disable_autosleep() => power_exit_autosleep() Those functions are only executed once, after booting done and before shutting down. Therefore the name init/exit is much proper than enable/disable. In addition, for the power_init_autosleep(), it has changed to acquire mainlock before writing "mem" on the /sys/power/autosleep. This prevents system from going suspend just after the writing "mem" on /sys/power/autosleep. Change-Id: Iafe5b4a3507ef983edaaa68735858c57577e24f8 Signed-off-by: Youngjae Cho --- src/power/power-off.c | 2 +- src/power/power-suspend.c | 9 +++++---- src/power/power-suspend.h | 4 ++-- src/power/power.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/power/power-off.c b/src/power/power-off.c index 9c454dd..a42261f 100644 --- a/src/power/power-off.c +++ b/src/power/power-off.c @@ -311,7 +311,7 @@ void poweroff_prepare(uint64_t state) if (ret < 0) _W("Failed to set vconf value for power off status: %d", vconf_get_ext_errno()); - power_disable_autosleep(); + power_exit_autosleep(); device_notify_once(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, (void *)(intptr_t) vconf); /* Poweroff event broadcasting */ diff --git a/src/power/power-suspend.c b/src/power/power-suspend.c index 12ec794..850dc52 100644 --- a/src/power/power-suspend.c +++ b/src/power/power-suspend.c @@ -253,15 +253,16 @@ int vital_state_changed(void *data) return 0; } -int power_enable_autosleep(void) +int power_init_autosleep(void) { - _I("System autosleep enabled."); + _I("System autosleep init."); + sys_set_str("/sys/power/wake_lock", "mainlock"); return sys_set_str(POWER_AUTOSLEEP_PATH, "mem"); } -int power_disable_autosleep(void) +int power_exit_autosleep(void) { - _I("System autosleep disabled."); + _I("System autosleep exit."); return sys_set_str(POWER_AUTOSLEEP_PATH, "off"); } diff --git a/src/power/power-suspend.h b/src/power/power-suspend.h index 3fac1a3..abdcf9d 100644 --- a/src/power/power-suspend.h +++ b/src/power/power-suspend.h @@ -75,8 +75,8 @@ void pm_history_print(int fd, int count); #endif bool vital_mode(void); int vital_state_changed(void *data); -int power_enable_autosleep(void); -int power_disable_autosleep(void); +int power_init_autosleep(void); +int power_exit_autosleep(void); int power_acquire_wakelock(void); int power_release_wakelock(void); int pm_get_power_lock(void); diff --git a/src/power/power.c b/src/power/power.c index f6f05e9..6682617 100644 --- a/src/power/power.c +++ b/src/power/power.c @@ -789,7 +789,7 @@ static int delayed_init_callback(void *data) trigger_transition(); } - power_enable_autosleep(); + power_init_autosleep(); return 0; } -- 2.7.4 From 9cf1687fef7c97151235a453fbdf4ee4e7216609 Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Mon, 24 Apr 2023 16:09:49 +0900 Subject: [PATCH 10/16] battery: Divide "update_ovp" plugin interface When there is a battery over voltage protection change, update_ovp is called. But the parts of update_ovp can be applied in common devices, so move some of the codes to the function "check_abnormal_status" in core. Also, there was little difference policy between wearable and mobile profile, in checking previous notification status. Unify them to wearable's policy. Change-Id: I210f0c094f4d0b8c356eb21d59da6e49d5de2d47 Signed-off-by: TaeminYeom --- plugins/mobile/battery/battery-notification.c | 4 ---- plugins/wearable/battery/battery-notification.c | 11 ----------- src/battery/power-supply.c | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index a93fd5f..09675eb 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -307,14 +307,10 @@ static int check_power_supply_noti(void) static void update_ovp(enum battery_noti_status status) { - _I("charge %d ovp %d(old %d)", battery->charge_now, battery->health, old_battery.health); - - old_battery.health = battery->health; if (status == DEVICE_NOTI_ON) battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); else battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); - device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery->health); } static void health_timer_reset(void) diff --git a/plugins/wearable/battery/battery-notification.c b/plugins/wearable/battery/battery-notification.c index b743e22..666aada 100644 --- a/plugins/wearable/battery/battery-notification.c +++ b/plugins/wearable/battery/battery-notification.c @@ -64,17 +64,6 @@ static int check_power_supply_noti(void) static void update_ovp(enum battery_noti_status status) { - static int old = DEVICE_NOTI_OFF; - - if (old == status) - return; - - old = status; - _I("Charge(%d) ovp(%d, old: %d) with lcd(%s)", battery->charge_now, battery->health, - old_battery.health, (status == DEVICE_NOTI_ON) ? "dim" : "normal"); - - old_battery.health = battery->health; - device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery->health); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index a91bae0..d6d210e 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -496,6 +496,8 @@ void relaunch_health_popup(void) static void check_abnormal_status(void) { + static int notify_status = DEVICE_NOTI_OFF; + if (old_battery.health != HEALTH_LOW && old_battery.health != HEALTH_HIGH && (battery.health == HEALTH_LOW || battery.health == HEALTH_HIGH)) update_health(DEVICE_NOTI_ON); @@ -509,9 +511,31 @@ static void check_abnormal_status(void) update_present(DEVICE_NOTI_OFF); if (old_battery.health != HEALTH_OVP && battery.health == HEALTH_OVP) { + _I("Charge %d OVP %d(old %d)", + battery.charge_now, battery.health, old_battery.health); + + old_battery.health = battery.health; + + if (notify_status == DEVICE_NOTI_ON) + return; + notify_status = DEVICE_NOTI_ON; + + device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery.health); + if (battery_plgn->update_ovp) battery_plgn->update_ovp(DEVICE_NOTI_ON); } else if (battery.health != HEALTH_OVP && old_battery.health == HEALTH_OVP) { + _I("Charge %d OVP %d(old %d)", + battery.charge_now, battery.health, old_battery.health); + + old_battery.health = battery.health; + + if (notify_status == DEVICE_NOTI_OFF) + return; + notify_status = DEVICE_NOTI_OFF; + + device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery.health); + if (battery_plgn->update_ovp) battery_plgn->update_ovp(DEVICE_NOTI_OFF); } -- 2.7.4 From 490d4eccca7ec27ce2588c6e9ff77b3e49b0aae1 Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Mon, 24 Apr 2023 10:23:25 +0900 Subject: [PATCH 11/16] battery: Divide "display_changed" plugin interface In battery notificaion plugin, there was a function "display_changed" used as a getter and setter duplicated about display state in mobile and wearable battery plugin. To divide the role of getting and setting display state and they can be used in common devices, it is moved to core. The role of setting display state in battery moudle is included in new function "handle_display_state_changed", and it calls plugin interface "launch_health_popup_by_display_state". Previous "display_changed" is deleted from mobile battery plugin. In wearable, the role of "display_changed" is moved to new function "launch_health_popup_by_display_state". And it consists of the action when display state is changed. Change-Id: I1f63502ba36f10fcf93c99987c9ce132295397aa Signed-off-by: TaeminYeom --- plugins/mobile/battery/battery-notification.c | 16 --------- plugins/wearable/battery/battery-notification.c | 29 +++++++--------- src/battery/battery-ops.h | 2 +- src/battery/power-supply.c | 44 ++++++++++++++++++------- 4 files changed, 44 insertions(+), 47 deletions(-) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index 09675eb..e91b7e3 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -358,18 +358,6 @@ static void abnormal_popup_dbus_signal_handler(GDBusConnection *conn, _E("Failed to add abnormal check timer."); } -static int display_changed(void *data) -{ - static enum state_t state; - - if (!data) - return state; - - state = *(int *)data; - - return state; -} - static void battery_notification_init(void *data) { struct battery_plugin *plugin = (struct battery_plugin *)data; @@ -387,14 +375,10 @@ static void battery_notification_init(void *data) plugin->check_power_supply_noti = check_power_supply_noti; plugin->update_ovp = update_ovp; - plugin->display_changed = display_changed; - ret = gdbus_signal_subscribe(NULL, DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, SIGNAL_CHARGEERR_RESPONSE, abnormal_popup_dbus_signal_handler, NULL, NULL); if (ret <= 0) _E("Failed to init dbus signal: %d", ret); - - register_notifier(DEVICE_NOTIFIER_LCD, display_changed); } static const struct battery_ops battery_notification_ops = { diff --git a/plugins/wearable/battery/battery-notification.c b/plugins/wearable/battery/battery-notification.c index 666aada..19701ca 100644 --- a/plugins/wearable/battery/battery-notification.c +++ b/plugins/wearable/battery/battery-notification.c @@ -29,26 +29,20 @@ static struct battery_status *battery; -static int display_changed(void *data) +static void launch_health_popup_by_display_state(int display_state) { - static enum state_t old; - static enum state_t state; + static enum state_t old = S_START; - if (!data) - return state; - - old = state; - state = *(int *)data; - - if (battery->health != HEALTH_LOW && battery->health != HEALTH_HIGH) - return state; + if (battery->health != HEALTH_LOW && battery->health != HEALTH_HIGH) { + old = display_state; + return; + } /* relaunch health popup on LCDON */ - if ((old == S_SLEEP || old == S_LCDOFF) - && (state == S_LCDDIM || state == S_NORMAL)) + if ((old == S_SLEEP || old == S_LCDOFF || old == S_START) + && (display_state == S_LCDDIM || display_state == S_NORMAL)) relaunch_health_popup(); - - return state; + old = display_state; } static int check_power_supply_noti(void) @@ -77,9 +71,8 @@ static void battery_notification_init(void *data) _D("Add plugins for battery notification."); plugin->check_power_supply_noti = check_power_supply_noti; plugin->update_ovp = update_ovp; - plugin->display_changed = display_changed; - - register_notifier(DEVICE_NOTIFIER_LCD, display_changed); + plugin->launch_health_popup_by_display_state = + launch_health_popup_by_display_state; } static const struct battery_ops battery_notification_ops = { diff --git a/src/battery/battery-ops.h b/src/battery/battery-ops.h index faee811..37efd0d 100644 --- a/src/battery/battery-ops.h +++ b/src/battery/battery-ops.h @@ -41,7 +41,7 @@ struct battery_plugin { int (*changed_battery_cf) (int status); void (*remove_health_popup) (void); - int (*display_changed) (void *); + void (*launch_health_popup_by_display_state) (int display_state); int (*check_power_supply_noti) (void); void (*update_ovp) (enum battery_noti_status status); /* Add plugins here */ diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index d6d210e..fb65178 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -94,6 +94,8 @@ static bool launching_health_popup; static guint power_timer; static device_notifier_state_e old_state = -1; +static enum state_t g_display_state = S_NORMAL; + bool battery_initialized; bool battery_do_not_disturb(void); @@ -1291,23 +1293,40 @@ static int delayed_init_done(void *data) return done; } +/** + * FIXME: Getting display state shoule be done by display module function. + * After refactoring display module, it should be changed to use getter in display module. + */ +static int handle_display_state_changed(void *data) +{ + if (!data) { + _E("Invalid parameter"); + return -EINVAL; + } + + g_display_state = *(int *)data; + + if (battery_plgn->launch_health_popup_by_display_state) + battery_plgn->launch_health_popup_by_display_state(g_display_state); + + return 0; +} + bool battery_do_not_disturb(void) { int block = 0, theater = 0, night = 0; int r; - if (battery_plgn->display_changed) { - if (battery_plgn->display_changed(NULL) == S_LCDOFF) { - r = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, &block); - if (r < 0) - _E("Failed to set vconf value for blockmode wearable: %d", vconf_get_ext_errno()); - r = vconf_get_bool(VCONFKEY_SETAPPL_THEATER_MODE_ENABLE, &theater); - if (r < 0) - _E("Failed to set vconf value for theator mode enable: %d", vconf_get_ext_errno()); - r = vconf_get_bool(VCONFKEY_SETAPPL_GOODNIGHT_MODE_ENABLE, &night); - if (r < 0) - _E("Failed to set vconf value for goodnight mode enable: %d", vconf_get_ext_errno()); - } + if (g_display_state == S_LCDOFF) { + r = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, &block); + if (r < 0) + _E("Failed to set vconf value for blockmode wearable: %d", vconf_get_ext_errno()); + r = vconf_get_bool(VCONFKEY_SETAPPL_THEATER_MODE_ENABLE, &theater); + if (r < 0) + _E("Failed to set vconf value for theator mode enable: %d", vconf_get_ext_errno()); + r = vconf_get_bool(VCONFKEY_SETAPPL_GOODNIGHT_MODE_ENABLE, &night); + if (r < 0) + _E("Failed to set vconf value for goodnight mode enable: %d", vconf_get_ext_errno()); } if (block != 0 || theater != 0 || night != 0) { @@ -1449,6 +1468,7 @@ static void power_supply_init(void *data) register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed); + register_notifier(DEVICE_NOTIFIER_LCD, handle_display_state_changed); ret_dbus = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface); if (ret_dbus < 0) -- 2.7.4 From 704c3594a4f8594034ef6d31c7b88a8508123ae7 Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Thu, 27 Apr 2023 16:26:20 +0900 Subject: [PATCH 12/16] battery: Rename config.c to battery-parser.c To unify the name of file and function with below format, change them. file: [module]-[name].c function: [moudle]-[verb]-[noun] Change-Id: I870e9bf78262157901fc80758f7412d6298ecc9d Signed-off-by: TaeminYeom --- plugins/mobile/battery/battery-notification.c | 2 +- src/battery/{config.c => battery-parser.c} | 4 ++-- src/battery/{config.h => battery-parser.h} | 8 ++++---- src/battery/lowbat-handler.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/battery/{config.c => battery-parser.c} (95%) rename src/battery/{config.h => battery-parser.h} (83%) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index e91b7e3..b815542 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -23,7 +23,7 @@ #include "core/log.h" #include "battery.h" -#include "config.h" +#include "battery-parser.h" #include "power-supply.h" #include "lowbat-handler.h" #include "battery-ops.h" diff --git a/src/battery/config.c b/src/battery/battery-parser.c similarity index 95% rename from src/battery/config.c rename to src/battery/battery-parser.c index 54e3da5..99cdac3 100644 --- a/src/battery/config.c +++ b/src/battery/battery-parser.c @@ -30,7 +30,7 @@ #include "shared/common.h" #include "core/udev.h" #include "battery.h" -#include "config.h" +#include "battery-parser.h" #define BAT_CONF_FILE "/etc/deviced/battery.conf" @@ -62,7 +62,7 @@ static int load_config(struct parse_result *result, void *user_data) return 0; } -void battery_config_load(struct battery_config_info *info) +void battery_parser_load_config(struct battery_config_info *info) { int ret; diff --git a/src/battery/config.h b/src/battery/battery-parser.h similarity index 83% rename from src/battery/config.h rename to src/battery/battery-parser.h index 0e0fa52..820718e 100644 --- a/src/battery/config.h +++ b/src/battery/battery-parser.h @@ -17,8 +17,8 @@ */ -#ifndef __BATTERY_CONFIG_H__ -#define __BATTERY_CONFIG_H__ +#ifndef __BATTERY_PARSER_H__ +#define __BATTERY_PARSER_H__ #define BATTERY_FULL 100 #define BATTERY_NORMAL BATTERY_FULL @@ -26,5 +26,5 @@ #define BATTERY_CRITICAL 5 #define BATTERY_POWEROFF 1 -void battery_config_load(struct battery_config_info *info); -#endif /* __BATTERY_CONFIG_H__ */ +void battery_parser_load_config(struct battery_config_info *info); +#endif /* __BATTERY_PARSER_H__ */ diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index d4a7b70..8ff3c68 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -31,7 +31,7 @@ #include "lowbat-handler.h" #include "battery-ops.h" #include "battery.h" -#include "config.h" +#include "battery-parser.h" #include "core/log.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -612,7 +612,7 @@ static int lowbat_monitor_init(void *data) unregister_notifier(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init); /* load battery configuration file */ - battery_config_load(&battery_info); + battery_parser_load_config(&battery_info); _I("Battery conf: %d %d %d %d", battery_info.normal, battery_info.warning, battery_info.critical, battery_info.poweroff); -- 2.7.4 From f308bd30d6e5fce14a00af5b629a367372c4ff5d Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Tue, 18 Apr 2023 14:26:33 +0900 Subject: [PATCH 13/16] battery: Move plugin iot-headless battery to core In plugin iot-headless battery, there are battery charger event handler codes. But all of them are functions, not policy depending some profiles. So, they are can be used in common devices. And the element "action" and "user_data" are removed because they were planned to be used in power transition, but now they are not used. Change-Id: I7a7a9281e7d2da5f6838ed302d2a7a330f57ebf3 Signed-off-by: TaeminYeom --- CMakeLists.txt | 1 - packaging/deviced.spec | 2 - plugins/iot-headless/battery/CMakeLists.txt | 18 --- plugins/iot-headless/battery/battery-plugin.c | 184 -------------------------- src/battery/battery-parser.c | 111 +++++++++++++++- src/battery/battery-parser.h | 3 + src/battery/battery.h | 20 +++ src/battery/lowbat-handler.c | 2 + src/battery/power-supply.c | 48 ++++++- 9 files changed, 179 insertions(+), 210 deletions(-) delete mode 100644 plugins/iot-headless/battery/CMakeLists.txt delete mode 100644 plugins/iot-headless/battery/battery-plugin.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c5e56c..1876051 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,7 +345,6 @@ ADD_SUBDIRECTORY(plugins/wearable/display) ADD_SUBDIRECTORY(plugins/tv/display) ADD_SUBDIRECTORY(plugins/iot-headed/display) ADD_SUBDIRECTORY(plugins/iot-headless/input) -ADD_SUBDIRECTORY(plugins/iot-headless/battery) ADD_SUBDIRECTORY(plugins/iot-headless/display) IF(BATTERY_MODULE STREQUAL on) ADD_SUBDIRECTORY(plugins/mobile/battery) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index a963293..2fbff7f 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -257,7 +257,6 @@ mv %{_sysconfdir}/deviced/input-profile-iot-headless.conf %{_sysconfdir}/deviced mv %{_sysconfdir}/deviced/power-profile-iot-headless.conf %{_sysconfdir}/deviced/power.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/iot-headless-input-handler.so %{_libdir}/deviced/input-handler.so -mv %{_libdir}/iot-headless-battery.so %{_libdir}/deviced/battery.so mv %{_libdir}/iot-headless-display.so %{_libdir}/deviced/display.so %files @@ -393,7 +392,6 @@ mv %{_libdir}/iot-headless-display.so %{_libdir}/deviced/display.so %config %{_sysconfdir}/deviced/input-profile-iot-headless.conf %config %{_sysconfdir}/deviced/power-profile-iot-headless.conf %{_libdir}/iot-headless-input-handler.so -%{_libdir}/iot-headless-battery.so %{_libdir}/iot-headless-display.so %{_unitdir}/rndis.service %{_bindir}/rndis.sh diff --git a/plugins/iot-headless/battery/CMakeLists.txt b/plugins/iot-headless/battery/CMakeLists.txt deleted file mode 100644 index a9ab36c..0000000 --- a/plugins/iot-headless/battery/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -PROJECT(iot-headless-battery C) - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(REQUIRED_PKGS REQUIRED - glib-2.0 - dlog - libsyscommon) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../power) - -FILE(GLOB SRCS "*.c") -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME iot-headless-battery) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/plugins/iot-headless/battery/battery-plugin.c b/plugins/iot-headless/battery/battery-plugin.c deleted file mode 100644 index 1c1d2d2..0000000 --- a/plugins/iot-headless/battery/battery-plugin.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#include "shared/device-notifier.h" -#include "shared/log.h" -#include "shared/event.h" -#include "battery/battery-ops.h" - -#include "power/power.h" - -#define BATTERY_CONF_PATH "/etc/deviced/battery.conf" - -struct battery_event_handler { - char *name; - int id; - - /* broadcast upon occuring this event */ - int broadcast; - - /* which action to do on receiving an event */ - enum device_notifier_type action; - void *user_data; - - /* hold wakelock for a duration on detecting the event */ - int wakelock_duration; -}; - -static struct battery_event_handler *handler_connected; -static struct battery_event_handler *handler_disconnected; - -static void parse_device_notifier(struct battery_event_handler *handler, const char *action) -{ - if (MATCH(action, "DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED")) { - handler_connected = handler; - } else if (MATCH(action, "DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED")) { - handler_disconnected = handler; - } -} - -static void add_action_transition_info(struct battery_event_handler *handler, char *curr, char *next) -{ - struct trans_info *ti = NULL; - GList **action_list = (GList **) &(handler->user_data); - - ti = calloc(1, sizeof(struct trans_info)); - if (!ti) - return; - - /* In configuration file, Enum= must be followed by Action=. - * Otherwise, handler->id won't be defined at this point.*/ - ti->reason = handler->id; - - ti->curr = convert_action_string_to_power_state(curr); - ti->next = convert_action_string_to_power_state(next); - - SYS_G_LIST_APPEND(*action_list, ti); -} - -static void parse_action(struct battery_event_handler *handler, const char *action) -{ - char curr[16] = { 0, }; - char next[16] = { 0, }; - - if (sscanf(action, "%15[^,],%15s", curr, next) == 2) { - handler->action = DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE; - /* append transition info to handler->user_data */ - add_action_transition_info(handler, curr, next); - } else { - _E("Invalid action=%s", action); - } -} - -static void parse_event_action_property(gpointer data, gpointer user_data) -{ - struct section_property *prop = (struct section_property *) data; - struct battery_event_handler *handler = (struct battery_event_handler *) user_data; - - if (!prop) - return; - - _D("Key=%s, Value=%s", prop->key, prop->value); - - if (MATCH(prop->key, "Name")) { - handler->name = strndup(prop->value, 32); - } else if (MATCH(prop->key, "Enum")) { - sscanf(prop->value, "%d", &handler->id); - } else if (MATCH(prop->key, "DeviceNotifier")) { - parse_device_notifier(handler, prop->value); - } else if (MATCH(prop->key, "ActionChangeState")) { - parse_action(handler, prop->value); - } else if (MATCH(prop->key, "ActionBroadcast")) { - handler->broadcast = MATCH(prop->value, "yes"); - } else if (MATCH(prop->key, "WakeLockDurationSec")) { - sscanf(prop->value, "%d", &handler->wakelock_duration); - } -} - -static int parse_event_action(const struct parse_result *result, void *data) -{ - struct battery_event_handler *handler = NULL; - - if (!result || !result->props) - return 0; - - if (MATCH(result->section, "EventAction")) { - handler = calloc(1, sizeof(struct battery_event_handler)); - if (!handler) - return 0; - - g_list_foreach(result->props, parse_event_action_property, handler); - } - - return 0; -} - -static int charger_connected_callback(void *data) -{ - _D("event=%s(%d), action=%d", handler_connected->name, handler_connected->id, handler_connected->action); - - if (handler_connected->wakelock_duration) - event_acquire_wakelock(handler_connected->id, handler_connected->wakelock_duration); - - if (handler_connected->broadcast) - event_broadcast_id(handler_connected->id); - - if (handler_connected->action) - device_notify(handler_connected->action, handler_connected->user_data); - - return 0; -} - -static int charger_disconnected_callback(void *data) -{ - _D("event=%s(%d), action=%d", handler_disconnected->name, handler_disconnected->id, handler_disconnected->action); - - if (handler_disconnected->wakelock_duration) - event_acquire_wakelock(handler_disconnected->id, handler_disconnected->wakelock_duration); - - if (handler_disconnected->broadcast) - event_broadcast_id(handler_disconnected->id); - - if (handler_disconnected->action) - device_notify(handler_disconnected->action, handler_disconnected->user_data); - - return 0; -} - -static void battery_plugin_init(void *data) -{ - libsys_config_parse_by_section(BATTERY_CONF_PATH, parse_event_action, NULL); - - if (handler_connected) - register_notifier(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED, charger_connected_callback); - - if (handler_disconnected) - register_notifier(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED, charger_disconnected_callback); -} - -static const struct battery_ops battery_plugin_ops = { - .name = "battery-plugin", - .init = battery_plugin_init, -}; - -BATTERY_OPS_REGISTER(&battery_plugin_ops) diff --git a/src/battery/battery-parser.c b/src/battery/battery-parser.c index 99cdac3..52932d5 100644 --- a/src/battery/battery-parser.c +++ b/src/battery/battery-parser.c @@ -34,6 +34,74 @@ #define BAT_CONF_FILE "/etc/deviced/battery.conf" +static void parse_device_notifier(struct battery_config_charger_event_handler *handler, + const char *notifier) +{ + if (MATCH(notifier, "DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED")) + handler->notifier = DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED; + else if (MATCH(notifier, "DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED")) + handler->notifier = DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED; +} + +static void parse_event_action_property(gpointer data, gpointer user_data) +{ + struct section_property *prop = (struct section_property *) data; + struct battery_config_charger_event_handler *handler = + (struct battery_config_charger_event_handler *) user_data; + + if (!prop || !handler) + return; + + _D("Key=%s, Value=%s", prop->key, prop->value); + + if (MATCH(prop->key, "Name")) { + handler->name = strndup(prop->value, 32); + } else if (MATCH(prop->key, "Enum")) { + sscanf(prop->value, "%d", &handler->id); + } else if (MATCH(prop->key, "DeviceNotifier")) { + parse_device_notifier(handler, prop->value); + } else if (MATCH(prop->key, "ActionBroadcast")) { + handler->broadcast = MATCH(prop->value, "yes"); + } else if (MATCH(prop->key, "WakeLockDurationSec")) { + sscanf(prop->value, "%d", &handler->wakelock_duration); + } +} + +static int parse_event_action(const struct parse_result *result, void *data) +{ + struct battery_config_info *info = data; + struct battery_config_charger_event_handler *handler; + + if (!result || !result->props || !info) + return 0; + + if (!MATCH(result->section, "EventAction")) + return 0; + + handler = calloc(1, sizeof(struct battery_config_charger_event_handler)); + if (!handler) { + _E("Failed to allocate memory"); + return 0; + } + + g_list_foreach(result->props, parse_event_action_property, handler); + + if (handler->notifier == 0) { + _E("Invalid device notifier"); + + free(handler->name); + free(handler); + + return 0; + } + + info->event_handlers = realloc(info->event_handlers, + sizeof(struct battery_config_charger_event_handler*) * (info->event_handler_number + 1)); + info->event_handlers[info->event_handler_number++] = handler; + + return 0; +} + static int load_config(struct parse_result *result, void *user_data) { struct battery_config_info *info = user_data; @@ -62,7 +130,7 @@ static int load_config(struct parse_result *result, void *user_data) return 0; } -void battery_parser_load_config(struct battery_config_info *info) +static void load_battery_level(struct battery_config_info *info) { int ret; @@ -78,3 +146,44 @@ void battery_parser_load_config(struct battery_config_info *info) info->poweroff = -3; } } + +static void load_battery_charger_event(struct battery_config_info *info) +{ + if (!info) + return; + + info->event_handlers = NULL; + info->event_handler_number = 0; + libsys_config_parse_by_section(BAT_CONF_FILE, parse_event_action, info); +} + +void battery_parser_load_config(struct battery_config_info *info) +{ + if (!info) { + _E("Invalid parameter"); + return; + } + + load_battery_level(info); + load_battery_charger_event(info); +} + +void battery_parser_unload_config(struct battery_config_info *info) +{ + if (!info) { + _E("Invalid parameter"); + return; + } + + if (info->event_handler_number <= 0 || !info->event_handlers) + return; + + for (int i = 0; i < info->event_handler_number; ++i) { + free(info->event_handlers[i]->name); + free(info->event_handlers[i]); + } + + free(info->event_handlers); + info->event_handlers = NULL; + info->event_handler_number = 0; +} diff --git a/src/battery/battery-parser.h b/src/battery/battery-parser.h index 820718e..9744302 100644 --- a/src/battery/battery-parser.h +++ b/src/battery/battery-parser.h @@ -26,5 +26,8 @@ #define BATTERY_CRITICAL 5 #define BATTERY_POWEROFF 1 +#include "battery.h" + void battery_parser_load_config(struct battery_config_info *info); +void battery_parser_unload_config(struct battery_config_info *info); #endif /* __BATTERY_PARSER_H__ */ diff --git a/src/battery/battery.h b/src/battery/battery.h index 0aa7b8d..2a6caa1 100644 --- a/src/battery/battery.h +++ b/src/battery/battery.h @@ -20,6 +20,8 @@ #ifndef __BATTERY_H__ #define __BATTERY_H__ +#include "shared/device-notifier.h" + #define BATTERY_LEVEL_CHECK_FULL 95 #define BATTERY_LEVEL_CHECK_HIGH 15 #define BATTERY_LEVEL_CHECK_LOW 5 @@ -36,11 +38,29 @@ enum battery_option_type { }; #define METHOD_NAME_MAX 32 + +struct battery_config_charger_event_handler { + char *name; + int id; + enum device_notifier_type notifier; + + /* broadcast upon occuring this event */ + int broadcast; + + /* hold wakelock for a duration on detecting the event */ + int wakelock_duration; +}; + struct battery_config_info { + /* battery level config */ int normal; int warning; int critical; int poweroff; + + /* battery charger event config */ + struct battery_config_charger_event_handler **event_handlers; + int event_handler_number; }; int battery_charge_err_low_act(void *data); diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 8ff3c68..3d294ab 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -700,6 +700,8 @@ static void lowbat_exit(void *data) g_source_remove(low_batt_sig_timer); low_batt_sig_timer = 0; } + + battery_parser_unload_config(&battery_info); } static gboolean low_battery_charging_status(void *data) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index fb65178..1f63c8a 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -35,6 +35,7 @@ #include "shared/eventsystem.h" #include "shared/plugin.h" #include "shared/apps.h" +#include "shared/event.h" #include "core.h" #include "display-ops.h" #include "power-supply.h" @@ -42,6 +43,7 @@ #include "battery-ops.h" #include "extcon/extcon.h" #include "lowbat-handler.h" +#include "battery-parser.h" #ifndef VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL #define VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL "db/setting/blockmode_wearable" @@ -96,6 +98,8 @@ static device_notifier_state_e old_state = -1; static enum state_t g_display_state = S_NORMAL; +static struct battery_config_info g_battery_info; + bool battery_initialized; bool battery_do_not_disturb(void); @@ -634,6 +638,36 @@ static void check_misc_status(const char *env_value) battery.misc = atoi(env_value); } +static void notify_charger_event(int notifier) +{ + struct battery_config_charger_event_handler **event_handlers = + g_battery_info.event_handlers; + int event_handler_number = g_battery_info.event_handler_number; + + if (!event_handlers || event_handler_number <= 0) { + _D("There is no charger event handler"); + return; + } + + for (int i = 0; i < event_handler_number; ++i) { + if (!event_handlers[i]) + continue; + + if (event_handlers[i]->notifier == notifier) { + _D("Battery charger event=%s(%d)", + event_handlers[i]->name, + event_handlers[i]->id); + + if (event_handlers[i]->wakelock_duration) + event_acquire_wakelock(event_handlers[i]->id, + event_handlers[i]->wakelock_duration); + + if (event_handlers[i]->broadcast) + event_broadcast_id(event_handlers[i]->id); + } + } +} + static void process_power_supply(void *data) { bool broadcasted = true; @@ -686,10 +720,12 @@ static void process_power_supply(void *data) CRITICAL_LOG("Battery charger disconnected"); event_system_send(SYS_EVENT_BATTERY_CHARGER_STATUS, EVT_KEY_BATTERY_CHARGER_STATUS, EVT_VAL_BATTERY_CHARGER_CONNECTED); device_notify(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED, NULL); + notify_charger_event(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED); } else if (battery.charger_connected == 1) { CRITICAL_LOG("Battery charger connected"); event_system_send(SYS_EVENT_BATTERY_CHARGER_STATUS, EVT_KEY_BATTERY_CHARGER_STATUS, EVT_VAL_BATTERY_CHARGER_DISCONNECTED); device_notify(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED, NULL); + notify_charger_event(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED); } else { _E("Invalid charger connected"); } @@ -1453,7 +1489,7 @@ static int event_handler_state_changed(void *data) static void power_supply_init(void *data) { - int ret_dbus; + int ret; memset(&battery, 0, sizeof(struct battery_status)); memset(&old_battery, 0, sizeof(struct battery_status)); @@ -1470,11 +1506,13 @@ static void power_supply_init(void *data) register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed); register_notifier(DEVICE_NOTIFIER_LCD, handle_display_state_changed); - ret_dbus = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface); - if (ret_dbus < 0) - _E("Failed to init dbus method: %d", ret_dbus); + ret = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface); + if (ret < 0) + _E("Failed to init dbus method: %d", ret); battery_ops_init((void *)battery_plgn); + + battery_parser_load_config(&g_battery_info); } static void power_supply_exit(void *data) @@ -1487,6 +1525,8 @@ static void power_supply_exit(void *data) event_handler_state_changed((void *)&state); battery_ops_exit(NULL); + + battery_parser_unload_config(&g_battery_info); } static const struct device_ops power_supply_ops = { -- 2.7.4 From 43d753a92aa2f39220e6e10853c521a2f008823e Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Thu, 18 May 2023 16:33:32 +0900 Subject: [PATCH 14/16] core: Change to register signal handler with glib Using standard signal handler can make deadlock in terminating progress. When standard signal handler is called dispatching g_main_context, glib attempts to lock g_main_context again. To prevent this situation, it is needed to use glib signal handler function. Change-Id: If2e2fa1c3ebc4bbc7a00b11b3c7f42a9e4fd36ee Signed-off-by: TaeminYeom --- src/core/main.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 342da1e..fbd25e8 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -56,16 +56,22 @@ static void writepid(char *pidpath) } } -static void sig_quit(int signo) +static gboolean handle_sigterm(gpointer data) { - _D("Received SIGTERM signal(%d).", signo); + long signo = (long) data; + _D("Received SIGTERM signal(%ld).", signo); + + return G_SOURCE_REMOVE; } -static void sig_usr1(int signo) +static gboolean handle_sigusr1(gpointer data) { - CRITICAL_LOG("Received SIGUSR1 signal(%d), deviced'll be finished.", signo); + long signo = (long) data; + CRITICAL_LOG("Received SIGUSR1 signal(%ld), deviced'll be finished.", signo); if (mainloop && g_main_loop_is_running(mainloop)) g_main_loop_quit(mainloop); + + return G_SOURCE_REMOVE; } void watchdog_notify(void) @@ -133,8 +139,8 @@ static int deviced_main(int argc, char **argv) gdbus_check_name_owner(NULL, DEVICED_BUS_NAME); } - signal(SIGTERM, sig_quit); - signal(SIGUSR1, sig_usr1); + g_unix_signal_add(SIGTERM, handle_sigterm, (gpointer) SIGTERM); + g_unix_signal_add(SIGUSR1, handle_sigusr1, (gpointer) SIGUSR1); timer = g_timeout_add_seconds_full(G_PRIORITY_HIGH, WATCHDOG_REFRESH_TIME, watchdog_cb, NULL, NULL); if (timer) { -- 2.7.4 From 69cfe07d66439beff0a58b6cc0b04b79d90f8af9 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 16 May 2023 11:25:03 +0200 Subject: [PATCH 15/16] extcon: Trivial typo fix Signed-off-by: Marek Szyprowski Change-Id: I369e56a03947bc50b05c799e6ff937c7bba62e20 --- src/extcon/earjack.c | 2 +- src/extcon/extcon.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index ae44eaa..43e8db2 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -78,7 +78,7 @@ static int earjack_update(const char *index, int status) _E("Failed to set vconf value for earjack: %d", vconf_get_ext_errno()); earjack_send_broadcast(status); earjack_send_system_event(status); - if (status != EARJACK_DICONNECTED) { + if (status != EARJACK_DISCONNECTED) { display_plugin_pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); } diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h index 77247b0..db68cfb 100644 --- a/src/extcon/extcon.h +++ b/src/extcon/extcon.h @@ -62,7 +62,7 @@ typedef enum { } extcon_usbhost_state_e; typedef enum { - EARJACK_DICONNECTED = 0, + EARJACK_DISCONNECTED = 0, EARJACK_3WIRE = 0x1, EARJACK_4WIRE = 0x3, EARJACK_TVOUT = 0x10 -- 2.7.4 From aac4e3f651bf622bc95b490444e09aee230b8ed3 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Fri, 28 Apr 2023 16:15:40 +0900 Subject: [PATCH 16/16] display: Move plugin-common files to core(src/display) The source code display-actor.c has been relocated: - src/display/plugin-common/display-actor.c => src/display/display-actor.c - src/display/plugin-common/display-ops.c => src/display/display-ops.c - src/display/plugin-common/slave-logging.c => src/display/slave-logging.c - src/display/plugin-common/display-signal.c => src/display/display-signal.c To remove display build dependency between plugin and core, thie file is relocated. Change-Id: Ia6e5e2e1771ee4ebdb84339dcda55973e6888241 Signed-off-by: Yunhee Seo --- src/display/{plugin-common => }/display-actor.c | 0 src/display/{plugin-common => }/display-actor.h | 0 src/display/{plugin-common => }/display-ops.c | 0 src/display/{plugin-common => }/display-ops.h | 0 src/display/{plugin-common => }/display-signal.c | 0 src/display/{plugin-common => }/display-signal.h | 0 src/display/{plugin-common => }/slave-logging.c | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename src/display/{plugin-common => }/display-actor.c (100%) rename src/display/{plugin-common => }/display-actor.h (100%) rename src/display/{plugin-common => }/display-ops.c (100%) rename src/display/{plugin-common => }/display-ops.h (100%) rename src/display/{plugin-common => }/display-signal.c (100%) rename src/display/{plugin-common => }/display-signal.h (100%) rename src/display/{plugin-common => }/slave-logging.c (100%) diff --git a/src/display/plugin-common/display-actor.c b/src/display/display-actor.c similarity index 100% rename from src/display/plugin-common/display-actor.c rename to src/display/display-actor.c diff --git a/src/display/plugin-common/display-actor.h b/src/display/display-actor.h similarity index 100% rename from src/display/plugin-common/display-actor.h rename to src/display/display-actor.h diff --git a/src/display/plugin-common/display-ops.c b/src/display/display-ops.c similarity index 100% rename from src/display/plugin-common/display-ops.c rename to src/display/display-ops.c diff --git a/src/display/plugin-common/display-ops.h b/src/display/display-ops.h similarity index 100% rename from src/display/plugin-common/display-ops.h rename to src/display/display-ops.h diff --git a/src/display/plugin-common/display-signal.c b/src/display/display-signal.c similarity index 100% rename from src/display/plugin-common/display-signal.c rename to src/display/display-signal.c diff --git a/src/display/plugin-common/display-signal.h b/src/display/display-signal.h similarity index 100% rename from src/display/plugin-common/display-signal.h rename to src/display/display-signal.h diff --git a/src/display/plugin-common/slave-logging.c b/src/display/slave-logging.c similarity index 100% rename from src/display/plugin-common/slave-logging.c rename to src/display/slave-logging.c -- 2.7.4