display: Integrate plugin is_lcdon_blocked() into display_is_lcdon_blocked() 23/297423/2
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 18 Aug 2023 04:18:11 +0000 (13:18 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 18 Aug 2023 06:28:19 +0000 (15:28 +0900)
Those is_lcdon_blocked(), scattered throughout the plugins, has been
gathered into display_is_lcdon_blocked() except the wearable one. The
display_plugin_is_lcd_on_blocked() is removed accordingly.

Change-Id: I3affc0dae9a50bcfb16df1036a5944d41b34c0cf
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
18 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/device-interface.c
plugins/mobile/display/core.c
plugins/mobile/display/device-interface.c
plugins/tv/display/core.c
plugins/tv/display/device-interface.c
plugins/wearable/display/core.c
plugins/wearable/display/device-interface.c
plugins/wearable/display/key-filter.c
plugins/wearable/display/plugin-util.h [new file with mode: 0644]
src/display/device-interface.h
src/display/display-dbus.c
src/display/display-plugin.c
src/display/display-plugin.h
src/display/display-state-transition.c
src/display/display.c
src/display/display.h
src/display/setting.c

index a28dc19..6714ec8 100644 (file)
@@ -134,7 +134,6 @@ static int display_probe(void *data)
        dp->display_on_by_reason = NULL;
        dp->display_off_by_reason = NULL;
        dp->default_saving_mode = NULL;
-       dp->is_lcdon_blocked = is_lcdon_blocked;
        dp->proc_change_state = NULL;
 
        /* check display feature */
index fb35ecb..caa3236 100644 (file)
@@ -50,12 +50,6 @@ static struct display_backlight_ops backlight_ops = {
        .transit_brt = NULL,
 };
 
-/* Dummy. Do not consider detached display state */
-int is_lcdon_blocked(void)
-{
-       return LCDON_BLOCK_NONE;
-}
-
 void setup_display_plugin_backlight_ops(struct display_plugin *dp)
 {
        assert(dp);
index ba2f793..33759c7 100644 (file)
@@ -213,7 +213,6 @@ static int display_probe(void *data)
        dp->display_on_by_reason = NULL;
        dp->display_off_by_reason = NULL;
        dp->default_saving_mode = NULL;
-       dp->is_lcdon_blocked = is_lcdon_blocked;
        dp->proc_change_state = default_proc_change_state;
 
        return 0;
index 3b3cd7a..0b70680 100644 (file)
@@ -61,27 +61,6 @@ static struct display_backlight_ops backlight_ops = {
        .transit_brt = NULL,
 };
 
-static int delayed_init_done(void *data)
-{
-       static int done = false;
-
-       if (!data)
-               return done;
-
-       done = *(int *)data;
-
-       return done;
-}
-
-int is_lcdon_blocked(void)
-{
-       /* block lcdon until booting done in silent boot mode */
-       if (silent_boot && !delayed_init_done(NULL))
-               return LCDON_BLOCK_DURING_SILENT_BOOT;
-
-       return LCDON_BLOCK_NONE;
-}
-
 void setup_display_plugin_backlight_ops(struct display_plugin *dp)
 {
        assert(dp);
index f679f92..e82416d 100644 (file)
@@ -160,7 +160,6 @@ static int display_probe(void *data)
        dp->display_on_by_reason = NULL;
        dp->display_off_by_reason = NULL;
        dp->default_saving_mode = NULL;
-       dp->is_lcdon_blocked = is_lcdon_blocked;
        dp->proc_change_state = NULL;
 
        return 0;
index 25cb33b..19f30b5 100644 (file)
@@ -60,12 +60,6 @@ static struct display_backlight_ops backlight_ops = {
        .transit_brt = NULL,
 };
 
-/* Dummy. Do not consider detached display state */
-int is_lcdon_blocked(void)
-{
-       return LCDON_BLOCK_NONE;
-}
-
 void setup_display_plugin_backlight_ops(struct display_plugin *dp)
 {
        assert(dp);
index c02f1f7..563e922 100644 (file)
@@ -74,6 +74,7 @@
 #include "display-config.h"
 #include "display-state-transition.h"
 #include "shared/plugin.h"
+#include "plugin-util.h"
 
 #define POWERLOCK_CONF_FILE  "/etc/deviced/powerlock.conf"
 
@@ -928,7 +929,6 @@ static int display_probe(void *data)
        dp->display_on_by_reason = display_on_by_reason;
        dp->display_off_by_reason = display_off_by_reason;
        dp->default_saving_mode = default_saving_mode;
-       dp->is_lcdon_blocked = is_lcdon_blocked;
        dp->proc_change_state = default_proc_change_state;
 
        return 0;
index 06709d0..413bbd2 100644 (file)
@@ -51,6 +51,7 @@
 #include "battery/power-supply.h"
 #include "power/power-suspend.h"
 #include "shared/plugin.h"
+#include "plugin-util.h"
 
 static struct display_backlight_ops backlight_ops;
 static struct battery_plugin *battery_plgn;
index f3f1d29..fdf1080 100644 (file)
@@ -52,6 +52,7 @@
 #include "power/power-suspend.h"
 #include "display-lock.h"
 #include "input/input.h"
+#include "plugin-util.h"
 
 #ifndef KEY_SCREENLOCK
 #define KEY_SCREENLOCK         0x98
diff --git a/plugins/wearable/display/plugin-util.h b/plugins/wearable/display/plugin-util.h
new file mode 100644 (file)
index 0000000..9df6c35
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __PLUGIN_UTIL_H__
+#define __PLUGIN_UTIL_H__
+
+int is_lcdon_blocked(void);
+
+#endif /* __PLUGIN_UTIL_H__ */
index f490053..a49edf3 100644 (file)
@@ -66,7 +66,6 @@ enum lcdon_block_state {
        LCDON_BLOCK_WHEN_DISPLAY_DETACHED,
        LCDON_BLOCK_DURING_SILENT_BOOT,
 };
-int is_lcdon_blocked(void);
 void setup_display_plugin_backlight_ops(struct display_plugin *dp);
 
 #endif
index c8ca11a..4bc3c5d 100644 (file)
@@ -354,7 +354,7 @@ static GVariant *dbus_changestate(GDBusConnection *conn,
                goto out;
        }
 
-       lcdon_blocked = display_plugin_is_lcd_on_blocked();
+       lcdon_blocked = display_is_lcdon_blocked();
        if (lcdon_blocked != LCDON_BLOCK_NONE) {
                if (state == LCD_NORMAL || state == LCD_DIM) {
                        _W("LCDON is blocked, %d.", lcdon_blocked);
@@ -938,7 +938,7 @@ static GVariant *dbus_customlcdon(GDBusConnection *conn,
 
        g_variant_get(param, "(i)", &timeout);
 
-       lcdon_blocked = display_plugin_is_lcd_on_blocked();
+       lcdon_blocked = display_is_lcdon_blocked();
        if (lcdon_blocked != LCDON_BLOCK_NONE) {
                _W("LCDON is blocked, %d.", lcdon_blocked);
                return g_variant_new("(i)", -ENOTSUP);
index 10d77bf..8f6a08b 100644 (file)
@@ -144,17 +144,6 @@ int display_plugin_set_power_save_mode_flag(int onoff)
        return -EOPNOTSUPP;
 }
 
-/** FIXME: is_lcdon_blocked() should be moved or refactored after plugin relocation
- *         Also, this is temporary wrapper function. It should be removed.
- */
-int display_plugin_is_lcd_on_blocked(void)
-{
-       if (g_display_plugin.is_lcdon_blocked)
-               return g_display_plugin.is_lcdon_blocked();
-
-       return -EOPNOTSUPP;
-}
-
 int display_plugin_backlight_set_brightness(int brightness)
 {
        if (g_display_plugin.backlight && g_display_plugin.backlight->set_brightness)
index c50928a..5bab3c4 100644 (file)
@@ -70,7 +70,6 @@ struct display_plugin {
        int (*display_on_by_reason) (const char *reason, int timeout);
        int (*display_off_by_reason) (const char *reason);
        void (*default_saving_mode) (int onoff);
-       int (*is_lcdon_blocked) (void);
        int (*proc_change_state) (unsigned int cond, pid_t pid);
        int (*set_autobrightness_min) (int val, char *name);
        void (*reset_autobrightness_min) (GDBusConnection *conn, const gchar *sender,
@@ -98,7 +97,6 @@ int display_plugin_custom_lcd_off(enum device_flags flag);
 int display_plugin_display_on_by_reason(const char *reason, int timeout);
 int display_plugin_display_off_by_reason(const char *reason);
 int display_plugin_set_power_save_mode_flag(int onoff);
-int display_plugin_is_lcd_on_blocked(void);
 
 int display_plugin_backlight_set_brightness(int brightness);
 int display_plugin_backlight_get_brightness(int *brightness);
index c58b2cb..f70ed46 100644 (file)
@@ -906,7 +906,7 @@ int display_state_transition_request_state_transition_with_option(pid_t pid, int
        if (cond < 0)
                return cond;
 
-       ret = display_plugin_is_lcd_on_blocked();
+       ret = display_is_lcdon_blocked();
        if (ret != LCDON_BLOCK_NONE && (cond & display_on)) {
                _W("LCDON is blocked, %d.", ret);
                return -ENOTSUP;
index 9d514dc..6a104dc 100644 (file)
@@ -29,6 +29,7 @@
 #include "shared/log.h"
 #include "power/power.h"
 #include "power/power-suspend.h"
+#include "power/power-boot.h"
 #include "device-interface.h"
 #include "display.h"
 #include "display-lock.h"
@@ -438,6 +439,14 @@ static int delayed_init_done(void *data)
        return done;
 }
 
+int display_is_lcdon_blocked(void)
+{
+       if (silent_boot && !delayed_init_done(NULL))
+               return LCDON_BLOCK_DURING_SILENT_BOOT;
+
+       return LCDON_BLOCK_NONE;
+}
+
 static void init_lcd_operation(void)
 {
        const struct device_ops *ops = NULL;
@@ -578,7 +587,7 @@ static void display_init(void *data)
                * In the case, display cannot be turned on at the first booting */
        // wm_ready = check_wm_ready();
        if (display_panel_init_dpms()) {
-               if (display_plugin_is_lcd_on_blocked() != LCDON_BLOCK_NONE) {
+               if (display_is_lcdon_blocked() != LCDON_BLOCK_NONE) {
                        display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
                } else {
                        display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
@@ -609,7 +618,7 @@ static void display_init(void *data)
                                        STAY_CUR_STATE, DELAYED_INIT_WATING_TIME);
 
                /* Initial display state right after the booting done */
-               if (display_plugin_is_lcd_on_blocked())
+               if (display_is_lcdon_blocked())
                        set_pm_cur_state(DEVICED_DISPLAY_STATE_OFF);
                else
                        set_pm_cur_state(DEVICED_DISPLAY_STATE_ON);
index 3a4d451..697979a 100644 (file)
@@ -64,5 +64,6 @@ void display_add_timer_for_waiting_dpms_init(void);
 void display_set_initial_brightness(void);
 void display_set_initial_battery_flag(void);
 void display_set_initial_lockscreen_status(void);
+int display_is_lcdon_blocked(void);
 
 #endif //__DISPLAY_H__
index 5487618..ba5a35e 100644 (file)
@@ -325,7 +325,7 @@ int display_setting_update_pm_setting(int key_idx, int val)
                if ((current == DEVICED_DISPLAY_STATE_ON) &&
                    val == VCONFKEY_IDLE_LOCK &&
                    display_panel_get_dpms_cached_state() != DPMS_ON &&
-                       display_plugin_is_lcd_on_blocked() == LCDON_BLOCK_NONE)
+                       display_is_lcdon_blocked() == LCDON_BLOCK_NONE)
                        display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
                display_state_transition_update_display_state_timeout_by_priority();
                if (current == DEVICED_DISPLAY_STATE_ON)