[alsa-devel] [PATCH 5/6] ASoC: add Component level struct snd_compr_ops

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Tue Dec 20 02:59:43 CET 2016


Hi Charles

Thank you for your review

> > -	if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
> > -		ret = platform->driver->compr_ops->open(cstream);
> > -		if (ret < 0) {
> > -			pr_err("compress asoc: can't open platform %s\n",
> > -				platform->component.name);
> > -			goto plat_err;
> > +	ret = 0;
> > +	for_each_component(component, rtd->card) {
> > +		const struct snd_compr_ops *compr_ops = component->compr_ops;
> > +
> > +		if (compr_ops && compr_ops->open) {
> > +			int _ret = compr_ops->open(cstream);
> > +
> > +			if (_ret < 0) {
> > +				pr_err("compress asoc: can't open component %s\n",
> > +				       component->name);
> > +				ret |= _ret;
> > +			}
> 
> Apologies if I am missing something but this really doesn't look
> like equivalent code? The old code calls the ops for the platform
> associated with the stream, the new code looks like it will call
> the ops for every single component in the system that has
> compressed ops, which would definitely cause issue. Am I missing
> something here?

Basically in *current* existing code, platform only has compr_ops.
So, converting existing code to new code should be OK.

Current ALSA SoC clearly separating CPU/Codec/Platform, but in these days,
new sound device has many features. Thus, it becaming difficult to
say "it is XXX" today. For example, some Codec has CPU feature,
some CPU has Platform feature etc.
So, our (= Me/Lars) plan is that remove current CPU/Codec/Platform separation,
and all will be Component connection.

Above code will call every component's compr_ops,
currently, it should be platform now.
But in the future device, Codec and/or CPU can have compr_ops.

If you want, currently, it can call 1st found compr_ops (= should be platform)
only with FIXME comment at this point.

Does this clear answer for you ?

	for_each_component(component, rtd->card) {
		const struct snd_compr_ops *compr_ops = component->compr_ops;

		/* FIXME: 1st compr_ops only at this point */
		if (compr_ops && compr_ops->open) {
			ret = compr_ops->open(cstream);
			if (ret < 0) {
				pr_err("compress asoc: can't open component %s\n",
				       component->name);
			}
			break;
		}
	}


More information about the Alsa-devel mailing list