motor: zh915: Update level value according to new motor interface 13/232713/2 accepted/tizen/unified/20200528.132926 submit/tizen/20200526.073613
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 7 May 2020 08:21:46 +0000 (17:21 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 7 May 2020 08:31:39 +0000 (17:31 +0900)
Priot to that 'u.rumble.strong_magnitude' contains the value as following:
- In case of intensity is strong : 65536
- In case of insensity is weak, 32767

But, the new motor interface uses 'u.rumble.strong_magnitude' as the
'intensity_level' which is range from 1 to 5. In order to keep
the compatibility, calculate the level in the kernel according to
the 'intensity_level' from user process (feedbackd).

In result, the 'level' would be initialized as following to keep
the compatibility.
- If level is 1 (strong), the calculated level value is 65536.
- If level is 2 (weak), the calculated level value is 32767.

Change-Id: Ia8f2fc730432ce9a6c589d571bd9c629627b9316
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/motor/zh915.c

index b848d43f3ea59785640f93dea6ea0621e3d18f6f..3e11e6556c64dfb032865a5781379ba1461af8b8 100644 (file)
@@ -193,10 +193,24 @@ static int zh915_haptic_play(struct input_dev *input, void *data,
                                struct ff_effect *effect)
 {
        struct zh915_data *pZh915data = input_get_drvdata(input);
-       __u16 level = effect->u.rumble.strong_magnitude;
+       __u16 level = (effect->u.rumble.weak_magnitude & 0xe000) >> 13;
+
+       /* using ff_runble effect */
+       /* struct ff_rumble_effect {
+        __u16 strong_magnitude; // strong_magnitude[15:15] = 0 (Reserved)
+                                // strong_magnitude[14:14]
+                                //   = Overdrive : 0 (Off) or 1 (On)
+                                // strong_magnitude[13:0]
+                                //   = Intensity Value : 0 (Stop)
+                                //     or 1 ~ 10000 (Intensity)
+        __u16 weak_magnitude;   // weak_magnitude[15:13]
+                                //   = Intensity Level : 1 ~ 5
+                                // weak_magnitude[12:0]
+                                //   = Frequency in 0.1Hz : 0 ~ 8191 (0 ~ 819.1 Hz)
+       }; */
 
        if (level) {
-               pZh915data->level = level;
+               pZh915data->level = MAX_LEVEL / level;
                queue_work(system_highpri_wq, &pZh915data->vibrator_work);
        }
        else {