• Kuninori Morimoto's avatar
    ASoC: soc-compress: add snd_compress_ops · c6cb522c
    Kuninori Morimoto authored
    Current snd_soc_component_driver has compr_ops, and each driver can
    have callback via it. But, it is mainly created for ALSA, thus, it
    doesn't have "component" as parameter.
    Thus, each callback can't know it is called for which component.
    Each callback currently is getting "component" by using
    snd_soc_rtdcom_lookup() with driver name.
    
    	--- ALSA SoC  ---
    	...
    	if (component->driver->compr_ops &&
    	    component->driver->compr_ops->open)
    =>		return component->driver->compr_ops->open(stream);
    	...
    
    	--- driver ---
    	static int xxx_open(struct snd_compr_stream *stream)
    	{
    		struct snd_soc_pcm_runtime *rtd = stream->private_data;
    =>		struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
    		...
    	}
    
    It works today, but, will not work in the future if we support multi
    CPU/Codec/Platform, because 1 rtd might have multiple same driver
    name component.
    
    To solve this issue, each callback need to be called with component.
    We already have many component driver callbacks.
    This patch adds new snd_compress_ops, and call it with "component".
    
    	--- ALSA SoC  ---
    	...
    	if (component->driver->compress_ops->open)
    =>		return component->driver->compress_ops->open(
    			component, substream);
    			~~~~~~~~~
    	...
    
    	--- driver ---
    	static int xxx_open(struct snd_soc_component *component,
    			    struct snd_compr_stream *stream)
    	{
    =>		/* it don't need to use snd_soc_rtdcom_lookup() */
    		...
    	}
    Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
    Tested-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
    Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
    Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
    Link: https://lore.kernel.org/r/87v9luvdmh.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    c6cb522c
soc-compress.c 27.6 KB