Skip to contentSkip to conversation

ASoC: snd_soc_set_dmi_name will use DMI_SYS_VENDOR if available

PATCH In review [email protected] 3 participants 4 messages Apr 28, 2017 – May 2, 2017

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

PATCH 1/1 ASoC: snd_soc_set_dmi_name will use DMI_SYS_VENDOR if available

From: Mengdong Lin <[email protected]>

This fix is based on Daniel Drake's suggestion: most x86 machines have a meaningfull DMI_SYS_VENDOR rather than DMI_BOARD_VENDOR.

So snd_soc_set_dmi_name will try to get vendor name from DMI_SYS_VENDOR at first, and if that's null, then use DMI_BOARD_VENDOR.

sound/soc/soc-core.c +3 -1
index 525f2f3..45f0a34 100644
@@ -1974,7 +1974,9 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
 		return 0; /* long name already set by driver or from DMI */
 
 	/* make up dmi long name as: vendor.product.version.board */
-	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+	vendor = dmi_get_system_info(DMI_SYS_VENDOR);
+	if (!vendor)
+		vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
 	if (!vendor) {
 		dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
 		return 0;
Signature · 1 line
2.5.0
#1 lore raw
Quoted 15 lines · On 4/28/17 11:19 AM, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This fix is based on Daniel Drake's suggestion: most x86 machines have a meaningfull DMI_SYS_VENDOR rather than DMI_BOARD_VENDOR.

So snd_soc_set_dmi_name will try to get vendor name from DMI_SYS_VENDOR at first, and if that's null, then use DMI_BOARD_VENDOR.

sound/soc/soc-core.c +0 -0
index 525f2f3..45f0a34 100644

sound/soc/soc-core.c int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour) · line 1979

Quoted 7 lines
sound/soc/soc-core.c +3 -1
@@ -1974,7 +1974,9 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
 		return 0; /* long name already set by driver or from DMI */
 
 	/* make up dmi long name as: vendor.product.version.board */
-	vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+	vendor = dmi_get_system_info(DMI_SYS_VENDOR);
+	if (!vendor)
+		vendor = dmi_get_system_info(DMI_BOARD_VENDOR);

We should also test all of vendor.product.version.board fields for "(To be filled by OEM)" and "Default String" and limit each field to 20 characters if you want to stick with 80 total (or a smarter rule that does not truncate a field if there was room saved by the others)

Quoted 4 lines
sound/soc/soc-core.c +0 -0
 	if (!vendor) {
 		dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
 		return 0;
#2 lore raw

Daniel and I have tested this patch on our platforms.

Quoted 19 lines · Pierre-Louis Bossart
Quoted 18 lines · On 4/28/17 11:19 AM, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This fix is based on Daniel Drake's suggestion: most x86 machines have a meaningfull DMI_SYS_VENDOR rather than DMI_BOARD_VENDOR.

So snd_soc_set_dmi_name will try to get vendor name from DMI_SYS_VENDOR at first, and if that's null, then use DMI_BOARD_VENDOR.

sound/soc/soc-core.c +0 -0
index 525f2f3..45f0a34 100644
@@ -1974,7 +1974,9 @@ int snd_soc_set_dmi_name(struct snd_soc_card
 *card, const char *flavour)
         return 0; /* long name already set by driver or from DMI */
 
Quoted 10 lines

sound/soc/soc-core.c int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour) · line 1979

Quoted 5 lines
sound/soc/soc-core.c +3 -1
     /* make up dmi long name as: vendor.product.version.board */
-    vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+    vendor = dmi_get_system_info(DMI_SYS_VENDOR);
+    if (!vendor)
+        vendor = dmi_get_system_info(DMI_BOARD_VENDOR);

We should also test all of vendor.product.version.board fields for "(To be filled by OEM)" and "Default String" and limit each field to 20 characters if you want to stick with 80 total (or a smarter rule that does not truncate a field if there was room saved by the others)

Now the risk on string size seems okay. The maximum size of the vendor.product.version.board is about 60 characters found in my test for some Lenovo, DELL, ASUS, Minnowboard and Intel machines.

Usually each field has 10 ~ 20 characters. Since it's difficult to judge which part in the string is more important, we just copy, concatenate and limit the total size of the concatenated string. But to save size, we've stripped SPACE characters from each field to reduce the string size. And if a DMI field is null, it will be skipped without any "Default string".

Thanks
Mengdong

Quoted 10 lines
Quoted 4 lines
sound/soc/soc-core.c +0 -0
     if (!vendor) {
         dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
         return 0;

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

#3 lore raw
Quoted 38 lines · Mengdong Lin

Daniel and I have tested this patch on our platforms.

Quoted 19 lines · Pierre-Louis Bossart
Quoted 18 lines · On 4/28/17 11:19 AM, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This fix is based on Daniel Drake's suggestion: most x86 machines have a meaningfull DMI_SYS_VENDOR rather than DMI_BOARD_VENDOR.

So snd_soc_set_dmi_name will try to get vendor name from DMI_SYS_VENDOR at first, and if that's null, then use DMI_BOARD_VENDOR.

sound/soc/soc-core.c +0 -0
index 525f2f3..45f0a34 100644
@@ -1974,7 +1974,9 @@ int snd_soc_set_dmi_name(struct snd_soc_card
 *card, const char *flavour)
         return 0; /* long name already set by driver or from DMI */
 
Quoted 10 lines

sound/soc/soc-core.c int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour) · line 1979

Quoted 5 lines
sound/soc/soc-core.c +3 -1
     /* make up dmi long name as: vendor.product.version.board */
-    vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+    vendor = dmi_get_system_info(DMI_SYS_VENDOR);
+    if (!vendor)
+        vendor = dmi_get_system_info(DMI_BOARD_VENDOR);

We should also test all of vendor.product.version.board fields for "(To be filled by OEM)" and "Default String" and limit each field to 20 characters if you want to stick with 80 total (or a smarter rule that does not truncate a field if there was room saved by the others)

Now the risk on string size seems okay. The maximum size of the vendor.product.version.board is about 60 characters found in my test for some Lenovo, DELL, ASUS, Minnowboard and Intel machines.

Quoted 6 lines

Usually each field has 10 ~ 20 characters. Since it's difficult to judge which part in the string is more important, we just copy, concatenate and limit the total size of the concatenated string. But to save size, we've stripped SPACE characters from each field to reduce the string size. And if a DMI field is null, it will be skipped without any "Default string".

Well, the two strings, "(To be filled by OEM)" and "Default String", are known to be bogus, and actually found on many devices with premature BIOS, so we can safely skip them.

Takashi