Subject: kern/9064: eso (ESS Solo-1) audio breaks with buffer size of 64k
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dave@dtsp.co.nz>
List: netbsd-bugs
Date: 12/27/1999 21:57:39
>Number:         9064
>Category:       kern
>Synopsis:       eso (ESS Solo-1) audio breaks with buffer size of 64k
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 27 21:57:01 1999
>Last-Modified:
>Originator:     Dave Sainty
>Organization:
Dynamic Technology Services and Products Ltd (NZ)
>Release:        Recent current
>Environment:
System: NetBSD tequila.dave.dtsp.co.nz 1.4P NetBSD 1.4P (TEQUILA) #5: Tue Dec 28 17:15:12 NZDT 1999 dave@tequila.dave.dtsp.co.nz:/vol/tequila/userB/u2/NetBSD-current/src/sys/arch/i386/compile/TEQUILA i386


>Description:
	The Solo-1 has a 16 bit register for the DMA byte count, which takes a
	literal byte count.  If the block size is 64k, this register will be
	programmed with 0, and problems will result (in the form of strange
	buzzes and whines).

>How-To-Repeat:
	Play Quake2, or try and play DVD audio with (mycrofts build of)
	mpeg2player.

>Fix:
	This change limits the playback buffer to 65535 bytes.  This is fine
	for mpeg2player, and Quake starts to sound like Quake but with skips
	and jumps.

	The quake problem appears to be due to iteractions with the ossaudio
	compatibility interface, which expects powers of 2.  Is it asking for
	trouble to use a non power of 2 here?

--- src/sys/dev/pci/eso.c.orig  Sat Dec 11 16:05:16 1999
+++ src/sys/dev/pci/eso.c       Tue Dec 28 17:36:11 1999
@@ -1577,10 +1577,21 @@
        int direction;
        size_t bufsize;
 {
+       size_t maxsize;
 
-       /* 64K restriction: ISA at eleven? */
-       if (bufsize > 65536)
-               bufsize = 65536;
+       /*
+        * The playback DMA buffer size on the Solo-1 is limited to 2^16 -
+        * 1 bytes.  This is because A2DMAC is a two byte value indicating
+        * the literal byte count, and zero does not appear to be used as
+        * a special case for 2^16.
+        *
+        * For recording, DMAC_DMAC is the byte count - 1, so 2^16 can be
+        * represented.
+        */
+       maxsize = direction == AUMODE_PLAY ? 65535 : 65536;
+
+       if (bufsize > maxsize)
+               bufsize = maxsize;
 
        return (bufsize);
 }
>Audit-Trail:
>Unformatted: