display: Initialize display core device 31/290231/4
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 21 Mar 2023 01:21:16 +0000 (10:21 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 27 Mar 2023 04:41:20 +0000 (13:41 +0900)
The display device is now added to the deviced core translation unit.
The existing display plugin devices are changed not to be initialized
by default. Instead its initialization is triggered by display core
device.

Change-Id: I864b8f7aa594c56076286e2d7d7516bee11f2245
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
plugins/iot-headed/display/core.c
plugins/iot-headless/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/display.c [new file with mode: 0644]

index 2650e47..4c5e56c 100644 (file)
@@ -76,6 +76,11 @@ SET(SRCS
        src/time/time-handler.c
 )
 
+IF(DISPLAY_MODULE STREQUAL on)
+       ADD_SOURCE(src/display DISPLAY_SRCS)
+       SET(SRCS ${SRCS} ${DISPLAY_SRCS})
+ENDIF()
+
 IF(BATTERY_MODULE STREQUAL on)
        ADD_SOURCE(src/battery BATTERY_SRCS)
        SET(SRCS ${SRCS} ${BATTERY_SRCS})
index 5d637b8..e3528f2 100644 (file)
@@ -2277,9 +2277,9 @@ static int display_status(void)
        return status;
 }
 
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       DECLARE_NAME_LEN("display"),
+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,
@@ -2288,7 +2288,7 @@ static const struct device_ops display_device_ops = {
        .status   = display_status,
 };
 
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
index ac7bd11..0b50049 100644 (file)
@@ -57,10 +57,10 @@ static void display_init(void *data)
                _W("Failed to init plugin iot-headless display dbus interface(%d)", ret);
 }
 
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       DECLARE_NAME_LEN("display"),
+static const struct device_ops display_plugin_device_ops = {
+       .disable_auto_init = true,
+       DECLARE_NAME_LEN("display-plugin"),
        .init     = display_init,
 };
 
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
index cbd9c6e..e8d4930 100644 (file)
@@ -2288,9 +2288,9 @@ static int display_status(void)
        return status;
 }
 
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       DECLARE_NAME_LEN("display"),
+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,
@@ -2299,7 +2299,7 @@ static const struct device_ops display_device_ops = {
        .status   = display_status,
 };
 
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
index e7b7ca5..30a8579 100644 (file)
@@ -2274,9 +2274,9 @@ static int display_status(void)
        return status;
 }
 
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       DECLARE_NAME_LEN("display"),
+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,
@@ -2285,7 +2285,7 @@ static const struct device_ops display_device_ops = {
        .status   = display_status,
 };
 
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
index 06fd7af..ca9cfc2 100644 (file)
@@ -2605,9 +2605,9 @@ static int display_status(void)
        return status;
 }
 
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       DECLARE_NAME_LEN("display"),
+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,
@@ -2616,7 +2616,7 @@ static const struct device_ops display_device_ops = {
        .status   = display_status,
 };
 
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
diff --git a/src/display/display.c b/src/display/display.c
new file mode 100644 (file)
index 0000000..a8f72ed
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2011 - 2013 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.
+ */
+
+#include <shared/devices.h>
+
+static const struct device_ops *display_plugin_device_ops;
+
+static int display_probe(void *data)
+{
+       display_plugin_device_ops = find_device("display-plugin");
+       if (!display_plugin_device_ops || !display_plugin_device_ops->probe)
+               return 0;
+
+       return display_plugin_device_ops->probe(data);
+}
+
+static void display_init(void *data)
+{
+       if (!display_plugin_device_ops || !display_plugin_device_ops->init)
+               return;
+
+       display_plugin_device_ops->init(data);
+}
+
+static void display_exit(void *data)
+{
+       if (!display_plugin_device_ops || !display_plugin_device_ops->exit)
+               return;
+
+       display_plugin_device_ops->exit(data);
+}
+
+static int display_start(enum device_flags flags)
+{
+       if (!display_plugin_device_ops || !display_plugin_device_ops->start)
+               return 0;
+
+       return display_plugin_device_ops->start(flags);
+}
+
+static int display_stop(enum device_flags flags)
+{
+       if (!display_plugin_device_ops || !display_plugin_device_ops->stop)
+               return 0;
+
+       return display_plugin_device_ops->stop(flags);
+}
+
+static int display_status(void)
+{
+       if (!display_plugin_device_ops || !display_plugin_device_ops->status)
+               return 0;
+
+       return display_plugin_device_ops->status();
+}
+
+static const struct device_ops display_device_ops = {
+       .priority = DEVICE_PRIORITY_HIGH,
+       DECLARE_NAME_LEN("display"),
+       .probe    = display_probe,
+       .init     = display_init,
+       .exit     = display_exit,
+       .start    = display_start,
+       .stop     = display_stop,
+       .status   = display_status,
+};
+
+DEVICE_OPS_REGISTER(&display_device_ops)