display: Support display setup when the dpms initialization done 94/316794/4
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 22 Aug 2024 07:29:05 +0000 (16:29 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Wed, 28 Aug 2024 10:38:27 +0000 (19:38 +0900)
When the dpms initialization is done, display state is set to DISPLAY_STATE_ON.
And then, normal state timeout counting starts.
After normal state timeout, display state can be changed to other state.
To support above description, this patch is necessary.

Change-Id: I03bf7eb8a64d70f6de5dd6a3c9d176bb4a64e0be
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/deviced-display/deviced-display.c

index a056e46210925aa05c91f67ab048bc15b9e78406..05c3526a30ac46b01ca90f0b63619f2e33ba1f82 100644 (file)
  * limitations under the License.
  */
 
+#include <stdio.h>
+#include <sys/types.h>
+
+#include <libsyscommon/log.h>
+#include <libsyscommon/notifier.h>
+#include <libsyscommon/resource-manager.h>
 #include <system/syscommon-plugin-common-interface.h>
 #include <system/syscommon-plugin-deviced-common-interface.h>
 #include <system/syscommon-plugin-deviced-display.h>
@@ -70,15 +76,61 @@ static syscommon_plugin_backend_deviced_display_funcs g_display_funcs = {
        .load_display_config = load_display_config,
 };
 
+static int setup_display_with_dpms_init(void *data)
+{
+       enum syscommon_deviced_display_state state = SYSCOMMON_DEVICED_DISPLAY_STATE_ON;
+       int normal_state_timeout = 0;
+       int ret = 0;
+
+       ret = syscommon_resman_get_resource_attr_uint64_with_1_user_data(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+                                       DEVICED_DISPLAY_ATTR_INT_STATE_TIMEOUT,
+                                       (u_int64_t *) &state,
+                                       (u_int64_t *) &normal_state_timeout);
+       if (ret < 0) {
+               _E("Failed to get display normal state timeout, err(%d)", ret);
+               return ret;
+       }
+
+       ret = syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+                                       DEVICED_DISPLAY_ATTR_INT_PM_CURRENT_STATE,
+                                       SYSCOMMON_DEVICED_DISPLAY_STATE_ON);
+       if (ret < 0) {
+               _E("Failed to set current state, err(%d)", ret);
+               return ret;
+       }
+
+       ret = syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+                                       DEVICED_DISPLAY_ATTR_INT_RESET_STATE_TIMEOUT,
+                                       normal_state_timeout);
+       if (ret < 0) {
+               _E("Failed to reset state timeout as normal state timeout value, err(%d)", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
 static int deviced_display_init(void **data)
 {
+       int ret = 0;
+
        *data = (void *)&g_display_funcs;
 
+       ret = syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_DISPLAY_DPMS_INIT, setup_display_with_dpms_init);
+       if (ret < 0)
+               _W("DEVICED_NOTIFIER_DISPLAY_DPMS_INIT is not subscribed.");
+
        return 0;
 }
 
 static int deviced_display_exit(void *data)
 {
+       int ret = 0;
+
+       ret = syscommon_notifier_unsubscribe_notify(DEVICED_NOTIFIER_DISPLAY_DPMS_INIT, setup_display_with_dpms_init);
+       if (ret < 0)
+               _W("DEVICED_NOTIFIER_DISPLAY_DPMS_INIT is not unsubscribed.");
+
        return 0;
 }