static gboolean haptic_duration_play(void *data)
{
dd_list *head, *n, *next;
- struct haptic_data *h_data;
struct duration_data *node;
int ret = 0;
}
if (!data) {
- cur_h_data.handle = INVALID_HANDLE;
- cur_h_data.priority = PRIORITY_MIN;
- goto out;
- }
+ if (cur_h_data.unlimit) /* In case of unlimit pattern, do not stop */
+ head = cur_h_data.vibration_data;
+ else {
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
+ goto out;
+ }
+ } else
+ head = (dd_list *)data;
- h_data = (struct haptic_data *)data;
- if (h_data->stop) {
- h_data->stop = false;
+ if (cur_h_data.stop) {
+ _I("Stop currunt vibration");
+ cur_h_data.stop = false;
cur_h_data.handle = INVALID_HANDLE;
cur_h_data.priority = PRIORITY_MIN;
goto out;
}
- head = h_data->vibration_data;
DD_LIST_FOREACH_SAFE(head, n, next, node) {
- _D("Play: %dms and Wait: %dms", node->duration, node->wait);
- if (!node->duration) {
- cur_h_data.handle = INVALID_HANDLE;
- cur_h_data.priority = PRIORITY_MIN;
- break;
+ _D("Handle %d play: %dms and Wait: %dms (with f:%d o:%d) %s type",
+ cur_h_data.handle, node->duration, node->wait,
+ node->frequency, node->overdriving,
+ cur_h_data.unlimit ? "Unlimit" : "Once");
+ if ((node->duration + node->wait) <= 0) {
+ if (!cur_h_data.unlimit) {
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
+ break;
+ } else {
+ next = cur_h_data.vibration_data;
+ continue;
+ }
}
- if (next) {
- h_data->vibration_data = next;
- duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, (void *)h_data);
- } else
- duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, NULL);
+ duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, (void *)next);
- ret = real_vibrate_monotone(h_data->handle, node->duration, h_data->level, h_data->priority, NULL);
- if (!next)
- goto out;
+ ret = real_vibrate_monotone(cur_h_data.handle, node->duration, cur_h_data.level, cur_h_data.priority, NULL);
break;
}
if (ret != 0) {
_D("auto stop vibration");
- if (h_data)
- h_data->stop = true;
+ cur_h_data.stop = true;
}
out:
return G_SOURCE_REMOVE;
size_t len;
char pattern[PATH_MAX];
int ret;
+ int unlimit = 0;
- if (device_handle < 0)
+ if (device_handle < 0 || !requested_pattern)
return -EINVAL;
/* Same or higher priority pattern should be played */
if (strncmp(conf->pattern, pattern, len))
continue;
if (conf->standard) {
+ unlimit = conf->unlimit;
snprintf(pattern, sizeof(pattern), "%s", conf->standard);
len = strlen(pattern) + 1;
continue;
}
+ if (unlimit)
+ cur_h_data.unlimit = unlimit;
+ else
+ cur_h_data.unlimit = conf->unlimit;
cur_h_data.vibration_data = conf->data;
cur_h_data.handle = device_handle;
cur_h_data.level = feedback;
cur_h_data.priority = priority;
cur_h_data.stop = false;
- _D("Play %s", conf->pattern);
+ _I("Handle %d play %s pri %d %s", cur_h_data.handle, conf->pattern, cur_h_data.priority,
+ cur_h_data.unlimit ? "Unlimit" : "Once");
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;
+ if (!cur_h_data.unlimit && conf->pattern_duration > 0) {
+ 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.vibration_data);
+ return 0;
}
+ _E("Handld %d %s is not supported", device_handle, pattern);
return 0;
}