Skip to contentSkip to conversation

ASoC: Use DMI name in sound card long name

RFC PATCH In review [email protected] 5 participants 8 messages Dec 16, 2016 – Jan 17, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Use DMI name in sound card long name

From: Mengdong Lin <[email protected]>

This series is based on Liam's idea to use DMI name as the sound card short name in the audio workshop. After testing on serveral machines, we changed the design a little:
- 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.

We hope to get aligned on the kernel side at first, then we'll update UCM code in alsa-lib: when the sound server ask UCM to open a sound card, UCM will try to find the best configuration file that matches the card long name, and only if not avaiable, fallback to the default configuration file that matches the card name (short 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                |   5 ++
 sound/soc/intel/boards/broadwell.c |   2 +
 sound/soc/soc-core.c               | 134 +++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
Signature · 1 line
2.5.0
#1 lore raw

RFC PATCH 1/2 ASoC: core: Add API to use DMI name in sound card long name

From: Liam Girdwood <[email protected]>

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 generate DMI name from the DMI vendor, product and board info, and then make up a unique card long name from the short name and DMI name. If the machine driver has already explicitly set the long name, although not observed, 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.

include/sound/soc.h +5 -0
index 795e6c4..b84648f 100644
@@ -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,9 @@ struct snd_soc_card {
 	const char *name;
 	const char *long_name;
 	const char *driver_name;
+	char dmi_longname[80];
+	char board_name[80];
+
 	struct device *dev;
 	struct snd_card *snd_card;
 	struct module *owner;
sound/soc/soc-core.c +134 -0

146 lines not on this page · raw message

Signature · 1 line
2.5.0
maintainer
#2 lore raw

Re: [RFC PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name

Quoted 87 lines · On Fri, 2016-12-16 at 10:51 +0800, [email protected] wrote:

From: Liam Girdwood <[email protected]>

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 generate DMI name from the DMI vendor, product and board info, and then make up a unique card long name from the short name and DMI name. If the machine driver has already explicitly set the long name, although not observed, 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.

include/sound/soc.h +5 -0
index 795e6c4..b84648f 100644
@@ -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,9 @@ struct snd_soc_card {
 	const char *name;
 	const char *long_name;
 	const char *driver_name;
+	char dmi_longname[80];
+	char board_name[80];
+
 	struct device *dev;
 	struct snd_card *snd_card;
 	struct module *owner;
sound/soc/soc-core.c +27 -0
index aaab26a..bb6a23a 100644
@@ -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,139 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 }
 EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
 
+/* Move the DMI stuff below to a new file soc-dmi.c? */
+struct snd_soc_dmi_name  {
+	const char *vendor;
+	const char *product;
+	const char *board;
+	const char *name;
+};
+
+#define SOC_DMI_ENTRY(_vendor, _product, _board, _name) \
+	{ .vendor = (_vendor), .board = (_board), \
+	  .product = (_product), .name = (_name) }
+
+/* DMI names. The matched DMI name will be appended to the card short name
+ * to make up the card long name. Machine drivers ususally use their own name
+ * as the card short name, and leave the long name empty. Machine driver may
+ * call API snd_soc_set_dmi_name() to get a unique long name. In user space,
+ * Use Case Manager (UCM) will try to find the best configuration file by
+ * matching the card long name at first, and if unavailable, match the short
+ * name as a fallback.
+ * For example, for a Boradwell-based Dell XPS 13-2015(9343), the card short
+ * name is "broadwell-rt286" and the DMI name is "DELL-XPS", so the long name
+ * will be "broadwell-rt286-Dell-XPS". For a new Skylake-based Dell XPS 13/15,
+ * if the short name is "skl-xyz" and DMI name is "Dell-XPS", the long name
+ * will be "skl-xyz-Dell-XPS".In user space, Use Case Manager (UCM) will try
+ * to find the best configuration file by matching the card long name (e.g.
+ * broadwell-rt286-Dell-XPS), and if unavailable, fallback to the default

sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1925

Quoted 10 lines
sound/soc/soc-core.c +10 -0
+ * configuration file by matching the short name (e.g. broadwell-rt286).
+ */
+static struct snd_soc_dmi_name dmi_names[]  = {
+	SOC_DMI_ENTRY("Intel Corp.", "Broadwell Client platform",
+		      "Wilson Beach SDS", "Intel-Wilson-Beach"),
+	SOC_DMI_ENTRY("Dell Inc.", "XPS 13 9343", "0310JH", "Dell-XPS"),
+	SOC_DMI_ENTRY("ASUSTeK COMPUTER INC.", "T100TA", "T100TA",
+		      "ASUS-T100"),
+	{}	/* terminator */
+};

We cant have any tables here or add new data for each machine. The intention is that the long name should be made from the DMI name (just a verbatim copy really). That way we dont need to do any new driver updates for a new machine, we just read the DMI name.

UCM will then try and find a config for the long name first, then will revert to the current short/driver name to load the existing configs. This way we dont break legacy or current users.

Liam

Quoted 100 lines
sound/soc/soc-core.c +97 -0
+
+/* retrieve the last word of shortname or longname */
+static const char *retrieve_id_from_card_name(const char *name)
+{
+	const char *spos = name;
+
+	while (*name) {
+		if (isspace(*name) && isalnum(name[1]))
+			spos = name + 1;
+		name++;
+	}
+	return spos;
+}
+
+static const char *find_dmi_name(const char *vendor, const char *product,
+			const char *board)
+{
+	struct snd_soc_dmi_name *name_entry;
+
+	/* vendor must be valid, either product or board must to be valid */
+	if (!vendor || (!product && !board))
+		return NULL;
+
+	name_entry = dmi_names;
+	while (name_entry->vendor) {
+		if (!strncmp(vendor, name_entry->vendor, 32)
+		    && (!product
+			|| !strncmp(product, name_entry->product, 32))
+		    && (!board || !strncmp(board, name_entry->board, 32)))
+			return name_entry->name;
+
+		name_entry++;
+	}
+
+	return NULL;
+}
+
+/**
+ * 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.
+ *
+ * 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, *name;
+	char *spos;
+
+	if (card->long_name)
+		return 0; /* already set long name by driver or from DMI */
+
+	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+	if (!vendor) {
+		dev_warn(card->dev, "ASoC: the DMI vendor name is empty!\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: both board/product name are empty!\n");
+		return 0;
+	}
+
+	name = find_dmi_name(vendor, product, board);
+	if (name)
+		snprintf(card->board_name, sizeof(card->board_name),
+			"%s-%s", card->name, name);
+	else
+		snprintf(card->board_name, sizeof(card->snd_card->longname),
+			"%s-%s-%s-%s", card->name, vendor, product, board);
+
+	/* replace SPACE with '-' */
+	spos = card->board_name;
+	while (*spos) {
+		if (isspace(*spos))
+			*spos = '-';
+		spos++;
+	}
+
+	/* long name */
+	card->long_name = card->board_name;
+
+	/* Add flavour to long name */
+	if (flavour) {
+		snprintf(card->dmi_longname, sizeof(card->snd_card->longname),
+			"%s-%s", retrieve_id_from_card_name(card->long_name),
+			flavour);
+		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;
#3 lore raw

Re: [RFC PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name

Quoted 105 lines · Liam Girdwood
Quoted 87 lines · On Fri, 2016-12-16 at 10:51 +0800, [email protected] wrote:

From: Liam Girdwood <[email protected]>

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 generate DMI name from the DMI vendor, product and board info, and then make up a unique card long name from the short name and DMI name. If the machine driver has already explicitly set the long name, although not observed, 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.

include/sound/soc.h +5 -0
index 795e6c4..b84648f 100644
@@ -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,9 @@ struct snd_soc_card {
  	const char *name;
  	const char *long_name;
  	const char *driver_name;
+	char dmi_longname[80];
+	char board_name[80];
+
  	struct device *dev;
  	struct snd_card *snd_card;
  	struct module *owner;
sound/soc/soc-core.c +27 -0
index aaab26a..bb6a23a 100644
@@ -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,139 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
  }
  EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
 
+/* Move the DMI stuff below to a new file soc-dmi.c? */
+struct snd_soc_dmi_name  {
+	const char *vendor;
+	const char *product;
+	const char *board;
+	const char *name;
+};
+
+#define SOC_DMI_ENTRY(_vendor, _product, _board, _name) \
+	{ .vendor = (_vendor), .board = (_board), \
+	  .product = (_product), .name = (_name) }
+
+/* DMI names. The matched DMI name will be appended to the card short name
+ * to make up the card long name. Machine drivers ususally use their own name
+ * as the card short name, and leave the long name empty. Machine driver may
+ * call API snd_soc_set_dmi_name() to get a unique long name. In user space,
+ * Use Case Manager (UCM) will try to find the best configuration file by
+ * matching the card long name at first, and if unavailable, match the short
+ * name as a fallback.
+ * For example, for a Boradwell-based Dell XPS 13-2015(9343), the card short
+ * name is "broadwell-rt286" and the DMI name is "DELL-XPS", so the long name
+ * will be "broadwell-rt286-Dell-XPS". For a new Skylake-based Dell XPS 13/15,
+ * if the short name is "skl-xyz" and DMI name is "Dell-XPS", the long name
+ * will be "skl-xyz-Dell-XPS".In user space, Use Case Manager (UCM) will try
+ * to find the best configuration file by matching the card long name (e.g.
+ * broadwell-rt286-Dell-XPS), and if unavailable, fallback to the default

sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1925

Quoted 10 lines
sound/soc/soc-core.c +10 -0
+ * configuration file by matching the short name (e.g. broadwell-rt286).
+ */
+static struct snd_soc_dmi_name dmi_names[]  = {
+	SOC_DMI_ENTRY("Intel Corp.", "Broadwell Client platform",
+		      "Wilson Beach SDS", "Intel-Wilson-Beach"),
+	SOC_DMI_ENTRY("Dell Inc.", "XPS 13 9343", "0310JH", "Dell-XPS"),
+	SOC_DMI_ENTRY("ASUSTeK COMPUTER INC.", "T100TA", "T100TA",
+		      "ASUS-T100"),
+	{}	/* terminator */
+};

We cant have any tables here or add new data for each machine. The intention is that the long name should be made from the DMI name (just a verbatim copy really). That way we dont need to do any new driver updates for a new machine, we just read the DMI name.

Quoted 5 lines

UCM will then try and find a config for the long name first, then will revert to the current short/driver name to load the existing configs. This way we dont break legacy or current users.

Liam

Hi Liam,

It seems different OEMs may have different flavor to define their DMI info. Directly using verbatim copy may result in too many different long names even for a product series that may share the same config. So I use the table here for a product family to share a single configuration file, which is not the default one with the same name as the card short name/driver name.

Take Dell XPS family for example, there are Boradwell based XPS 13/15 in 2014 and 2015, their product name can be different like:
XPS-13-xxxx, XPS-15-xxxx, and xxxx numbers are different for different years. And its board name could also change. I hope they can share the same card long name "broadwell-rt286-Dell-XPS" and the same UCM configuration file. Since XPS 13 and 15 only differ in screen size and GFX, only in audio HW. And xxxx does not matter here.

Although Dell XPS family may always revert to the short name/driver name to use the default UCM configuration file "broadwell-rt286" or "skl-xxx". But there may be other OEM machine family that can share a same UCM config file but not the default one. And I hope when users write a UCM configuration file, the file name could be more user friendly than a pure number.

And actually, the table is an option. If user don't want to define an entry for a specific machine, this function will to the verbatim copy to make the long name in the code below.

Quoted 22 lines
Quoted 22 lines
sound/soc/soc-core.c +22 -0
+int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
+{
+	const char *vendor, *product, *board, *name;
+	char *spos;
+
+	if (card->long_name)
+		return 0; /* already set long name by driver or from DMI */
+
+	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+	if (!vendor) {
+		dev_warn(card->dev, "ASoC: the DMI vendor name is empty!\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: both board/product name are empty!\n");
+		return 0;
+	}
+
Quoted 8 lines

sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1999

Quoted 8 lines
sound/soc/soc-core.c +8 -0
+	name = find_dmi_name(vendor, product, board);
+	if (name)
+		snprintf(card->board_name, sizeof(card->board_name),
+			"%s-%s", card->name, name);
+	else
+		snprintf(card->board_name, sizeof(card->snd_card->longname),
+			"%s-%s-%s-%s", card->name, vendor, product, board);
+

Here, if we cannot find a predefined DMI model in the able, we'll do the verbatim copy to make a long name automatically as "shortname-verdor-product-board".

Thanks
Mengdong

#4 lore raw

Re: [RFC PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name

Quoted 134 lines · Mengdong Lin
Quoted 126 lines · Liam Girdwood
Quoted 110 lines · On Fri, 2016-12-16 at 10:51 +0800, [email protected] wrote:

From: Liam Girdwood <[email protected]>

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 generate DMI name from the
DMI vendor, product and board info, and then make up a unique card long name from the short name and DMI name. If the machine driver has already explicitly set the long name, although not observed, 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.

include/sound/soc.h +2 -0
index 795e6c4..b84648f 100644
@@ -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);

include/sound/soc.h +3 -0
@@ -1094,6 +1096,9 @@ struct snd_soc_card {
      const char *name;
      const char *long_name;
      const char *driver_name;
+    char dmi_longname[80];
+    char board_name[80];
+
      struct device *dev;
      struct snd_card *snd_card;
      struct module *owner;
sound/soc/soc-core.c +14 -0
index aaab26a..bb6a23a 100644
@@ -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,139 @@ int snd_soc_runtime_set_dai_fmt(struct
 snd_soc_pcm_runtime *rtd,
  }
  EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
 
+/* Move the DMI stuff below to a new file soc-dmi.c? */
+struct snd_soc_dmi_name  {
+    const char *vendor;
+    const char *product;
+    const char *board;
+    const char *name;
+};
+
+#define SOC_DMI_ENTRY(_vendor, _product, _board, _name) \
+    { .vendor = (_vendor), .board = (_board), \
+      .product = (_product), .name = (_name) }
+
+/* DMI names. The matched DMI name will be appended to the card

short name
+ * to make up the card long name. Machine drivers ususally use their own name
+ * as the card short name, and leave the long name empty. Machine driver may
+ * call API snd_soc_set_dmi_name() to get a unique long name. In user space,
+ * Use Case Manager (UCM) will try to find the best configuration file by
+ * matching the card long name at first, and if unavailable, match the short
+ * name as a fallback.
+ * For example, for a Boradwell-based Dell XPS 13-2015(9343), the card short
+ * name is "broadwell-rt286" and the DMI name is "DELL-XPS", so the long name
+ * will be "broadwell-rt286-Dell-XPS". For a new Skylake-based Dell XPS 13/15,
+ * if the short name is "skl-xyz" and DMI name is "Dell-XPS", the long name
+ * will be "skl-xyz-Dell-XPS".In user space, Use Case Manager (UCM) will try
+ * to find the best configuration file by matching the card long name (e.g.
+ * broadwell-rt286-Dell-XPS), and if unavailable, fallback to the default
+ * configuration file by matching the short name (e.g. broadwell-rt286).
+ */

sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1925

Quoted 8 lines
sound/soc/soc-core.c +8 -0
+static struct snd_soc_dmi_name dmi_names[]  = {
+    SOC_DMI_ENTRY("Intel Corp.", "Broadwell Client platform",
+              "Wilson Beach SDS", "Intel-Wilson-Beach"),
+    SOC_DMI_ENTRY("Dell Inc.", "XPS 13 9343", "0310JH", "Dell-XPS"),
+    SOC_DMI_ENTRY("ASUSTeK COMPUTER INC.", "T100TA", "T100TA",
+              "ASUS-T100"),
+    {}    /* terminator */
+};

We cant have any tables here or add new data for each machine. The intention is that the long name should be made from the DMI name (just a verbatim copy really). That way we dont need to do any new driver updates for a new machine, we just read the DMI name.

Quoted 5 lines

UCM will then try and find a config for the long name first, then will revert to the current short/driver name to load the existing configs. This way we dont break legacy or current users.

Liam

Quoted 8 lines

Hi Liam,

It seems different OEMs may have different flavor to define their DMI info. Directly using verbatim copy may result in too many different long names even for a product series that may share the same config. So I use the table here for a product family to share a single configuration file, which is not the default one with the same name as the card short name/driver name.

we can't have a table, it's just impossible to maintain.

Quoted 16 lines

Take Dell XPS family for example, there are Boradwell based XPS 13/15 in 2014 and 2015, their product name can be different like:
XPS-13-xxxx, XPS-15-xxxx, and xxxx numbers are different for different years. And its board name could also change. I hope they can share the same card long name "broadwell-rt286-Dell-XPS" and the same UCM configuration file. Since XPS 13 and 15 only differ in screen size and GFX, only in audio HW. And xxxx does not matter here.

Although Dell XPS family may always revert to the short name/driver name to use the default UCM configuration file "broadwell-rt286" or "skl-xxx". But there may be other OEM machine family that can share a same UCM config file but not the default one. And I hope when users write a UCM configuration file, the file name could be more user friendly than a pure number.

Quoted 3 lines

And actually, the table is an option. If user don't want to define an entry for a specific machine, this function will to the verbatim copy to make the long name in the code below.

The intent is to provide the information to userspace so that a UCM configuration is selected. the decision on how to use the information can be made there in user space, taking into account the way the DMI information is set and the desire from the community to track hardware differences.
For example Asus is pretty clean, you can use the full name bytcr_rt5640_Asus_T100TA to find a configuration. Others keep changing the product name so there is no way to track hardware proliferation. For Dell you may need to broadwell-rt286-Dell and ignore the suffixes and variations of the same hardware. You'd have one configuration for an entire family of products.

Quoted 44 lines
Quoted 25 lines
Quoted 25 lines

+int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)

sound/soc/soc-core.c +18 -0
+{
+    const char *vendor, *product, *board, *name;
+    char *spos;
+
+    if (card->long_name)
+        return 0; /* already set long name by driver or from DMI */
+
+    vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+    if (!vendor) {
+        dev_warn(card->dev, "ASoC: the DMI vendor name is empty!\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: both board/product name are

empty!\n");

sound/soc/soc-core.c +3 -0
+        return 0;
+    }
+
Quoted 8 lines

sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1999

Quoted 8 lines
sound/soc/soc-core.c +8 -0
+    name = find_dmi_name(vendor, product, board);
+    if (name)
+        snprintf(card->board_name, sizeof(card->board_name),
+            "%s-%s", card->name, name);
+    else
+        snprintf(card->board_name, sizeof(card->snd_card->longname),
+            "%s-%s-%s-%s", card->name, vendor, product, board);
+

Here, if we cannot find a predefined DMI model in the able, we'll do the verbatim copy to make a long name automatically as "shortname-verdor-product-board".

Thanks
Mengdong
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw

Re: [RFC PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name

Quoted 99 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Friday, December 16, 2016 10:38 PM
To: Mengdong Lin <[email protected]>; Liam Girdwood <[email protected]>
Cc: [email protected]; Koul, Vinod <[email protected]>; alsa-devel@alsa- project.org; [email protected]; Lin, Mengdong <[email protected]>
Subject: Re: [alsa-devel] [RFC PATCH 1/2] ASoC: core: Add API to use DMI name in sound card long name

Quoted 88 lines · Mengdong Lin
Quoted 78 lines · Liam Girdwood
Quoted 62 lines · On Fri, 2016-12-16 at 10:51 +0800, [email protected] wrote:

From: Liam Girdwood <[email protected]>

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 generate DMI name from the DMI vendor, product and board info, and then make up a unique card long name from the short name and DMI name. If the machine driver has already explicitly set the long name, although not observed, 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.

sound/soc/soc-core.c +13 -0
+/* Move the DMI stuff below to a new file soc-dmi.c? */ struct
+snd_soc_dmi_name  {
+    const char *vendor;
+    const char *product;
+    const char *board;
+    const char *name;
+};
+
+#define SOC_DMI_ENTRY(_vendor, _product, _board, _name) \
+    { .vendor = (_vendor), .board = (_board), \
+      .product = (_product), .name = (_name) }
+
+/* DMI names. The matched DMI name will be appended to the card

short name
+ * to make up the card long name. Machine drivers ususally use
+ their
own name
+ * as the card short name, and leave the long name empty. Machine driver may
+ * call API snd_soc_set_dmi_name() to get a unique long name. In user space,
+ * Use Case Manager (UCM) will try to find the best configuration file by
+ * matching the card long name at first, and if unavailable, match the short
+ * name as a fallback.
+ * For example, for a Boradwell-based Dell XPS 13-2015(9343), the card short
+ * name is "broadwell-rt286" and the DMI name is "DELL-XPS", so the long name
+ * will be "broadwell-rt286-Dell-XPS". For a new Skylake-based Dell XPS 13/15,
+ * if the short name is "skl-xyz" and DMI name is "Dell-XPS", the long name
+ * will be "skl-xyz-Dell-XPS".In user space, Use Case Manager (UCM) will try
+ * to find the best configuration file by matching the card long name (e.g.
+ * broadwell-rt286-Dell-XPS), and if unavailable, fallback to the default
+ * configuration file by matching the short name (e.g. broadwell-rt286).
+ */

sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1925

Quoted 8 lines
sound/soc/soc-core.c +8 -0
+static struct snd_soc_dmi_name dmi_names[]  = {
+    SOC_DMI_ENTRY("Intel Corp.", "Broadwell Client platform",
+              "Wilson Beach SDS", "Intel-Wilson-Beach"),
+    SOC_DMI_ENTRY("Dell Inc.", "XPS 13 9343", "0310JH", "Dell-XPS"),
+    SOC_DMI_ENTRY("ASUSTeK COMPUTER INC.", "T100TA", "T100TA",
+              "ASUS-T100"),
+    {}    /* terminator */
+};

We cant have any tables here or add new data for each machine. The intention is that the long name should be made from the DMI name (just a verbatim copy really). That way we dont need to do any new driver updates for a new machine, we just read the DMI name.

Quoted 5 lines

UCM will then try and find a config for the long name first, then will revert to the current short/driver name to load the existing configs. This way we dont break legacy or current users.

Liam

Hi Liam,

Quoted 8 lines
Quoted 6 lines

It seems different OEMs may have different flavor to define their DMI info. Directly using verbatim copy may result in too many different long names even for a product series that may share the same config. So I use the table here for a product family to share a single configuration file, which is not the default one with the same name as the card short name/driver name.

we can't have a table, it's just impossible to maintain.

You're right, this cannot scale. I'll remove the table and do verbatim copy on DMI info as Liam suggested.

The card long name will be "shortname-vendor-product-board". The 'product' field will sit before the 'board' field because Dell XPS and ASUS tablets show that 'product' may be more meaningful than or equivalent to the 'board' . I'll keep the 'board' field in the long name since other OEMs may have a more meaningful 'board' that 'product', like Intel.

Quoted 20 lines
Quoted 16 lines

Take Dell XPS family for example, there are Boradwell based XPS 13/15 in
2014 and 2015, their product name can be different like:
XPS-13-xxxx, XPS-15-xxxx, and xxxx numbers are different for different years. And its board name could also change. I hope they can share the same card long name "broadwell-rt286-Dell-XPS" and the same UCM configuration file. Since XPS 13 and 15 only differ in screen size and GFX, only in audio HW. And xxxx does not matter here.

Although Dell XPS family may always revert to the short name/driver name to use the default UCM configuration file "broadwell-rt286" or "skl-xxx". But there may be other OEM machine family that can share a same UCM config file but not the default one. And I hope when users write a UCM configuration file, the file name could be more user friendly than a pure number.

Quoted 3 lines

And actually, the table is an option. If user don't want to define an entry for a specific machine, this function will to the verbatim copy to make the long name in the code below.

Quoted 10 lines

The intent is to provide the information to userspace so that a UCM configuration is selected. the decision on how to use the information can be made there in user space, taking into account the way the DMI information is set and the desire from the community to track hardware differences. For example Asus is pretty clean, you can use the full name bytcr_rt5640_Asus_T100TA to find a configuration. Others keep changing the product name so there is no way to track hardware proliferation. For Dell you may need to broadwell-rt286-Dell and ignore the suffixes and variations of the same hardware. You'd have one configuration for an entire family of products.

Okay. We'll let UCM library in user space do the name matching to select the best UCM file. I'll try to make UCM do the matching automatically, maybe we still need some simple rules for different vendors, but will never maintain a table for each machine.

Thanks for your advice, Pierre and Liam!

Regards
Mengdong

#6 lore raw

RFC PATCH 2/2 ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver

In reply to [email protected]

From: Mengdong Lin <[email protected]>

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:

             short name & driver name   long name
WilsonBeach:       broadwell-rt286      broadwell-rt286-Intel-Wilson-Beach
Dell XPS-13(2015): broadwell-rt286      broadwell-rt286-Dell-XPS

The card short name has no change, and ASoC will use the card name as the card driver name.

sound/soc/intel/boards/broadwell.c +2 -0
index 5bb64d1..cda73bb 100644
@@ -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);
 }
 
Signature · 1 line
2.5.0
maintainer
#7 lore raw

Applied "ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver" to the asoc tree

The patch

ASoC: Intel: Use DMI name for sound card long name in Broadwell machine driver

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All 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

Quoted 1 line

From 3122c66fd2159f4ab210da8d95465af2f145fad7 Mon Sep 17 00:00:00 2001

From: Mengdong Lin <[email protected]>
Date: Sat, 14 Jan 2017 16:13:09 +0800
Subject: [PATCH] ASoC: Intel: Use DMI name for sound card long name in
Broadwell machine driver

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

For example, here are the changed long name for two Broadwell-based machines:
Dell XPS-13(2015): DellInc.-XPS139343-01-0310JH
Intel WilsonBeach: Intel Corp.-BroadwellClientplatform-0.1-WilsonBeachSDS

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

---
 sound/soc/intel/boards/broadwell.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/intel/boards/broadwell.c +2 -0
index 4d7e9decfa92..faf865bb1765 100644
@@ -270,6 +270,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);
 }
 
Signature · 1 line
2.11.0