From 156f44c6bd0218865b1362a97cd5c016f63b068b Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Mon, 17 Jan 2022 10:17:34 +0800 Subject: [PATCH] input: qcom-hv-haptics: set Vmax before toggling HAPTICS_EN in FIFO play Currently, HAPTICS_EN bit is toggled whenever a FIFO pattern is played followed by setting Vmax. However, this would issue a SWR_VMAX handshake and then follow a SPMI_VMAX handshake in HW if haptics effect is played over SWR bus in the background. This back to back Vmax handshake would potentially cause the HW not responding and no vibration being played. To address this, set the Vmax before toggling HAPTICS_EN bit to avoid back to back Vmax handshakes when SWR and FIFO are played concurrently. Change-Id: I0b8924ab7f369db446458fe2510a0da01519a978 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 16a425e5ab9b..92d253a1a179 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1943,22 +1943,11 @@ static int haptics_load_predefined_effect(struct haptics_chip *chip, return -EINVAL; play->effect = effect; - if (play->pattern_src == FIFO) { - /* Toggle HAPTICS_EN for a clear start point of FIFO playing */ - rc = haptics_toggle_module_enable(chip); - if (rc < 0) - return rc; - } - /* Clamp VMAX for different vibration strength */ rc = haptics_set_vmax_mv(chip, play->vmax_mv); if (rc < 0) return rc; - rc = haptics_enable_autores(chip, !play->effect->auto_res_disable); - if (rc < 0) - return rc; - play->pattern_src = play->effect->src; if (play->pattern_src == DIRECT_PLAY || play->pattern_src == SWR) { @@ -1967,6 +1956,17 @@ static int haptics_load_predefined_effect(struct haptics_chip *chip, return -EINVAL; } + if (play->pattern_src == FIFO) { + /* Toggle HAPTICS_EN for a clear start point of FIFO playing */ + rc = haptics_toggle_module_enable(chip); + if (rc < 0) + return rc; + } + + rc = haptics_enable_autores(chip, !play->effect->auto_res_disable); + if (rc < 0) + return rc; + play->brake = play->effect->brake; /* Config brake settings if it's necessary */ if (play->brake) { @@ -2149,12 +2149,12 @@ static int haptics_load_custom_effect(struct haptics_chip *chip, play->effect = chip->custom_effect; play->brake = NULL; play->vmax_mv = (magnitude * chip->custom_effect->vmax_mv) / 0x7fff; - /* Toggle HAPTICS_EN for a clear start point of FIFO playing */ - rc = haptics_toggle_module_enable(chip); + rc = haptics_set_vmax_mv(chip, play->vmax_mv); if (rc < 0) goto cleanup; - rc = haptics_set_vmax_mv(chip, play->vmax_mv); + /* Toggle HAPTICS_EN for a clear start point of FIFO playing */ + rc = haptics_toggle_module_enable(chip); if (rc < 0) goto cleanup;