display: Move common display_start()/stop()/status() to core 58/297458/1
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 18 Aug 2023 11:16:53 +0000 (20:16 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 18 Aug 2023 11:16:53 +0000 (20:16 +0900)
Change-Id: I07eb94b2401ed1dc494f1922d6954daa81d4e8e4
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
src/display/display.c

index 9a4e228..3f3c2c9 100644 (file)
@@ -54,8 +54,6 @@
  * @{
  */
 
-static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-
 static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
        { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
        { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
@@ -152,78 +150,12 @@ static void display_exit(void *data)
        return;
 }
 
-static int display_start(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               if (flags & LCD_PANEL_OFF_MODE)
-                       /* standby on */
-                       syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
-                               DEVICED_DISPLAY_ATTR_INT_DPMS_STATE, SYSCOMMON_DEVICED_DPMS_STANDBY);
-               else
-                       /* normal lcd on */
-                       syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
-                               DEVICED_DISPLAY_ATTR_INT_DPMS_STATE, SYSCOMMON_DEVICED_DPMS_ON);
-
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_START)
-               return -EALREADY;
-
-       if (display_probe(NULL) < 0)
-               return -EPERM;
-
-       display_init(NULL);
-
-       return 0;
-}
-
-static int display_stop(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
-                       DEVICED_DISPLAY_ATTR_INT_DPMS_STATE, SYSCOMMON_DEVICED_DPMS_OFF);
-               return 0;
-       } else if (flags & FORCE_OFF_MODE) {
-               syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
-                       DEVICED_DISPLAY_ATTR_INT_DPMS_STATE, SYSCOMMON_DEVICED_DPMS_FORCE_OFF);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_STOP)
-               return -EALREADY;
-
-       display_exit(NULL);
-
-       return 0;
-}
-
-static int display_status(void)
-{
-       return status;
-}
-
 static const struct device_ops display_plugin_device_ops = {
        .disable_auto_init = true,
        DECLARE_NAME_LEN("display-plugin"),
        .probe    = display_probe,
        .init     = display_init,
        .exit     = display_exit,
-       .start    = display_start,
-       .stop     = display_stop,
-       .status   = display_status,
 };
 
 DEVICE_OPS_REGISTER(&display_plugin_device_ops)
index 7a29b74..fe1f10a 100644 (file)
@@ -83,8 +83,6 @@
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
 
-static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-
 static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
        { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
        { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
@@ -229,70 +227,12 @@ static void display_exit(void *data)
        return;
 }
 
-static int display_start(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               if (flags & LCD_PANEL_OFF_MODE)
-                       /* standby on */
-                       display_panel_set_panel_state_by_standby_state(true);
-               else
-                       /* normal lcd on */
-                       display_panel_set_panel_state_by_on_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_START)
-               return -EALREADY;
-
-       if (display_probe(NULL) < 0)
-               return -EPERM;
-
-       display_init(NULL);
-
-       return 0;
-}
-
-static int display_stop(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
-               display_panel_set_panel_state_by_off_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_STOP)
-               return -EALREADY;
-
-       display_exit(NULL);
-
-       return 0;
-}
-
-static int display_status(void)
-{
-       return status;
-}
-
 static const struct device_ops display_plugin_device_ops = {
        .disable_auto_init = true,
        DECLARE_NAME_LEN("display-plugin"),
        .probe    = display_probe,
        .init     = display_init,
        .exit     = display_exit,
-       .start    = display_start,
-       .stop     = display_stop,
-       .status   = display_status,
 };
 
 DEVICE_OPS_REGISTER(&display_plugin_device_ops)
index 4d1080a..953dede 100644 (file)
@@ -81,8 +81,6 @@
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
 
-static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-
 static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
        { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
        { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
@@ -176,71 +174,12 @@ static void display_exit(void *data)
        return;
 }
 
-static int display_start(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               if (flags & LCD_PANEL_OFF_MODE)
-                       /* standby on */
-                       display_panel_set_panel_state_by_standby_state(true);
-               else
-                       /* normal lcd on */
-                       display_panel_set_panel_state_by_on_state(flags);
-
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_START)
-               return -EALREADY;
-
-       if (display_probe(NULL) < 0)
-               return -EPERM;
-
-       display_init(NULL);
-
-       return 0;
-}
-
-static int display_stop(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
-               display_panel_set_panel_state_by_off_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_STOP)
-               return -EALREADY;
-
-       display_exit(NULL);
-
-       return 0;
-}
-
-static int display_status(void)
-{
-       return status;
-}
-
 static const struct device_ops display_plugin_device_ops = {
        .disable_auto_init = true,
        DECLARE_NAME_LEN("display-plugin"),
        .probe    = display_probe,
        .init     = display_init,
        .exit     = display_exit,
-       .start    = display_start,
-       .stop     = display_stop,
-       .status   = display_status,
 };
 
 DEVICE_OPS_REGISTER(&display_plugin_device_ops)
index 9d26c1f..a107188 100644 (file)
@@ -699,26 +699,55 @@ static void display_exit(void *data)
 
 static int display_start(enum device_flags flags)
 {
-       if (!display_plugin_device_ops || !display_plugin_device_ops->start)
+       /* NORMAL MODE */
+       if (flags & NORMAL_MODE) {
+               if (flags & LCD_PANEL_OFF_MODE)
+                       /* standby on */
+                       display_panel_set_panel_state_by_standby_state(true);
+               else
+                       /* normal lcd on */
+                       display_panel_set_panel_state_by_on_state(flags);
+               return 0;
+       }
+
+       /* CORE LOGIC MODE */
+       if (!(flags & CORE_LOGIC_MODE))
                return 0;
 
-       return display_plugin_device_ops->start(flags);
+       if (display_ops_status == DEVICE_OPS_STATUS_START)
+               return -EALREADY;
+
+       if (display_probe(NULL) < 0)
+               return -EPERM;
+
+       display_init(NULL);
+
+       return 0;
 }
 
 static int display_stop(enum device_flags flags)
 {
-       if (!display_plugin_device_ops || !display_plugin_device_ops->stop)
+       /* NORMAL MODE */
+       if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
+               display_panel_set_panel_state_by_off_state(flags);
                return 0;
+       }
+
+       /* CORE LOGIC MODE */
+       if (!(flags & CORE_LOGIC_MODE))
+               return 0;
+
+       if (display_ops_status == DEVICE_OPS_STATUS_STOP)
+               return -EALREADY;
 
-       return display_plugin_device_ops->stop(flags);
+       display_exit(NULL);
+
+       return 0;
 }
 
 static int display_status(void)
 {
-       if (!display_plugin_device_ops || !display_plugin_device_ops->status)
-               return 0;
-
-       return display_plugin_device_ops->status();
+       return display_ops_status;
 }
 
 static const struct device_ops display_device_ops = {