Skip to content

Commit

Permalink
ASoC: mediatek: mt6358: initialize setting when ramping volume
Browse files Browse the repository at this point in the history
Mt6358 ramps up from the smallest volume (i.e. -10dB) to target dB when
opening and ramps down from target dB to mute (i.e. -40dB) when closing.
If target is equal to -10dB when opening, headset_volume_ramp() simply
leaves current setting (which may not be -10dB) unchanged.

Execute the loop at least once to initialize the setting to the
starting point (i.e. from).

Signed-off-by: Tzung-Bi Shih <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Tzung-Bi Shih authored and broonie committed May 8, 2019
1 parent ce38a75 commit bdb8fa6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sound/soc/codecs/mt6358.c
Original file line number Diff line number Diff line change
@@ -405,10 +405,9 @@ static bool is_valid_hp_pga_idx(int reg_idx)
reg_idx == DL_GAIN_N_40DB;
}

static void headset_volume_ramp(struct mt6358_priv *priv,
int from, int to)
static void headset_volume_ramp(struct mt6358_priv *priv, int from, int to)
{
int offset = 0, count = 1, reg_idx;
int offset = 0, count = 0, reg_idx;

if (!is_valid_hp_pga_idx(from) || !is_valid_hp_pga_idx(to))
dev_warn(priv->dev, "%s(), volume index is not valid, from %d, to %d\n",
@@ -422,7 +421,7 @@ static void headset_volume_ramp(struct mt6358_priv *priv,
else
offset = from - to;

while (offset > 0) {
while (offset >= 0) {
if (to > from)
reg_idx = from + count;
else

0 comments on commit bdb8fa6

Please sign in to comment.