diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-04 22:12:09 +0100 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-16 19:36:29 +0100 |
commit | c74184ed30ecce2a5e9ae9aa22cb5e3942e0c7c7 (patch) | |
tree | 6d0043cf3b0b7734b8b98dd0d632309d94969c47 /sound/soc/soc-core.c | |
parent | 054880febeb890b24d705240384856ea6b3ccf7b (diff) |
ASoC: core: Support transparent CODEC<->CODEC DAI links
Rather than having the user half start a stream but avoid any DMA to
trigger data flow on links which don't pass through the CPU create a
DAPM route between the two DAI widgets using a hw_params configuration
provided by the machine driver with the new 'params' member of the
dai_link struct. If no configuration is provided in the dai_link then
use the old style even for CODEC<->CODEC links to avoid breaking
systems.
This greatly simplifies the userspace usage of such links, making them
as simple as analogue connections with the stream configuration being
completely transparent to them.
This is achieved by defining a new dai_link widget type which is created
when CODECs are linked and triggering the configuration of the link via
the normal PCM operations from there. It is expected that the bias
level callbacks will be used for clock configuration.
Currently only the DAI format, rate and channel count can be configured
and currently the only DAI operations which can be called are hw_params
and digital_mute(). This corresponds well to the majority of CODEC
drivers which only use other callbacks for constraint setting but there
is obviously much room for extension here. We can't simply call
hw_params() on startup as things like the system clocking configuration
may change at runtime and in future it will be desirable to offer some
configurability of the link parameters.
At present we are also restricted to a single DAPM link for the entire
DAI. Once we have better support for channel mapping it would also be
desirable to extend this feature so that we can propagate per-channel
power state over the link.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0caa8d9e685..77f35292f1b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1189,7 +1189,9 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order) struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; struct snd_soc_codec *codec = rtd->codec; struct snd_soc_platform *platform = rtd->platform; - struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dapm_widget *play_w, *capture_w; int ret; dev_dbg(card->dev, "probe %s dai link %d late %d\n", @@ -1270,12 +1272,39 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order) if (ret < 0) pr_warn("asoc: failed to add pmdown_time sysfs:%d\n", ret); - /* create the pcm */ - ret = soc_new_pcm(rtd, num); - if (ret < 0) { - pr_err("asoc: can't create pcm %s :%d\n", - dai_link->stream_name, ret); - return ret; + if (!dai_link->params) { + /* create the pcm */ + ret = soc_new_pcm(rtd, num); + if (ret < 0) { + pr_err("asoc: can't create pcm %s :%d\n", + dai_link->stream_name, ret); + return ret; + } + } else { + /* link the DAI widgets */ + play_w = codec_dai->playback_widget; + capture_w = cpu_dai->capture_widget; + if (play_w && capture_w) { + ret = snd_soc_dapm_new_pcm(card, dai_link->params, + capture_w, play_w); + if (ret != 0) { + dev_err(card->dev, "Can't link %s to %s: %d\n", + play_w->name, capture_w->name, ret); + return ret; + } + } + + play_w = cpu_dai->playback_widget; + capture_w = codec_dai->capture_widget; + if (play_w && capture_w) { + ret = snd_soc_dapm_new_pcm(card, dai_link->params, + capture_w, play_w); + if (ret != 0) { + dev_err(card->dev, "Can't link %s to %s: %d\n", + play_w->name, capture_w->name, ret); + return ret; + } + } } /* add platform data for AC97 devices */ |