Subject: Re: Recording with wss(4) hardware seems to be broken in NetBSD-3.X, anyone else agree?
To: None <current-users@NetBSD.org, port-i386@NetBSD.org>
From: Valeriy E. Ushakov <uwe@stderr.spb.ru>
List: current-users
Date: 08/13/2007 07:44:50
I have wss(4) in my old dell laptop, and I tried to record something
and saw two problems:

. cat /dev/audio produces nothing
. audiorecord complains about invalid arguments to ioctl

There seems to be two bugs contributing to this.  


The following patch makes cat /dev/audio work.  The quality is crappy
but I haven't tried to fool with any mixer settings, etc, and I really
have no clue as to what's going on here hardware-wise, so someone with
a datasheet should verify this.

Index: isa/ad1848_isa.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/ad1848_isa.c,v
retrieving revision 1.32
diff -u -r1.32 ad1848_isa.c
--- isa/ad1848_isa.c	16 Nov 2006 01:33:00 -0000	1.32
+++ isa/ad1848_isa.c	13 Aug 2007 03:21:20 -0000
@@ -580,7 +580,7 @@
 	    DMAMODE_READ | DMAMODE_LOOPDEMAND, BUS_DMA_NOWAIT);
 
 	isc->sc_recrun = 1;
-	if (sc->mode == 2 && isc->sc_playdrq != isc->sc_recdrq) {
+	if (sc->mode >= 2 && isc->sc_playdrq != isc->sc_recdrq) {
 		isc->sc_rintr = intr;
 		isc->sc_rarg = arg;
 	} else {
@@ -711,7 +711,7 @@
 
 	/* Handle interrupt */
 	if ((status & INTERRUPT_STATUS) != 0) {
-		if (sc->mode == 2 && isc->sc_playdrq != isc->sc_recdrq) {
+		if (sc->mode >= 2 && isc->sc_playdrq != isc->sc_recdrq) {
 			status = ad_read(sc, CS_IRQ_STATUS);
 			if ((status & CS_IRQ_PI) && isc->sc_playrun) {
 				(*isc->sc_pintr)(isc->sc_parg);


The next patch is necessary to make audiorecord work (cat /dev/audio
bypasses SETINFO dance that audiorecord makes and so doens't bump into
this bug).

I *very* much doubt that hiding nports++ behind a short-circuiting &&
was really intended.  Please correct me if there's some higher purpose
in this.

(As an aside, this is exactly the reason why I hate assignments hidden
in tests, especially pre/post-increments.  while (*dst++=*src++); is
cute, clarity of the code is much more valuable)

Index: audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio.c,v
retrieving revision 1.222
diff -u -r1.222 audio.c
--- audio.c	11 Jun 2007 13:05:46 -0000	1.222
+++ audio.c	13 Aug 2007 03:21:20 -0000
@@ -576,8 +576,9 @@
 				    au_portof(sc, mi->un.e.member[j].label.name,
 				    mi->mixer_class);
 				if (ports->mixerout != -1 &&
-				    ports->miport[ports->nports++] != -1)
+				    ports->miport[ports->nports] != -1)
 					ports->isdual = true;
+				++ports->nports;
 			}
 	} else if (mi->type == AUDIO_MIXER_SET) {
 		for(i = 0; tbl[i].name; i++)

SY, Uwe
-- 
uwe@stderr.spb.ru                       |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen