OSDN Git Service

ASoC: soc-core: merge snd_pcm_ops member to component driver
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 2 Oct 2019 05:30:48 +0000 (14:30 +0900)
committerMark Brown <broonie@kernel.org>
Tue, 8 Oct 2019 12:39:53 +0000 (13:39 +0100)
commite2cb4a14541dba3587bb78e0f62da27a0e1ad399
tree0b63d347dfcf4f024115c8dd9ee0c39ddbca9ab0
parent9e985503ee4b23d576c303a17dfe52cfc8f32727
ASoC: soc-core: merge snd_pcm_ops member to component driver

Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).

--- ALSA SoC  ---
...
if (component->driver->ops &&
    component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...

--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) 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 components which
have same driver name.

To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.

--- ALSA SoC  ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...

--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
    struct snd_pcm_substream *substream)
{
...
}

*Note*

Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-component.h
sound/soc/soc-component.c
sound/soc/soc-pcm.c