UPSTREAM: ASoC: core: Add name prefix for machines with topology rewrites

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit f11a5c27f9287cacad74af31cd92d4413eccc05a)
Signed-off-by: Samaga Prasanna Krishna <samaga.krishna@intel.corp-partner.google.com>

BUG=b:110025789
TEST=Test Audio use cases after full SOF series patches are applied.

Change-Id: Id83d71dcd9348c9a25c12da81609fd46ff0bb319
Reviewed-on: https://chromium-review.googlesource.com/1120573
Commit-Ready: Curtis Malainey <cujomalainey@chromium.org>
Tested-by: Curtis Malainey <cujomalainey@chromium.org>
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 55d20e6..36426bd 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1008,6 +1008,7 @@
 
 	/* this platform uses topology and ignore machine driver FEs */
 	const char *ignore_machine;
+	const char *topology_name_prefix;
 	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
 				  struct snd_pcm_hw_params *params);
 	bool use_dai_pcm_id;	/* use the DAI link PCM ID as PCM device number */
@@ -1160,6 +1161,7 @@
 	const char *long_name;
 	const char *driver_name;
 	char dmi_longname[80];
+	char topology_shortname[32];
 
 	struct device *dev;
 	struct snd_card *snd_card;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 338b73d..d0752ba 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2202,6 +2202,14 @@
 			if (!dai_link->stream_name)
 				dai_link->stream_name = dai_link->name;
 		}
+
+		/* Inform userspace we are using alternate topology */
+		if (platform->driver->topology_name_prefix) {
+			snprintf(card->topology_shortname, 32, "%s-%s",
+				 platform->driver->topology_name_prefix,
+				 card->name);
+			card->name = card->topology_shortname;
+		}
 	}
 }