From b620f8911b6748c805f0f485d5da6ad7ed1693de Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Wed, 28 Nov 2018 15:25:12 +0900 Subject: [PATCH] haptic: Request power lock before vibration - When device goes suspend mode after vibration started, vibration stops immediately. To prevent this, feedbackd request power lock during vibration time. Change-Id: I04bca81481c979ffaeb8d1676c33ec562841ab69 Signed-off-by: pr.jung --- CMakeLists.txt | 1 + packaging/feedbackd.spec | 1 + src/haptic/standard-vibcore.c | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eeb80b..ad93c9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ SET(PKG_MODULES capi-system-info libgdbus libsystemd + capi-system-device ) IF(DRIVER STREQUAL gpio) diff --git a/packaging/feedbackd.spec b/packaging/feedbackd.spec index d33ccfb..0c9fc13 100644 --- a/packaging/feedbackd.spec +++ b/packaging/feedbackd.spec @@ -23,6 +23,7 @@ BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-system-peripheral-io) BuildRequires: pkgconfig(libgdbus) BuildRequires: pkgconfig(libsystemd) +BuildRequires: pkgconfig(capi-system-device) Requires(post): /usr/bin/vconftool diff --git a/src/haptic/standard-vibcore.c b/src/haptic/standard-vibcore.c index f8982c9..528875f 100644 --- a/src/haptic/standard-vibcore.c +++ b/src/haptic/standard-vibcore.c @@ -19,6 +19,7 @@ #include #include +#include #include "core/log.h" #include "core/list.h" @@ -30,6 +31,7 @@ struct vibration_config { char *pattern; + int pattern_duration; dd_list *data; }; @@ -67,6 +69,7 @@ static int vibration_load_config(struct parse_result *result, void *user_data) return -ENOMEM; } + conf->pattern_duration = 0; conf->pattern = strdup(result->name); if (!conf->pattern) { _E("fail to copy %s pattern data", result->name); @@ -111,6 +114,7 @@ static int vibration_load_config(struct parse_result *result, void *user_data) data->duration = strtol(value, NULL, 10); len = len - strlen(value) - 1; value = check + 1; + conf->pattern_duration += data->duration; } check = strchr(value, 'W'); @@ -119,6 +123,7 @@ static int vibration_load_config(struct parse_result *result, void *user_data) data->wait = strtol(value, NULL, 10); len = len - strlen(value) - 1; value = check + 1; + conf->pattern_duration += data->wait; } DD_LIST_APPEND(conf->data, data); @@ -227,6 +232,7 @@ int standard_vibrate_effect(int device_handle, const char *pattern, int feedback dd_list *elem; struct vibration_config *conf; size_t len; + int ret; if (device_handle < 0) return -EINVAL; @@ -250,6 +256,13 @@ int standard_vibrate_effect(int device_handle, const char *pattern, int feedback cur_h_data.priority = priority; cur_h_data.stop = false; _D("Play %s", conf->pattern); + + if (conf->pattern_duration <= 0) + break; + + ret = device_power_request_lock(POWER_LOCK_CPU, conf->pattern_duration); + if (ret != DEVICE_ERROR_NONE) + _E("Failed to request power lock"); haptic_duration_play((void *)&cur_h_data); break; } -- 2.7.4