From a7b2b418ea7286204b8212276756afc0233bd878 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Tue, 28 Apr 2020 09:00:52 +0800 Subject: [PATCH 1/2] input: misc: qcom-hv-haptics: check nvmem before using it Currently, nvmem device is used to store closed loop brake settings. If nvmem-cells is not specified for closed loop brake, then nvmem device can be NULL. For such case, skip updating closed loop brake settings by not writing to the nvmem device. Change-Id: I18d455814f3731af519949f21a3a553bd1692548 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 5fa16466cee7..e767d4958439 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1478,6 +1478,9 @@ static int haptics_store_cl_brake_settings(struct haptics_chip *chip) int rc = 0; u8 val; + if (!chip->cl_brake_nvmem) + return 0; + val = MOD_STATUS_SEL_BRAKE_CAL_RNAT_RCAL_VAL; rc = haptics_write(chip, chip->cfg_addr_base, HAP_CFG_MOD_STATUS_SEL_REG, &val, 1); From ec870b7d84e0cfbd3a91911f9499147b03b2fbd3 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Wed, 29 Apr 2020 14:05:59 +0800 Subject: [PATCH 2/2] input: qcom-hv-haptics: set auto resonance when loading effects Set auto resonance when loading effect according to the effect settings. Change-Id: I8dc9ac99a57e396d67da28ae7b1eb31813ab3362 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index e767d4958439..2d8077498a05 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1082,6 +1082,10 @@ static int haptics_load_predefined_effect(struct haptics_chip *chip, 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 != PATTERN1 && play->pattern_src != PATTERN2 && @@ -1246,6 +1250,10 @@ static int haptics_load_custom_effect(struct haptics_chip *chip, if (rc < 0) goto cleanup; + rc = haptics_enable_autores(chip, !play->effect->auto_res_disable); + if (rc < 0) + goto cleanup; + play->pattern_src = FIFO; rc = haptics_set_fifo(chip, play->effect->fifo); if (rc < 0)