All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier Moysan <olivier.moysan@st.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>, <perex@perex.cz>,
	<tiwai@suse.com>, <mcoquelin.stm32@gmail.com>,
	<alexandre.torgue@st.com>, <alsa-devel@alsa-project.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-kernel@vger.kernel.org>, <olivier.moysan@st.com>,
	<arnaud.pouliquen@st.com>, <benjamin.gaignard@st.com>
Subject: [PATCH 2/3] ASoC: stm32: i2s: improve channel capabilities handling
Date: Mon, 11 Mar 2019 16:26:29 +0100	[thread overview]
Message-ID: <1552317990-24219-3-git-send-email-olivier.moysan@st.com> (raw)
In-Reply-To: <1552317990-24219-1-git-send-email-olivier.moysan@st.com>

Use alsa snd_pcm_hw_constraint_single service to manage
channels restriction. This provides better status on driver
limitations, to the application.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
---
 sound/soc/stm/stm32_i2s.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 783b33497435..06bbbef74b3a 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -496,12 +496,6 @@ static int stm32_i2s_configure(struct snd_soc_dai *cpu_dai,
 	unsigned int fthlv;
 	int ret;
 
-	if ((params_channels(params) == 1) &&
-	    ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)) {
-		dev_err(cpu_dai->dev, "Mono mode supported only by DSP_A\n");
-		return -EINVAL;
-	}
-
 	switch (format) {
 	case 16:
 		cfgr = I2S_CGFR_DATLEN_SET(I2S_I2SMOD_DATLEN_16);
@@ -551,6 +545,10 @@ static int stm32_i2s_startup(struct snd_pcm_substream *substream,
 	i2s->substream = substream;
 	spin_unlock_irqrestore(&i2s->irq_lock, flags);
 
+	if ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)
+		snd_pcm_hw_constraint_single(substream->runtime,
+					     SNDRV_PCM_HW_PARAM_CHANNELS, 2);
+
 	ret = clk_prepare_enable(i2s->i2sclk);
 	if (ret < 0) {
 		dev_err(cpu_dai->dev, "Failed to enable clock: %d\n", ret);
-- 
2.7.4


WARNING: multiple messages have this Message-ID (diff)
From: Olivier Moysan <olivier.moysan@st.com>
To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, mcoquelin.stm32@gmail.com,
	alexandre.torgue@st.com, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org, olivier.moysan@st.com,
	arnaud.pouliquen@st.com, benjamin.gaignard@st.com
Subject: [PATCH 2/3] ASoC: stm32: i2s: improve channel capabilities handling
Date: Mon, 11 Mar 2019 16:26:29 +0100	[thread overview]
Message-ID: <1552317990-24219-3-git-send-email-olivier.moysan@st.com> (raw)
In-Reply-To: <1552317990-24219-1-git-send-email-olivier.moysan@st.com>

Use alsa snd_pcm_hw_constraint_single service to manage
channels restriction. This provides better status on driver
limitations, to the application.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
---
 sound/soc/stm/stm32_i2s.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 783b33497435..06bbbef74b3a 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -496,12 +496,6 @@ static int stm32_i2s_configure(struct snd_soc_dai *cpu_dai,
 	unsigned int fthlv;
 	int ret;
 
-	if ((params_channels(params) == 1) &&
-	    ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)) {
-		dev_err(cpu_dai->dev, "Mono mode supported only by DSP_A\n");
-		return -EINVAL;
-	}
-
 	switch (format) {
 	case 16:
 		cfgr = I2S_CGFR_DATLEN_SET(I2S_I2SMOD_DATLEN_16);
@@ -551,6 +545,10 @@ static int stm32_i2s_startup(struct snd_pcm_substream *substream,
 	i2s->substream = substream;
 	spin_unlock_irqrestore(&i2s->irq_lock, flags);
 
+	if ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)
+		snd_pcm_hw_constraint_single(substream->runtime,
+					     SNDRV_PCM_HW_PARAM_CHANNELS, 2);
+
 	ret = clk_prepare_enable(i2s->i2sclk);
 	if (ret < 0) {
 		dev_err(cpu_dai->dev, "Failed to enable clock: %d\n", ret);
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Olivier Moysan <olivier.moysan@st.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>, <perex@perex.cz>,
	<tiwai@suse.com>, <mcoquelin.stm32@gmail.com>,
	<alexandre.torgue@st.com>, <alsa-devel@alsa-project.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-kernel@vger.kernel.org>, <olivier.moysan@st.com>,
	<arnaud.pouliquen@st.com>, <benjamin.gaignard@st.com>
Subject: [PATCH 2/3] ASoC: stm32: i2s: improve channel capabilities handling
Date: Mon, 11 Mar 2019 16:26:29 +0100	[thread overview]
Message-ID: <1552317990-24219-3-git-send-email-olivier.moysan@st.com> (raw)
In-Reply-To: <1552317990-24219-1-git-send-email-olivier.moysan@st.com>

Use alsa snd_pcm_hw_constraint_single service to manage
channels restriction. This provides better status on driver
limitations, to the application.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
---
 sound/soc/stm/stm32_i2s.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 783b33497435..06bbbef74b3a 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -496,12 +496,6 @@ static int stm32_i2s_configure(struct snd_soc_dai *cpu_dai,
 	unsigned int fthlv;
 	int ret;
 
-	if ((params_channels(params) == 1) &&
-	    ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)) {
-		dev_err(cpu_dai->dev, "Mono mode supported only by DSP_A\n");
-		return -EINVAL;
-	}
-
 	switch (format) {
 	case 16:
 		cfgr = I2S_CGFR_DATLEN_SET(I2S_I2SMOD_DATLEN_16);
@@ -551,6 +545,10 @@ static int stm32_i2s_startup(struct snd_pcm_substream *substream,
 	i2s->substream = substream;
 	spin_unlock_irqrestore(&i2s->irq_lock, flags);
 
+	if ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)
+		snd_pcm_hw_constraint_single(substream->runtime,
+					     SNDRV_PCM_HW_PARAM_CHANNELS, 2);
+
 	ret = clk_prepare_enable(i2s->i2sclk);
 	if (ret < 0) {
 		dev_err(cpu_dai->dev, "Failed to enable clock: %d\n", ret);
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-03-11 15:27 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 15:26 [PATCH 0/3] ASoC: stm32: i2s: add minor improvements Olivier Moysan
2019-03-11 15:26 ` Olivier Moysan
2019-03-11 15:26 ` Olivier Moysan
2019-03-11 15:26 ` [PATCH 1/3] ASoC: stm32: i2s: change trigger traces Olivier Moysan
2019-03-11 15:26   ` Olivier Moysan
2019-03-11 15:26   ` Olivier Moysan
2019-03-11 17:23   ` Applied "ASoC: stm32: i2s: change trigger traces" to the asoc tree Mark Brown
2019-03-11 17:23     ` Mark Brown
2019-03-11 17:23     ` Mark Brown
2019-03-13 15:38   ` Mark Brown
2019-03-13 15:38     ` Mark Brown
2019-03-13 15:38     ` Mark Brown
2019-03-14 15:53   ` Mark Brown
2019-03-14 15:53     ` Mark Brown
2019-03-14 15:53     ` Mark Brown
2019-03-11 15:26 ` Olivier Moysan [this message]
2019-03-11 15:26   ` [PATCH 2/3] ASoC: stm32: i2s: improve channel capabilities handling Olivier Moysan
2019-03-11 15:26   ` Olivier Moysan
2019-03-11 17:23   ` Applied "ASoC: stm32: i2s: improve channel capabilities handling" to the asoc tree Mark Brown
2019-03-11 17:23     ` Mark Brown
2019-03-11 17:23     ` Mark Brown
2019-03-13 15:38   ` Mark Brown
2019-03-13 15:38     ` Mark Brown
2019-03-13 15:38     ` Mark Brown
2019-03-14 15:53   ` Mark Brown
2019-03-14 15:53     ` Mark Brown
2019-03-14 15:53     ` Mark Brown
2019-03-11 15:26 ` [PATCH 3/3] ASoC: stm32: i2s: use default dai name Olivier Moysan
2019-03-11 15:26   ` Olivier Moysan
2019-03-11 15:26   ` Olivier Moysan
2019-03-11 17:23   ` Applied "ASoC: stm32: i2s: use default dai name" to the asoc tree Mark Brown
2019-03-11 17:23     ` Mark Brown
2019-03-11 17:23     ` Mark Brown
2019-03-13 15:38   ` Mark Brown
2019-03-13 15:38     ` Mark Brown
2019-03-13 15:38     ` Mark Brown
2019-03-14 15:53   ` Mark Brown
2019-03-14 15:53     ` Mark Brown
2019-03-14 15:53     ` 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=1552317990-24219-3-git-send-email-olivier.moysan@st.com \
    --to=olivier.moysan@st.com \
    --cc=alexandre.torgue@st.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnaud.pouliquen@st.com \
    --cc=benjamin.gaignard@st.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.