summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--packaging/feedbackd.spec1
-rw-r--r--src/haptic/standard-vibcore.c13
3 files changed, 15 insertions, 0 deletions
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 <stdlib.h>
#include <stdbool.h>
+#include <device/power.h>
#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;
}