diff mbox series

[01/15] ASoC: add helper to change platform name for all dailinks

Message ID 20190125203509.22994-2-pierre-louis.bossart@linux.intel.com (mailing list archive)
State Accepted
Commit cb50358b83846e4dcb37137c431327c4dd68561b
Headers show
Series ASoC: Intel: pass platform name to machine drivers | expand

Commit Message

Pierre-Louis Bossart Jan. 25, 2019, 8:34 p.m. UTC
To reuse the same machine drivers with Atom/SST, Skylake and SOF, we
need to change the default platform_name (or platforms->name in the
"modern" representation).

So far, this override was done with an automatic override, which was
broken by a set of changes for DT platforms related to deferred probe
handling.

This automatic override is actually not really needed, the machine
driver can already receive the platform name as a platform_data
parameter. This is used e.g. for HDaudio support where we have
different PCI aliases used for different platforms. We can reuse the
same mechanism and modify the machine drivers to override the dailinks
prior to registrating the card.

This will require additional work for SOF, but with this helper it'll
be just two lines of additional code per machine driver which is
reused, not the end of the world.

This helper can be simplified when all drivers have transitioned to
the "modern" representation of dailinks.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 include/sound/soc.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Takashi Iwai Jan. 26, 2019, 5:47 p.m. UTC | #1
On Fri, 25 Jan 2019 21:34:55 +0100,
Pierre-Louis Bossart wrote:
> 
> To reuse the same machine drivers with Atom/SST, Skylake and SOF, we
> need to change the default platform_name (or platforms->name in the
> "modern" representation).
> 
> So far, this override was done with an automatic override, which was
> broken by a set of changes for DT platforms related to deferred probe
> handling.
> 
> This automatic override is actually not really needed, the machine
> driver can already receive the platform name as a platform_data
> parameter. This is used e.g. for HDaudio support where we have
> different PCI aliases used for different platforms. We can reuse the
> same mechanism and modify the machine drivers to override the dailinks
> prior to registrating the card.
> 
> This will require additional work for SOF, but with this helper it'll
> be just two lines of additional code per machine driver which is
> reused, not the end of the world.
> 
> This helper can be simplified when all drivers have transitioned to
> the "modern" representation of dailinks.
> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>  include/sound/soc.h | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 3089257ead95..95689680336b 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -1580,6 +1580,37 @@ struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
>  	return NULL;
>  }
>  
> +static inline
> +int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
> +					  const char *platform_name)
> +{
> +	struct snd_soc_dai_link *dai_link;
> +	const char *name;
> +	int i;
> +
> +	if (!platform_name) /* nothing to do */
> +		return 0;
> +
> +	/* set platform name for each dailink */
> +	for_each_card_prelinks(card, i, dai_link) {
> +		name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
> +		if (!name)
> +			return -ENOMEM;
> +
> +		if (dai_link->platforms)
> +			/* only single platform is supported for now */
> +			dai_link->platforms->name = name;
> +		else
> +			/*
> +			 * legacy mode, this case will be removed when all
> +			 * derivers are switched to modern style dai_link.
> +			 */
> +			dai_link->platform_name = name;
> +	}
> +
> +	return 0;
> +}

Does it have to be inline?  The function has a significant size, and
it's supposed to be called by every Intel driver.


thanks,

Takashi
Mark Brown Jan. 28, 2019, 12:19 p.m. UTC | #2
On Sat, Jan 26, 2019 at 06:47:57PM +0100, Takashi Iwai wrote:
> Pierre-Louis Bossart wrote:

> > +static inline
> > +int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
> > +					  const char *platform_name)
> > +{

> Does it have to be inline?  The function has a significant size, and
> it's supposed to be called by every Intel driver.

Yeah, if it gets too big the compiler will just ignore you but given
that this isn't exactly in a hot path or anything I can't see any reason
why it should be inline.
Pierre-Louis Bossart Jan. 28, 2019, 3:57 p.m. UTC | #3
>>> +static inline
>>> +int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
>>> +					  const char *platform_name)
>>> +{
>> Does it have to be inline?  The function has a significant size, and
>> it's supposed to be called by every Intel driver.
> Yeah, if it gets too big the compiler will just ignore you but given
> that this isn't exactly in a hot path or anything I can't see any reason
> why it should be inline.
Sure, I can fix this, no worries.
diff mbox series

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 3089257ead95..95689680336b 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1580,6 +1580,37 @@  struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
 	return NULL;
 }
 
+static inline
+int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
+					  const char *platform_name)
+{
+	struct snd_soc_dai_link *dai_link;
+	const char *name;
+	int i;
+
+	if (!platform_name) /* nothing to do */
+		return 0;
+
+	/* set platform name for each dailink */
+	for_each_card_prelinks(card, i, dai_link) {
+		name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
+		if (!name)
+			return -ENOMEM;
+
+		if (dai_link->platforms)
+			/* only single platform is supported for now */
+			dai_link->platforms->name = name;
+		else
+			/*
+			 * legacy mode, this case will be removed when all
+			 * derivers are switched to modern style dai_link.
+			 */
+			dai_link->platform_name = name;
+	}
+
+	return 0;
+}
+
 #ifdef CONFIG_DEBUG_FS
 extern struct dentry *snd_soc_debugfs_root;
 #endif