* 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>
.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;
}