ASoC: mediatek: Allow separate handling of headphone and headset mic jack
Subsystems (3)
cover ASoC: mediatek: Allow separate handling of headphone and headset mic jack
This series allows the headphone and headset mic jack status to be handled separately by userspace on MT8192, MT8195 and MT8186.
Changes based on commit d0508b4f1604 ("ASoC: rk3399_gru_sound: Add DAPM pins, kcontrols for jack detection"). Found while searching for an alternative for JackSwitch [1].
[1] https://lore.kernel.org/all/[email protected]/
Nícolas F. R. A. Prado (6):
ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
ASoC: mediatek: mt8195: Expose individual headset jack pins
ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
.../mt8186/mt8186-mt6366-da7219-max98357.c | 25 +++++++++++++++++-- .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 25 +++++++++++++++++-- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 17 +++++++++++-- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 17 +++++++++++-- 4 files changed, 76 insertions(+), 8 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/6 ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8192-mt6359 driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.
Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
---
.../mt8192/mt8192-mt6359-rt1015-rt5682.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +15 -2
@@ -41,6 +41,18 @@ struct mt8192_mt6359_priv {struct snd_soc_jack hdmi_jack; }; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8192_jack_pins[] = { + { + .pin ="Headphone Jack" , + .mask =SND_JACK_HEADPHONE , + }, + { + .pin ="Headset Mic" , + .mask =SND_JACK_MICROPHONE , + }, +}; +static int mt8192_rt1015_i2s_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params) {
@@ -326,11 +338,12 @@ static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd)return ret; } - ret =snd_soc_card_jack_new (rtd->card,"Headset Jack" , + ret =snd_soc_card_jack_new_pins (rtd->card,"Headset Jack" ,SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 , - jack); + jack, mt8192_jack_pins, +ARRAY_SIZE (mt8192_jack_pins));if (ret) {dev_err (rtd->dev,"Headset Jack creation failed: %d\n" , ret);return ret;
Signature · 1 line
2.37.3
Re: [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
Quoted 11 lines
The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8192-mt6359 driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 2/6 ASoC: mediatek: mt8195: Expose individual headset jack pins
In reply to Nícolas F. R. A. PradoThe rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8195 ASoC driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.
Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
---
sound/soc/mediatek/mt8195/mt8195-mt6359.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8195/mt8195-mt6359.c +15 -2
@@ -63,6 +63,18 @@ struct mt8195_mt6359_priv {struct clk *i2so1_mclk; }; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8195_jack_pins[] = { + { + .pin ="Headphone" , + .mask =SND_JACK_HEADPHONE , + }, + { + .pin ="Headset Mic" , + .mask =SND_JACK_MICROPHONE , + }, +}; +static const struct snd_soc_dapm_widget mt8195_mt6359_widgets[] = {SND_SOC_DAPM_HP ("Headphone" ,NULL ),SND_SOC_DAPM_MIC ("Headset Mic" ,NULL ),
@@ -563,11 +575,12 @@ static int mt8195_rt5682_init(struct snd_soc_pcm_runtime *rtd) priv->i2so1_mclk = afe_priv->clk[MT8195_CLK_TOP_APLL12_DIV2 ]; - ret =snd_soc_card_jack_new (rtd->card,"Headset Jack" , + ret =snd_soc_card_jack_new_pins (rtd->card,"Headset Jack" ,SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 , - jack); + jack, mt8195_jack_pins, +ARRAY_SIZE (mt8195_jack_pins));if (ret) {dev_err (rtd->dev,"Headset Jack creation failed: %d\n" , ret);return ret;
Signature · 1 line
2.37.3
Re: [PATCH 2/6] ASoC: mediatek: mt8195: Expose individual headset jack pins
Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
Quoted 6 lines
The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8195 ASoC driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.
Quoted 6 lines
Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
Nit: for the title... ASoC: mediatek: mt8195-mt6359: ....
Apart from that,
PATCH 3/6 ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
In reply to Nícolas F. R. A. PradoAdd DAPM widgets for headphones and headset microphone, with matching switches, to allow toggling these paths based on the jack connection status.
Note that differently from others (mt8192, mt8195 and mt8186-rt5682), the widget here is named "Headphones" (with an 's'), since "Headphone Switch" was already registered by da7219.
---
sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +8 -0
@@ -950,6 +950,8 @@ static struct snd_soc_dai_link mt8186_mt6366_da7219_max98357_dai_links[] = {static const struct snd_soc_dapm_widget mt8186_mt6366_da7219_max98357_widgets[] = {SND_SOC_DAPM_SPK ("Speakers" ,NULL ), +SND_SOC_DAPM_HP ("Headphones" ,NULL ), +SND_SOC_DAPM_MIC ("Headset Mic" ,NULL ),SND_SOC_DAPM_OUTPUT ("HDMI1" ),SND_SOC_DAPM_MIXER (SOF_DMA_DL1 ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ),SND_SOC_DAPM_MIXER (SOF_DMA_DL2 ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ),
@@ -961,6 +963,10 @@ static const struct snd_soc_dapm_route mt8186_mt6366_da7219_max98357_routes[] = {/* SPK */ { "Speakers", NULL, "Speaker"}, +/* Headset */ + { "Headphones", NULL, "HPL" }, + { "Headphones", NULL, "HPR" }, + { "MIC", NULL, "Headset Mic" },/* HDMI */ { "HDMI1", NULL, "TX"}, /* SOF Uplink */
@@ -976,6 +982,8 @@ mt8186_mt6366_da7219_max98357_routes[] = {static const struct snd_kcontrol_new mt8186_mt6366_da7219_max98357_controls[] = {SOC_DAPM_PIN_SWITCH ("Speakers" ), +SOC_DAPM_PIN_SWITCH ("Headphones" ), +SOC_DAPM_PIN_SWITCH ("Headset Mic" ),SOC_DAPM_PIN_SWITCH ("HDMI1" ), };
Signature · 1 line
2.37.3
Re: [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
Quoted 9 lines
Add DAPM widgets for headphones and headset microphone, with matching switches, to allow toggling these paths based on the jack connection status.
Note that differently from others (mt8192, mt8195 and mt8186-rt5682), the widget here is named "Headphones" (with an 's'), since "Headphone Switch" was already registered by da7219.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 4/6 ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
In reply to Nícolas F. R. A. PradoThe da7219 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8186-da7219 driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.
Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
---
.../mt8186/mt8186-mt6366-da7219-max98357.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +15 -2
@@ -37,6 +37,18 @@ struct mt8186_mt6366_da7219_max98357_priv {struct snd_soc_jack headset_jack, hdmi_jack; }; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8186_jack_pins[] = { + { + .pin ="Headphones" , + .mask =SND_JACK_HEADPHONE , + }, + { + .pin ="Headset Mic" , + .mask =SND_JACK_MICROPHONE , + }, +}; +static struct snd_soc_codec_conf mt8186_mt6366_da7219_max98357_codec_conf[] = { { .dlc =COMP_CODEC_CONF ("mt6358-sound" ),
@@ -72,11 +84,12 @@ static int mt8186_da7219_init(struct snd_soc_pcm_runtime *rtd) }/* Enable Headset and 4 Buttons Jack detection */ - ret =snd_soc_card_jack_new (rtd->card,"Headset Jack" , + ret =snd_soc_card_jack_new_pins (rtd->card,"Headset Jack" ,SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 |SND_JACK_LINEOUT , - jack); + jack, mt8186_jack_pins, +ARRAY_SIZE (mt8186_jack_pins));if (ret) {dev_err (rtd->dev,"Headset Jack creation failed: %d\n" , ret);return ret;
Signature · 1 line
2.37.3
Re: [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
Quoted 11 lines
The da7219 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8186-da7219 driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 5/6 ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
In reply to Nícolas F. R. A. PradoAdd DAPM widgets for headphones and headset microphone, with matching switches, to allow toggling these paths based on the jack connection status.
---
sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +8 -0
@@ -926,6 +926,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = {static const struct snd_soc_dapm_widget mt8186_mt6366_rt1019_rt5682s_widgets[] = {SND_SOC_DAPM_SPK ("Speakers" ,NULL ), +SND_SOC_DAPM_HP ("Headphone" ,NULL ), +SND_SOC_DAPM_MIC ("Headset Mic" ,NULL ),SND_SOC_DAPM_OUTPUT ("HDMI1" ),SND_SOC_DAPM_MIXER (SOF_DMA_DL1 ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ),SND_SOC_DAPM_MIXER (SOF_DMA_DL2 ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ),
@@ -937,6 +939,10 @@ static const struct snd_soc_dapm_route mt8186_mt6366_rt1019_rt5682s_routes[] = {/* SPK */ { "Speakers", NULL, "Speaker" }, +/* Headset */ + { "Headphone", NULL, "HPOL" }, + { "Headphone", NULL, "HPOR" }, + { "IN1P", NULL, "Headset Mic" },/* HDMI */ { "HDMI1", NULL, "TX" }, /* SOF Uplink */
@@ -952,6 +958,8 @@ mt8186_mt6366_rt1019_rt5682s_routes[] = {static const struct snd_kcontrol_new mt8186_mt6366_rt1019_rt5682s_controls[] = {SOC_DAPM_PIN_SWITCH ("Speakers" ), +SOC_DAPM_PIN_SWITCH ("Headphone" ), +SOC_DAPM_PIN_SWITCH ("Headset Mic" ),SOC_DAPM_PIN_SWITCH ("HDMI1" ), };
Signature · 1 line
2.37.3
Re: [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Add DAPM widgets for headphones and headset microphone, with matching switches, to allow toggling these paths based on the jack connection status.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 6/6 ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
In reply to Nícolas F. R. A. PradoThe rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8186-rt5682 driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.
Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
---
.../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +15 -2
@@ -41,6 +41,18 @@ struct mt8186_mt6366_rt1019_rt5682s_priv {struct snd_soc_jack headset_jack, hdmi_jack; }; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8186_jack_pins[] = { + { + .pin ="Headphone" , + .mask =SND_JACK_HEADPHONE , + }, + { + .pin ="Headset Mic" , + .mask =SND_JACK_MICROPHONE , + }, +}; +static struct snd_soc_codec_conf mt8186_mt6366_rt1019_rt5682s_codec_conf[] = { { .dlc =COMP_CODEC_CONF ("mt6358-sound" ),
@@ -75,11 +87,12 @@ static int mt8186_rt5682s_init(struct snd_soc_pcm_runtime *rtd)return ret; } - ret =snd_soc_card_jack_new (rtd->card,"Headset Jack" , + ret =snd_soc_card_jack_new_pins (rtd->card,"Headset Jack" ,SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 , - jack); + jack, mt8186_jack_pins, +ARRAY_SIZE (mt8186_jack_pins));if (ret) {dev_err (rtd->dev,"Headset Jack creation failed: %d\n" , ret);return ret;
Signature · 1 line
2.37.3
Re: [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
Quoted 11 lines
The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8186-rt5682 driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events.Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
Mark Brown
maintainerQuoted 8 lines · Nícolas F. R. A. Prado
This series allows the headphone and headset mic jack status to be handled separately by userspace on MT8192, MT8195 and MT8186.
Changes based on commit
d0508b4f1604("ASoC:rk3399_gru_sound: Add DAPM pins, kcontrols for jack detection"). Found while searching for an alternative for JackSwitch [1].[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
commit: 194ff8db03782d1dae41b7b42ea65da5748884c2
[2/6] ASoC: mediatek: mt8195: Expose individual headset jack pins
commit: aa51e3c127a43cf4862db5f0081da281f1aa6429
[3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
commit: 13bee4a16ac5c5f0e3a5db868df991be57e74aa5
[4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
commit: 8e986748680629a82398c65da0c5bda4c6a01b3d
[5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
commit: d888e7afa03f06d8091ecdd43f87d5396dfbf907
[6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
commit: 42de42c22453064ffc9b72c259b2ab901dd766dcAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark