[Sound-open-firmware] jack detection via input/event on linux

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Fri Jun 3 17:48:19 CEST 2022


[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" },


More information about the Sound-open-firmware mailing list