Commit 9c7388ba authored by Alper Nebi Yasak's avatar Alper Nebi Yasak Committed by Mark Brown

ASoC: mediatek: mt8183-da7219-max98357: Map missing jack kcontrols

This driver does not properly map jack pins to kcontrols that PulseAudio
and PipeWire need to handle jack detection events. The DA7219 codec used
here can detect Headphones, Headset Mic and Line Out connections. Expose
each to userspace as kcontrols and add the necessary widgets.
Signed-off-by: default avatarAlper Nebi Yasak <alpernebiyasak@gmail.com>
Link: https://lore.kernel.org/r/20230802175737.263412-17-alpernebiyasak@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0ef5533f
...@@ -29,6 +29,21 @@ struct mt8183_da7219_max98357_priv { ...@@ -29,6 +29,21 @@ struct mt8183_da7219_max98357_priv {
struct snd_soc_jack headset_jack, hdmi_jack; struct snd_soc_jack headset_jack, hdmi_jack;
}; };
static struct snd_soc_jack_pin mt8183_da7219_max98357_jack_pins[] = {
{
.pin = "Headphone",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
{
.pin = "Line Out",
.mask = SND_JACK_LINEOUT,
},
};
static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream, static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
...@@ -572,13 +587,15 @@ mt8183_da7219_max98357_headset_init(struct snd_soc_component *component) ...@@ -572,13 +587,15 @@ mt8183_da7219_max98357_headset_init(struct snd_soc_component *component)
snd_soc_card_get_drvdata(component->card); snd_soc_card_get_drvdata(component->card);
/* Enable Headset and 4 Buttons Jack detection */ /* Enable Headset and 4 Buttons Jack detection */
ret = snd_soc_card_jack_new(component->card, ret = snd_soc_card_jack_new_pins(component->card,
"Headset Jack", "Headset Jack",
SND_JACK_HEADSET | SND_JACK_HEADSET |
SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_BTN_2 | SND_JACK_BTN_3 |
SND_JACK_LINEOUT, SND_JACK_LINEOUT,
&priv->headset_jack); &priv->headset_jack,
mt8183_da7219_max98357_jack_pins,
ARRAY_SIZE(mt8183_da7219_max98357_jack_pins));
if (ret) if (ret)
return ret; return ret;
...@@ -609,12 +626,18 @@ static struct snd_soc_codec_conf mt6358_codec_conf[] = { ...@@ -609,12 +626,18 @@ static struct snd_soc_codec_conf mt6358_codec_conf[] = {
}; };
static const struct snd_kcontrol_new mt8183_da7219_max98357_snd_controls[] = { static const struct snd_kcontrol_new mt8183_da7219_max98357_snd_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Speakers"), SOC_DAPM_PIN_SWITCH("Speakers"),
SOC_DAPM_PIN_SWITCH("Line Out"),
}; };
static const static const
struct snd_soc_dapm_widget mt8183_da7219_max98357_dapm_widgets[] = { struct snd_soc_dapm_widget mt8183_da7219_max98357_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_SPK("Speakers", NULL), SND_SOC_DAPM_SPK("Speakers", NULL),
SND_SOC_DAPM_SPK("Line Out", NULL),
SND_SOC_DAPM_PINCTRL("TDM_OUT_PINCTRL", SND_SOC_DAPM_PINCTRL("TDM_OUT_PINCTRL",
"aud_tdm_out_on", "aud_tdm_out_off"), "aud_tdm_out_on", "aud_tdm_out_off"),
}; };
...@@ -657,14 +680,20 @@ static struct snd_soc_codec_conf mt8183_da7219_rt1015_codec_conf[] = { ...@@ -657,14 +680,20 @@ static struct snd_soc_codec_conf mt8183_da7219_rt1015_codec_conf[] = {
}; };
static const struct snd_kcontrol_new mt8183_da7219_rt1015_snd_controls[] = { static const struct snd_kcontrol_new mt8183_da7219_rt1015_snd_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Left Spk"), SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"), SOC_DAPM_PIN_SWITCH("Right Spk"),
SOC_DAPM_PIN_SWITCH("Line Out"),
}; };
static const static const
struct snd_soc_dapm_widget mt8183_da7219_rt1015_dapm_widgets[] = { struct snd_soc_dapm_widget mt8183_da7219_rt1015_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_SPK("Left Spk", NULL), SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL),
SND_SOC_DAPM_LINE("Line Out", NULL),
SND_SOC_DAPM_PINCTRL("TDM_OUT_PINCTRL", SND_SOC_DAPM_PINCTRL("TDM_OUT_PINCTRL",
"aud_tdm_out_on", "aud_tdm_out_off"), "aud_tdm_out_on", "aud_tdm_out_off"),
}; };
......
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