From 01f0d334a8e44a04d19f70dcba8b570164af5e42 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Thu, 22 Oct 2020 11:41:44 +0800 Subject: [PATCH] input: qcom-hv-haptics: only use 4-byte writes when refilling FIFO The haptics module supports writing FIFO samples using 4-byte burst mode as well as 1-byte mode. During FIFO refilling, if a 1-byte write was used, then the hardware would fill zeros automatically after that to keep the FIFO data 4-byte aligned. When this happened in the middle of playing, the hardware inserted 0 values would cause spurs on the haptics output. To fix this, only use 4-byte burst writes during FIFO refilling until the end of the play. Change-Id: I0441942585e0e0d5da62ec4a7123b2763b292739 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 47ee2fa58fec..1363d2ea80d7 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -2282,8 +2282,19 @@ static irqreturn_t fifo_empty_irq_handler(int irq, void *data) if (num < 0) return IRQ_HANDLED; + /* + * With HAPTICS_PATTERN module revision 2.0 and above, if use + * 1-byte write before 4-byte write, the hardware would insert + * zeros in between to keep the FIFO samples 4-byte aligned, and + * the inserted 0 values would cause HW stop driving hence spurs + * will be seen on the haptics output. So only use 1-byte write + * at the end of FIFO streaming. + */ if (samples_left <= num) num = samples_left; + else if ((chip->ptn_revision >= HAP_PTN_V2) && + (num % HAP_PTN_V2_FIFO_DIN_NUM)) + num -= (num % HAP_PTN_V2_FIFO_DIN_NUM); samples = fifo->samples + status->samples_written;