Requires: %{name}-compat = %{version}-%{release}
Recommends: %{name}-driver-standard = %{version}-%{release}
+Requires: configuration-compat = %{version}-%{release}
+Recommends: %{name}-conf-level6 = %{version}-%{release}
+
%description
feedback daemon
%description driver-circle
Feedbackd binaries with circle plugin. Required by main feedbackd package
+%package conf-level3
+Summary: Feedbackd level configuration file
+Provides: configuration-compat = %{version}-%{release}
+Conflicts: %{name}-conf-level6
+%description conf-level3
+Feedbackd level configuration file. Required by main feedbackd package
+
+%package conf-level6
+Summary: Feedbackd level configuration file
+Provides: configuration-compat = %{version}-%{release}
+Conflicts: %{name}-conf-level3
+%description conf-level6
+Feedbackd level configuration file. Required by main feedbackd package
+
%package auto-test
Summary: Feedbackd auto test tool
Group: System/Utilities
systemctl stop feedbackd.service
fi
-%files -n feedbackd
+%post conf-level3
+mv %{_sysconfdir}/feedbackd/haptic-level3.conf %{_sysconfdir}/feedbackd/haptic.conf
+
+%post conf-level6
+mv %{_sysconfdir}/feedbackd/haptic-level6.conf %{_sysconfdir}/feedbackd/haptic.conf
+
+%files -n feedbackd
%manifest %{name}.manifest
%license LICENSE.Apache-2.0
%config %{_sysconfdir}/dbus-1/system.d/feedbackd.conf
%manifest %{name}.manifest
%{_bindir}/feedbackd.circle
+%files conf-level3
+%license LICENSE.Apache-2.0
+%manifest %{name}.manifest
+%config %{_sysconfdir}/feedbackd/haptic-level3.conf
+
+%files conf-level6
+%license LICENSE.Apache-2.0
+%manifest %{name}.manifest
+%config %{_sysconfdir}/feedbackd/haptic-level6.conf
+
%files auto-test
%license LICENSE.Apache-2.0
%manifest %{name}.manifest
#include "core/config-parser.h"
#include "haptic.h"
+#define HAPTIC_CONF_PATH "/etc/feedbackd/haptic.conf"
#define SIGNAL_CHANGE_HARDKEY "ChangeHardkey"
#define SIGNAL_POWEROFF_STATE "ChangeState"
#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator"
static bool haptic_disabled;
struct haptic_config {
+ int level;
+ int *level_arr;
int sound_capture;
};
return 0;
}
+static int convert_magnitude_by_conf(int level)
+{
+ int i, step;
+
+ if (level < LOW_FEEDBACK_LEVEL)
+ level = LOW_FEEDBACK_LEVEL;
+ else if (level > HIGH_FEEDBACK_LEVEL)
+ level = HIGH_FEEDBACK_LEVEL;
+
+ step = 100 / (haptic_conf.level-1);
+ for (i = 0; i < haptic_conf.level; ++i) {
+ if (level <= i*step) {
+ _D("Level changed : %d -> %d", level, haptic_conf.level_arr[i]);
+ return haptic_conf.level_arr[i];
+ }
+ }
+
+ _D("Play default level");
+ return DEFAULT_FEEDBACK_LEVEL * HAPTIC_FEEDBACK_STEP;
+}
+
GVariant *hdbus_get_count(GDBusConnection *conn,
const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
g_variant_get(param, "(uiii)", &handle, &duration, &level, &priority);
- if (level < LOW_FEEDBACK_LEVEL)
- level = LOW_FEEDBACK_LEVEL;
- else if (level > HIGH_FEEDBACK_LEVEL)
- level = HIGH_FEEDBACK_LEVEL;
+ /* convert as per conf value */
+ level = convert_magnitude_by_conf(level);
+ if (level < 0) {
+ ret = -EINVAL;
+ goto exit;
+ }
if (priority < PRIORITY_MIN)
priority = PRIORITY_MIN;
data = g_variant_get_fixed_array(pvar, &size, sizeof(char));
g_variant_unref(pvar);
- if (level < LOW_FEEDBACK_LEVEL)
- level = LOW_FEEDBACK_LEVEL;
- else if (level > HIGH_FEEDBACK_LEVEL)
- level = HIGH_FEEDBACK_LEVEL;
+ /* convert as per conf value */
+ level = convert_magnitude_by_conf(level);
+ if (level < 0) {
+ ret = -EINVAL;
+ goto exit;
+ }
ret = h_ops->vibrate_buffer(handle, data, iteration, level, priority, &e_handle);
if (ret >= 0)
g_variant_get(param, "(usii)", &handle, &pattern, &level, &priority);
- if (level < LOW_FEEDBACK_LEVEL)
- level = LOW_FEEDBACK_LEVEL;
- else if (level > HIGH_FEEDBACK_LEVEL)
- level = HIGH_FEEDBACK_LEVEL;
+ /* convert as per conf value */
+ level = convert_magnitude_by_conf(level);
+ if (level < 0) {
+ ret = -EINVAL;
+ goto exit;
+ }
if (priority < PRIORITY_MIN)
priority = PRIORITY_MIN;
else if (priority > PRIORITY_TOP)
haptic_start();
}
-/* Left for the case of sound_capture in use
static int parse_section(struct parse_result *result, void *user_data, int index)
{
struct haptic_config *conf = (struct haptic_config *)user_data;
if (MATCH(result->name, "sound_capture")) {
conf->sound_capture = atoi(result->value);
+ } else if (MATCH(result->name, "level")) {
+ conf->level = atoi(result->value);
+ if (conf->level < 0 || conf->level >= INT_MAX - 1) {
+ _E("You must set level with positive number in integer range");
+ return -EINVAL;
+ }
+ conf->level_arr = calloc(sizeof(int), conf->level);
+ if (!conf->level_arr) {
+ _E("failed to allocate memory for level");
+ return -errno;
+ }
+ } else if (MATCH(result->name, "value")) {
+ if (index < 0)
+ return -EINVAL;
+ conf->level_arr[index] = atoi(result->value);
}
return 0;
static int haptic_load_config(struct parse_result *result, void *user_data)
{
+ struct haptic_config *conf = (struct haptic_config *)user_data;
+ char name[NAME_MAX];
int ret;
+ static int index;
if (!result)
return 0;
goto out;
}
+ // Parsing 'level' section
+ for (index = 0; index < conf->level; ++index) {
+ snprintf(name, sizeof(name), "level%d", index);
+ if (MATCH(result->section, name)) {
+ ret = parse_section(result, user_data, index);
+ if (ret < 0) {
+ _E("failed to parse [level] section : %d", ret);
+ return ret;
+ }
+ goto out;
+ }
+ }
+
out:
return 0;
}
-*/
static const dbus_method_s hdbus_methods[] = {
{ "GetCount", NULL, "i", hdbus_get_count },
{
int r;
+ /* get haptic data from configuration file */
+ r = config_parse(HAPTIC_CONF_PATH, haptic_load_config, &haptic_conf);
+ if (r < 0) {
+ _E("failed to load configuration file(%s) : %d", HAPTIC_CONF_PATH, r);
+ safe_free(haptic_conf.level_arr);
+ }
+
/* init dbus interface */
r = dbus_handle_register_dbus_object(NULL, VIBRATOR_PATH_HAPTIC, &dbus_interface);
if (r < 0)
unsubscribe_dbus_signal(NULL, id_sig_change_hardkey);
unsubscribe_dbus_signal(NULL, id_sig_pwr_off_state);
+ /* release haptic data memory */
+ safe_free(haptic_conf.level_arr);
+
if (!CHECK_VALID_OPS(h_ops, r))
return;
#define STANDARD_FILE_PATH FEEDBACK_BASE_PATH"vibration/"
#define VIBRATION_CONF_PATH FEEDBACK_BASE_PATH"vibration.conf"
+#define INTENSITY_BASE_RATE (10000)
#define VALUE_MAX_LEN 10
#define VIB_LOCK_TIMEOUT_MAX (300000) /* 5minutes */
len = strlen(pattern) + 1;
ret = 0;
DD_LIST_FOREACH(vib_conf_list, elem, conf) {
- if (!conf->pattern || conf->len != len)
+ if (!conf->pattern || conf->len != len)
continue;
if (!strncmp(conf->pattern, pattern, len)) {
ret = true;
{
dd_list *head, *n, *next;
struct duration_data *node;
+ int level;
int ret = 0;
if (duration_timer) {
}
}
+ if (node->intensity)
+ level = (cur_h_data.level * node->intensity) / INTENSITY_BASE_RATE;
+ else
+ level = cur_h_data.level;
+
duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, (void *)next);
- ret = real_vibrate_monotone(cur_h_data.handle, node->duration, cur_h_data.level, cur_h_data.priority, NULL);
+ ret = real_vibrate_monotone(cur_h_data.handle, node->duration, level, cur_h_data.priority, NULL);
break;
}