static int get_config_data(int count, bool *packed, char *val, unsigned int *pattern_duration, struct duration_data *update)
{
static int duration = 0;
+ static int intensity = 0;
int value;
+ int ret;
- if (count > 2 || count <= 0) {
+ if (count > 4 || count <= 0) {
_E("Invalid parameter: count is invalid");
return -EINVAL;
}
get_pattern_property(&val, 'C', &value);
- if (count == 1) {
+ ret = count;
+ if (count == 1) { //duration
duration = value;
*pattern_duration += duration;
if (*pattern_duration > VIB_LOCK_TIMEOUT_MAX) {
_D("Max pattern duration.");
*pattern_duration = VIB_LOCK_TIMEOUT_MAX;
-
}
- return count;
- }
-
- if (value > INTENSITY_BASE_RATE)
- value = INTENSITY_BASE_RATE;
- if (*packed == false) {
- update->duration = duration;
- update->intensity = value;
- *packed = true;
- return 0;
- }
- if (value == 0)
- update->wait = duration;
- else
- update->wait = 0;
- *packed = false;
- duration = 0;
+ } else if (count == 2) {
+ /* if intensity is 0, duration use for wait(off) time */
+ if (value > INTENSITY_BASE_RATE)
+ value = INTENSITY_BASE_RATE;
+ intensity = value;
+ if (*packed == false) {
+ update->duration = duration;
+ update->intensity = intensity;
+ *packed = true;
+ } else {
+ if (intensity == 0)
+ update->wait = duration;
+ else
+ update->wait = 0;
+ *packed = false;
+ duration = 0;
+ ret = -1;
+ }
+ } else if (count == 4)
+ ret = 0;
- return -1;
+ return ret;
}
/*