From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 3/6] ASoC: soc-pcm: add soc_pcm_set_dai_params()
Date: 11 Dec 2020 14:55:27 +0900 [thread overview]
Message-ID: <87y2i47uyw.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87360c99kb.wl-kuninori.morimoto.gx@renesas.com>
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Getting rate/channels/sample_bits from param needs fixed method.
This patch adds new soc_pcm_set_dai_params() and replace existing code.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-pcm.c | 52 +++++++++++++++++++++++----------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 713fa202c67b..98a47fc43923 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -329,6 +329,20 @@ int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
return 0;
}
+static void soc_pcm_set_dai_params(struct snd_soc_dai *dai,
+ struct snd_pcm_hw_params *params)
+{
+ if (params) {
+ dai->rate = params_rate(params);
+ dai->channels = params_channels(params);
+ dai->sample_bits = snd_pcm_format_physical_width(params_format(params));
+ } else {
+ dai->rate = 0;
+ dai->channels = 0;
+ dai->sample_bits = 0;
+ }
+}
+
static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
struct snd_soc_dai *soc_dai)
{
@@ -390,13 +404,12 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_dai d;
struct snd_soc_dai *dai;
struct snd_soc_dai *cpu_dai;
- unsigned int rate, channels, sample_bits, symmetry, i;
+ unsigned int symmetry, i;
- rate = params_rate(params);
- channels = params_channels(params);
- sample_bits = snd_pcm_format_physical_width(params_format(params));
+ soc_pcm_set_dai_params(&d, params);
/* reject unmatched parameters when applying symmetry */
symmetry = rtd->dai_link->symmetric_rates;
@@ -406,9 +419,9 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
if (symmetry) {
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
- if (cpu_dai->rate && cpu_dai->rate != rate) {
+ if (cpu_dai->rate && cpu_dai->rate != d.rate) {
dev_err(rtd->dev, "ASoC: unmatched rate symmetry: %d - %d\n",
- cpu_dai->rate, rate);
+ cpu_dai->rate, d.rate);
return -EINVAL;
}
}
@@ -422,9 +435,9 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
if (symmetry) {
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (cpu_dai->channels &&
- cpu_dai->channels != channels) {
+ cpu_dai->channels != d.channels) {
dev_err(rtd->dev, "ASoC: unmatched channel symmetry: %d - %d\n",
- cpu_dai->channels, channels);
+ cpu_dai->channels, d.channels);
return -EINVAL;
}
}
@@ -438,9 +451,9 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
if (symmetry) {
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (cpu_dai->sample_bits &&
- cpu_dai->sample_bits != sample_bits) {
+ cpu_dai->sample_bits != d.sample_bits) {
dev_err(rtd->dev, "ASoC: unmatched sample bits symmetry: %d - %d\n",
- cpu_dai->sample_bits, sample_bits);
+ cpu_dai->sample_bits, d.sample_bits);
return -EINVAL;
}
}
@@ -898,11 +911,8 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback)
for_each_rtd_dais(rtd, i, dai) {
int active = snd_soc_dai_stream_active(dai, substream->stream);
- if (snd_soc_dai_active(dai) == 1) {
- dai->rate = 0;
- dai->channels = 0;
- dai->sample_bits = 0;
- }
+ if (snd_soc_dai_active(dai) == 1)
+ soc_pcm_set_dai_params(dai, NULL);
if (active == 1)
snd_soc_dai_digital_mute(dai, 1, substream->stream);
@@ -999,11 +1009,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
if(ret < 0)
goto out;
- codec_dai->rate = params_rate(&codec_params);
- codec_dai->channels = params_channels(&codec_params);
- codec_dai->sample_bits = snd_pcm_format_physical_width(
- params_format(&codec_params));
-
+ soc_pcm_set_dai_params(codec_dai, &codec_params);
snd_soc_dapm_update_dai(substream, &codec_params, codec_dai);
}
@@ -1020,11 +1026,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
goto out;
/* store the parameters for each DAI */
- cpu_dai->rate = params_rate(params);
- cpu_dai->channels = params_channels(params);
- cpu_dai->sample_bits =
- snd_pcm_format_physical_width(params_format(params));
-
+ soc_pcm_set_dai_params(cpu_dai, params);
snd_soc_dapm_update_dai(substream, params, cpu_dai);
}
--
2.25.1
next prev parent reply other threads:[~2020-12-11 5:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 5:54 [PATCH 0/6] ASoC: soc-pcm: cleanup code Kuninori Morimoto
2020-12-11 5:55 ` [PATCH 1/6] ASoC: soc-pcm: move dpcm_set_fe_update_state() Kuninori Morimoto
2020-12-11 5:55 ` [PATCH 2/6] ASoC: soc-pcm: add dpcm_set_be_update_state() Kuninori Morimoto
2020-12-11 5:55 ` Kuninori Morimoto [this message]
2020-12-11 5:55 ` [PATCH 4/6] ASoC: soc-pcm: cleanup soc_pcm_apply_symmetry() Kuninori Morimoto
2020-12-11 5:55 ` [PATCH 5/6] ASoC: soc-pcm: cleanup soc_pcm_params_symmetry() Kuninori Morimoto
2020-12-18 6:51 ` Kuninori Morimoto
2020-12-11 5:55 ` [PATCH 6/6] ASoC: soc-pcm: setup pcm at one place in soc_new_pcm() Kuninori Morimoto
2021-01-13 15:26 ` (subset) [PATCH 0/6] ASoC: soc-pcm: cleanup code Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2i47uyw.wl-kuninori.morimoto.gx@renesas.com \
--to=kuninori.morimoto.gx@renesas.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).