@@ -486,6 +486,9 @@ 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_card_names(struct snd_soc_card *card, const char *board,
+ const char *vendor, const char *firmware);
+
/* 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);
@@ -1828,6 +1828,59 @@ 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_card_names() - Set the shortname/drivername/longname/component
+ * of a ASoC card.
+ * @card: The card to set names
+ * @board: DMI_BOARD_NAME or DMI_PRODUCT_NAME
+ * @vendor: DMI_SYS_VENDOR
+ * @firmware: The firmware name
+ *
+ * This function registers DMI names to card for the userspace to distinguish
+ * different boards/products:
+ * card driver name ---> machine driver name
+ * card short name ---> DMI_BOARD_NAME or DMI_PRODUCT_NAME
+ * card long name and
+ * card component ---> short name:driver name:(DMI_SYS_VENDOR)
+ * :(firmware name)
+ *
+ * Returns 0 on success, otherwise a negative error code.
+ */
+int snd_soc_set_card_names(struct snd_soc_card *card, const char *board,
+ const char *vendor, const char *firmware)
+{
+ int ret = 0;
+ size_t buf_size, name_size;
+ char *name;
+
+ if (!board) {
+ dev_err(card->dev, "ASoC: the board/product name is empty!\n");
+ return -EINVAL;
+ }
+
+ /* card driver name */
+ card->driver_name = card->name;
+ /* card short name */
+ card->name = board;
+ /* card long name / card component */
+ buf_size = sizeof(card->snd_card->longname);
+ name_size = strlen(card->name) + strlen(card->driver_name)
+ + strlen(vendor) + strlen(firmware) + 4;
+ if (buf_size < name_size + strlen(card->snd_card->components))
+ return -ENOMEM;
+ name = kmalloc(buf_size, GFP_KERNEL);
+ if (!name)
+ return -ENOMEM;
+ snprintf(name, buf_size, "%s:%s:%s:%s", card->name,
+ card->driver_name, vendor, firmware);
+ ret = snd_component_add(card->snd_card, name);
+ card->long_name = card->snd_card->components;
+
+ kfree(name);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_set_card_names);
+
static int snd_soc_instantiate_card(struct snd_soc_card *card)
{
struct snd_soc_codec *codec;