4 bit resolution means 16 steps -> for loop till >=15 (HS) 5 bit resolution means 32 steps -> for loop till >=31 (HF)
In case of the Handsfree we have 0x1e, 0x1f as invalid values. In case of HF we can limit the loop for 0x1d (29).
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/codecs/twl6040.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 156ebf7..5a33fe1 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -497,7 +497,7 @@ static void twl6040_pga_hs_work(struct work_struct *work) return;
/* HS PGA volumes have 4 bits of resolution to ramp */ - for (i = 0; i <= 16; i++) { + for (i = 0; i <= 15; i++) { headset_complete = twl6040_hs_ramp_step(codec, headset->left_step, headset->right_step); @@ -539,8 +539,11 @@ static void twl6040_pga_hf_work(struct work_struct *work) if (handsfree->ramp == TWL6040_RAMP_NONE) return;
- /* HF PGA volumes have 5 bits of resolution to ramp */ - for (i = 0; i <= 32; i++) { + /* + * HF PGA volumes have 5 bits of resolution to ramp, but 0x1e, 0x1f are + * invalid values, loop till 0x1d + */ + for (i = 0; i <= 29; i++) { handsfree_complete = twl6040_hf_ramp_step(codec, handsfree->left_step, handsfree->right_step);