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 a28dc19eb6e2aeb37d9e670ca46e2f30eaaaaa81..6714ec89eb0a14bdef75dceda28d52d2a0f37bae 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 fb35ecbe32584344eac1325278b532b6c86381b0..caa32360c1b5ef68731ea569136caeaa1ebb4083 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 ba2f79316f55bda22a67cd53da5ea763b30d0612..33759c776c3686a3d5d42e2caf98304604fee4f8 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 3b3cd7a036839db0d3fc71b3edaf7264ac03b238..0b70680e09b015e48c234009918e0152f54d2974 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 f679f926cb23331e9992707751f3eaf8f8dfcbf2..e82416d9aa81cb5f1f1bc6fd3a71fc0d29bd474b 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 25cb33b768e7d4a9dd1f341d3d49e1cf4912fbdb..19f30b5980442f745cbce98b77a46e369e4cbec7 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 c02f1f73299d369392cc3f1ba6c3d6ea9bc151a9..563e9224d2c5ea6d2269b51b3c397d1ec363a8a7 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 06709d06337ce080c2a24043f8a45f6afaccf640..413bbd262722dc78f322819b38e6acdce62cf7eb 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 f3f1d296ed2efa3f140cb1661a59b87de1013148..fdf1080acbe9799c691b6b281ef6f26e30ddd8db 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 f490053a1685722bc54f555a3e963d6b52eb59f2..a49edf374cc6560b4bd8331df5406201851ca3d0 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 c8ca11a5971b62716c6568c063f52121430b073f..4bc3c5d92f608f67a132cdd8bcbc5bc1a2d61ede 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 10d77bf70ad4d792507b0a068d207873005b28d4..8f6a08b773e833e8a4e02939060d6d7bc84ff95d 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 c50928a4114448819f45cceb005e67306ae701c1..5bab3c4708480ea2eb1af43f8379b4f259131368 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 c58b2cb3166d82aae54e2770a7191d15162490be..f70ed46ac2e77b1d85f0ada77fd015393f693ae3 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 9d514dc52d54221c4078d07183d533d5426a6a46..6a104dc42dda8fe4a65973a12befb0afa67a8c2d 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 3a4d451b6022485cb22ad2005eadeb1bf2f2463b..697979aa4ffd8a2dbe27936c8b43f424dab07f65 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 5487618b5d1474203cd8390d297e0c9c25980369..ba5a35e638cf0b208c90fa3e45d6604404974026 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)