Skip to contentSkip to conversation

ASoC: sti: correction for HBRA support

PATCH NAK Moise Gergaud 3 participants 16 messages Dec 2, 2015 – Dec 9, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: sti: correction for HBRA support

This patchset is V2 of "[PATCH 2/2] ASoC: sti: correction for HBRA support"

Moise Gergaud (3):
ALSA: pcm: add IEC958 channel status update
ASoC: sti: use pcm iec958 channel status helper
ASoC: sti: correction for HBRA (High Bit Rate Audio) support

 include/sound/pcm_iec958.h      | 19 ++++++++-
 sound/core/pcm_iec958.c         | 78 +++++++++++++++++++++++++------------
 sound/soc/sti/Kconfig           |  1 +
 sound/soc/sti/uniperif_player.c | 86 +++++++++++++++++------------------------
 4 files changed, 107 insertions(+), 77 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 ALSA: pcm: add IEC958 channel status update

Add a helper to update only the IEC958 channel status sampling freq and word length parameters from an ALSA snd_pcm_runtime structure, taking account of the sample rate and sample size.

---
 include/sound/pcm_iec958.h | 19 ++++++++++-
 sound/core/pcm_iec958.c    | 78 +++++++++++++++++++++++++++++++---------------
 2 files changed, 71 insertions(+), 26 deletions(-)
include/sound/pcm_iec958.h +18 -1
index 0eed397..0c84c69 100644
@@ -3,7 +3,24 @@
 
 #include <linux/types.h>
 
+#ifdef CONFIG_SND_PCM_IEC958
 int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
-	size_t len);
+				   size_t len);
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len);
+#else
+int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
+{
+	return len;
+}
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
+{
+	return len;
+}
+#endif
 
 #endif
sound/core/pcm_iec958.c +53 -25

135 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 29 lines · Moise Gergaud

Add a helper to update only the IEC958 channel status sampling freq and word length parameters from an ALSA snd_pcm_runtime structure, taking account of the sample rate and sample size.

---
 include/sound/pcm_iec958.h | 19 ++++++++++-
 sound/core/pcm_iec958.c    | 78 +++++++++++++++++++++++++++++++---------------
 2 files changed, 71 insertions(+), 26 deletions(-)
include/sound/pcm_iec958.h +7 -1
index 0eed397..0c84c69 100644
@@ -3,7 +3,24 @@
 
 #include <linux/types.h>
 
+#ifdef CONFIG_SND_PCM_IEC958
 int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
-	size_t len);
+				   size_t len);
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len);
+#else
+int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,

include/sound/pcm_iec958.h line 23

Quoted 10 lines
include/sound/pcm_iec958.h +10 -0
+				   size_t len)
+{
+	return len;
+}
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
+{
+	return len;
+}

These must be static inline.
And, shouldn't they return an error?

Takashi

#3 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

In reply to Moise Gergaud
Quoted 6 lines · Moise Gergaud

Add a helper to update only the IEC958 channel status sampling freq and word length parameters from an ALSA snd_pcm_runtime structure, taking account of the sample rate and sample size.

NAK.

Quoted 17 lines
include/sound/pcm_iec958.h +7 -1
index 0eed397..0c84c69 100644
@@ -3,7 +3,24 @@
 
 #include <linux/types.h>
 
+#ifdef CONFIG_SND_PCM_IEC958
 int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
-	size_t len);
+				   size_t len);
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len);
+#else
+int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,

include/sound/pcm_iec958.h line 23

Quoted 10 lines
include/sound/pcm_iec958.h +10 -0
+				   size_t len)
+{
+	return len;
+}
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
+{
+	return len;
+}

Firstly, this is dangerous. If you don't have anything defined here, then the channel status ends up being undefined.

The intention here is that if you're a user of this, then select the config symbol. That makes providing stubs totally unnecessary and removes this problem.

Quoted 64 lines
include/sound/pcm_iec958.h +1 -0
+#endif
 
 #endif
sound/core/pcm_iec958.c +17 -15
index 36b2d7a..abe3967 100644
@@ -11,67 +11,72 @@
 #include <sound/pcm.h>
 #include <sound/pcm_iec958.h>
 
-/**
- * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status
+/*
+ * snd_pcm_update_iec958_consumer - update consumer format IEC958 channel status
  * @runtime: pcm runtime structure with ->rate filled in
  * @cs: channel status buffer, at least four bytes
  * @len: length of channel status buffer
  *
- * Create the consumer format channel status data in @cs of maximum size
- * @len corresponding to the parameters of the PCM runtime @runtime.
- *
- * Drivers may wish to tweak the contents of the buffer after creation.
+ * Update sampling frequency and word length parameters of the consumer format
+ * channel status data in @cs of maximum size @len.
+ * Values correspond to the rate and format parameters of the PCM runtime
+ * @runtime.
  *
  * Returns: length of buffer, or negative error code if something failed.
  */
-int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
-	size_t len)
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
 {
-	unsigned int fs, ws;
-
 	if (len < 4)
 		return -EINVAL;
 
+	cs[3] &= ~IEC958_AES3_CON_FS;
+
 	switch (runtime->rate) {
+	case 22050:
+		cs[3] |= IEC958_AES3_CON_FS_22050;
+		break;
 	case 32000:
-		fs = IEC958_AES3_CON_FS_32000;
+		cs[3] |= IEC958_AES3_CON_FS_32000;
 		break;
 	case 44100:
-		fs = IEC958_AES3_CON_FS_44100;
+		cs[3] |= IEC958_AES3_CON_FS_44100;
 		break;
 	case 48000:
-		fs = IEC958_AES3_CON_FS_48000;
+		cs[3] |= IEC958_AES3_CON_FS_48000;
 		break;
 	case 88200:
-		fs = IEC958_AES3_CON_FS_88200;
+		cs[3] |= IEC958_AES3_CON_FS_88200;
 		break;
 	case 96000:
-		fs = IEC958_AES3_CON_FS_96000;

sound/core/pcm_iec958.c line 59

Quoted 10 lines
sound/core/pcm_iec958.c +3 -2
+		cs[3] |= IEC958_AES3_CON_FS_96000;
 		break;
 	case 176400:
-		fs = IEC958_AES3_CON_FS_176400;
+		cs[3] |= IEC958_AES3_CON_FS_176400;
 		break;
 	case 192000:
-		fs = IEC958_AES3_CON_FS_192000;
+		cs[3] |= IEC958_AES3_CON_FS_192000;
 		break;

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#4 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 41 lines · Russell King - ARM Linux
Quoted 6 lines · Moise Gergaud

Add a helper to update only the IEC958 channel status sampling freq and word length parameters from an ALSA snd_pcm_runtime structure, taking account of the sample rate and sample size.

NAK.

Quoted 17 lines
include/sound/pcm_iec958.h +7 -1
index 0eed397..0c84c69 100644
@@ -3,7 +3,24 @@
 
  #include <linux/types.h>
 
+#ifdef CONFIG_SND_PCM_IEC958
  int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
-	size_t len);
+				   size_t len);
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len);
+#else
+int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,

include/sound/pcm_iec958.h line 23

Quoted 10 lines
include/sound/pcm_iec958.h +10 -0
+				   size_t len)
+{
+	return len;
+}
+
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
+{
+	return len;
+}

Firstly, this is dangerous. If you don't have anything defined here, then the channel status ends up being undefined.

Quoted 3 lines

The intention here is that if you're a user of this, then select the config symbol. That makes providing stubs totally unnecessary and removes this problem.

agree

Quoted 71 lines
Quoted 71 lines
include/sound/pcm_iec958.h +1 -0
+#endif
 
  #endif
sound/core/pcm_iec958.c +19 -16
index 36b2d7a..abe3967 100644
@@ -11,67 +11,72 @@
  #include <sound/pcm.h>
  #include <sound/pcm_iec958.h>
 
-/**
- * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status
+/*
+ * snd_pcm_update_iec958_consumer - update consumer format IEC958 channel status
   * @runtime: pcm runtime structure with ->rate filled in
   * @cs: channel status buffer, at least four bytes
   * @len: length of channel status buffer
   *
- * Create the consumer format channel status data in @cs of maximum size
- * @len corresponding to the parameters of the PCM runtime @runtime.
- *
- * Drivers may wish to tweak the contents of the buffer after creation.
+ * Update sampling frequency and word length parameters of the consumer format
+ * channel status data in @cs of maximum size @len.
+ * Values correspond to the rate and format parameters of the PCM runtime
+ * @runtime.
   *
   * Returns: length of buffer, or negative error code if something failed.
   */
-int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
-	size_t len)
+int snd_pcm_update_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
+				   size_t len)
  {
-	unsigned int fs, ws;
-
  	if (len < 4)
  		return -EINVAL;
 
+	cs[3] &= ~IEC958_AES3_CON_FS;
+
  	switch (runtime->rate) {
+	case 22050:
+		cs[3] |= IEC958_AES3_CON_FS_22050;
+		break;
  	case 32000:
-		fs = IEC958_AES3_CON_FS_32000;
+		cs[3] |= IEC958_AES3_CON_FS_32000;
  		break;
  	case 44100:
-		fs = IEC958_AES3_CON_FS_44100;
+		cs[3] |= IEC958_AES3_CON_FS_44100;
  		break;
  	case 48000:
-		fs = IEC958_AES3_CON_FS_48000;
+		cs[3] |= IEC958_AES3_CON_FS_48000;
  		break;
  	case 88200:
-		fs = IEC958_AES3_CON_FS_88200;
+		cs[3] |= IEC958_AES3_CON_FS_88200;
  		break;
  	case 96000:
-		fs = IEC958_AES3_CON_FS_96000;
+		cs[3] |= IEC958_AES3_CON_FS_96000;
  		break;
  	case 176400:
-		fs = IEC958_AES3_CON_FS_176400;
+		cs[3] |= IEC958_AES3_CON_FS_176400;
  		break;
Quoted 9 lines

sound/core/pcm_iec958.c line 59

Quoted 4 lines
sound/core/pcm_iec958.c +1 -1
  	case 192000:
-		fs = IEC958_AES3_CON_FS_192000;
+		cs[3] |= IEC958_AES3_CON_FS_192000;
  		break;

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM).
In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer. So we propose a second function that only updates the sampling freq and word length. Other parameters are unchanged (set by user).

In a previous patch proposal, we managed channel status sampling freq directly in our driver. Mark suggested us to manage it in a generic function (could be useful for other drivers).

#5 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 8 lines · Moise Gergaud
Quoted 4 lines · Russell King - ARM Linux

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM). In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer.

Why can you not use snd_pcm_create_iec958_consumer() for this case? You are allowed to modify the values you get afterwards in order to handle this case if you so wish to toggle this bit.

However, if you are using data mode, you really should be using the AES bytes passed by the application through alsalib and into the kernel via the IEC958 controls. There are three controls specified for this:

SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK) - the bits which can be changed for consumer mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK) - the bits which can be changed for professional mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT) - the value of the changable bits.

When using this, it is userspace's responsibility to set the sample rate appropriately for the stream.

The only case to use snd_pcm_create_iec958_consumer() is to generate the status bytes for PCM audio, where the userspace API doesn't facilitiate generating and/or passing the AES status bytes.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#6 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 26 lines · Russell King - ARM Linux
Quoted 8 lines · Moise Gergaud
Quoted 4 lines · Russell King - ARM Linux

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM). In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer.

Why can you not use snd_pcm_create_iec958_consumer() for this case? You are allowed to modify the values you get afterwards in order to handle this case if you so wish to toggle this bit.

However, if you are using data mode, you really should be using the AES bytes passed by the application through alsalib and into the kernel via the IEC958 controls. There are three controls specified for this:

SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK) - the bits which can be changed for consumer mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK) - the bits which can be changed for professional mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT) - the value of the changable bits.

Quoted 6 lines

When using this, it is userspace's responsibility to set the sample rate appropriately for the stream.

The only case to use snd_pcm_create_iec958_consumer() is to generate the status bytes for PCM audio, where the userspace API doesn't facilitiate generating and/or passing the AES status bytes.

That's true. OTOH, in most drivers, we try to be kind not to be too strict for this requirement and adjust the status bits accordingly. This comes from the lessons we learned how user-space doesn't care the things.

So, if we want to keep that good uncle attitude, this change doesn't look so bad to me.

thanks,

Takashi

#7 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 35 lines · Takashi Iwai
Quoted 26 lines · Russell King - ARM Linux
Quoted 8 lines · Moise Gergaud
Quoted 4 lines · Russell King - ARM Linux

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM). In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer.

Why can you not use snd_pcm_create_iec958_consumer() for this case? You are allowed to modify the values you get afterwards in order to handle this case if you so wish to toggle this bit.

However, if you are using data mode, you really should be using the AES bytes passed by the application through alsalib and into the kernel via the IEC958 controls. There are three controls specified for this:

SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK) - the bits which can be changed for consumer mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK) - the bits which can be changed for professional mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT) - the value of the changable bits.

Quoted 6 lines

When using this, it is userspace's responsibility to set the sample rate appropriately for the stream.

The only case to use snd_pcm_create_iec958_consumer() is to generate the status bytes for PCM audio, where the userspace API doesn't facilitiate generating and/or passing the AES status bytes.

Quoted 8 lines

That's true. OTOH, in most drivers, we try to be kind not to be too strict for this requirement and adjust the status bits accordingly. This comes from the lessons we learned how user-space doesn't care the things.

So, if we want to keep that good uncle attitude, this change doesn't look so bad to me.

shall I deliver a new version of this patch with header correction or shall I abandon this patch?

Quoted 5 lines

thanks,

Takashi

#8 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 42 lines · Moise Gergaud
Quoted 40 lines · Takashi Iwai
Quoted 26 lines · Russell King - ARM Linux
Quoted 8 lines · Moise Gergaud
Quoted 4 lines · Russell King - ARM Linux

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM). In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer.

Why can you not use snd_pcm_create_iec958_consumer() for this case? You are allowed to modify the values you get afterwards in order to handle this case if you so wish to toggle this bit.

However, if you are using data mode, you really should be using the AES bytes passed by the application through alsalib and into the kernel via the IEC958 controls. There are three controls specified for this:

SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK) - the bits which can be changed for consumer mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK) - the bits which can be changed for professional mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT) - the value of the changable bits.

Quoted 6 lines

When using this, it is userspace's responsibility to set the sample rate appropriately for the stream.

The only case to use snd_pcm_create_iec958_consumer() is to generate the status bytes for PCM audio, where the userspace API doesn't facilitiate generating and/or passing the AES status bytes.

That's true. OTOH, in most drivers, we try to be kind not to be too strict for this requirement and adjust the status bits accordingly. This comes from the lessons we learned how user-space doesn't care the things.

Quoted 5 lines
Quoted 3 lines

So, if we want to keep that good uncle attitude, this change doesn't look so bad to me.

shall I deliver a new version of this patch with header correction or shall I abandon this patch?

It's up to you whether you want further convincing Russell :) I'd happily merge this once when we get his ack.

thanks,

Takashi

#9 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 50 lines · Takashi Iwai
Quoted 42 lines · Moise Gergaud
Quoted 40 lines · Takashi Iwai
Quoted 26 lines · Russell King - ARM Linux
Quoted 8 lines · Moise Gergaud
Quoted 4 lines · Russell King - ARM Linux

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM). In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer.

Why can you not use snd_pcm_create_iec958_consumer() for this case? You are allowed to modify the values you get afterwards in order to handle this case if you so wish to toggle this bit.

However, if you are using data mode, you really should be using the AES bytes passed by the application through alsalib and into the kernel via the IEC958 controls. There are three controls specified for this:

SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK) - the bits which can be changed for consumer mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK) - the bits which can be changed for professional mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT) - the value of the changable bits.

Quoted 6 lines

When using this, it is userspace's responsibility to set the sample rate appropriately for the stream.

The only case to use snd_pcm_create_iec958_consumer() is to generate the status bytes for PCM audio, where the userspace API doesn't facilitiate generating and/or passing the AES status bytes.

That's true. OTOH, in most drivers, we try to be kind not to be too strict for this requirement and adjust the status bits accordingly. This comes from the lessons we learned how user-space doesn't care the things.

Quoted 5 lines
Quoted 3 lines

So, if we want to keep that good uncle attitude, this change doesn't look so bad to me.

shall I deliver a new version of this patch with header correction or shall I abandon this patch?

Quoted 8 lines

It's up to you whether you want further convincing Russell :) I'd happily merge this once when we get his ack.

thanks,

Takashi

I share Takashi's view; unfortunately, we cannot always trust user space.
And so, for robustness reason, I think drivers shall ensure that channel status params are correct. For that purpose, the update helper function could be useful.

#10 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

Quoted 57 lines · Moise Gergaud
Quoted 56 lines · Takashi Iwai
Quoted 42 lines · Moise Gergaud
Quoted 40 lines · Takashi Iwai
Quoted 26 lines · Russell King - ARM Linux
Quoted 8 lines · Moise Gergaud
Quoted 4 lines · Russell King - ARM Linux

Again, I'm not happy with this change. The intention here is that we validate all arguments before we change anything. This breaks that principle.

We propose this change for compressed mode (IEC61937/non linear PCM). In case of compressed mode, iec958 channel status byte 0 bit1 = 1, then we cannot use snd_pcm_create_iec958_consumer.

Why can you not use snd_pcm_create_iec958_consumer() for this case? You are allowed to modify the values you get afterwards in order to handle this case if you so wish to toggle this bit.

However, if you are using data mode, you really should be using the AES bytes passed by the application through alsalib and into the kernel via the IEC958 controls. There are three controls specified for this:

SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK) - the bits which can be changed for consumer mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK) - the bits which can be changed for professional mode.
SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT) - the value of the changable bits.

Quoted 6 lines

When using this, it is userspace's responsibility to set the sample rate appropriately for the stream.

The only case to use snd_pcm_create_iec958_consumer() is to generate the status bytes for PCM audio, where the userspace API doesn't facilitiate generating and/or passing the AES status bytes.

That's true. OTOH, in most drivers, we try to be kind not to be too strict for this requirement and adjust the status bits accordingly. This comes from the lessons we learned how user-space doesn't care the things.

Quoted 5 lines
Quoted 3 lines

So, if we want to keep that good uncle attitude, this change doesn't look so bad to me.

shall I deliver a new version of this patch with header correction or shall I abandon this patch?

It's up to you whether you want further convincing Russell :) I'd happily merge this once when we get his ack.

thanks,

Quoted 7 lines
Quoted 2 lines

Takashi

I share Takashi's view; unfortunately, we cannot always trust user space. And so, for robustness reason, I think drivers shall ensure that channel status params are correct. For that purpose, the update helper function could be useful.

I don't, and now that you mention about not trusting userspace, I'm entrenching into that position. I have hardware where userspace must get it correct: I need to use the IEC958 alsalib plugin, and that relies on userspace getting it right - the kernel plays no part in generating the channel status, it's all handled in userspace. I do have kernel-side channel status generation for 24-bit 4-byte PCM audio though, because it's easy to merge in the channel status information (basically doing what the IEC958 alsalib plugin does.) I'd much rather that was moved out to userspace though.

What you're suggesting creates two separate classes of driver:
* those which always overwrite the channel status information from userspace, which will make userspace lazy and _more_ buggy.
* those which have to use the channel status information from userspace.

If the second is a minority, what we end up with are bugs with channel status information being missed, because programs will work on the "majority" of drivers which overwrite the userspace specified channel status.

IMHO, that's really not a sane position.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#11 lore raw

Re: [PATCH 1/3] ALSA: pcm: add IEC958 channel status update

In reply to Moise Gergaud
Quoted 3 lines · Moise Gergaud

Add a helper to update only the IEC958 channel status sampling freq and word length parameters from an ALSA snd_pcm_runtime structure, taking account of the sample rate and sample size.

What's also missing is an explanation of why this change is needed.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#12 lore raw

PATCH 2/3 ASoC: sti: use pcm iec958 channel status helper

In reply to Moise Gergaud

Use pcm iec958 channel status helper to update sampling freq parameter.

---
 sound/soc/sti/Kconfig           |  1 +
 sound/soc/sti/uniperif_player.c | 58 ++++++++---------------------------------
 2 files changed, 12 insertions(+), 47 deletions(-)
sound/soc/sti/Kconfig +1 -0
index 64a6900..8e616a4 100644
@@ -6,6 +6,7 @@ menuconfig SND_SOC_STI
 	depends on SND_SOC
 	depends on ARCH_STI || COMPILE_TEST
 	select SND_SOC_GENERIC_DMAENGINE_PCM
+	select SND_PCM_IEC958
 	help
 		Say Y if you want to enable ASoC-support for
 		any of the STI platforms (e.g. STIH416).
sound/soc/sti/uniperif_player.c +11 -47

102 lines not on this page · raw message

Signature · 1 line
1.9.1
#13 lore raw

Re: [PATCH 2/3] ASoC: sti: use pcm iec958 channel status helper

Quoted 87 lines · Moise Gergaud

Use pcm iec958 channel status helper to update sampling freq parameter.

---
 sound/soc/sti/Kconfig           |  1 +
 sound/soc/sti/uniperif_player.c | 58 ++++++++---------------------------------
 2 files changed, 12 insertions(+), 47 deletions(-)
sound/soc/sti/Kconfig +1 -0
index 64a6900..8e616a4 100644
@@ -6,6 +6,7 @@ menuconfig SND_SOC_STI
 	depends on SND_SOC
 	depends on ARCH_STI || COMPILE_TEST
 	select SND_SOC_GENERIC_DMAENGINE_PCM
+	select SND_PCM_IEC958
 	help
 		Say Y if you want to enable ASoC-support for
 		any of the STI platforms (e.g. STIH416).
sound/soc/sti/uniperif_player.c +2 -41
index 7aca6b9..b55e412 100644
@@ -12,6 +12,7 @@
 
 #include <sound/asoundef.h>
 #include <sound/soc.h>
+#include <sound/pcm_iec958.h>
 
 #include "uniperif.h"
 
@@ -244,6 +245,7 @@ static void uni_player_set_channel_status(struct uniperif *player,
 {
 	int n;
 	unsigned int status;
+	unsigned char *aes = player->stream_settings.iec958.status;
 
 	/*
 	 * Some AVRs and TVs require the channel status to contain a correct
@@ -251,51 +253,9 @@ static void uni_player_set_channel_status(struct uniperif *player,
 	 * set one.
 	 */
 	mutex_lock(&player->ctrl_lock);
-	if (runtime) {
-		switch (runtime->rate) {
-		case 22050:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_22050;
-			break;
-		case 44100:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_44100;
-			break;
-		case 88200:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_88200;
-			break;
-		case 176400:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_176400;
-			break;
-		case 24000:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_24000;
-			break;
-		case 48000:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_48000;
-			break;
-		case 96000:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_96000;
-			break;
-		case 192000:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_192000;
-			break;
-		case 32000:
-			player->stream_settings.iec958.status[3] =
-						IEC958_AES3_CON_FS_32000;
-			break;
-		default:
-			/* Mark as sampling frequency not indicated */
-			player->stream_settings.iec958.status[3] =

sound/soc/sti/uniperif_player.c static void uni_player_set_channel_status(struct uniperif *player, · line 261

Quoted 10 lines
sound/soc/sti/uniperif_player.c +3 -4
-						IEC958_AES3_CON_FS_NOTID;
-			break;
-		}
-	}
+
+	/* update channel status sampling freq */
+	snd_pcm_update_iec958_consumer(runtime, aes, 4);
 
 	/* Audio mode:
 	 * Use audio mode status to select PCM or encoded mode

The changes until this point are indeed about the conversion with a helper function. However....

Quoted 20 lines
sound/soc/sti/uniperif_player.c +2 -1
@@ -318,7 +278,7 @@ static void uni_player_set_channel_status(struct uniperif *player,
 	/* Program the new channel status */
 	for (n = 0; n < 6; ++n) {
 		status  =
-		player->stream_settings.iec958.status[0 + (n * 4)] & 0xf;
+		player->stream_settings.iec958.status[0 + (n * 4)] & 0xff;
 		status |=
 		player->stream_settings.iec958.status[1 + (n * 4)] << 8;
 		status |=
@@ -563,6 +523,7 @@ static int uni_player_ctl_iec958_get(struct snd_kcontrol *kcontrol,
 	ucontrol->value.iec958.status[1] = iec958->status[1];
 	ucontrol->value.iec958.status[2] = iec958->status[2];
 	ucontrol->value.iec958.status[3] = iec958->status[3];
+	ucontrol->value.iec958.status[4] = iec958->status[4];
 	mutex_unlock(&player->ctrl_lock);
 	return 0;
 }
@@ -574,15 +535,18 @@ static int uni_player_ctl_iec958_put(struct snd_kcontrol *kcontrol,
 	struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
 	struct uniperif *player = priv->dai_data.uni;

sound/soc/sti/uniperif_player.c static int uni_player_ctl_iec958_put(struct snd_kcontrol *kcontrol, · line 546

Quoted 10 lines
sound/soc/sti/uniperif_player.c +2 -0
 	struct snd_aes_iec958 *iec958 =  &player->stream_settings.iec958;
+	struct snd_pcm_substream *substream = player->substream;
 
 	mutex_lock(&player->ctrl_lock);
 	iec958->status[0] = ucontrol->value.iec958.status[0];
 	iec958->status[1] = ucontrol->value.iec958.status[1];
 	iec958->status[2] = ucontrol->value.iec958.status[2];
 	iec958->status[3] = ucontrol->value.iec958.status[3];
+	iec958->status[4] = ucontrol->value.iec958.status[4];
 	mutex_unlock(&player->ctrl_lock);

These changes are basically irrelevant. They look like real fixes, and if it's really so, they should be split to a different patch.

Takashi

#14 lore raw

PATCH 3/3 ASoC: sti: correction for HBRA (High Bit Rate Audio) support

In reply to Moise Gergaud

Detect HBRA based on rate and channels used in the pcm session In case of HBRA:
- CH_STS repeat is disabled
- channel status sampling freq is not set if already set (because it can be a multiple of the runtime rate)

---
 sound/soc/sti/uniperif_player.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)
sound/soc/sti/uniperif_player.c +27 -7
index b55e412..cf99dee 100644
@@ -246,16 +246,39 @@ static void uni_player_set_channel_status(struct uniperif *player,
 	int n;
 	unsigned int status;
 	unsigned char *aes = player->stream_settings.iec958.status;
+	const unsigned int cs_rate[] = {
+		44100, 0, 48000, 32000, 22050, 24000,
+		88200, 768000, 176400, 192000
+	};
 
 	/*
 	 * Some AVRs and TVs require the channel status to contain a correct
-	 * sampling frequency. If no sample rate is already specified, then
-	 * set one.
+	 * sampling freq.
+	 * In case of HBRA is not detected:
+	 *   set the channel status sampling freq
+	 * In case of HBRA is detected:
+	 *   channel status sampling freq is already set; it can be a multiple
+	 *   of runtime rate
+	 *
+	 * HBRA is detected when:
+	 *   runtime channels is 8 and runtime->rate < channel status rate
 	 */
+
 	mutex_lock(&player->ctrl_lock);
 
-	/* update channel status sampling freq */
-	snd_pcm_update_iec958_consumer(runtime, aes, 4);
+	if ((runtime->channels == 8) &&
+	    (runtime->rate < cs_rate[aes[3] & IEC958_AES3_CON_FS])) {
+		/*
+		 * Consecutive frames repetition of Z preamble needs to be
+		 * disabled in case of HBRA
+		 */
+		SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_DISABLE(player);
+	} else {
+		SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_ENABLE(player);
+
+		/* update channel status sampling freq */
+		snd_pcm_update_iec958_consumer(runtime, aes, 4);
+	}
 
 	/* Audio mode:
 	 * Use audio mode status to select PCM or encoded mode
@@ -358,9 +381,6 @@ static int uni_player_prepare_iec958(struct uniperif *player,
 	/* Disable one-bit audio mode */
 	SET_UNIPERIF_CONFIG_ONE_BIT_AUD_DISABLE(player);
 
-	/* Enable consecutive frames repetition of Z preamble (not for HBRA) */
-	SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_ENABLE(player);
-
 	/* Change to SUF0_SUBF1 and left/right channels swap! */
 	SET_UNIPERIF_CONFIG_SUBFRAME_SEL_SUBF1_SUBF0(player);
 
Signature · 1 line
1.9.1
#15 lore raw
In reply to Moise Gergaud
Quoted 7 lines · Moise Gergaud

This patchset is V2 of "[PATCH 2/2] ASoC: sti: correction for HBRA support"

Moise Gergaud (3):
ALSA: pcm: add IEC958 channel status update
ASoC: sti: use pcm iec958 channel status helper
ASoC: sti: correction for HBRA (High Bit Rate Audio) support

Quoted 6 lines
  include/sound/pcm_iec958.h      | 19 ++++++++-
  sound/core/pcm_iec958.c         | 78 +++++++++++++++++++++++++------------
  sound/soc/sti/Kconfig           |  1 +
  sound/soc/sti/uniperif_player.c | 86 +++++++++++++++++------------------------
  4 files changed, 107 insertions(+), 77 deletions(-)

patchset abandoned