Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
@ 2020-10-27  1:50 Kuninori Morimoto
  2020-10-27  1:51 ` [PATCH 1/2] " Kuninori Morimoto
  2020-10-27  1:51 ` [PATCH 2/2] ASoC: soc-compress: add soc_compr_cstream_to_stream() Kuninori Morimoto
  0 siblings, 2 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2020-10-27  1:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

soc-compress is using both SNDRV_PCM_STREAM_xxx and SND_COMPRESS_xxx.
It needs to be converted, but some of them didn't.
This is bug, but this bug does nothing because these are using
same value.
This patch-set cleanup these.

Kuninori Morimoto (2):
  ASoC: soc-compress: tidyup STREAM vs COMPRESS
  ASoC: soc-compress: add soc_compr_cstream_to_stream()

 sound/soc/soc-compress.c | 65 ++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 40 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-27  1:50 [PATCH 0/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS Kuninori Morimoto
@ 2020-10-27  1:51 ` Kuninori Morimoto
  2020-10-27 16:05   ` Pierre-Louis Bossart
  2020-10-27  1:51 ` [PATCH 2/2] ASoC: soc-compress: add soc_compr_cstream_to_stream() Kuninori Morimoto
  1 sibling, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2020-10-27  1:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_runtime_activate() and
snd_soc_dai_digital_mute() need SNDRV_PCM_STREAM_xxx
instead of SND_COMPRESS_xxx.

These are bug but nothing happen because these are same value.

	enum {
		SNDRV_PCM_STREAM_PLAYBACK = 0,
		SNDRV_PCM_STREAM_CAPTURE,
		...
	};

	enum snd_compr_direction {
		SND_COMPRESS_PLAYBACK = 0,
		SND_COMPRESS_CAPTURE
	};

This patch tidyup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-compress.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 3a6a60215e81..52544a85725d 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -75,8 +75,14 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_component *component = NULL;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+	int stream;
 	int ret;
 
+	if (cstream->direction == SND_COMPRESS_PLAYBACK)
+		stream = SNDRV_PCM_STREAM_PLAYBACK;
+	else
+		stream = SNDRV_PCM_STREAM_CAPTURE;
+
 	ret = snd_soc_pcm_component_pm_runtime_get(rtd, cstream);
 	if (ret < 0)
 		goto pm_err;
@@ -95,7 +101,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	if (ret < 0)
 		goto machine_err;
 
-	snd_soc_runtime_activate(rtd, cstream->direction);
+	snd_soc_runtime_activate(rtd, stream);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 
@@ -208,7 +214,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 
 	snd_soc_runtime_deactivate(rtd, stream);
 
-	snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
+	snd_soc_dai_digital_mute(codec_dai, 1, stream);
 
 	if (!snd_soc_dai_active(cpu_dai))
 		cpu_dai->rate = 0;
@@ -304,10 +310,16 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+	int stream;
 	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
+	if (cstream->direction == SND_COMPRESS_PLAYBACK)
+		stream = SNDRV_PCM_STREAM_PLAYBACK;
+	else
+		stream = SNDRV_PCM_STREAM_CAPTURE;
+
 	ret = soc_compr_components_trigger(cstream, cmd);
 	if (ret < 0)
 		goto out;
@@ -318,10 +330,10 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		snd_soc_dai_digital_mute(codec_dai, 0, cstream->direction);
+		snd_soc_dai_digital_mute(codec_dai, 0, stream);
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
-		snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
+		snd_soc_dai_digital_mute(codec_dai, 1, stream);
 		break;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] ASoC: soc-compress: add soc_compr_cstream_to_stream()
  2020-10-27  1:50 [PATCH 0/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS Kuninori Morimoto
  2020-10-27  1:51 ` [PATCH 1/2] " Kuninori Morimoto
@ 2020-10-27  1:51 ` Kuninori Morimoto
  1 sibling, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2020-10-27  1:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc-compress.c exchanges SND_COMPRESS_XXX to SNDRV_PCM_STREAM_xxx
at many place. This patch adds soc_compr_cstream_to_stream()
and reduce duplicate code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-compress.c | 69 ++++++++++++----------------------------
 1 file changed, 21 insertions(+), 48 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 52544a85725d..5a5f4d8fbf18 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -22,6 +22,14 @@
 #include <sound/soc-link.h>
 #include <linux/pm_runtime.h>
 
+static int soc_compr_cstream_to_stream(struct snd_compr_stream *cstream)
+{
+	if (cstream->direction == SND_COMPRESS_PLAYBACK)
+		return SNDRV_PCM_STREAM_PLAYBACK;
+	else
+		return SNDRV_PCM_STREAM_CAPTURE;
+}
+
 static int soc_compr_components_open(struct snd_compr_stream *cstream,
 				     struct snd_soc_component **last)
 {
@@ -75,14 +83,9 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_component *component = NULL;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-	int stream;
+	int stream = soc_compr_cstream_to_stream(cstream);
 	int ret;
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
-
 	ret = snd_soc_pcm_component_pm_runtime_get(rtd, cstream);
 	if (ret < 0)
 		goto pm_err;
@@ -128,14 +131,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
 	struct snd_soc_dpcm *dpcm;
 	struct snd_soc_dapm_widget_list *list;
-	int stream;
+	int stream = soc_compr_cstream_to_stream(cstream);
 	int ret;
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
-
 	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
 	fe->dpcm[stream].runtime = fe_substream->runtime;
 
@@ -203,15 +201,10 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
-	int stream;
+	int stream = soc_compr_cstream_to_stream(cstream);
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
-
 	snd_soc_runtime_deactivate(rtd, stream);
 
 	snd_soc_dai_digital_mute(codec_dai, 1, stream);
@@ -242,15 +235,11 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
 	struct snd_soc_dpcm *dpcm;
-	int stream, ret;
+	int stream = soc_compr_cstream_to_stream(cstream);
+	int ret;
 
 	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
-
 	snd_soc_runtime_deactivate(fe, stream);
 
 	fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
@@ -310,16 +299,11 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-	int stream;
+	int stream = soc_compr_cstream_to_stream(cstream);
 	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
-
 	ret = soc_compr_components_trigger(cstream, cmd);
 	if (ret < 0)
 		goto out;
@@ -346,17 +330,14 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
-	int ret, stream;
+	int stream = soc_compr_cstream_to_stream(cstream);
+	int ret;
+
 
 	if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
 	    cmd == SND_COMPR_TRIGGER_DRAIN)
 		return soc_compr_components_trigger(cstream, cmd);
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
-
 	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
 
 	ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
@@ -418,6 +399,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+	int stream = soc_compr_cstream_to_stream(cstream);
 	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -441,12 +423,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto err;
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
-					  SND_SOC_DAPM_STREAM_START);
-	else
-		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
-					  SND_SOC_DAPM_STREAM_START);
+	snd_soc_dapm_stream_event(rtd, stream, SND_SOC_DAPM_STREAM_START);
 
 	/* cancel any delayed stream shutdown that is pending */
 	rtd->pop_wait = 0;
@@ -468,12 +445,8 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 	struct snd_pcm_substream *fe_substream =
 		 fe->pcm->streams[cstream->direction].substream;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
-	int ret, stream;
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		stream = SNDRV_PCM_STREAM_PLAYBACK;
-	else
-		stream = SNDRV_PCM_STREAM_CAPTURE;
+	int stream = soc_compr_cstream_to_stream(cstream);
+	int ret;
 
 	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-27  1:51 ` [PATCH 1/2] " Kuninori Morimoto
@ 2020-10-27 16:05   ` Pierre-Louis Bossart
  2020-10-28 23:23     ` Kuninori Morimoto
  0 siblings, 1 reply; 10+ messages in thread
From: Pierre-Louis Bossart @ 2020-10-27 16:05 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA



On 10/26/20 8:51 PM, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> snd_soc_runtime_activate() and
> snd_soc_dai_digital_mute() need SNDRV_PCM_STREAM_xxx
> instead of SND_COMPRESS_xxx.
> 
> These are bug but nothing happen because these are same value.
> 
> 	enum {
> 		SNDRV_PCM_STREAM_PLAYBACK = 0,
> 		SNDRV_PCM_STREAM_CAPTURE,
> 		...
> 	};
> 
> 	enum snd_compr_direction {
> 		SND_COMPRESS_PLAYBACK = 0,
> 		SND_COMPRESS_CAPTURE
> 	};
> 
> This patch tidyup it.


Could we use this instead:

enum snd_compr_direction {
	SND_COMPRESS_PLAYBACK = SNDRV_PCM_STREAM_PLAYBACK,
	SND_COMPRESS_CAPTURE = SNDRV_PCM_STREAM_CAPTURE
};

Or remove this duplication completely and get rid of snd_compr_direction?

I find it odd to convert two things that had no reason to be different 
in the first place.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-27 16:05   ` Pierre-Louis Bossart
@ 2020-10-28 23:23     ` Kuninori Morimoto
  2020-10-28 23:43       ` Kuninori Morimoto
  0 siblings, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2020-10-28 23:23 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: Linux-ALSA, Mark Brown


Hi Pierre-Louis
Cc Mark

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > snd_soc_runtime_activate() and
> > snd_soc_dai_digital_mute() need SNDRV_PCM_STREAM_xxx
> > instead of SND_COMPRESS_xxx.
> > 
> > These are bug but nothing happen because these are same value.
> > 
> > 	enum {
> > 		SNDRV_PCM_STREAM_PLAYBACK = 0,
> > 		SNDRV_PCM_STREAM_CAPTURE,
> > 		...
> > 	};
> > 
> > 	enum snd_compr_direction {
> > 		SND_COMPRESS_PLAYBACK = 0,
> > 		SND_COMPRESS_CAPTURE
> > 	};
> > 
> > This patch tidyup it.
> 
> 
> Could we use this instead:
> 
> enum snd_compr_direction {
> 	SND_COMPRESS_PLAYBACK = SNDRV_PCM_STREAM_PLAYBACK,
> 	SND_COMPRESS_CAPTURE = SNDRV_PCM_STREAM_CAPTURE
> };
> 
> Or remove this duplication completely and get rid of snd_compr_direction?
> 
> I find it odd to convert two things that had no reason to be different
> in the first place.

Yes I agree with you.
I'm not sure why this duplication was created,
but my patch tried to make it sane.
If Mark can agree, I can post snd_compr_direction remove patch.


Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-28 23:23     ` Kuninori Morimoto
@ 2020-10-28 23:43       ` Kuninori Morimoto
  2020-10-29  7:04         ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2020-10-28 23:43 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: Linux-ALSA, Mark Brown


Hi Pierre-Louis, again

> > enum snd_compr_direction {
> > 	SND_COMPRESS_PLAYBACK = SNDRV_PCM_STREAM_PLAYBACK,
> > 	SND_COMPRESS_CAPTURE = SNDRV_PCM_STREAM_CAPTURE
> > };
> > 
> > Or remove this duplication completely and get rid of snd_compr_direction?
> > 
> > I find it odd to convert two things that had no reason to be different
> > in the first place.
> 
> Yes I agree with you.
> I'm not sure why this duplication was created,
> but my patch tried to make it sane.
> If Mark can agree, I can post snd_compr_direction remove patch.

Oops, snd_compr_direction was uapi.
We can't remove it, and can't use your above suggestion...

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-28 23:43       ` Kuninori Morimoto
@ 2020-10-29  7:04         ` Takashi Iwai
  2020-10-29 15:33           ` Pierre-Louis Bossart
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2020-10-29  7:04 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown, Pierre-Louis Bossart

On Thu, 29 Oct 2020 00:43:08 +0100,
Kuninori Morimoto wrote:
> 
> 
> Hi Pierre-Louis, again
> 
> > > enum snd_compr_direction {
> > > 	SND_COMPRESS_PLAYBACK = SNDRV_PCM_STREAM_PLAYBACK,
> > > 	SND_COMPRESS_CAPTURE = SNDRV_PCM_STREAM_CAPTURE
> > > };
> > > 
> > > Or remove this duplication completely and get rid of snd_compr_direction?
> > > 
> > > I find it odd to convert two things that had no reason to be different
> > > in the first place.
> > 
> > Yes I agree with you.
> > I'm not sure why this duplication was created,
> > but my patch tried to make it sane.
> > If Mark can agree, I can post snd_compr_direction remove patch.
> 
> Oops, snd_compr_direction was uapi.
> We can't remove it, and can't use your above suggestion...

Right, such uapi can't be removed.

Essentially both compress and PCM definitions are identical, and can
be never different because of ABI compatibility, which means it's safe
to mix both variants in the code.  If you're unsure, we may add
BUILD_BUG_ON() to check the coincidence of both values.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-29  7:04         ` Takashi Iwai
@ 2020-10-29 15:33           ` Pierre-Louis Bossart
  2020-10-29 16:47             ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Pierre-Louis Bossart @ 2020-10-29 15:33 UTC (permalink / raw)
  To: Takashi Iwai, Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown




>>>> enum snd_compr_direction {
>>>> 	SND_COMPRESS_PLAYBACK = SNDRV_PCM_STREAM_PLAYBACK,
>>>> 	SND_COMPRESS_CAPTURE = SNDRV_PCM_STREAM_CAPTURE
>>>> };
>>>>
>>>> Or remove this duplication completely and get rid of snd_compr_direction?
>>>>
>>>> I find it odd to convert two things that had no reason to be different
>>>> in the first place.
>>>
>>> Yes I agree with you.
>>> I'm not sure why this duplication was created,
>>> but my patch tried to make it sane.
>>> If Mark can agree, I can post snd_compr_direction remove patch.
>>
>> Oops, snd_compr_direction was uapi.
>> We can't remove it, and can't use your above suggestion...

I knew I was missing something... Thanks for correcting my flawed assertion.

> Right, such uapi can't be removed.
> 
> Essentially both compress and PCM definitions are identical, and can
> be never different because of ABI compatibility, which means it's safe
> to mix both variants in the code.  If you're unsure, we may add
> BUILD_BUG_ON() to check the coincidence of both values.


In case we add this BUILD_BUG_ON(), can we keep the code as is then, 
there's no need to convert values?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-29 15:33           ` Pierre-Louis Bossart
@ 2020-10-29 16:47             ` Takashi Iwai
  2020-10-30  0:48               ` Kuninori Morimoto
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2020-10-29 16:47 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: Linux-ALSA, Mark Brown, Kuninori Morimoto

On Thu, 29 Oct 2020 16:33:35 +0100,
Pierre-Louis Bossart wrote:
> 
> 
> 
> 
> >>>> enum snd_compr_direction {
> >>>> 	SND_COMPRESS_PLAYBACK = SNDRV_PCM_STREAM_PLAYBACK,
> >>>> 	SND_COMPRESS_CAPTURE = SNDRV_PCM_STREAM_CAPTURE
> >>>> };
> >>>>
> >>>> Or remove this duplication completely and get rid of snd_compr_direction?
> >>>>
> >>>> I find it odd to convert two things that had no reason to be different
> >>>> in the first place.
> >>>
> >>> Yes I agree with you.
> >>> I'm not sure why this duplication was created,
> >>> but my patch tried to make it sane.
> >>> If Mark can agree, I can post snd_compr_direction remove patch.
> >>
> >> Oops, snd_compr_direction was uapi.
> >> We can't remove it, and can't use your above suggestion...
> 
> I knew I was missing something... Thanks for correcting my flawed assertion.
> 
> > Right, such uapi can't be removed.
> >
> > Essentially both compress and PCM definitions are identical, and can
> > be never different because of ABI compatibility, which means it's safe
> > to mix both variants in the code.  If you're unsure, we may add
> > BUILD_BUG_ON() to check the coincidence of both values.
> 
> 
> In case we add this BUILD_BUG_ON(), can we keep the code as is then,
> there's no need to convert values?

Unless any strong type is used, it should be fine as is.
BUILD_BUG_ON() would catch if the value is changed inconsistently.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS
  2020-10-29 16:47             ` Takashi Iwai
@ 2020-10-30  0:48               ` Kuninori Morimoto
  0 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2020-10-30  0:48 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Linux-ALSA, Mark Brown, Pierre-Louis Bossart


Hi

> > > Right, such uapi can't be removed.
> > >
> > > Essentially both compress and PCM definitions are identical, and can
> > > be never different because of ABI compatibility, which means it's safe
> > > to mix both variants in the code.  If you're unsure, we may add
> > > BUILD_BUG_ON() to check the coincidence of both values.
> > 
> > 
> > In case we add this BUILD_BUG_ON(), can we keep the code as is then,
> > there's no need to convert values?
> 
> Unless any strong type is used, it should be fine as is.
> BUILD_BUG_ON() would catch if the value is changed inconsistently.

OK, Thanks.
v2 Will use BUILD_BUG_ON().

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-30  0:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-27  1:50 [PATCH 0/2] ASoC: soc-compress: tidyup STREAM vs COMPRESS Kuninori Morimoto
2020-10-27  1:51 ` [PATCH 1/2] " Kuninori Morimoto
2020-10-27 16:05   ` Pierre-Louis Bossart
2020-10-28 23:23     ` Kuninori Morimoto
2020-10-28 23:43       ` Kuninori Morimoto
2020-10-29  7:04         ` Takashi Iwai
2020-10-29 15:33           ` Pierre-Louis Bossart
2020-10-29 16:47             ` Takashi Iwai
2020-10-30  0:48               ` Kuninori Morimoto
2020-10-27  1:51 ` [PATCH 2/2] ASoC: soc-compress: add soc_compr_cstream_to_stream() Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox