aw8695: Add wakelock to make vibration stop on time

Without wakelock, system would suspend when vibration is on going,
which may cause the STOP command failed to be sent and in turn leave
the phone vibrating for a long time.

Signed-off-by: yangjq <yangjq@lenovo.com>

Change-Id: Iee5d2691954f960f203f4be8c82c9198304f5977
Reviewed-on: https://gerrit.mot.com/1387741
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
yangjq 2019-07-18 18:27:26 +08:00 • committed by Jianqi Yang
commit 4cd52d87bc
2 changed files with 13 additions and 2 deletions

View file

@ -1837,8 +1837,11 @@ static void aw8695_vibrate(struct aw8695 *aw8695, int value)
mutex_lock(&aw8695->lock);
aw8695_haptic_stop(aw8695);
if (aw8695->index == 0x02)
__pm_relax(aw8695->ws);
seq = aw8695->seq[0];
pr_info("%s: value=%d, seq=%d\n", __FUNCTION__, value, seq);
pr_info("%s: value=%d, seq=%d, index=%x\n", __FUNCTION__, value, seq, aw8695->index);
if (value > 0 || seq > 2) {
@ -1867,6 +1870,7 @@ static void aw8695_vibrate(struct aw8695 *aw8695, int value)
case HAPTIC_SHORT:
if (aw8695->seq[0] == 0)
aw8695->seq[0] = 0x01;
aw8695->index = 0x01;
aw8695_haptic_set_wav_seq(aw8695, 0x00, aw8695->seq[0]);
aw8695_haptic_set_wav_loop(aw8695, 0x00, 0x00);
aw8695_haptic_ram_vbat_comp(aw8695, false);
@ -1877,7 +1881,7 @@ static void aw8695_vibrate(struct aw8695 *aw8695, int value)
/* wav index config */
aw8695->index = 0x02;
aw8695_haptic_set_repeat_wav_seq(aw8695, aw8695->index);
//__pm_wakeup_event(aw8695->ws, value + 100);
__pm_wakeup_event(aw8695->ws, value + 100);
/* run ms timer */
hrtimer_cancel(&aw8695->timer);
aw8695->state = 0x01;
@ -3225,6 +3229,10 @@ static int aw8695_vibrator_init(struct aw8695 *aw8695)
INIT_WORK(&aw8695->rtp_work, aw8695_rtp_work_routine);
aw8695->ws = wakeup_source_register("vibrator");
if (!aw8695->ws)
return -ENOMEM;
mutex_init(&aw8695->lock);
return 0;
@ -3690,6 +3698,8 @@ static int aw8695_i2c_remove(struct i2c_client *i2c)
if (gpio_is_valid(aw8695->reset_gpio))
devm_gpio_free(&i2c->dev, aw8695->reset_gpio);
wakeup_source_unregister(aw8695->ws);
devm_kfree(&i2c->dev, aw8695);
aw8695 = NULL;

View file

@ -295,6 +295,7 @@ struct aw8695 {
struct device *dev;
struct input_dev *input;
struct wakeup_source *ws;
struct mutex lock;
struct hrtimer timer;
struct work_struct vibrator_work;