[alsa-devel] [RFC] ASoC: multi-component: Add optional kcontrol prefix name for a DAI link

Mark Brown broonie at opensource.wolfsonmicro.com
Mon Aug 23 17:21:45 CEST 2010


On Fri, Aug 20, 2010 at 11:51:44AM +0300, Jarkko Nikula wrote:
> Jarkko Nikula <jhnikula at gmail.com> wrote:

> +int _snd_soc_dapm_new_control(struct snd_soc_codec *codec,
> +	const struct snd_soc_dapm_widget *widget,
> +	const char *name_prefix);
>  int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
>  	const struct snd_soc_dapm_widget *widget);
> +int _snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
> +	const struct snd_soc_dapm_widget *widget,
> +	int num, const char *name_prefix);

Best not in the header; these are not things individual drivers should
be worrying their pretty little heads about.  If they should be used by
individual drivers then we need better names than just _.

> @@ -539,6 +543,7 @@ struct snd_soc_dai_link {
>  	const char *platform_name;	/* for multi-platform */
>  	const char *cpu_dai_name;
>  	const char *codec_dai_name;
> +	const char *kcontrol_prefix;	/* kcontrol prefix for multi-codec */
>  
>  	/* Keep DAI active over suspend */
>  	unsigned int ignore_suspend:1;

I don't see how a DAI link can ever be used to configure prefix names -
there's just not any real association between DAI links and controls,
and as soon as you hit mixing any that does exist gets lost.  Probably a
table of CODEC to prefix mappings would be better.

> +			if (codec->kcontrol_prefix && !w->prefixed) {
> +				name_len += 1 + strlen(codec->kcontrol_prefix);
> +				snprintf(prefix, sizeof(prefix), "%s.",
> +					 codec->kcontrol_prefix);

A space would probably be more idiomatic for the separator.

> +int _snd_soc_dapm_add_routes(struct snd_soc_codec *codec,
> +			    const struct snd_soc_dapm_route *route, int num,
> +			    const char *name_prefix)
>  {
>  	int i, ret;
>  
>  	for (i = 0; i < num; i++) {
> -		ret = snd_soc_dapm_add_route(codec, route);
> +		ret = snd_soc_dapm_add_route(codec, route, name_prefix);

This one is a bit more fun.  For this to work properly we need to
consider what happens with the cross-device links in the DAI maps which
means we need to able to cope with separate prefixes for the source and
the sink.


More information about the Alsa-devel mailing list