alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: Use DMI name in sound card long name
@ 2016-12-21 13:02 mengdong.lin
  2016-12-21 13:04 ` [PATCH 1/2] ASoC: core: Add API to use " mengdong.lin
  2016-12-21 13:04 ` [PATCH 2/2] ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver mengdong.lin
  0 siblings, 2 replies; 9+ messages in thread
From: mengdong.lin @ 2016-12-21 13:02 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, tiwai, mengdong.lin, liam.r.girdwood, vinod.koul,
	pierre-louis.bossart

From: Mengdong Lin <mengdong.lin@linux.intel.com>

This series is based on Liam's idea to use DMI name as the sound card
short name in the audio workshop. Now we add DMI info to the card long
name:
- Not change the card name (short name), keep it simple. So the card ID
  won't change as well.
- Use short name and DMI name together to make a readable and unqique
  long name.

Machine drivers can use a new API to get this feature.

In user space, when the sound server ask UCM to open a sound card, UCM
will try to find the best configuration file based on the card long name,
and only if not avaiable, fallback to the default configuration file that
matches the card name (short name). Please see patch:
ucm: Automatically load the best config file based on the card long name

History:
  v1 from RFC: Give up using a table to map DMI info to a simple string,
        since we cannot maintain such a table for each machine. Just do
        verbatim copy of DMI info and let user space decide how to use the
        DMI info in card long name to find the best UCM config file.

        If device driver adds a flavor string, just append it after the
        DMI info fields to the card long name.

Liam Girdwood (1):
  ASoC: core: Add API to use DMI name in sound card long name

Mengdong Lin (1):
  ASoC: Intel: Use DMI name for sound card long name in Broadwell
    machine driver

 include/sound/soc.h                |  4 ++
 sound/soc/intel/boards/broadwell.c |  2 +
 sound/soc/soc-core.c               | 81 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 13:02 [PATCH 0/2] ASoC: Use DMI name in sound card long name mengdong.lin
@ 2016-12-21 13:04 ` mengdong.lin
  2016-12-21 14:27   ` Liam Girdwood
  2016-12-21 14:37   ` Pierre-Louis Bossart
  2016-12-21 13:04 ` [PATCH 2/2] ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver mengdong.lin
  1 sibling, 2 replies; 9+ messages in thread
From: mengdong.lin @ 2016-12-21 13:04 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, tiwai, mengdong.lin, liam.r.girdwood, vinod.koul,
	pierre-louis.bossart

From: Liam Girdwood <liam.r.girdwood@linux.intel.com>

Intel DSP platform drivers are used by many different devices but are
difficult for userspace to differentiate. This patch adds an API to allow
the DMI name to be used in the sound card long name, thereby helping
userspace load the correct UCM configuration. Usually machine drivers
uses their own name as the sound card name (short name), and leave the
long name and driver name blank. This API will append the DMI info
like vendor, product and board info, to the card name to make up the card
long name. If the machine driver has already explicitly set the long name,
this API will do nothing.

This patch also allows for further differentiation as many devices that
share the same DMI name i.e. Minnowboards, UP boards may be configured
with different codecs or firmwares. The API supports flavoring the DMI
name into the card longname to provide the extra differentiation required
for these devices.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 795e6c4..e4f1844 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -497,6 +497,8 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	unsigned int dai_fmt);
 
+int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
+
 /* Utility functions to get clock rates from various things */
 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
@@ -1094,6 +1096,8 @@ struct snd_soc_card {
 	const char *name;
 	const char *long_name;
 	const char *driver_name;
+	char dmi_longname[80];
+
 	struct device *dev;
 	struct snd_card *snd_card;
 	struct module *owner;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index aaab26a..8bcf241 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -34,6 +34,7 @@
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/dmi.h>
 #include <sound/core.h>
 #include <sound/jack.h>
 #include <sound/pcm.h>
@@ -1886,6 +1887,86 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 }
 EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
 
+/**
+ * snd_soc_set_dmi_name() - Register DMI names to card
+ * @card: The card to register DMI names
+ * @flavour: The flavour "differentiator" for the card amongst its peers.
+ *
+ * Intel DSP platform drivers are used by many different devices but are
+ * difficult for userspace to differentiate, since machine drivers ususally
+ * use their own name as the card name (short name) and leave the card long
+ * name blank. This function will allow DMI info to be used in the sound
+ * card long name, thereby helping userspace load the correct UCM (Use Case
+ * Manager) configuration.
+ * Possible card long names may be:
+ * broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH
+ * broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach SDS
+ * bytcr-rt5640-ASUSTeK COMPUTER INC.-T100TA-T100TA
+ * bytcr-rt5651-Circuitco-Minnowboard Max D0 PLATFORM-MinnowBoard MAX
+ *
+ * This function also supports flavoring the card longname to provide
+ * the extra differentiation.
+ *
+ * Returns 0 on success, otherwise a negative error code.
+ */
+int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
+{
+	const char *vendor, *product, *board;
+
+	if (card->long_name)
+		return 0; /* long name already set by driver or from DMI */
+
+	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+	if (!vendor) {
+		dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
+		return 0;
+	}
+
+	product = dmi_get_system_info(DMI_PRODUCT_NAME);
+	board = dmi_get_system_info(DMI_BOARD_NAME);
+	if (!board && !product) {
+		/* fall back to using legacy name */
+		dev_warn(card->dev, "ASoC: no DMI board/product name!\n");
+		return 0;
+	}
+
+	/* make up dmi long name as:
+	 * card name (usually machine driver name) -vendor -product -board
+	 */
+	snprintf(card->dmi_longname, sizeof(card->snd_card->longname),
+			"%s-%s", card->name, vendor);
+
+	if (product) {
+		strncat(card->dmi_longname, "-",
+			sizeof(card->snd_card->longname));
+		strncat(card->dmi_longname, product,
+			sizeof(card->snd_card->longname));
+	}
+
+	if (board) {
+		strncat(card->dmi_longname, "-",
+			sizeof(card->snd_card->longname));
+		strncat(card->dmi_longname, board,
+			sizeof(card->snd_card->longname));
+	}
+
+
+	/* Add flavour to dmi long name */
+	if (flavour) {
+		strncat(card->dmi_longname, "-",
+			sizeof(card->snd_card->longname));
+		strncat(card->dmi_longname, flavour,
+			sizeof(card->snd_card->longname));
+	}
+
+	/* set long name */
+	card->long_name = card->dmi_longname;
+
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_set_dmi_name);
+
 static int snd_soc_instantiate_card(struct snd_soc_card *card)
 {
 	struct snd_soc_codec *codec;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver
  2016-12-21 13:02 [PATCH 0/2] ASoC: Use DMI name in sound card long name mengdong.lin
  2016-12-21 13:04 ` [PATCH 1/2] ASoC: core: Add API to use " mengdong.lin
@ 2016-12-21 13:04 ` mengdong.lin
  1 sibling, 0 replies; 9+ messages in thread
From: mengdong.lin @ 2016-12-21 13:04 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, tiwai, mengdong.lin, liam.r.girdwood, vinod.koul,
	pierre-louis.bossart

From: Mengdong Lin <mengdong.lin@linux.intel.com>

Intel Broadwell machine driver will call API snd_soc_set_dmi_name() to
use DMI info to make the sound card long name.

Here are the changed long name for two Broadwell-based machines:
Dell XPS-13(2015): broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH

Intel WilsonBeach:
broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach SDS

They still share the same card name "broadwell-rt286".

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c
index 5bb64d1..cda73bb 100644
--- a/sound/soc/intel/boards/broadwell.c
+++ b/sound/soc/intel/boards/broadwell.c
@@ -266,6 +266,8 @@ static int broadwell_audio_probe(struct platform_device *pdev)
 {
 	broadwell_rt286.dev = &pdev->dev;
 
+	snd_soc_set_dmi_name(&broadwell_rt286, NULL);
+
 	return devm_snd_soc_register_card(&pdev->dev, &broadwell_rt286);
 }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 13:04 ` [PATCH 1/2] ASoC: core: Add API to use " mengdong.lin
@ 2016-12-21 14:27   ` Liam Girdwood
  2016-12-21 15:46     ` Lin, Mengdong
  2016-12-21 14:37   ` Pierre-Louis Bossart
  1 sibling, 1 reply; 9+ messages in thread
From: Liam Girdwood @ 2016-12-21 14:27 UTC (permalink / raw)
  To: mengdong.lin
  Cc: alsa-devel, tiwai, mengdong.lin, vinod.koul, broonie,
	pierre-louis.bossart

On Wed, 2016-12-21 at 21:04 +0800, mengdong.lin@linux.intel.com wrote:
> From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> 
> Intel DSP platform drivers are used by many different devices but are
> difficult for userspace to differentiate. This patch adds an API to allow
> the DMI name to be used in the sound card long name, thereby helping
> userspace load the correct UCM configuration. Usually machine drivers
> uses their own name as the sound card name (short name), and leave the
> long name and driver name blank. This API will append the DMI info
> like vendor, product and board info, to the card name to make up the card
> long name. If the machine driver has already explicitly set the long name,
> this API will do nothing.
> 
> This patch also allows for further differentiation as many devices that
> share the same DMI name i.e. Minnowboards, UP boards may be configured
> with different codecs or firmwares. The API supports flavoring the DMI
> name into the card longname to provide the extra differentiation required
> for these devices.
> 
> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 795e6c4..e4f1844 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -497,6 +497,8 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
>  int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
>  	unsigned int dai_fmt);
>  
> +int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
> +
>  /* Utility functions to get clock rates from various things */
>  int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
>  int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
> @@ -1094,6 +1096,8 @@ struct snd_soc_card {
>  	const char *name;
>  	const char *long_name;
>  	const char *driver_name;
> +	char dmi_longname[80];
> +
>  	struct device *dev;
>  	struct snd_card *snd_card;
>  	struct module *owner;
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index aaab26a..8bcf241 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -34,6 +34,7 @@
>  #include <linux/ctype.h>
>  #include <linux/slab.h>
>  #include <linux/of.h>
> +#include <linux/dmi.h>
>  #include <sound/core.h>
>  #include <sound/jack.h>
>  #include <sound/pcm.h>
> @@ -1886,6 +1887,86 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
>  
> +/**
> + * snd_soc_set_dmi_name() - Register DMI names to card
> + * @card: The card to register DMI names
> + * @flavour: The flavour "differentiator" for the card amongst its peers.
> + *
> + * Intel DSP platform drivers are used by many different devices but are
> + * difficult for userspace to differentiate, since machine drivers ususally
> + * use their own name as the card name (short name) and leave the card long
> + * name blank. This function will allow DMI info to be used in the sound
> + * card long name, thereby helping userspace load the correct UCM (Use Case
> + * Manager) configuration.
> + * Possible card long names may be:
> + * broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH
> + * broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach SDS
> + * bytcr-rt5640-ASUSTeK COMPUTER INC.-T100TA-T100TA
> + * bytcr-rt5651-Circuitco-Minnowboard Max D0 PLATFORM-MinnowBoard MAX
> + *


Lets keep it simpler, we dont need to prepend the driver name to the
longname as it's already available in driver_name. 

The purpose of the patch is to uniquely identify the machine, so we dont
need to provide or duplicate other information in the name.

So longname should be "dmi-flavour" where dmi is product OR board (if
product is not available).

Liam

> + * This function also supports flavoring the card longname to provide
> + * the extra differentiation.
> + *
> + * Returns 0 on success, otherwise a negative error code.
> + */
> +int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
> +{
> +	const char *vendor, *product, *board;
> +
> +	if (card->long_name)
> +		return 0; /* long name already set by driver or from DMI */
> +
> +	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
> +	if (!vendor) {
> +		dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
> +		return 0;
> +	}
> +
> +	product = dmi_get_system_info(DMI_PRODUCT_NAME);
> +	board = dmi_get_system_info(DMI_BOARD_NAME);
> +	if (!board && !product) {
> +		/* fall back to using legacy name */
> +		dev_warn(card->dev, "ASoC: no DMI board/product name!\n");
> +		return 0;
> +	}
> +
> +	/* make up dmi long name as:
> +	 * card name (usually machine driver name) -vendor -product -board
> +	 */
> +	snprintf(card->dmi_longname, sizeof(card->snd_card->longname),
> +			"%s-%s", card->name, vendor);
> +
> +	if (product) {
> +		strncat(card->dmi_longname, "-",
> +			sizeof(card->snd_card->longname));
> +		strncat(card->dmi_longname, product,
> +			sizeof(card->snd_card->longname));
> +	}
> +
> +	if (board) {
> +		strncat(card->dmi_longname, "-",
> +			sizeof(card->snd_card->longname));
> +		strncat(card->dmi_longname, board,
> +			sizeof(card->snd_card->longname));
> +	}
> +
> +
> +	/* Add flavour to dmi long name */
> +	if (flavour) {
> +		strncat(card->dmi_longname, "-",
> +			sizeof(card->snd_card->longname));
> +		strncat(card->dmi_longname, flavour,
> +			sizeof(card->snd_card->longname));
> +	}
> +
> +	/* set long name */
> +	card->long_name = card->dmi_longname;
> +
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_set_dmi_name);
> +
>  static int snd_soc_instantiate_card(struct snd_soc_card *card)
>  {
>  	struct snd_soc_codec *codec;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 13:04 ` [PATCH 1/2] ASoC: core: Add API to use " mengdong.lin
  2016-12-21 14:27   ` Liam Girdwood
@ 2016-12-21 14:37   ` Pierre-Louis Bossart
  2016-12-21 15:01     ` Liam Girdwood
  2016-12-21 16:01     ` Lin, Mengdong
  1 sibling, 2 replies; 9+ messages in thread
From: Pierre-Louis Bossart @ 2016-12-21 14:37 UTC (permalink / raw)
  To: mengdong.lin, alsa-devel, broonie
  Cc: tiwai, mengdong.lin, vinod.koul, liam.r.girdwood,
	pierre-louis.bossart


>  /* Utility functions to get clock rates from various things */
>  int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
>  int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
> @@ -1094,6 +1096,8 @@ struct snd_soc_card {
>  	const char *name;
>  	const char *long_name;
>  	const char *driver_name;
> +	char dmi_longname[80];

why 80? is this linked to DMI restrictions on board/product names?

>
> +/**
> + * snd_soc_set_dmi_name() - Register DMI names to card
> + * @card: The card to register DMI names
> + * @flavour: The flavour "differentiator" for the card amongst its peers.
> + *
> + * Intel DSP platform drivers are used by many different devices but are
> + * difficult for userspace to differentiate, since machine drivers ususally
> + * use their own name as the card name (short name) and leave the card long
> + * name blank. This function will allow DMI info to be used in the sound
> + * card long name, thereby helping userspace load the correct UCM (Use Case
> + * Manager) configuration.
> + * Possible card long names may be:
> + * broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH
> + * broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach SDS
> + * bytcr-rt5640-ASUSTeK COMPUTER INC.-T100TA-T100TA
> + * bytcr-rt5651-Circuitco-Minnowboard Max D0 PLATFORM-MinnowBoard MAX

You may want to add a comment that the '.' is not a separator but part 
of the DMI name. I was trying to figure out why there were cases with .-

> + *
> + * This function also supports flavoring the card longname to provide
> + * the extra differentiation.
> + *
> + * Returns 0 on success, otherwise a negative error code.
> + */
> +int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
> +{
> +	const char *vendor, *product, *board;
> +
> +	if (card->long_name)
> +		return 0; /* long name already set by driver or from DMI */
> +
> +	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
> +	if (!vendor) {
> +		dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
> +		return 0;
> +	}
> +
> +	product = dmi_get_system_info(DMI_PRODUCT_NAME);
> +	board = dmi_get_system_info(DMI_BOARD_NAME);
> +	if (!board && !product) {
> +		/* fall back to using legacy name */
> +		dev_warn(card->dev, "ASoC: no DMI board/product name!\n");
> +		return 0;
> +	}
> +
> +	/* make up dmi long name as:
> +	 * card name (usually machine driver name) -vendor -product -board
> +	 */
> +	snprintf(card->dmi_longname, sizeof(card->snd_card->longname),
> +			"%s-%s", card->name, vendor);
> +
> +	if (product) {
> +		strncat(card->dmi_longname, "-",
> +			sizeof(card->snd_card->longname));
> +		strncat(card->dmi_longname, product,
> +			sizeof(card->snd_card->longname));
> +	}
> +
> +	if (board) {
> +		strncat(card->dmi_longname, "-",
> +			sizeof(card->snd_card->longname));
> +		strncat(card->dmi_longname, board,
> +			sizeof(card->snd_card->longname));
> +	}
> +
> +
> +	/* Add flavour to dmi long name */
> +	if (flavour) {
> +		strncat(card->dmi_longname, "-",
> +			sizeof(card->snd_card->longname));
> +		strncat(card->dmi_longname, flavour,
> +			sizeof(card->snd_card->longname));
> +	}

how is the 'flavour' defined? This doesn't seem to come from the DMI 
decode information? Is this for example intended to be used with quirks?


> +
> +	/* set long name */
> +	card->long_name = card->dmi_longname;
> +
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_set_dmi_name);
> +
>  static int snd_soc_instantiate_card(struct snd_soc_card *card)
>  {
>  	struct snd_soc_codec *codec;
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 14:37   ` Pierre-Louis Bossart
@ 2016-12-21 15:01     ` Liam Girdwood
  2016-12-21 16:01     ` Lin, Mengdong
  1 sibling, 0 replies; 9+ messages in thread
From: Liam Girdwood @ 2016-12-21 15:01 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, mengdong.lin, tiwai, mengdong.lin, vinod.koul,
	broonie, pierre-louis.bossart

On Wed, 2016-12-21 at 08:37 -0600, Pierre-Louis Bossart wrote:
> > +
> > +     /* Add flavour to dmi long name */
> > +     if (flavour) {
> > +             strncat(card->dmi_longname, "-",
> > +                     sizeof(card->snd_card->longname));
> > +             strncat(card->dmi_longname, flavour,
> > +                     sizeof(card->snd_card->longname));
> > +     }
> 
> how is the 'flavour' defined? This doesn't seem to come from the DMI 
> decode information? Is this for example intended to be used with
> quirks?


Yes, it's intended for identifying quirks, different firmwares, etc

Liam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 14:27   ` Liam Girdwood
@ 2016-12-21 15:46     ` Lin, Mengdong
  2016-12-22  3:07       ` Mengdong Lin
  0 siblings, 1 reply; 9+ messages in thread
From: Lin, Mengdong @ 2016-12-21 15:46 UTC (permalink / raw)
  To: Liam Girdwood, mengdong.lin@linux.intel.com
  Cc: tiwai@suse.de, Koul, Vinod, alsa-devel@alsa-project.org,
	broonie@kernel.org, Bossart, Pierre-louis

> -----Original Message-----
> From: Liam Girdwood [mailto:liam.r.girdwood@linux.intel.com]
> Sent: Wednesday, December 21, 2016 10:27 PM
> To: mengdong.lin@linux.intel.com
> Cc: alsa-devel@alsa-project.org; broonie@kernel.org; tiwai@suse.de; Bossart,
> Pierre-louis <pierre-louis.bossart@intel.com>; Koul, Vinod
> <vinod.koul@intel.com>; Lin, Mengdong <mengdong.lin@intel.com>
> Subject: Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card
> long name
> 
> On Wed, 2016-12-21 at 21:04 +0800, mengdong.lin@linux.intel.com wrote:
> > From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> >
> > Intel DSP platform drivers are used by many different devices but are
> > difficult for userspace to differentiate. This patch adds an API to
> > allow the DMI name to be used in the sound card long name, thereby
> > helping userspace load the correct UCM configuration. Usually machine
> > drivers uses their own name as the sound card name (short name), and
> > leave the long name and driver name blank. This API will append the
> > DMI info like vendor, product and board info, to the card name to make
> > up the card long name. If the machine driver has already explicitly
> > set the long name, this API will do nothing.
> >
> > This patch also allows for further differentiation as many devices
> > that share the same DMI name i.e. Minnowboards, UP boards may be
> > configured with different codecs or firmwares. The API supports
> > flavoring the DMI name into the card longname to provide the extra
> > differentiation required for these devices.
> >
> > Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> > Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
> >
> > diff --git a/include/sound/soc.h b/include/sound/soc.h index
> > 795e6c4..e4f1844 100644
> > --- a/include/sound/soc.h
> > +++ b/include/sound/soc.h
> > @@ -497,6 +497,8 @@ void snd_soc_runtime_deactivate(struct
> > snd_soc_pcm_runtime *rtd, int stream);  int
> snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
> >  	unsigned int dai_fmt);
> >
> > +int snd_soc_set_dmi_name(struct snd_soc_card *card, const char
> > +*flavour);
> > +
> >  /* Utility functions to get clock rates from various things */  int
> > snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
> > int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
> @@
> > -1094,6 +1096,8 @@ struct snd_soc_card {
> >  	const char *name;
> >  	const char *long_name;
> >  	const char *driver_name;
> > +	char dmi_longname[80];
> > +
> >  	struct device *dev;
> >  	struct snd_card *snd_card;
> >  	struct module *owner;
> > diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index
> > aaab26a..8bcf241 100644
> > --- a/sound/soc/soc-core.c
> > +++ b/sound/soc/soc-core.c
> > @@ -34,6 +34,7 @@
> >  #include <linux/ctype.h>
> >  #include <linux/slab.h>
> >  #include <linux/of.h>
> > +#include <linux/dmi.h>
> >  #include <sound/core.h>
> >  #include <sound/jack.h>
> >  #include <sound/pcm.h>
> > @@ -1886,6 +1887,86 @@ int snd_soc_runtime_set_dai_fmt(struct
> > snd_soc_pcm_runtime *rtd,  }
> > EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
> >
> > +/**
> > + * snd_soc_set_dmi_name() - Register DMI names to card
> > + * @card: The card to register DMI names
> > + * @flavour: The flavour "differentiator" for the card amongst its peers.
> > + *
> > + * Intel DSP platform drivers are used by many different devices but
> > +are
> > + * difficult for userspace to differentiate, since machine drivers
> > +ususally
> > + * use their own name as the card name (short name) and leave the
> > +card long
> > + * name blank. This function will allow DMI info to be used in the
> > +sound
> > + * card long name, thereby helping userspace load the correct UCM
> > +(Use Case
> > + * Manager) configuration.
> > + * Possible card long names may be:
> > + * broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH
> > + * broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach
> > +SDS
> > + * bytcr-rt5640-ASUSTeK COMPUTER INC.-T100TA-T100TA
> > + * bytcr-rt5651-Circuitco-Minnowboard Max D0 PLATFORM-MinnowBoard
> MAX
> > + *
> 
> 
> Lets keep it simpler, we dont need to prepend the driver name to the
> longname as it's already available in driver_name.
> 
> The purpose of the patch is to uniquely identify the machine, so we dont
> need to provide or duplicate other information in the name.
> 
> So longname should be "dmi-flavour" where dmi is product OR board (if
> product is not available).
> 
> Liam

Hi Liam,

Yes, there is some duplication. But may we keep this?

It's because that if the card long name itself has all the information, the user space UCM code can just compare the configuration file names against the card long name, no need to involve the card name (driver name).
In addition, I want to make the naming same as HD-Audio, their card long name is the card short name with some suffixes. Although HD-Audio does not use UCM now, but maybe in the future? So we can process ASoC and HD-Audio cards in the same way.

Thanks
Mengdong

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 14:37   ` Pierre-Louis Bossart
  2016-12-21 15:01     ` Liam Girdwood
@ 2016-12-21 16:01     ` Lin, Mengdong
  1 sibling, 0 replies; 9+ messages in thread
From: Lin, Mengdong @ 2016-12-21 16:01 UTC (permalink / raw)
  To: Pierre-Louis Bossart, mengdong.lin@linux.intel.com,
	alsa-devel@alsa-project.org, broonie@kernel.org
  Cc: tiwai@suse.de, liam.r.girdwood@linux.intel.com, Koul, Vinod,
	Bossart, Pierre-louis

> -----Original Message-----
> From: Pierre-Louis Bossart [mailto:pierre-louis.bossart@linux.intel.com]
> Sent: Wednesday, December 21, 2016 10:37 PM
> To: mengdong.lin@linux.intel.com; alsa-devel@alsa-project.org;
> broonie@kernel.org
> Cc: tiwai@suse.de; Lin, Mengdong <mengdong.lin@intel.com>;
> liam.r.girdwood@linux.intel.com; Koul, Vinod <vinod.koul@intel.com>;
> Bossart, Pierre-louis <pierre-louis.bossart@intel.com>
> Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: core: Add API to use DMI name in
> sound card long name
> 
> 
> >  /* Utility functions to get clock rates from various things */  int
> > snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
> > int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
> @@
> > -1094,6 +1096,8 @@ struct snd_soc_card {
> >  	const char *name;
> >  	const char *long_name;
> >  	const char *driver_name;
> > +	char dmi_longname[80];
> 
> why 80? is this linked to DMI restrictions on board/product names?

Because kernel uses a 80-character array to give the card long name to user space, in struct snd_ctl_card_info in include/uapi/sound/asound.h
 
> >
> > +/**
> > + * snd_soc_set_dmi_name() - Register DMI names to card
> > + * @card: The card to register DMI names
> > + * @flavour: The flavour "differentiator" for the card amongst its peers.
> > + *
> > + * Intel DSP platform drivers are used by many different devices but
> > +are
> > + * difficult for userspace to differentiate, since machine drivers
> > +ususally
> > + * use their own name as the card name (short name) and leave the
> > +card long
> > + * name blank. This function will allow DMI info to be used in the
> > +sound
> > + * card long name, thereby helping userspace load the correct UCM
> > +(Use Case
> > + * Manager) configuration.
> > + * Possible card long names may be:
> > + * broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH
> > + * broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach
> > +SDS
> > + * bytcr-rt5640-ASUSTeK COMPUTER INC.-T100TA-T100TA
> > + * bytcr-rt5651-Circuitco-Minnowboard Max D0 PLATFORM-MinnowBoard
> MAX
> 
> You may want to add a comment that the '.' is not a separator but part of
> the DMI name. I was trying to figure out why there were cases with .-

Okay, I'll add the comment. Actually the '-' is not necessary for the user space UCM code to do the matching. It's just give a hint to the developer to identify DMI fields in the card long name. I choose '-'  since both '.' and SPACE can be part of the DMI vendor or product names. I'll to add a UCM command to show both the card long name and its best matched configuration file, for developers to revise the name for a new configuration file.
 
Thanks
Mengdong

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name
  2016-12-21 15:46     ` Lin, Mengdong
@ 2016-12-22  3:07       ` Mengdong Lin
  0 siblings, 0 replies; 9+ messages in thread
From: Mengdong Lin @ 2016-12-22  3:07 UTC (permalink / raw)
  To: Lin, Mengdong, Liam Girdwood
  Cc: tiwai@suse.de, Koul, Vinod, alsa-devel@alsa-project.org,
	broonie@kernel.org, Bossart, Pierre-louis



On 12/21/2016 11:46 PM, Lin, Mengdong wrote:
>> -----Original Message-----
>> From: Liam Girdwood [mailto:liam.r.girdwood@linux.intel.com]
>> Sent: Wednesday, December 21, 2016 10:27 PM
>> To: mengdong.lin@linux.intel.com
>> Cc: alsa-devel@alsa-project.org; broonie@kernel.org; tiwai@suse.de; Bossart,
>> Pierre-louis <pierre-louis.bossart@intel.com>; Koul, Vinod
>> <vinod.koul@intel.com>; Lin, Mengdong <mengdong.lin@intel.com>
>> Subject: Re: [PATCH 1/2] ASoC: core: Add API to use DMI name in sound card
>> long name
>>
>> On Wed, 2016-12-21 at 21:04 +0800, mengdong.lin@linux.intel.com wrote:
>>> From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
>>>
>>> Intel DSP platform drivers are used by many different devices but are
>>> difficult for userspace to differentiate. This patch adds an API to
>>> allow the DMI name to be used in the sound card long name, thereby
>>> helping userspace load the correct UCM configuration. Usually machine
>>> drivers uses their own name as the sound card name (short name), and
>>> leave the long name and driver name blank. This API will append the
>>> DMI info like vendor, product and board info, to the card name to make
>>> up the card long name. If the machine driver has already explicitly
>>> set the long name, this API will do nothing.
>>>
>>> This patch also allows for further differentiation as many devices
>>> that share the same DMI name i.e. Minnowboards, UP boards may be
>>> configured with different codecs or firmwares. The API supports
>>> flavoring the DMI name into the card longname to provide the extra
>>> differentiation required for these devices.
>>>
>>> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
>>> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
>>>
>>> diff --git a/include/sound/soc.h b/include/sound/soc.h index
>>> 795e6c4..e4f1844 100644
>>> --- a/include/sound/soc.h
>>> +++ b/include/sound/soc.h
>>> @@ -497,6 +497,8 @@ void snd_soc_runtime_deactivate(struct
>>> snd_soc_pcm_runtime *rtd, int stream);  int
>> snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
>>>   	unsigned int dai_fmt);
>>>
>>> +int snd_soc_set_dmi_name(struct snd_soc_card *card, const char
>>> +*flavour);
>>> +
>>>   /* Utility functions to get clock rates from various things */  int
>>> snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
>>> int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
>> @@
>>> -1094,6 +1096,8 @@ struct snd_soc_card {
>>>   	const char *name;
>>>   	const char *long_name;
>>>   	const char *driver_name;
>>> +	char dmi_longname[80];
>>> +
>>>   	struct device *dev;
>>>   	struct snd_card *snd_card;
>>>   	struct module *owner;
>>> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index
>>> aaab26a..8bcf241 100644
>>> --- a/sound/soc/soc-core.c
>>> +++ b/sound/soc/soc-core.c
>>> @@ -34,6 +34,7 @@
>>>   #include <linux/ctype.h>
>>>   #include <linux/slab.h>
>>>   #include <linux/of.h>
>>> +#include <linux/dmi.h>
>>>   #include <sound/core.h>
>>>   #include <sound/jack.h>
>>>   #include <sound/pcm.h>
>>> @@ -1886,6 +1887,86 @@ int snd_soc_runtime_set_dai_fmt(struct
>>> snd_soc_pcm_runtime *rtd,  }
>>> EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
>>>
>>> +/**
>>> + * snd_soc_set_dmi_name() - Register DMI names to card
>>> + * @card: The card to register DMI names
>>> + * @flavour: The flavour "differentiator" for the card amongst its peers.
>>> + *
>>> + * Intel DSP platform drivers are used by many different devices but
>>> +are
>>> + * difficult for userspace to differentiate, since machine drivers
>>> +ususally
>>> + * use their own name as the card name (short name) and leave the
>>> +card long
>>> + * name blank. This function will allow DMI info to be used in the
>>> +sound
>>> + * card long name, thereby helping userspace load the correct UCM
>>> +(Use Case
>>> + * Manager) configuration.
>>> + * Possible card long names may be:
>>> + * broadwell-rt286-Dell Inc.-XPS 13 9343-0310JH
>>> + * broadwell-rt286-Intel Corp.-Broadwell Client platform-Wilson Beach
>>> +SDS
>>> + * bytcr-rt5640-ASUSTeK COMPUTER INC.-T100TA-T100TA
>>> + * bytcr-rt5651-Circuitco-Minnowboard Max D0 PLATFORM-MinnowBoard
>> MAX
>>> + *
>>
>>
>> Lets keep it simpler, we dont need to prepend the driver name to the
>> longname as it's already available in driver_name.
>>
>> The purpose of the patch is to uniquely identify the machine, so we dont
>> need to provide or duplicate other information in the name.
>>
>> So longname should be "dmi-flavour" where dmi is product OR board (if
>> product is not available).
>>
>> Liam
>
> Hi Liam,
>
> Yes, there is some duplication. But may we keep this?
>
> It's because that if the card long name itself has all the information, the user space UCM code can just compare the configuration file names against the card long name, no need to involve the card name (driver name).
> In addition, I want to make the naming same as HD-Audio, their card long name is the card short name with some suffixes. Although HD-Audio does not use UCM now, but maybe in the future? So we can process ASoC and HD-Audio cards in the same way.
>
> Thanks
> Mengdong

Hi Liam,

I'll remove the driver name from the long name and keep the long name as 
"dmi-flavor" as you suggested. I found dmi info could be quite long and 
if we keep the duplicated info, we may not have enough room for the 
"flavor" field. user space can accept 80 characters at most.

I'll modify the UCM code.

Thanks
Mengdong

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-12-22  3:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-21 13:02 [PATCH 0/2] ASoC: Use DMI name in sound card long name mengdong.lin
2016-12-21 13:04 ` [PATCH 1/2] ASoC: core: Add API to use " mengdong.lin
2016-12-21 14:27   ` Liam Girdwood
2016-12-21 15:46     ` Lin, Mengdong
2016-12-22  3:07       ` Mengdong Lin
2016-12-21 14:37   ` Pierre-Louis Bossart
2016-12-21 15:01     ` Liam Girdwood
2016-12-21 16:01     ` Lin, Mengdong
2016-12-21 13:04 ` [PATCH 2/2] ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver mengdong.lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).