Commit b7a742cf authored by Akshu Agrawal's avatar Akshu Agrawal Committed by Mark Brown

ASoC: AMD: Use mixer control to switch between DMICs

Having mixer control to switch between DMICs prevents user to
initiate capture simultaneously on both the DMIcs.
Earlier 2 separate devices, one for each DMIC, gave an option of
using them simultaneously, which is not supported.
Signed-off-by: default avatarAkshu Agrawal <akshu.agrawal@amd.com>
Link: https://lore.kernel.org/r/20200530095519.24324-1-akshu.agrawal@amd.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9ba4af79
...@@ -188,25 +188,27 @@ static int acp3x_ec_dmic0_startup(struct snd_pcm_substream *substream) ...@@ -188,25 +188,27 @@ static int acp3x_ec_dmic0_startup(struct snd_pcm_substream *substream)
machine->cap_i2s_instance = I2S_BT_INSTANCE; machine->cap_i2s_instance = I2S_BT_INSTANCE;
snd_soc_dai_set_bclk_ratio(codec_dai, 64); snd_soc_dai_set_bclk_ratio(codec_dai, 64);
if (dmic_sel)
gpiod_set_value(dmic_sel, 0);
return rt5682_clk_enable(substream); return rt5682_clk_enable(substream);
} }
static int acp3x_ec_dmic1_startup(struct snd_pcm_substream *substream) static int dmic_switch;
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
struct acp3x_platform_info *machine = snd_soc_card_get_drvdata(card);
machine->cap_i2s_instance = I2S_BT_INSTANCE; static int dmic_get(struct snd_kcontrol *kcontrol,
snd_soc_dai_set_bclk_ratio(codec_dai, 64); struct snd_ctl_elem_value *ucontrol)
if (dmic_sel) {
gpiod_set_value(dmic_sel, 1); ucontrol->value.integer.value[0] = dmic_switch;
return 0;
}
return rt5682_clk_enable(substream); static int dmic_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
if (dmic_sel) {
dmic_switch = ucontrol->value.integer.value[0];
gpiod_set_value(dmic_sel, dmic_switch);
}
return 0;
} }
static void rt5682_shutdown(struct snd_pcm_substream *substream) static void rt5682_shutdown(struct snd_pcm_substream *substream)
...@@ -229,11 +231,6 @@ static const struct snd_soc_ops acp3x_ec_cap0_ops = { ...@@ -229,11 +231,6 @@ static const struct snd_soc_ops acp3x_ec_cap0_ops = {
.shutdown = rt5682_shutdown, .shutdown = rt5682_shutdown,
}; };
static const struct snd_soc_ops acp3x_ec_cap1_ops = {
.startup = acp3x_ec_dmic1_startup,
.shutdown = rt5682_shutdown,
};
SND_SOC_DAILINK_DEF(acp3x_i2s, SND_SOC_DAILINK_DEF(acp3x_i2s,
DAILINK_COMP_ARRAY(COMP_CPU("acp3x_i2s_playcap.0"))); DAILINK_COMP_ARRAY(COMP_CPU("acp3x_i2s_playcap.0")));
SND_SOC_DAILINK_DEF(acp3x_bt, SND_SOC_DAILINK_DEF(acp3x_bt,
...@@ -279,21 +276,26 @@ static struct snd_soc_dai_link acp3x_dai_5682_98357[] = { ...@@ -279,21 +276,26 @@ static struct snd_soc_dai_link acp3x_dai_5682_98357[] = {
.ops = &acp3x_ec_cap0_ops, .ops = &acp3x_ec_cap0_ops,
SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform), SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform),
}, },
{
.name = "acp3x-ec-dmic1-capture",
.stream_name = "Capture DMIC1",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBS_CFS,
.dpcm_capture = 1,
.ops = &acp3x_ec_cap1_ops,
SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform),
},
}; };
static const char * const dmic_mux_text[] = {
"Front Mic",
"Rear Mic",
};
static SOC_ENUM_SINGLE_DECL(
acp3x_dmic_enum, SND_SOC_NOPM, 0, dmic_mux_text);
static const struct snd_kcontrol_new acp3x_dmic_mux_control =
SOC_DAPM_ENUM_EXT("DMIC Select Mux", acp3x_dmic_enum,
dmic_get, dmic_set);
static const struct snd_soc_dapm_widget acp3x_widgets[] = { static const struct snd_soc_dapm_widget acp3x_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_SPK("Spk", NULL), SND_SOC_DAPM_SPK("Spk", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0,
&acp3x_dmic_mux_control),
}; };
static const struct snd_soc_dapm_route acp3x_audio_route[] = { static const struct snd_soc_dapm_route acp3x_audio_route[] = {
...@@ -301,6 +303,8 @@ static const struct snd_soc_dapm_route acp3x_audio_route[] = { ...@@ -301,6 +303,8 @@ static const struct snd_soc_dapm_route acp3x_audio_route[] = {
{"Headphone Jack", NULL, "HPOR"}, {"Headphone Jack", NULL, "HPOR"},
{"IN1P", NULL, "Headset Mic"}, {"IN1P", NULL, "Headset Mic"},
{"Spk", NULL, "Speaker"}, {"Spk", NULL, "Speaker"},
{"Dmic Mux", "Front Mic", "DMIC"},
{"Dmic Mux", "Rear Mic", "DMIC"},
}; };
static const struct snd_kcontrol_new acp3x_mc_controls[] = { static const struct snd_kcontrol_new acp3x_mc_controls[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment