Troika : vibrator add delay before stop
authordengwei1 <dengwei1@motorola.com>
Tue, 9 Jul 2019 06:42:44 +0000 (14:42 +0800)
committerPDO SCM Team <hudsoncm@motorola.com>
Wed, 10 Jul 2019 03:30:31 +0000 (22:30 -0500)
add delay before stop
pick up from awinic vendor

Change-Id: I01edc4c6719e75d81d6f01205ebd24e25538fbf5
Signed-off-by: dengwei1 <dengwei1@motorola.com>
Reviewed-on: https://gerrit.mot.com/1383349
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

drivers/misc/aw8695_haptic/aw8695.c
drivers/misc/aw8695_haptic/aw8695.h

index e91bd1b5552265d0c44bf8033ebe96732fb05c5a..d280980147de46a4144fa9430758dcd4aa45e514 100755 (executable)
@@ -570,9 +570,19 @@ static int aw8695_haptic_play_go(struct aw8695 *aw8695, bool flag)
 {
     pr_debug("%s enter\n", __func__);
 
+    if (!flag) {
+        do_gettimeofday(&aw8695->current_time);
+        aw8695->interval_us = (aw8695->current_time.tv_sec - aw8695->pre_enter_time.tv_sec) * 1000000
+          + (aw8695->current_time.tv_usec - aw8695->pre_enter_time.tv_usec);
+        if (aw8695->interval_us < 2000) {
+            pr_info("aw8695->interval_us t=%ld\n", aw8695->interval_us);
+            mdelay(2);
+       }
+    }
     if(flag == true) {
         aw8695_i2c_write_bits(aw8695, AW8695_REG_GO,
             AW8695_BIT_GO_MASK, AW8695_BIT_GO_ENABLE);
+        do_gettimeofday(&aw8695->pre_enter_time);
     } else {
         aw8695_i2c_write_bits(aw8695, AW8695_REG_GO,
             AW8695_BIT_GO_MASK, AW8695_BIT_GO_DISABLE);
index 8bce6bad8f3ab83fbddb4243f6a0d12a07346ca0..4124fe32caf7438ade3f97d61a5778b307d9a63c 100755 (executable)
@@ -296,6 +296,8 @@ struct aw8695 {
     struct work_struct vibrator_work;
     struct work_struct rtp_work;
     struct delayed_work ram_work;
+    struct timeval current_time;
+    struct timeval pre_enter_time;
 #ifdef TIMED_OUTPUT
     struct timed_output_dev to_dev;
 #else
@@ -356,6 +358,7 @@ struct aw8695 {
     struct trig trig[AW8695_TRIG_NUM];
 
     struct haptic_audio haptic_audio;
+    unsigned int interval_us;
 };
 
 struct aw8695_container{