/* set optimum DL1 output path gain for ABE -> McPDM -> twl6040 */
static int omap_abe_set_pdm_dl1_gains(struct snd_soc_dapm_context *dapm)
{
	int gain_dB = 0, gain;
	struct snd_soc_card *card = dapm->card;
	struct omap_abe_data *abe_data = snd_soc_card_get_drvdata(card);
	struct snd_soc_codec *codec = abe_data->twl6040_codec;
	struct snd_soc_platform *platform = abe_data->abe_platform;
	struct omap_abe *abe = snd_soc_platform_get_drvdata(platform);

	if (codec) {
#if !defined(CONFIG_SND_OMAP_SOC_ABE_DL2)
		gain_dB = twl6040_get_dl2_gain(codec);
#endif
		if (!gain_dB)
			gain_dB = twl6040_get_dl1_gain(codec);
	}

	switch (gain_dB) {
	case -8:
		gain = GAIN_M8dB;
		break;
	case -7:
		gain = GAIN_M7dB;
		break;
	case -1:
		gain = GAIN_M1dB;
		break;
	default:
		gain = GAIN_0dB;
		break;
	}
	omap_aess_write_gain(abe->aess, OMAP_AESS_GAIN_DL1_LEFT, gain);
	omap_aess_write_gain(abe->aess, OMAP_AESS_GAIN_DL1_RIGHT, gain);
	return 0;
}
static int volume_put_gain(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol);
	struct omap_abe *abe = snd_soc_platform_get_drvdata(platform);
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;

	abe_dsp_pm_get(abe);
	/*SEBG: Ramp 2ms */
	omap_aess_write_gain(abe->aess, mc->shift,
		       abe_val_to_gain(ucontrol->value.integer.value[0]));
	omap_aess_write_gain(abe->aess, mc->rshift,
		       abe_val_to_gain(ucontrol->value.integer.value[1]));
	pm_runtime_put_sync(abe->dev);

	return 1;
}