From: Yunhee Seo Date: Fri, 14 Jul 2023 07:25:10 +0000 (+0900) Subject: display: Relocate display hal-backend loader/unloader X-Git-Tag: accepted/tizen/unified/20230726.163529~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6195ac94623f2c756fa3a52adc6fd0234d8e97b2;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: Relocate display hal-backend loader/unloader display_service_load/display_service_free() is used as display hal-backend loader/unloader. However, display core should treat hal-backend using during display probe,exit process. Thus, display_service_load/display_service_free() are removed. Also, display_set_hal_backend_available() is removed. Because display core(display.c) only decides whether the display hal-backend using or not. Change-Id: I6533145b0d558c2bae831eee1ea04ab313f286ac Signed-off-by: Yunhee Seo --- diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 1a4e4b2..b4d71dd 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -156,7 +156,6 @@ static void init_display_states(void *data) */ static int display_probe(void *data) { - int ret; struct display_plugin *dp = (struct display_plugin *) data; assert(dp); @@ -179,15 +178,6 @@ static int display_probe(void *data) if (!is_feature_display_supported()) return -ENODEV; - /** - * load display service - * if there is no display shared library, - * deviced does not provide any method and function of display. - */ - ret = display_service_load(); - if (ret) - return ret; - return 0; } @@ -236,9 +226,6 @@ static void display_exit(void *data) display_unregister_dependent_device(); free_lock_info_list(); - /* free display service */ - display_service_free(); - _I("Stop power manager."); } diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index e599fc7..36f1854 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -46,7 +46,6 @@ #include "display-panel.h" static struct display_backlight_ops backlight_ops; -static bool display_dev_available = false; static const struct display_config *display_conf; inline struct display_backlight_ops *get_var_backlight_ops(void) @@ -54,11 +53,6 @@ inline struct display_backlight_ops *get_var_backlight_ops(void) return &backlight_ops; } -bool display_dev_ready(void) -{ - return display_dev_available; -} - static struct display_backlight_ops backlight_ops = { .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = NULL, @@ -67,33 +61,6 @@ static struct display_backlight_ops backlight_ops = { .transit_brt = NULL, }; -int display_service_load(void) -{ - int r; - - if (display_dev_available) - return 0; - - r = hal_device_display_get_backend(); - if (r < 0) { - _E("There is no HAL for display."); - display_dev_available = false; - display_set_hal_backend_available(display_dev_available); - return 0; - } - - display_dev_available = true; - display_set_hal_backend_available(display_dev_available); - _D("Display device structure load success."); - return 0; -} - -int display_service_free(void) -{ - display_dev_available = false; - return hal_device_display_put_backend(); -} - /* Dummy. Do not consider detached display state */ int is_lcdon_blocked(void) { diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 85f378d..bb1fbbc 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -209,7 +209,6 @@ static void init_display_states(void *data) */ static int display_probe(void *data) { - int ret; struct display_plugin *dp = (struct display_plugin *) data; assert(dp); @@ -228,15 +227,6 @@ static int display_probe(void *data) dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = default_proc_change_state; - /** - * load display service - * if there is no display shared library, - * deviced does not provide any method and function of display. - */ - ret = display_service_load(); - if (ret) - return ret; - return 0; } @@ -287,9 +277,6 @@ static void display_exit(void *data) display_unregister_dependent_device(); free_lock_info_list(); - /* free display service */ - display_service_free(); - _I("Stop power manager."); } diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 60bee65..df36e8e 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -47,7 +47,6 @@ #include "power/power-suspend.h" static struct display_backlight_ops backlight_ops; -static bool display_dev_available = false; static const struct display_config *display_conf; inline struct display_backlight_ops *get_var_backlight_ops(void) @@ -55,11 +54,6 @@ inline struct display_backlight_ops *get_var_backlight_ops(void) return &backlight_ops; } -bool display_dev_ready(void) -{ - return display_dev_available; -} - static struct display_backlight_ops backlight_ops = { .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = NULL, @@ -68,33 +62,6 @@ static struct display_backlight_ops backlight_ops = { .transit_brt = NULL, }; -int display_service_load(void) -{ - int r; - - if (display_dev_available) - return 0; - - r = hal_device_display_get_backend(); - if (r < 0) { - _E("There is no HAL for display."); - display_dev_available = false; - display_set_hal_backend_available(display_dev_available); - return 0; - } - - display_dev_available = true; - display_set_hal_backend_available(display_dev_available); - _D("Display device structure load success."); - return 0; -} - -int display_service_free(void) -{ - display_dev_available = false; - return hal_device_display_put_backend(); -} - static int delayed_init_done(void *data) { static int done = false; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 5a40817..341527d 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -158,7 +158,6 @@ static void init_display_states(void *data) */ static int display_probe(void *data) { - int ret; struct display_plugin *dp = (struct display_plugin *) data; assert(dp); @@ -177,15 +176,6 @@ static int display_probe(void *data) dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = NULL; - /** - * load display service - * if there is no display shared library, - * deviced does not provide any method and function of display. - */ - ret = display_service_load(); - if (ret) - return ret; - return 0; } @@ -235,9 +225,6 @@ static void display_exit(void *data) display_unregister_dependent_device(); free_lock_info_list(); - /* free display service */ - display_service_free(); - _I("Stop power manager."); } diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 8935e77..9857e12 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -46,7 +46,6 @@ #include "display-lock.h" static struct display_backlight_ops backlight_ops; -static bool display_dev_available = false; static const struct display_config *display_conf; inline struct display_backlight_ops *get_var_backlight_ops(void) @@ -54,11 +53,6 @@ inline struct display_backlight_ops *get_var_backlight_ops(void) return &backlight_ops; } -bool display_dev_ready(void) -{ - return display_dev_available; -} - static struct display_backlight_ops backlight_ops = { .get_lcd_power = display_panel_get_dpms_cached_state, .set_brightness = NULL, @@ -67,33 +61,6 @@ static struct display_backlight_ops backlight_ops = { .transit_brt = NULL, }; -int display_service_load(void) -{ - int r; - - if (display_dev_available) - return 0; - - r = hal_device_display_get_backend(); - if (r < 0) { - _E("There is no HAL for display."); - display_dev_available = false; - display_set_hal_backend_available(display_dev_available); - return 0; - } - - display_dev_available = true; - display_set_hal_backend_available(display_dev_available); - _D("Display device structure load success."); - return 0; -} - -int display_service_free(void) -{ - display_dev_available = false; - return hal_device_display_put_backend(); -} - /* Dummy. Do not consider detached display state */ int is_lcdon_blocked(void) { diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 5b514e8..94f6823 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -923,7 +923,6 @@ static void init_display_states(void *data) */ static int display_probe(void *data) { - int ret; struct display_plugin *dp = (struct display_plugin *) data; assert(dp); @@ -942,15 +941,6 @@ static int display_probe(void *data) dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = default_proc_change_state; - /** - * load display service - * if there is no display shared library, - * deviced does not provide any method and function of display. - */ - ret = display_service_load(); - if (ret) - return ret; - return 0; } @@ -1042,9 +1032,6 @@ static void display_exit(void *data) display_unregister_dependent_device(); free_lock_info_list(); - /* free display service */ - display_service_free(); - _I("Stop power manager."); } diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 6db9e32..135740c 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -51,7 +51,6 @@ 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; static int aod_normal_level = -1; static int aod_min_level = -1; @@ -65,11 +64,6 @@ inline struct display_backlight_ops *get_var_backlight_ops(void) return &backlight_ops; } -bool display_dev_ready(void) -{ - return display_dev_available; -} - static int set_brightness(int val) { int max, ret; @@ -78,7 +72,7 @@ static int set_brightness(int val) display_backlight_get_default_brightness(&default_brightness); display_backlight_get_force_brightness(&force_brightness); - if (!display_dev_available) { + if (!display_is_hal_backend_available()) { _E("There is no display device."); return -ENOENT; } @@ -210,33 +204,6 @@ static struct display_backlight_ops backlight_ops = { .transit_brt = NULL, }; -int display_service_load(void) -{ - int r; - - if (display_dev_available) - return 0; - - r = hal_device_display_get_backend(); - if (r < 0) { - _E("There is no HAL for display."); - display_dev_available = false; - display_set_hal_backend_available(display_dev_available); - return 0; - } - - display_dev_available = true; - display_set_hal_backend_available(display_dev_available); - _D("Display device structure load success."); - return 0; -} - -int display_service_free(void) -{ - display_dev_available = false; - return hal_device_display_put_backend(); -} - int is_lcdon_blocked(void) { int state = display_panel_get_dpms_cached_state(); diff --git a/plugins/wearable/display/lbm.c b/plugins/wearable/display/lbm.c index eea8f65..f15adbc 100644 --- a/plugins/wearable/display/lbm.c +++ b/plugins/wearable/display/lbm.c @@ -338,7 +338,7 @@ static void lbm_init(void *data) if (ret < 0) _E("Failed to init dbus method, %d.", ret); - display_dev_available = display_dev_ready(); + display_dev_available = display_is_hal_backend_available(); _I("LBM setting value is %d.", lbm_setting_mode); } diff --git a/src/display/device-interface.h b/src/display/device-interface.h index f286464..c3d87bf 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -59,12 +59,9 @@ enum { int init_sysfs(unsigned int); int exit_sysfs(void); -int display_service_load(void); -int display_service_free(void); struct display_backlight_ops *get_var_backlight_ops(void); -bool display_dev_ready(void); void dpms_set_running_state(int val); enum lcdon_block_state { diff --git a/src/display/display.c b/src/display/display.c index 9c57d95..c0a42d3 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -44,7 +44,7 @@ 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 bool g_display_hal_backend_available = false; static GList *display_dependent_device_ops; static enum device_ops_status display_ops_status = DEVICE_OPS_STATUS_UNINIT; @@ -115,13 +115,6 @@ void lcd_direct_control(enum dpms_state dpms_state, int flags) } } -/* 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; @@ -461,13 +454,48 @@ static void init_lcd_operation(void) display_register_dependent_device(ops); } +static void load_display_hal_backend(void) +{ + int ret; + + if (g_display_hal_backend_available) + return; + + ret = hal_device_display_get_backend(); + if (ret < 0) { + _W("There is no HAL for display."); + g_display_hal_backend_available = false; + } + + g_display_hal_backend_available = true; + _W("Display device structure load success."); +} + +static int unload_display_hal_backend(void) +{ + g_display_hal_backend_available = false; + return hal_device_display_put_backend(); +} + static int display_probe(void *data) { + int ret = 0; + display_plugin_device_ops = find_device("display-plugin"); if (!display_plugin_device_ops || !display_plugin_device_ops->probe) return 0; - return display_plugin_device_ops->probe(&g_display_plugin); + ret = display_plugin_device_ops->probe(&g_display_plugin); + if (ret < 0) + return ret; + + /** + * load display hal backend + * if there is no display shared library, + * deviced does not provide any method and function of display. + */ + load_display_hal_backend(); + return 0; } static int input_init_handler(void) @@ -613,6 +641,8 @@ static void display_exit(void *data) unregister_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback); unregister_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback); unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + + unload_display_hal_backend(); } static int display_start(enum device_flags flags) diff --git a/src/display/display.h b/src/display/display.h index 48c7d35..3a4d451 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -49,7 +49,6 @@ void set_pm_status_flag(unsigned int status_flag); void clear_pm_status_flag(unsigned int status_flag); 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);