Subject: kern/18342: eso (ess solo-1) audio playback garbled
To: None <gnats-bugs@gnats.netbsd.org>
From: None <stephenm@employees.org>
List: netbsd-bugs
Date: 09/19/2002 17:38:09
>Number:         18342
>Category:       kern
>Synopsis:       eso (ess solo-1) audio playback garbled
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 19 17:39:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Stephen Ma
>Release:        NetBSD 1.6H 2002-09-17
>Organization:
	People's Front for the correct spelling of the word "Organisation"
>Environment:
System: NetBSD whitewater.nowhere.org 1.6H NetBSD 1.6H (WHITEWATER) #29: Thu Sep 19 16:20:56 PDT 2002 stephenm@whitewater.nowhere.org:/usr/src/sys/arch/i386/compile/WHITEWATER i386
Architecture: i386
Machine: i386
>Description:
The solo-1's audio 2 DMA channel only includes a 20-bit address
counter, so the DMA buffer can't straddle a 1Mbyte address
boundary. eso.c doesn't pass this restriction to bus_dmamem_alloc()
for that buffer. Also, need to fix a malloc size parameter, and some
code for setting the monoin/monoout register. 
>How-To-Repeat:
Playback some audio, read the code, compare against the solo-1 datasheet.
>Fix:
     $NetBSD: eso.c,v 1.24 2002/04/25 00:52:21 kleink Exp $
     $NetBSD: esoreg.h,v 1.5 1999/12/10 19:13:00 kleink Exp $

--- /v1/netbsd/src/sys/dev/pci/esoreg.h	Sat Dec 11 04:21:22 1999
+++ ./esoreg.h	Thu Sep 19 02:22:57 2002
@@ -181,11 +181,12 @@
 #define  ESO_MIXREG_A2C2_IRQ	0x80	 /* IRQ latch */
 #define ESO_MIXREG_PVR_A2	0x7c	/* Playback mixer: Audio 2 */
 #define ESO_MIXREG_MPM		0x7d	/* Microphone Preamp, Mono In/Out */
-#define  ESO_MIXREG_MPM_MOMASK  0x03	 /* MONO_OUT value mask */
+#define  ESO_MIXREG_MPM_BYPASS	0x01	 /* Bypass MONO_IN mixer */
+#define  ESO_MIXREG_MPM_MOMASK  0x06	 /* MONO_OUT value mask */
 #define  ESO_MIXREG_MPM_MOMUTE  0x00	 /* MONO_OUT mute */
-#define  ESO_MIXREG_MPM_MOCINR  0x01	 /* MONO_OUT source CIN_R */
-#define  ESO_MIXREG_MPM_MOA2R	0x02	 /* MONO_OUT source Audio 2 Right */
-#define  ESO_MIXREG_MPM_MOREC	0x03	 /* MONO_OUT source record stage */
+#define  ESO_MIXREG_MPM_MOCINR  0x02	 /* MONO_OUT source CIN_R */
+#define  ESO_MIXREG_MPM_MOA2R	0x04	 /* MONO_OUT source Audio 2 Right */
+#define  ESO_MIXREG_MPM_MOREC	0x06	 /* MONO_OUT source record stage */
 #define  ESO_MIXREG_MPM_PREAMP	0x08	 /* Preamp enable */
 #define  ESO_MIXREG_MPM_RESV0	0xf0	 /* Reserved, always write 0 */
 
--- /v1/netbsd/src/sys/dev/pci/eso.c	Fri Apr 26 04:37:05 2002
+++ ./eso.c	Thu Sep 19 16:16:35 2002
@@ -281,6 +281,7 @@ eso_attach(parent, self, aux)
 	/* Set mixer regs to something reasonable, needs work. */
 	sc->sc_recsrc = ESO_MIXREG_ERS_LINE;
 	sc->sc_monooutsrc = ESO_MIXREG_MPM_MOMUTE;
+	eso_set_monooutsrc(sc, ESO_MONOOUT_SOURCE);
 	sc->sc_recmon = sc->sc_spatializer = sc->sc_mvmute = 0;
 	for (idx = 0; idx < ESO_NGAINDEVS; idx++) {
 		int v;
@@ -1541,19 +1542,19 @@ eso_allocm(hdl, direction, size, type, f
 	size_t boundary;
 	int error;
 
-	if ((ed = malloc(size, type, flags)) == NULL)
+	if ((ed = malloc(sizeof(struct eso_dma), type, flags)) == NULL)
 		return (NULL);
 
 	/*
 	 * Apparently the Audio 1 DMA controller's current address
 	 * register can't roll over a 64K address boundary, so we have to
-	 * take care of that ourselves.  The second channel DMA controller
-	 * doesn't have that restriction, however.
+	 * take care of that ourselves. Similarly, the Audio 2 DMA
+	 * controller needs a 1M address boundary.
 	 */
 	if (direction == AUMODE_RECORD)
 		boundary = 0x10000;
 	else
-		boundary = 0;
+		boundary = 0x100000;
 
 #ifdef alpha
 	/*
@@ -1854,6 +1855,7 @@ eso_set_monooutsrc(sc, monooutsrc)
 		if (monooutsrc == di.un.e.member[i].ord) {
 			mpm = eso_read_mixreg(sc, ESO_MIXREG_MPM);
 			mpm &= ~ESO_MIXREG_MPM_MOMASK;
+			mpm &= ~ESO_MIXREG_MPM_BYPASS;
 			mpm |= monooutsrc;
 			eso_write_mixreg(sc, ESO_MIXREG_MPM, mpm);
 			sc->sc_monooutsrc = monooutsrc;

>Release-Note:
>Audit-Trail:
>Unformatted: