From 08ae9b456d393dfd1bbe7619b994189be6a26449 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 6 Jan 2014 14:19:06 +0100 Subject: [PATCH 1/4] ASoC: dpcm: Add helper function for initializing runtime pcm We have the same code for initializing the runtime pcm on both the playback and the capture path. Factor this out into a common helper function. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 10f29a0ad5a6..b649e32791df 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1228,6 +1228,17 @@ unwind: return err; } +static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime, + struct snd_soc_pcm_stream *stream) +{ + runtime->hw.rate_min = stream->rate_min; + runtime->hw.rate_max = stream->rate_max; + runtime->hw.channels_min = stream->channels_min; + runtime->hw.channels_max = stream->channels_max; + runtime->hw.formats &= stream->formats; + runtime->hw.rates = stream->rates; +} + static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -1235,21 +1246,10 @@ static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream) struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw.rate_min = cpu_dai_drv->playback.rate_min; - runtime->hw.rate_max = cpu_dai_drv->playback.rate_max; - runtime->hw.channels_min = cpu_dai_drv->playback.channels_min; - runtime->hw.channels_max = cpu_dai_drv->playback.channels_max; - runtime->hw.formats &= cpu_dai_drv->playback.formats; - runtime->hw.rates = cpu_dai_drv->playback.rates; - } else { - runtime->hw.rate_min = cpu_dai_drv->capture.rate_min; - runtime->hw.rate_max = cpu_dai_drv->capture.rate_max; - runtime->hw.channels_min = cpu_dai_drv->capture.channels_min; - runtime->hw.channels_max = cpu_dai_drv->capture.channels_max; - runtime->hw.formats &= cpu_dai_drv->capture.formats; - runtime->hw.rates = cpu_dai_drv->capture.rates; - } + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback); + else + dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture); } static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream) From 002220a90db8ab9a6313887934dec25b54404cbd Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 6 Jan 2014 14:19:07 +0100 Subject: [PATCH 2/4] ASoC: dpcm: Allow PCMs to omit the set of supported formats Allow PCMs that do not impose any restrictions on the supported formats to set the formats field to 0, Instead of assuming that this means that the PCM does not support any formats (which doesn't make much sense), assume that it supports all formats. This brings the behavior of DPCM closer to that of non-DPCM. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b649e32791df..feb0f2843026 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1235,7 +1235,10 @@ static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime, runtime->hw.rate_max = stream->rate_max; runtime->hw.channels_min = stream->channels_min; runtime->hw.channels_max = stream->channels_max; - runtime->hw.formats &= stream->formats; + if (runtime->hw.formats) + runtime->hw.formats &= stream->formats; + else + runtime->hw.formats = stream->formats; runtime->hw.rates = stream->rates; } From dcf0fa27a56025793a700e81edd261ee3369e294 Mon Sep 17 00:00:00 2001 From: Jean-Francois Moine Date: Fri, 3 Jan 2014 09:19:18 +0100 Subject: [PATCH 3/4] ASoC: pcm: Fix lack of platform bespoke_trigger() call When the platform driver has no ops, the platform function bespoke_trigger() is no more called. The problem was introduced by the commit c5914b0aaea6494aaa9e415cbd32f8b7eb604af0 "ASoC: pcm: Check for ops before deferencing them" Signed-off-by: Jean-Francois Moine Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index feb0f2843026..d70eecd9e168 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -769,7 +769,7 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, return ret; } - if (platform->driver->ops && platform->driver->bespoke_trigger) { + if (platform->driver->bespoke_trigger) { ret = platform->driver->bespoke_trigger(substream, cmd); if (ret < 0) return ret; From 1104a9c822f0e9f5e57a236f20a142166dd8f91e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 15 Jan 2014 19:04:19 +0000 Subject: [PATCH 4/4] ASoC: core: Return -ENOTSUPP from set_sysclk() if no operation provided Make it easier for generic code to work with set_sysclk() by distinguishing between the operation not being supported and an error as is done for other operations like set_dai_fmt() Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 03c779ebd729..0ebf1dac330d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3484,7 +3484,7 @@ int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0, freq, dir); else - return -EINVAL; + return -ENOTSUPP; } EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); @@ -3505,7 +3505,7 @@ int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, return codec->driver->set_sysclk(codec, clk_id, source, freq, dir); else - return -EINVAL; + return -ENOTSUPP; } EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk);