[alsa-devel] [PATCH 0/2 v2] ASoC: DPCM can care FE/BE merged format
Hi Mark
These are v2 patches of new .dpcm_merged_foramt for merging FE/BE formats. It will be no sound if DPCM were below style, and user selects S24_LE.
FE: S16_LE/S24_LE BE: S16_LE
DPCM will selects FE/BE merged formats (= S16_LE here) if FE has .dpcm_merged_foramt.
Kuninori Morimoto (2): ASoC: soc-pcm: DPCM cares BE format ASoC: rsnd: rsrc-card uses FE/BE merged format when DPCM
include/sound/soc.h | 3 +++ sound/soc/sh/rcar/rsrc-card.c | 1 + sound/soc/soc-pcm.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 5 deletions(-)
Best regards --- Kuninori Morimoto _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current DPCM is caring only FE format. but it will be no sound if FE/BE was below style, and user selects S24_LE format.
FE: S16_LE/S24_LE BE: S16_LE
DPCM can rewrite the format, so basically we don't want to constrain with the BE constraints. But sometimes it will be trouble. This patch adds new .dpcm_merged_format on struct snd_soc_dai_link. DPCM will use FE / BE merged format if .struct snd_soc_dai_link has it. We can have other .dpcm_merged_xxx in the future
.dpcm_merged_foramt .dpcm_merged_rate .dpcm_merged_chan
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Tested-by: Keita Kobayashi keita.kobayashi.ym@renesas.com --- v1 -> v2
- foramt -> format - Tested by Keita
include/sound/soc.h | 3 +++ sound/soc/soc-pcm.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 28b8ae6..f10f48f 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1006,6 +1006,9 @@ struct snd_soc_dai_link { unsigned int dpcm_capture:1; unsigned int dpcm_playback:1;
+ /* DPCM used FE & BE merged format */ + unsigned int dpcm_merged_format:1; + /* pmdown_time is ignored at stop */ unsigned int ignore_pmdown_time:1; }; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 35fe58f4..256b9c9 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1485,30 +1485,67 @@ unwind: }
static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime, - struct snd_soc_pcm_stream *stream) + struct snd_soc_pcm_stream *stream, + u64 formats) { 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; if (runtime->hw.formats) - runtime->hw.formats &= stream->formats; + runtime->hw.formats &= formats & stream->formats; else - runtime->hw.formats = stream->formats; + runtime->hw.formats = formats & stream->formats; runtime->hw.rates = stream->rates; }
+static u64 dpcm_runtime_base_format(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *fe = substream->private_data; + struct snd_soc_dpcm *dpcm; + u64 formats = ULLONG_MAX; + int stream = substream->stream; + + if (!fe->dai_link->dpcm_merged_format) + return formats; + + /* + * It returns merged BE codec format + * if FE want to use it (= dpcm_merged_format) + */ + + list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) { + struct snd_soc_pcm_runtime *be = dpcm->be; + struct snd_soc_dai_driver *codec_dai_drv; + struct snd_soc_pcm_stream *codec_stream; + int i; + + for (i = 0; i < be->num_codecs; i++) { + codec_dai_drv = be->codec_dais[i]->driver; + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + codec_stream = &codec_dai_drv->playback; + else + codec_stream = &codec_dai_drv->capture; + + formats &= codec_stream->formats; + } + } + + return formats; +} + static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver; + u64 format = dpcm_runtime_base_format(substream);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback); + dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback, format); else - dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture); + dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture, format); }
static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd);
On Tue, May 12, 2015 at 02:03:33AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current DPCM is caring only FE format. but it will be no sound if FE/BE was below style, and user selects S24_LE format.
Applied, thanks.
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Tested-by: Keita Kobayashi keita.kobayashi.ym@renesas.com --- v1 -> v2
- no change
sound/soc/sh/rcar/rsrc-card.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index a68517a..050b0db 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -232,6 +232,7 @@ rsrc_card_sub_parse_of(struct rsrc_card_priv *priv, if (args_count) { *args_count = args.args_count; dai_link->dynamic = 1; + dai_link->dpcm_merged_format = 1; } else { dai_link->no_pcm = 1; priv->codec_conf.of_node = (*p_node);
On Tue, May 12, 2015 at 02:03:51AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Applied, thanks.
Hi Mark
Do I need to re-send these patches ?
These are v2 patches of new .dpcm_merged_foramt for merging FE/BE formats. It will be no sound if DPCM were below style, and user selects S24_LE.
FE: S16_LE/S24_LE BE: S16_LE
DPCM will selects FE/BE merged formats (= S16_LE here) if FE has .dpcm_merged_foramt.
Kuninori Morimoto (2): ASoC: soc-pcm: DPCM cares BE format ASoC: rsnd: rsrc-card uses FE/BE merged format when DPCM
include/sound/soc.h | 3 +++ sound/soc/sh/rcar/rsrc-card.c | 1 + sound/soc/soc-pcm.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 5 deletions(-)
Best regards
Kuninori Morimoto _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (2)
-
Kuninori Morimoto
-
Mark Brown