display: Relocate lcd_uevent_changed() 87/294887/3
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 28 Jun 2023 05:37:42 +0000 (14:37 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Thu, 29 Jun 2023 04:56:37 +0000 (13:56 +0900)
lcd_uevent_ops is registered from all display plugin initialization.
It controls touchscreen_ops stop/start through uevent.
All the plugins have same lcd_uevent_changed() logic.
Thus it is relocated to display core.

Change-Id: Ie42b11f6f20e77463ea81dcf72aee662d368c5d5
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/display.c

index 226f141..8bd2cd2 100644 (file)
@@ -264,44 +264,6 @@ static int input_init_handler(void)
        return 0;
 }
 
-static void esd_action(void)
-{
-       const struct device_ops *touchscreen_ops = NULL;
-
-       _I("ESD on");
-
-       touchscreen_ops = find_device("touchscreen");
-
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->stop(NORMAL_MODE);
-       display_panel_set_panel_state_by_off_state(NORMAL_MODE);
-       display_panel_set_panel_state_by_on_state(NORMAL_MODE);
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->start(NORMAL_MODE);
-}
-
-static void lcd_uevent_changed(struct udev_device *dev)
-{
-       const char *devpath;
-       const char *action;
-
-       devpath = udev_device_get_devpath(dev);
-       if (!devpath)
-               return;
-
-       if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
-               action = udev_device_get_action(dev);
-               if (!strcmp(action, UDEV_CHANGE))
-                       esd_action();
-       }
-}
-
-static const struct uevent_handler lcd_uevent_ops = {
-       .subsystem      = LCD_EVENT_SUBSYSTEM,
-       .uevent_func    = lcd_uevent_changed,
-       .data           = NULL,
-};
-
 static void display_init(void *data)
 {
        int ret, i;
@@ -316,8 +278,6 @@ static void display_init(void *data)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
 
-       register_kernel_uevent_control(&lcd_uevent_ops);
-
        register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
@@ -439,8 +399,6 @@ static void display_exit(void *data)
        /* timeout is not needed */
        display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
 
-       unregister_kernel_uevent_control(&lcd_uevent_ops);
-
        display_ops_exit(NULL);
 
        for (i = i - 1; i >= INIT_SETTING; i--) {
index d6553b6..c772856 100644 (file)
@@ -313,44 +313,6 @@ static int input_init_handler(void)
        return 0;
 }
 
-static void esd_action(void)
-{
-       const struct device_ops *touchscreen_ops = NULL;
-
-       _I("ESD on");
-
-       touchscreen_ops = find_device("touchscreen");
-
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->stop(NORMAL_MODE);
-       display_panel_set_panel_state_by_off_state(NORMAL_MODE);
-       display_panel_set_panel_state_by_on_state(NORMAL_MODE);
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->start(NORMAL_MODE);
-}
-
-static void lcd_uevent_changed(struct udev_device *dev)
-{
-       const char *devpath;
-       const char *action;
-
-       devpath = udev_device_get_devpath(dev);
-       if (!devpath)
-               return;
-
-       if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
-               action = udev_device_get_action(dev);
-               if (!strcmp(action, UDEV_CHANGE))
-                       esd_action();
-       }
-}
-
-static const struct uevent_handler lcd_uevent_ops = {
-       .subsystem      = LCD_EVENT_SUBSYSTEM,
-       .uevent_func    = lcd_uevent_changed,
-       .data           = NULL,
-};
-
 static void display_init(void *data)
 {
        int ret, i;
@@ -365,8 +327,6 @@ static void display_init(void *data)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
 
-       register_kernel_uevent_control(&lcd_uevent_ops);
-
        register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
@@ -489,8 +449,6 @@ static void display_exit(void *data)
        /* timeout is not needed */
        display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
 
-       unregister_kernel_uevent_control(&lcd_uevent_ops);
-
        display_ops_exit(NULL);
 
        for (i = i - 1; i >= INIT_SETTING; i--) {
index 7f73e9b..e52191a 100644 (file)
@@ -261,44 +261,6 @@ static int input_init_handler(void)
        return 0;
 }
 
-static void esd_action(void)
-{
-       const struct device_ops *touchscreen_ops = NULL;
-
-       _I("ESD on");
-
-       touchscreen_ops = find_device("touchscreen");
-
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->stop(NORMAL_MODE);
-       display_panel_set_panel_state_by_off_state(NORMAL_MODE);
-       display_panel_set_panel_state_by_on_state(NORMAL_MODE);
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->start(NORMAL_MODE);
-}
-
-static void lcd_uevent_changed(struct udev_device *dev)
-{
-       const char *devpath;
-       const char *action;
-
-       devpath = udev_device_get_devpath(dev);
-       if (!devpath)
-               return;
-
-       if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
-               action = udev_device_get_action(dev);
-               if (!strcmp(action, UDEV_CHANGE))
-                       esd_action();
-       }
-}
-
-static const struct uevent_handler lcd_uevent_ops = {
-       .subsystem      = LCD_EVENT_SUBSYSTEM,
-       .uevent_func    = lcd_uevent_changed,
-       .data           = NULL,
-};
-
 static void display_init(void *data)
 {
        int ret, i;
@@ -313,8 +275,6 @@ static void display_init(void *data)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
 
-       register_kernel_uevent_control(&lcd_uevent_ops);
-
        register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
@@ -436,8 +396,6 @@ static void display_exit(void *data)
        /* timeout is not needed */
        display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
 
-       unregister_kernel_uevent_control(&lcd_uevent_ops);
-
        display_ops_exit(NULL);
 
        for (i = i - 1; i >= INIT_SETTING; i--) {
index 81a1f01..91e9c9b 100644 (file)
@@ -1018,38 +1018,6 @@ static int input_init_handler(void)
        return 0;
 }
 
-static void esd_action(void)
-{
-       const struct device_ops *touchscreen_ops = NULL;
-
-       _I("ESD on");
-
-       touchscreen_ops = find_device("touchscreen");
-
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->stop(NORMAL_MODE);
-       display_panel_set_panel_state_by_off_state(NORMAL_MODE);
-       display_panel_set_panel_state_by_on_state(NORMAL_MODE);
-       if (!check_default(touchscreen_ops))
-               touchscreen_ops->start(NORMAL_MODE);
-}
-
-static void lcd_uevent_changed(struct udev_device *dev)
-{
-       const char *devpath;
-       const char *action;
-
-       devpath = udev_device_get_devpath(dev);
-       if (!devpath)
-               return;
-
-       if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
-               action = udev_device_get_action(dev);
-               if (!strcmp(action, UDEV_CHANGE))
-                       esd_action();
-       }
-}
-
 static void sec_dsim_uevent_changed(struct udev_device *dev)
 {
        const char *devpath;
@@ -1075,12 +1043,6 @@ static void sec_dsim_uevent_changed(struct udev_device *dev)
        }
 }
 
-static const struct uevent_handler lcd_uevent_ops = {
-       .subsystem      = LCD_EVENT_SUBSYSTEM,
-       .uevent_func    = lcd_uevent_changed,
-       .data           = NULL,
-};
-
 static const struct uevent_handler sec_dsim_uevent_ops = {
        .subsystem      = SEC_DSIM_EVENT_SUBSYSTEM,
        .uevent_func    = sec_dsim_uevent_changed,
@@ -1101,7 +1063,6 @@ static void display_init(void *data)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
 
-       register_kernel_uevent_control(&lcd_uevent_ops);
        register_kernel_uevent_control(&sec_dsim_uevent_ops);
 
        register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
@@ -1227,7 +1188,6 @@ static void display_exit(void *data)
        /* timeout is not needed */
        display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
 
-       unregister_kernel_uevent_control(&lcd_uevent_ops);
        unregister_kernel_uevent_control(&sec_dsim_uevent_ops);
 
        display_ops_exit(NULL);
index 200d23d..7d2048c 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+#include <fnmatch.h>
 #include <signal.h>
 
 #include <libsyscommon/list.h>
 #include <shared/devices.h>
 
+#include "core/udev.h"
 #include "shared/device-notifier.h"
 #include "shared/log.h"
 #include "device-interface.h"
@@ -367,6 +368,47 @@ void display_set_initial_lockscreen_status(void)
        }
 }
 
+/** FIXME: below uevent functions usage and role are unclear, during refactoring
+   these can be removed.
+*/
+static void esd_action(void)
+{
+       const struct device_ops *touchscreen_ops = NULL;
+
+       _I("ESD on");
+
+       touchscreen_ops = find_device("touchscreen");
+
+       if (!check_default(touchscreen_ops))
+               touchscreen_ops->stop(NORMAL_MODE);
+       display_panel_set_panel_state_by_off_state(NORMAL_MODE);
+       display_panel_set_panel_state_by_on_state(NORMAL_MODE);
+       if (!check_default(touchscreen_ops))
+               touchscreen_ops->start(NORMAL_MODE);
+}
+
+static void lcd_uevent_changed(struct udev_device *dev)
+{
+       const char *devpath;
+       const char *action;
+
+       devpath = udev_device_get_devpath(dev);
+       if (!devpath)
+               return;
+
+       if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
+               action = udev_device_get_action(dev);
+               if (!strcmp(action, UDEV_CHANGE))
+                       esd_action();
+       }
+}
+
+static const struct uevent_handler lcd_uevent_ops = {
+       .subsystem      = LCD_EVENT_SUBSYSTEM,
+       .uevent_func    = lcd_uevent_changed,
+       .data           = NULL,
+};
+
 static gboolean handle_sighup(gpointer data)
 {
        int signo = (int) data;
@@ -393,6 +435,8 @@ static void display_init(void *data)
        g_unix_signal_add(SIGHUP, handle_sighup, (gpointer) SIGHUP);
        display_plugin_device_ops->init(data);
 
+       register_kernel_uevent_control(&lcd_uevent_ops);
+
        display_signal_register_display_brightness_notifier();
        display_misc_register_battery_health_notifier();
        register_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
@@ -406,6 +450,8 @@ static void display_exit(void *data)
 
        display_plugin_device_ops->exit(data);
 
+       unregister_kernel_uevent_control(&lcd_uevent_ops);
+
        display_signal_unregister_display_brightness_notifier();
        display_misc_unregister_battery_health_notifier();
        unregister_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);