Module Name:    src
Committed By:   jmcneill
Date:           Sat Feb 15 00:35:18 UTC 2025

Modified Files:
        src/sys/arch/evbppc/wii/dev: bwai.c

Log Message:
wii: Audio playback improvements.

Instead of resetting the byte counter for every block (which is racy),
increment the interrupt timing register by the exact byte count for
each block. Should do better at keeping things in sync.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbppc/wii/dev/bwai.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbppc/wii/dev/bwai.c
diff -u src/sys/arch/evbppc/wii/dev/bwai.c:1.3 src/sys/arch/evbppc/wii/dev/bwai.c:1.4
--- src/sys/arch/evbppc/wii/dev/bwai.c:1.3	Tue Jan 23 21:56:07 2024
+++ src/sys/arch/evbppc/wii/dev/bwai.c	Sat Feb 15 00:35:18 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: bwai.c,v 1.3 2024/01/23 21:56:07 jmcneill Exp $ */
+/* $NetBSD: bwai.c,v 1.4 2025/02/15 00:35:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.3 2024/01/23 21:56:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.4 2025/02/15 00:35:18 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -65,6 +65,8 @@ struct bwai_softc {
 
 	void			(*sc_intr)(void *);
 	void			*sc_intrarg;
+	uint32_t		sc_intrnext;
+	uint32_t		sc_intrstep;
 
 	kmutex_t		*sc_intr_lock;
 };
@@ -92,7 +94,9 @@ bwai_intr(void *priv)
 
 	val = RD4(sc, AI_CONTROL);
 	if ((val & AI_CONTROL_AIINT) != 0) {
-		WR4(sc, AI_CONTROL, val | AI_CONTROL_SCRESET);
+		sc->sc_intrnext += sc->sc_intrstep;
+		WR4(sc, AI_AIIT, sc->sc_intrnext);
+		WR4(sc, AI_CONTROL, val);
 
 		mutex_enter(sc->sc_intr_lock);
 		if (sc->sc_intr) {
@@ -217,7 +221,9 @@ bwai_trigger_output(void *priv, void *st
 		WR4(sc, AI_CONTROL, 0);
 	}
 
-	WR4(sc, AI_AIIT, blksize / 4);
+	sc->sc_intrstep = blksize / 4;
+	sc->sc_intrnext = sc->sc_intrstep;
+	WR4(sc, AI_AIIT, sc->sc_intrnext);
 
 	val = AI_CONTROL_SCRESET |
 	      AI_CONTROL_AIINT |

Reply via email to