From: pr.jung Date: Mon, 30 Apr 2018 09:39:48 +0000 (+0900) Subject: haptic: Remove convert_magnitude_by_conf X-Git-Tag: submit/tizen/20180510.011352 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Fsubmit%2Ftizen%2F20180510.011352;p=platform%2Fcore%2Fsystem%2Ffeedbackd.git haptic: Remove convert_magnitude_by_conf Change-Id: I47a8cd4049fd9e0b24d3f99bd0267a23854f11e9 Signed-off-by: pr.jung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a15676..273646c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,5 @@ INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/system FILES_MATCHING PATTERN "feedbackd.service") INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.vibrator.service DESTINATION /usr/share/dbus-1/system-services) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/haptic/conf/haptic-level3.conf DESTINATION /etc/feedbackd) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/haptic/conf/haptic-level6.conf DESTINATION /etc/feedbackd) ADD_SUBDIRECTORY(src/auto-test) diff --git a/packaging/feedbackd.spec b/packaging/feedbackd.spec index 39ff443..8e38701 100644 --- a/packaging/feedbackd.spec +++ b/packaging/feedbackd.spec @@ -31,9 +31,6 @@ Requires(post): /usr/bin/vconftool 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 @@ -95,20 +92,6 @@ Conflicts: %{name}-driver-standard %description driver-circle Feedbackd binaries with circle plugin. Required by main feedbackd package -%package conf-level3 -Summary: Feedbackd configuration file -Provides: configuration-compat = %{version}-%{release} -Conflicts: %{name}-conf-level6 -%description conf-level3 -Feedbackd configuration file. - -%package conf-level6 -Summary: Feedbackd configuration file -Provides: configuration-compat = %{version}-%{release} -Conflicts: %{name}-conf-level3 -%description conf-level6 -Feedbackd configuration file. - %package auto-test Summary: Feedbackd auto test tool Group: System/Utilities @@ -280,12 +263,6 @@ if [ "$1" == "0" ]; then systemctl stop feedbackd.service fi -%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 @@ -319,16 +296,6 @@ mv %{_sysconfdir}/feedbackd/haptic-level6.conf %{_sysconfdir}/feedbackd/haptic.c %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 diff --git a/src/haptic/conf/haptic-level3.conf b/src/haptic/conf/haptic-level3.conf deleted file mode 100644 index 6e52318..0000000 --- a/src/haptic/conf/haptic-level3.conf +++ /dev/null @@ -1,15 +0,0 @@ -[Haptic] -# level -# how much does the vibration level to subdivide. -# The max value of vibration level fixed at 100. -# The min value of vibration level fixed at 0. -level=3 - -[level0] -value=0 - -[level1] -value=58 - -[level2] -value=100 diff --git a/src/haptic/conf/haptic-level6.conf b/src/haptic/conf/haptic-level6.conf deleted file mode 100644 index 84271f1..0000000 --- a/src/haptic/conf/haptic-level6.conf +++ /dev/null @@ -1,24 +0,0 @@ -[Haptic] -# level -# how much does the vibration level to subdivide. -# The max value of vibration level fixed at 100. -# The min value of vibration level fixed at 0. -level=6 - -[level0] -value=0 - -[level1] -value=20 - -[level2] -value=40 - -[level3] -value=60 - -[level4] -value=80 - -[level5] -value=100 diff --git a/src/haptic/haptic.c b/src/haptic/haptic.c index a352ec2..505a6de 100644 --- a/src/haptic/haptic.c +++ b/src/haptic/haptic.c @@ -33,7 +33,6 @@ #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" @@ -45,6 +44,8 @@ #define HARDKEY_VIB_DURATION 30 #define HAPTIC_FEEDBACK_STEP 20 #define DEFAULT_FEEDBACK_LEVEL 3 +#define HIGH_FEEDBACK_LEVEL 100 +#define LOW_FEEDBACK_LEVEL 0 /* power on, power off vibration variable */ #define POWER_ON_VIB_DURATION 300 @@ -85,8 +86,6 @@ static enum haptic_type h_type; static bool haptic_disabled; struct haptic_config { - int level; - int *level_arr; int sound_capture; }; @@ -140,28 +139,9 @@ static int haptic_module_load(void) return 0; } -static int convert_magnitude_by_conf(int level) -{ - int i, step; - - assert(level >= 0 && level <= 100); - - 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) - { int ret, val; @@ -349,12 +329,11 @@ GVariant *hdbus_vibrate_monotone(GDBusConnection *conn, g_variant_get(param, "(uiii)", &handle, &duration, &level, &priority); - /* convert as per conf value */ - level = convert_magnitude_by_conf(level); - if (level < 0) { - ret = -EINVAL; - goto exit; - } + if (level < LOW_FEEDBACK_LEVEL) + level = LOW_FEEDBACK_LEVEL; + else if (level > HIGH_FEEDBACK_LEVEL) + level = HIGH_FEEDBACK_LEVEL; + if (priority < PRIORITY_MIN) priority = PRIORITY_MIN; else if (priority > PRIORITY_TOP) @@ -388,12 +367,10 @@ GVariant *hdbus_vibrate_buffer(GDBusConnection *conn, data = g_variant_get_fixed_array(pvar, &size, sizeof(char)); g_variant_unref(pvar); - /* convert as per conf value */ - level = convert_magnitude_by_conf(level); - if (level < 0) { - ret = -EINVAL; - goto exit; - } + if (level < LOW_FEEDBACK_LEVEL) + level = LOW_FEEDBACK_LEVEL; + else if (level > HIGH_FEEDBACK_LEVEL) + level = HIGH_FEEDBACK_LEVEL; ret = h_ops->vibrate_buffer(handle, data, iteration, level, priority, &e_handle); if (ret >= 0) @@ -430,12 +407,10 @@ GVariant *hdbus_vibrate_effect(GDBusConnection *conn, g_variant_get(param, "(usii)", &handle, &pattern, &level, &priority); - /* convert as per conf value */ - level = convert_magnitude_by_conf(level); - if (level < 0) { - ret = -EINVAL; - goto exit; - } + if (level < LOW_FEEDBACK_LEVEL) + level = LOW_FEEDBACK_LEVEL; + else if (level > HIGH_FEEDBACK_LEVEL) + level = HIGH_FEEDBACK_LEVEL; if (priority < PRIORITY_MIN) priority = PRIORITY_MIN; else if (priority > PRIORITY_TOP) @@ -742,6 +717,7 @@ static void sound_capturing_cb(keynode_t *key, void *data) 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; @@ -754,21 +730,6 @@ static int parse_section(struct parse_result *result, void *user_data, int index 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; @@ -776,10 +737,7 @@ static int parse_section(struct parse_result *result, void *user_data, int index 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; @@ -787,7 +745,7 @@ static int haptic_load_config(struct parse_result *result, void *user_data) if (!result->section || !result->name || !result->value) return 0; - /* Parsing 'Haptic' section */ + // Parsing 'Haptic' section if (MATCH(result->section, "Haptic")) { ret = parse_section(result, user_data, -1); if (ret < 0) { @@ -797,22 +755,10 @@ static int haptic_load_config(struct parse_result *result, void *user_data) 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 }, @@ -854,13 +800,6 @@ void haptic_init(void) { 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) @@ -907,9 +846,6 @@ void haptic_exit(void) 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;