All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaroslav Kysela <perex@perex.cz>
To: ALSA development <alsa-devel@alsa-project.org>
Cc: Takashi Iwai <tiwai@suse.de>, Mark Brown <broonie@kernel.org>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [alsa-devel] [PATCH 2/2] ASoC: Intel - use control components to describe card config
Date: Tue, 19 Nov 2019 18:49:33 +0100	[thread overview]
Message-ID: <20191119174933.25526-2-perex@perex.cz> (raw)
In-Reply-To: <20191119174933.25526-1-perex@perex.cz>

Use the control interface (field 'components' in the info structure)
to pass the I/O configuration details. The long card name might
be used in GUI. This information should be hidden.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/Kconfig                |  9 +++++++++
 sound/soc/intel/boards/bytcht_es8316.c | 16 ++++++++++++----
 sound/soc/intel/boards/bytcr_rt5640.c  | 14 +++++++++++---
 sound/soc/intel/boards/bytcr_rt5651.c  | 26 ++++++++++++++++----------
 4 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index c8de0bb5bed9..3421957adedb 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -47,6 +47,15 @@ config SND_SOC_INTEL_SST_FIRMWARE
 	# Haswell/Broadwell/Baytrail legacy and will be set
 	# when these platforms are enabled
 
+config SND_SOC_INTEL_USE_CTL_COMPONENTS
+	bool "Use CTL components for I/O configuration"
+	help
+	  Some drivers might pass the I/O configuration through the
+	  soundcard's driver name in the control user space API.
+	  The new scheme is to put this information to the components
+	  field in the ALSA's card info structure. Say Y, if you
+	  have ALSA user space version 1.2.2+.
+
 config SND_SOC_INTEL_HASWELL
 	tristate "Haswell/Broadwell Platforms"
 	depends on SND_DMA_SGBUF
diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index 46612331f5ea..a4d098ef0f57 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -360,7 +360,7 @@ static struct snd_soc_dai_link byt_cht_es8316_dais[] = {
 
 /* SoC card */
 static char codec_name[SND_ACPI_I2C_ID_LEN];
-static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */
+static char config_string[50]; /* = long name or components */
 
 static int byt_cht_es8316_suspend(struct snd_soc_card *card)
 {
@@ -572,11 +572,19 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 		}
 	}
 
-	/* register the soc card */
-	snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic",
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_USE_CTL_COMPONENTS)
+	snprintf(config_string, sizeof(config_string), "cfg-spk:%s cfg-mic:%s",
+		 (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "1" : "2",
+		 mic_name[BYT_CHT_ES8316_MAP(quirk)]);
+	byt_cht_es8316_card.components = config_string;
+#else
+	snprintf(config_string, sizeof(config_string), "bytcht-es8316-%s-spk-%s-mic",
 		 (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo",
 		 mic_name[BYT_CHT_ES8316_MAP(quirk)]);
-	byt_cht_es8316_card.long_name = long_name;
+	byt_cht_es8316_card.long_name = config_string;
+#endif
+
+	/* register the soc card */
 	snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
 
 	ret = devm_snd_soc_register_card(dev, &byt_cht_es8316_card);
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 9c1aa4ec9cba..22be0c294e4c 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -1080,7 +1080,7 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = {
 static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN];
 static char byt_rt5640_codec_aif_name[12]; /*  = "rt5640-aif[1|2]" */
 static char byt_rt5640_cpu_dai_name[10]; /*  = "ssp[0|2]-port" */
-static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
+static char byt_rt5640_config[40]; /* = long name or components */
 
 static int byt_rt5640_suspend(struct snd_soc_card *card)
 {
@@ -1303,12 +1303,20 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
 		}
 	}
 
-	snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_USE_CTL_COMPONENTS)
+	snprintf(byt_rt5640_config, sizeof(byt_rt5640_config),
+		 "cfg-spk:%s cfg-mic:%s",
+		 (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "1" : "2",
+		 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
+	byt_rt5640_card.components = byt_rt5640_config;
+#else
+	snprintf(byt_rt5640_config, sizeof(byt_rt5640_config),
 		 "bytcr-rt5640-%s-spk-%s-mic",
 		 (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ?
 			"mono" : "stereo",
 		 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
-	byt_rt5640_card.long_name = byt_rt5640_long_name;
+	byt_rt5640_card.long_name = byt_rt5640_config;
+#endif
 
 	/* override plaform name, if required */
 	platform_name = mach->mach_params.platform;
diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
index 4606f6f582d6..485f91b059fb 100644
--- a/sound/soc/intel/boards/bytcr_rt5651.c
+++ b/sound/soc/intel/boards/bytcr_rt5651.c
@@ -797,7 +797,7 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = {
 static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN];
 static char byt_rt5651_codec_aif_name[12]; /*  = "rt5651-aif[1|2]" */
 static char byt_rt5651_cpu_dai_name[10]; /*  = "ssp[0|2]-port" */
-static char byt_rt5651_long_name[50]; /* = "bytcr-rt5651-*-spk-*-mic[-swapped-hp]" */
+static char byt_rt5651_config[50]; /* = long name or components */
 
 static int byt_rt5651_suspend(struct snd_soc_card *card)
 {
@@ -876,7 +876,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
 	const char *platform_name;
 	struct acpi_device *adev;
 	struct device *codec_dev;
-	const char *hp_swapped;
 	bool is_bytcr = false;
 	int ret_val = 0;
 	int dai_index = 0;
@@ -1080,17 +1079,24 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED)
-		hp_swapped = "-hp-swapped";
-	else
-		hp_swapped = "";
-
-	snprintf(byt_rt5651_long_name, sizeof(byt_rt5651_long_name),
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_USE_CTL_COMPONENTS)
+	snprintf(byt_rt5651_config, sizeof(byt_rt5651_config),
+		 "cfg-spk:%s cfg-mic:%s%s",
+		 (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ? "1" : "2",
+		 mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)],
+		 (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
+			" cfg-hp:lrswap" : "");
+	byt_rt5651_card.components = byt_rt5651_config;
+#else
+	snprintf(byt_rt5651_config, sizeof(byt_rt5651_config),
 		 "bytcr-rt5651-%s-spk-%s-mic%s",
 		 (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ?
 			"mono" : "stereo",
-		 mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)], hp_swapped);
-	byt_rt5651_card.long_name = byt_rt5651_long_name;
+		 mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)],
+		 (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
+			"-hp-swapped" : "");
+	byt_rt5651_card.long_name = byt_rt5651_config;
+#endif
 
 	/* override plaform name, if required */
 	platform_name = mach->mach_params.platform;
-- 
2.20.1
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2019-11-19 17:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 17:49 [alsa-devel] [PATCH 1/2] ASoC: add control components management Jaroslav Kysela
2019-11-19 17:49 ` Jaroslav Kysela [this message]
2019-11-19 19:12   ` [alsa-devel] [PATCH 2/2] ASoC: Intel - use control components to describe card config Pierre-Louis Bossart
2019-11-19 19:22     ` Jaroslav Kysela
2019-11-19 19:39       ` Pierre-Louis Bossart
2019-11-19 20:27         ` Jaroslav Kysela
2019-11-20  0:24           ` Pierre-Louis Bossart
2019-11-19 20:37       ` Takashi Iwai
2019-11-19 20:41         ` Mark Brown
2019-11-19 20:47           ` Jaroslav Kysela
2019-11-20 17:18 ` [alsa-devel] Applied "ASoC: add control components management" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191119174933.25526-2-perex@perex.cz \
    --to=perex@perex.cz \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.