public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: aoa: onyx: Update IEC958 sample-rate status for PCM playback
@ 2026-04-03  3:47 Cássio Gabriel
  2026-04-06  8:41 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Cássio Gabriel @ 2026-04-03  3:47 UTC (permalink / raw)
  To: Johannes Berg, Takashi Iwai, Jaroslav Kysela
  Cc: linuxppc-dev, linux-sound, linux-kernel, Cássio Gabriel

onyx_prepare() accepts 32/44.1/48 kHz PCM playback, but it leaves the
Onyx IEC958 sample-rate status bits at the driver's initial 44.1 kHz
setting in DIG_INFO3. As a result, 32 kHz and 48 kHz PCM streams
advertise a stale IEC958 sample rate unless userspace rewrites IEC958
Playback Default first.

Update only the consumer sample-frequency bits in DIG_INFO3 from the PCM
runtime during prepare, resolving the long-standing FIXME in the PCM
playback path while leaving the other user-controlled IEC958 status bits
unchanged.

Mark IEC958 Playback Default as volatile as well, since prepare() now
changes the exposed register contents outside the control put callback.

Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
 sound/aoa/codecs/onyx.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
index 04961c456d2c..6e2da2aca2ab 100644
--- a/sound/aoa/codecs/onyx.c
+++ b/sound/aoa/codecs/onyx.c
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/slab.h>
+#include <sound/asoundef.h>
 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("pcm3052 (onyx) codec driver for snd-aoa");
@@ -514,8 +515,36 @@ static int onyx_spdif_put(struct snd_kcontrol *kcontrol,
 	return 1;
 }
 
+static int onyx_set_spdif_pcm_rate(struct onyx *onyx, unsigned int rate)
+{
+	u8 dig_info3, fs;
+
+	switch (rate) {
+	case 32000:
+		fs = IEC958_AES3_CON_FS_32000;
+		break;
+	case 44100:
+		fs = IEC958_AES3_CON_FS_44100;
+		break;
+	case 48000:
+		fs = IEC958_AES3_CON_FS_48000;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (onyx_read_register(onyx, ONYX_REG_DIG_INFO3, &dig_info3))
+		return -EBUSY;
+	dig_info3 = (dig_info3 & ~IEC958_AES3_CON_FS) | fs;
+	if (onyx_write_register(onyx, ONYX_REG_DIG_INFO3, dig_info3))
+		return -EBUSY;
+
+	return 0;
+}
+
 static const struct snd_kcontrol_new onyx_spdif_ctrl = {
-	.access =	SNDRV_CTL_ELEM_ACCESS_READWRITE,
+	.access =	SNDRV_CTL_ELEM_ACCESS_READWRITE |
+			SNDRV_CTL_ELEM_ACCESS_VOLATILE,
 	.iface =	SNDRV_CTL_ELEM_IFACE_PCM,
 	.name =		SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
 	.info =		onyx_spdif_info,
@@ -695,9 +724,9 @@ static int onyx_prepare(struct codec_info_item *cii,
 	case 32000:
 	case 44100:
 	case 48000:
-		/* these rates are ok for all outputs */
-		/* FIXME: program spdif channel control bits here so that
-		 *	  userspace doesn't have to if it only plays pcm! */
+		if (onyx->codec.connected & 2)
+			return onyx_set_spdif_pcm_rate(onyx,
+						       substream->runtime->rate);
 		return 0;
 	default:
 		/* got some rate that the digital output can't do,

---
base-commit: f16695c0dc9db64f0a5a9871a10b70daee2653e3
change-id: 20260401-onyx-spdif-pcm-rate-ec45243ae8a3

Best regards,
--  
Cássio Gabriel <cassiogabrielcontato@gmail.com>


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

* Re: [PATCH] ALSA: aoa: onyx: Update IEC958 sample-rate status for PCM playback
  2026-04-03  3:47 [PATCH] ALSA: aoa: onyx: Update IEC958 sample-rate status for PCM playback Cássio Gabriel
@ 2026-04-06  8:41 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-04-06  8:41 UTC (permalink / raw)
  To: Cássio Gabriel
  Cc: Johannes Berg, Takashi Iwai, Jaroslav Kysela, linuxppc-dev,
	linux-sound, linux-kernel

On Fri, 03 Apr 2026 05:47:13 +0200,
Cássio Gabriel wrote:
> 
> onyx_prepare() accepts 32/44.1/48 kHz PCM playback, but it leaves the
> Onyx IEC958 sample-rate status bits at the driver's initial 44.1 kHz
> setting in DIG_INFO3. As a result, 32 kHz and 48 kHz PCM streams
> advertise a stale IEC958 sample rate unless userspace rewrites IEC958
> Playback Default first.
> 
> Update only the consumer sample-frequency bits in DIG_INFO3 from the PCM
> runtime during prepare, resolving the long-standing FIXME in the PCM
> playback path while leaving the other user-controlled IEC958 status bits
> unchanged.
> 
> Mark IEC958 Playback Default as volatile as well, since prepare() now
> changes the exposed register contents outside the control put callback.
> 
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>

Applied now to for-next branch.  Thanks.


Takashi

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

end of thread, other threads:[~2026-04-06  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03  3:47 [PATCH] ALSA: aoa: onyx: Update IEC958 sample-rate status for PCM playback Cássio Gabriel
2026-04-06  8:41 ` Takashi Iwai

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