Re: [Sound-open-firmware] jack detection via input/event on linux
[Adding alsa-devel, Mark and Takashi to this thread]
On 6/3/22 08:33, Jaroslav Kysela wrote:
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 5d67a2c87a1d4..1db17ebd26f63 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -85,6 +85,17 @@ struct sof_card_private { bool idisp_codec; };
+static struct snd_soc_jack_pin sof_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static int sof_rt5682_quirk_cb(const struct dmi_system_id *id) { sof_rt5682_quirk = (unsigned long)id->driver_data; @@ -295,11 +306,13 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) * Headset buttons map to the google Reference headset. * These can be configured by userspace. */ - ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", - SND_JACK_HEADSET | SND_JACK_BTN_0 | - SND_JACK_BTN_1 | SND_JACK_BTN_2 | - SND_JACK_BTN_3, - &ctx->sof_headset); + 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, + &ctx->sof_headset, + sof_jack_pins, + ARRAY_SIZE(sof_jack_pins)); if (ret) { dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); return ret; @@ -481,7 +494,7 @@ static int sof_card_late_probe(struct snd_soc_card *card) }
static const struct snd_kcontrol_new sof_controls[] = { - SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Left Spk"), SOC_DAPM_PIN_SWITCH("Right Spk"), @@ -489,7 +502,7 @@ static const struct snd_kcontrol_new sof_controls[] = { };
static const struct snd_soc_dapm_widget sof_widgets[] = { - SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_SPK("Left Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL), @@ -501,8 +514,8 @@ static const struct snd_soc_dapm_widget dmic_widgets[] = {
static const struct snd_soc_dapm_route sof_map[] = { /* HP jack connectors - unknown if we have jack detection */ - { "Headphone Jack", NULL, "HPOL" }, - { "Headphone Jack", NULL, "HPOR" }, + { "Headphone", NULL, "HPOL" }, + { "Headphone", NULL, "HPOR" },
/* other jacks */ { "IN1P", NULL, "Headset Mic" },
On 03. 06. 22 17:48, Pierre-Louis Bossart wrote:
[Adding alsa-devel, Mark and Takashi to this thread]
On 6/3/22 08:33, Jaroslav Kysela wrote:
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
Yes, it looks like a way to go. It seems that the drivers were tested only with the CRAS audio server. Note that pulseaudio can be run with the user permissions only - thus the input devices may not be reachable.
Thanks, Jaroslav
Jaroslav, would it help if we made our UCMs closer to upstream so we could just send them directly so pulse could test them easier? (this is a goal I have, it just unfortunately really low priority)
Curtis Malainey | Chrome OS Audio Senior Software Engineer | cujomalainey@google.com | We're Hiring!
Curtis Malainey | Chrome OS Audio Senior Software Engineer | cujomalainey@google.com | We're Hiring!
On Fri, Jun 3, 2022 at 8:58 AM Jaroslav Kysela perex@perex.cz wrote:
On 03. 06. 22 17:48, Pierre-Louis Bossart wrote:
[Adding alsa-devel, Mark and Takashi to this thread]
On 6/3/22 08:33, Jaroslav Kysela wrote:
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
Yes, it looks like a way to go. It seems that the drivers were tested only with the CRAS audio server. Note that pulseaudio can be run with the user permissions only - thus the input devices may not be reachable.
Thanks, Jaroslav
-- Jaroslav Kysela perex@perex.cz Linux Sound Maintainer; ALSA Project; Red Hat, Inc. _______________________________________________ Sound-open-firmware mailing list Sound-open-firmware@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/sound-open-firmware
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
Yes, it looks like a way to go. It seems that the drivers were tested only with the CRAS audio server. Note that pulseaudio can be run with the user permissions only - thus the input devices may not be reachable.
I added a similar patch on a GeminiLake device, and it does help with jack detection (along with an update in https://github.com/alsa-project/alsa-ucm-conf/pull/150).
I can see PulseAudio detecting the changes, but for some reason the automatic switch only happens when the jack is unplugged. I still have to manually select the headphone/headset after plugging it in. Likely still missing something in the UCM file?
D: [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [Out] Headphone to status no
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [Out] Headphone, found [Out] Speaker
D: [pulseaudio] module-alsa-card.c: Jack 'Headset Mic Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [In] Headset to status no
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [In] Headset, found [In] InternalMic
<<< AUTOMATIC SWITCH DONE
D: [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now plugged in
D: [pulseaudio] device-port.c: Setting port [Out] Headphone to status yes
D: [pulseaudio] module-alsa-card.c: Jack 'Headset Mic Jack' is now plugged in
D: [pulseaudio] device-port.c: Setting port [In] Headset to status yes
<<< NOTHING HAPPENS HERE
D: [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [Out] Headphone to status no
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [Out] Headphone, found [Out] Speaker
D: [pulseaudio] module-alsa-card.c: Jack 'Headset Mic Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [In] Headset to status no
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [In] Headset, found [In] InternalMic
participants (3)
-
Curtis Malainey
-
Jaroslav Kysela
-
Pierre-Louis Bossart