display: Remove display_info interface
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 28 Jun 2023 07:44:59 +0000 (16:44 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 6 Jul 2023 02:13:18 +0000 (11:13 +0900)
display_info interface is only used in the wearable plugins.
Thus there is no reason why display_info should exist in all display plugins.
Furthermore, it is hard to figure out above interface usage and role.
Delete display_info to eliminate the dependence between core and display plugins.

During refactoring, the wearable plugin codes must be cleaned up later.

Change-Id: I3caa44fb213cd70416435b02214f0bc0c26edddd
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
15 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/core.c
plugins/mobile/display/key-filter.c
plugins/tv/display/core.c
plugins/tv/display/key-filter.c
plugins/wearable/display/auto-brightness-sensorhub.c
plugins/wearable/display/auto-brightness.c
plugins/wearable/display/core.c
plugins/wearable/display/display-handler.c
plugins/wearable/display/display-info.h
plugins/wearable/display/key-filter.c
src/display/core.h
src/display/display-plugin.h
src/display/plugin-common/display-dbus.c

index 8bd2cd2..3311604 100644 (file)
@@ -129,13 +129,6 @@ static struct display_config display_conf = {
        .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
-struct display_function_info display_info = {
-       .update_auto_brightness         = NULL,
-       .set_autobrightness_min         = NULL,
-       .reset_autobrightness_min       = NULL,
-       .face_detection                 = NULL,
-};
-
 inline const struct display_config* get_var_display_config()
 {
        return &display_conf;
index 3b6d84a..4c31753 100644 (file)
@@ -386,8 +386,6 @@ static int lcdoff_powerkey(void)
        int ignore = true;
 
        if (decide_lcdoff() == true) {
-               if (display_info.update_auto_brightness)
-                       display_info.update_auto_brightness(false);
                switch_off_lcd();
                display_lock_release_lock_all(S_NORMAL);
                display_lock_release_lock_all(S_LCDDIM);
index c772856..7abf561 100644 (file)
@@ -131,13 +131,6 @@ static struct display_config display_conf = {
        .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
-struct display_function_info display_info = {
-       .update_auto_brightness         = NULL,
-       .set_autobrightness_min         = NULL,
-       .reset_autobrightness_min       = NULL,
-       .face_detection                 = NULL,
-};
-
 inline const struct display_config* get_var_display_config()
 {
        return &display_conf;
index 2124a8c..f3914c1 100644 (file)
@@ -376,8 +376,6 @@ static int lcdoff_powerkey(void)
        int ignore = true;
 
        if (decide_lcdoff() == true) {
-               if (display_info.update_auto_brightness)
-                       display_info.update_auto_brightness(false);
                switch_off_lcd();
                display_lock_release_lock_all(S_NORMAL);
                display_lock_release_lock_all(S_LCDDIM);
index e52191a..0f2a7af 100644 (file)
@@ -129,13 +129,6 @@ static struct display_config display_conf = {
        .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
-struct display_function_info display_info = {
-       .update_auto_brightness         = NULL,
-       .set_autobrightness_min         = NULL,
-       .reset_autobrightness_min       = NULL,
-       .face_detection                 = NULL,
-};
-
 inline const struct display_config* get_var_display_config()
 {
        return &display_conf;
index f6e4a48..149da8f 100644 (file)
@@ -386,8 +386,6 @@ static int lcdoff_powerkey(void)
        int ignore = true;
 
        if (decide_lcdoff() == true) {
-               if (display_info.update_auto_brightness)
-                       display_info.update_auto_brightness(false);
                switch_off_lcd();
                display_lock_release_lock_all(S_NORMAL);
                display_lock_release_lock_all(S_LCDDIM);
index 52b4e27..04187bb 100644 (file)
@@ -30,6 +30,7 @@
 #include "util.h"
 #include "core.h"
 #include "device-interface.h"
+#include "display-info.h"
 #include "display-ops.h"
 #include "display-backlight.h"
 #include "display-config.h"
@@ -55,7 +56,7 @@ static void change_brightness_transit(int start, int end)
                        display_conf->brightness_change_step);
 }
 
-static void set_brightness_level(int level)
+void set_brightness_level(int level)
 {
        int default_brightness;
        int current_brightness;
@@ -348,7 +349,6 @@ int prepare_level_handler(void)
 {
        int status, ret;
 
-       display_info.set_brightness_level = set_brightness_level;
        disp_plgn->auto_brightness_control = auto_brightness_control;
 
        ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &status);
index 64b4251..4103f72 100644 (file)
@@ -32,6 +32,7 @@
 #include "util.h"
 #include "core.h"
 #include "device-interface.h"
+#include "display-info.h"
 #include "display-ops.h"
 #include "display-backlight.h"
 #include "display-config.h"
@@ -251,7 +252,7 @@ static int alc_action(int timeout)
 
        /* sampling timer add */
        if (alc_timeout_id == 0 && !(get_pm_status_flag() & PWRSV_FLAG)) {
-               display_info.update_auto_brightness(true);
+               update_auto_brightness(true);
 
                alc_timeout_id =
                    g_timeout_add_seconds(g_display_plugin.config->lightsensor_interval,
@@ -419,7 +420,7 @@ static int set_autobrightness_state(int status)
                        _default_action = state_st(S_NORMAL)->action;
                state_st(S_NORMAL)->action = alc_action;
 
-               display_info.update_auto_brightness(true);
+               update_auto_brightness(true);
 
                alc_timeout_id =
                    g_timeout_add_seconds(g_display_plugin.config->lightsensor_interval,
@@ -508,7 +509,7 @@ static gboolean update_handler(void *data)
        return G_SOURCE_REMOVE;
 }
 
-static void update_auto_brightness(bool update)
+void update_auto_brightness(bool update)
 {
        if (update_timeout) {
                g_source_remove(update_timeout);
@@ -660,9 +661,8 @@ static void exit_lsensor(void)
 
 static void auto_brightness_init(void *data)
 {
-       display_info.update_auto_brightness = update_auto_brightness;
-       display_info.set_autobrightness_min = set_autobrightness_min;
-       display_info.reset_autobrightness_min = reset_autobrightness_min;
+       g_display_plugin.set_autobrightness_min = set_autobrightness_min;
+       g_display_plugin.reset_autobrightness_min = reset_autobrightness_min;
 
        register_notifier(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
        register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
index 91e9c9b..23551d1 100644 (file)
@@ -152,13 +152,6 @@ static struct display_config display_conf = {
        .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
-struct display_function_info display_info = {
-       .update_auto_brightness         = NULL,
-       .set_autobrightness_min         = NULL,
-       .reset_autobrightness_min       = NULL,
-       .face_detection                 = NULL,
-};
-
 inline const struct display_config *get_var_display_config()
 {
        return &display_conf;
index a30835b..60cc33e 100644 (file)
@@ -31,6 +31,7 @@
 #include "shared/common.h"
 #include "shared/devices.h"
 #include "display-actor.h"
+#include "display-info.h"
 #include "display-panel.h"
 #include "display-backlight.h"
 #include "display-ops.h"
@@ -63,7 +64,7 @@ static gboolean lcdon_from_aod_cb(gpointer data)
                return G_SOURCE_REMOVE;
 
        display_backlight_change_brightness_by_dpms_state(DPMS_ON);
-       display_info.set_brightness_level(level);
+       set_brightness_level(level);
 
        /* lcdon is completed, aod disappered */
        aod_clock_displayed = false;
@@ -89,26 +90,22 @@ static GVariant *dbus_autobrightnesschanged(GDBusConnection *conn,
                return g_variant_new("(i)", ret);
        }
 
-       if (display_info.set_brightness_level) {
-               if (autobrt_timer) {
-                       g_source_remove(autobrt_timer);
-                       autobrt_timer = 0;
-               }
+       if (autobrt_timer) {
+               g_source_remove(autobrt_timer);
+               autobrt_timer = 0;
+       }
 
-               device_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
-
-               /* When display state changes from AOD to LCDON, brightness change
-                * effect seems sluggish because of heavy load of jobs for turning on
-                * display. So delay this brightness change a bit to avoid this
-                * heavy loaded time and therefore make it change smoothly. */
-               if (aod_clock_displayed) {
-                       autobrtlevel = level; /* reserve the level, defer applying */
-                       autobrt_timer = g_timeout_add(200, lcdon_from_aod_cb, (gpointer)(intptr_t) level);
-               } else { /* S_NORMAL state or LCDON from usual OFF state, not from AOD */
-                       display_info.set_brightness_level(level);
-               }
-       } else {
-               ret = -ENOTSUP;
+       device_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
+
+       /* When display state changes from AOD to LCDON, brightness change
+               * effect seems sluggish because of heavy load of jobs for turning on
+               * display. So delay this brightness change a bit to avoid this
+               * heavy loaded time and therefore make it change smoothly. */
+       if (aod_clock_displayed) {
+               autobrtlevel = level; /* reserve the level, defer applying */
+               autobrt_timer = g_timeout_add(200, lcdon_from_aod_cb, (gpointer)(intptr_t) level);
+       } else { /* S_NORMAL state or LCDON from usual OFF state, not from AOD */
+               set_brightness_level(level);
        }
 
        return g_variant_new("(i)", ret);
@@ -149,7 +146,7 @@ static void aod_change_signal(GDBusConnection  *conn,
                if (autobrt_timer) { /* if there is reserved level, apply it */
                        g_source_remove(autobrt_timer);
                        autobrt_timer = 0;
-                       display_info.set_brightness_level(autobrtlevel);
+                       set_brightness_level(autobrtlevel);
                }
                /* lcdon is completed, aod disappered */
                aod_clock_displayed = false;
index bf368da..c28127b 100644 (file)
@@ -47,4 +47,7 @@ struct hbmsetstate {
        int timeout;
 };
 
+void update_auto_brightness(bool update);
+void set_brightness_level(int level);
+
 #endif
index 51a874f..c399df1 100644 (file)
@@ -33,6 +33,7 @@
 #include "poll.h"
 #include "device-interface.h"
 #include "display-actor.h"
+#include "display-info.h"
 #include "display-ops.h"
 #include "display-panel.h"
 #include "display-backlight.h"
@@ -383,8 +384,7 @@ static int lcdoff_powerkey(void)
        int ignore = true;
 
        if (decide_lcdoff() == true) {
-               if (display_info.update_auto_brightness)
-                       display_info.update_auto_brightness(false);
+               update_auto_brightness(false);
                switch_off_lcd();
                display_lock_release_lock_all(S_NORMAL);
                display_lock_release_lock_all(S_LCDDIM);
index a1599e6..468fdb1 100644 (file)
@@ -86,19 +86,6 @@ struct state *state_st(enum state_t state);
  */
 const struct display_config* get_var_display_config();
 
-/*
- * @brief Display Extension features
- */
-struct display_function_info {
-       void (*update_auto_brightness)(bool);
-       int (*set_autobrightness_min)(int, char *);
-       GBusNameAppearedCallback reset_autobrightness_min;
-       int (*face_detection)(int, int, int);
-       void (*set_brightness_level)(int);
-};
-
-extern struct display_function_info display_info;
-
 typedef struct {
        pid_t pid;
        unsigned int cond;
index 3b38dd4..f6d9949 100644 (file)
@@ -75,6 +75,9 @@ struct display_plugin {
        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,
+                                       const gchar *unique_name, gpointer data);
 
        struct display_config *config;
        struct display_backlight_ops *backlight;
index 42c07f1..3e428c3 100644 (file)
@@ -685,7 +685,7 @@ static GVariant *dbus_setautobrightnessmin(GDBusConnection *conn,
        pid_t pid;
        int id = 0;
 
-       if (!display_info.set_autobrightness_min) {
+       if (!g_display_plugin.set_autobrightness_min) {
                ret = -EIO;
                goto error;
        }
@@ -697,13 +697,13 @@ static GVariant *dbus_setautobrightnessmin(GDBusConnection *conn,
                ret = -ESRCH;
                goto error;
        }
-       ret = display_info.set_autobrightness_min(val, (char *)sender);
+       ret = g_display_plugin.set_autobrightness_min(val, (char *)sender);
        if (ret) {
                _W("fail to set autobrightness min %d, %d by %d", val, ret, pid);
                goto error;
        }
-       if (display_info.reset_autobrightness_min) {
-               id = gdbus_watch_name(sender, display_info.reset_autobrightness_min, NULL, NULL, NULL);
+       if (g_display_plugin.reset_autobrightness_min) {
+               id = gdbus_watch_name(sender, g_display_plugin.reset_autobrightness_min, NULL, NULL, NULL);
                if (id <= 0) {
                        _E("failed to watch name %s, id %d", sender, id);
                        //todo: set return value