From b12ea3cf7f04d4c2ee2cb6db11c778e1ed84014c Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 7 May 2020 17:21:46 +0900 Subject: [PATCH] motor: zh915: Update level value according to new motor interface 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 --- drivers/motor/zh915.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/motor/zh915.c b/drivers/motor/zh915.c index b848d43f3ea..3e11e6556c6 100644 --- a/drivers/motor/zh915.c +++ b/drivers/motor/zh915.c @@ -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 { -- 2.34.1