From CQG00620@nifty.ne.jp  Sun Nov 24 09:17:38 2002
Return-Path: <CQG00620@nifty.ne.jp>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0D91637B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Nov 2002 09:17:38 -0800 (PST)
Received: from ums509.nifty.ne.jp (ums509.nifty.ne.jp [202.248.20.208])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2F13D43E4A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Nov 2002 09:17:37 -0800 (PST)
	(envelope-from CQG00620@nifty.ne.jp)
Received: from nifty.ne.jp (mcda014n040.ppp.infoweb.ne.jp [61.124.80.167])
	by ums509.nifty.ne.jp (8.9.3+3.2W/3.7W-991025) with ESMTP id CAA20372
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Nov 2002 02:17:34 +0900 (JST)
Message-Id: <200211241717.CAA20372@ums509.nifty.ne.jp>
Date: Mon, 25 Nov 2002 02:10:10 +0900
From: Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Sometime failed to record/play with CS4231A & newpcm

>Number:         45682
>Category:       kern
>Synopsis:       [sound] [patch] Sometime failed to record/play with CS4231A & newpcm
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-multimedia
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 24 09:20:02 PST 2002
>Closed-Date:    Sun Sep 11 13:59:34 GMT 2005
>Last-Modified:  Sun Sep 11 13:59:34 GMT 2005
>Originator:     Watanabe Kazuhiro
>Release:        FreeBSD 4.5-RELEASE i386
>Organization:
>Environment:
System: FreeBSD aries.zodiac.org 4.5-RELEASE FreeBSD 4.5-RELEASE #13: Sun Nov
 24 15:30:52 JST 2002     nabe@aries.zodiac.org:/usr/src/sys/compile/LEFTEYE
 i386

dmesg:
 pcm0: <CS4231A> at port 0xf40-0xf47 irq 10 drq 1 flags 0x1a100 on isa0
 drq/irq conf 1a

I'm tested on NEC PC-9821Xa9 and applied patches posted below:

"PC98 internal CS4231A is mis-detected to OPTi chip (newpcm)"
 http://www.FreeBSD.org/cgi/query-pr.cgi?pr=kern/45673
"Cannot record except 8bit-mono with CS4231A & newpcm (half-duplex mode)"
 http://www.FreeBSD.org/cgi/query-pr.cgi?pr=kern/45679


>Description:
With newpcm driver & CS4231A, an application software (such as
ports/audio/wavplay) sometime failed to play/record with a console
message like "play interrupt timeout, channel dead".

OSS/Free driver work fine.


In newpcm driver, doesn't call ad_wait_init() after set the sampling
frequency or rec/play format to CS4231A.

>How-To-Repeat:
/usr/bin/time wavrec -S -b 16 -t 5 test.wav
      5.38 real         0.01 user         0.34 sys
# recording stereo/16bit/5sec.

/usr/bin/time wavplay test.wav
Pathname:       test.wav
Device:         /dev/audio
Sampling Rate:  22050 Hz
Mode:           Stereo
Samples:        110250
Bits:           16

Writing samples to audio device
      2.31 real         0.01 user         0.30 sys
# aborted.

console message:
 Nov 25 01:45:37 aries /kernel: pcm0: play interrupt timeout, channel dead

>Fix:
--- mss.c.orig	Mon Nov 25 01:36:16 2002
+++ mss.c	Mon Nov 25 01:36:19 2002
@@ -959,6 +959,7 @@
 			    abs(speed-speeds[i]) < abs(speed-speeds[sel])) sel = i;
         	speed = speeds[sel];
         	ad_write(mss, 8, (ad_read(mss, 8) & 0xf0) | sel);
+		ad_wait_init(mss, 10000);
     	}
     	ad_leave_MCE(mss);
 
@@ -998,8 +999,10 @@
     	arg <<= 4;
     	ad_enter_MCE(mss);
     	ad_write(mss, 8, (ad_read(mss, 8) & 0x0f) | arg);
+	ad_wait_init(mss, 10000);
 	if (ad_read(mss, 12) & 0x40) {  /* mode2 ? */
 		ad_write(mss, 28, arg); /* capture mode */
+		ad_wait_init(mss, 10000);
 	}
     	ad_leave_MCE(mss);
     	return format;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sound 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Sat Dec 21 04:55:21 PST 2002 
Responsible-Changed-Why:  
Another sound PR form Watanabe Kazuhiro. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45682 

From: Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
To: freebsd-gnats-submit@FreeBSD.org, CQG00620@nifty.ne.jp
Cc:  
Subject: Re: kern/45682: Sometime failed to record/play with CS4231A & newpcm
Date: Fri, 13 Jun 2003 21:37:04 +0900

 I have tested these three patches (kern/45673, kern/45679/, kern/45682)
 with AOpen AW37Pro ISA soundcard, which uses Crystal CX4235 (It looks
 like a variant of CS4235).
 OS version is 4.7-RELEASE (FreeBSD/i386).
 
 After applied the patches, the soundcard works well
 (recording/playback OK).
 
 
 However, the soundcard also works without the patches. I think there
 are some reasons (probed "real" full-duplex with two DMA channels,
 different bus timing, a different CPU speed, and so on).
 
 At least, there is no side effect.
 
 
 I have tested the patches with NEC PC-9821Xa9 on-board CS4231A, too.
 OS version is 4.7-RELEASE (FreeBSD/pc98).
 
 In this case, same problems described these PRs has occured. After
 applied the patches, CS4231A works well.
State-Changed-From-To: open->closed 
State-Changed-By: netchild 
State-Changed-When: Sun Sep 11 13:59:19 GMT 2005 
State-Changed-Why:  
Committed, thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45682 
>Unformatted:
