diff --git a/sound/soc/codecs/aw882xx/aw882xx.c b/sound/soc/codecs/aw882xx/aw882xx.c index cb84a35e1255cc850c7fcd73043c36fcefbdf750..7d12821053b1cf619345b9803ca548b33b4f6e3b 100644 --- a/sound/soc/codecs/aw882xx/aw882xx.c +++ b/sound/soc/codecs/aw882xx/aw882xx.c @@ -349,18 +349,24 @@ static int aw882xx_fade_in_out(struct aw882xx *aw882xx, bool fade_in) { int i = 0; uint32_t start_volume = 0; + int target_offset = 0; /*volume up*/ if (fade_in) { - for (i = AW_FADE_OUT_TARGET_VOL; i >= (int32_t)aw882xx->db_offset; + if (aw882xx->cfg_num != AW882XX_RECEIVER_MODE) { + target_offset = aw882xx->db_offset; + } else { + target_offset = AW_EARPIECE_MAX_GAIN; + } + for (i = AW_FADE_OUT_TARGET_VOL; i >= (int32_t)target_offset; i -= aw882xx->fade_step) { if (i < (int32_t)aw882xx->fade_step) - i = aw882xx->db_offset; + i = target_offset; aw882xx_set_volume(aw882xx, i); usleep_range(1400, 1600); } - if (i != (int32_t)aw882xx->db_offset) - aw882xx_set_volume(aw882xx, aw882xx->db_offset); + if (i != (int32_t)target_offset) + aw882xx_set_volume(aw882xx, target_offset); } else { /*volume down*/ aw882xx_get_volume(aw882xx, &start_volume); diff --git a/sound/soc/codecs/aw882xx/aw882xx.h b/sound/soc/codecs/aw882xx/aw882xx.h index 92cac5997ab3b3c5915180756076357af67a4cd7..393881197f986291f5febe62bad79ab64ce2ba12 100644 --- a/sound/soc/codecs/aw882xx/aw882xx.h +++ b/sound/soc/codecs/aw882xx/aw882xx.h @@ -32,6 +32,7 @@ #define AW882XX_CFG_NAME_MAX (64) #define AW_FADE_OUT_TARGET_VOL (90 * 2) +#define AW_EARPIECE_MAX_GAIN (40) #define AW882XX_VOLUME_STEP_DB (6 * 2)