From Martin.Kaeske@Stud.TU-Ilmenau.DE  Fri May 10 09:51:04 2002
Return-Path: <Martin.Kaeske@Stud.TU-Ilmenau.DE>
Received: from piggy.rz.tu-ilmenau.de (piggy.rz.tu-ilmenau.de [141.24.4.8])
	by hub.freebsd.org (Postfix) with ESMTP id A431837B400
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 10 May 2002 09:51:02 -0700 (PDT)
Received: from gtw.hh59.local (pD9508BBA.dip.t-dialin.net [217.80.139.186])
	(authenticated (0 bits))
	by piggy.rz.tu-ilmenau.de (8.11.1/8.11.1) with ESMTP id g4AGoxv13493
	(using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified NO)
	; Fri, 10 May 2002 18:51:01 +0200 (MET DST)
Received: from walnut.hh59.local (walnut.hh59.local [192.168.2.10])
	by gtw.hh59.local (8.11.3/8.11.3) with ESMTP id g4AHMQK10990
	(using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified FAIL)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 10 May 2002 19:22:30 +0200 (CEST)
Received: (qmail 16596 invoked by uid 1000); 10 May 2002 16:50:53 -0000
Message-Id: <20020510165053.16595.qmail@walnut.hh59.local>
Date: 10 May 2002 16:50:53 -0000
From: Martin Kaeske <Martin.Kaeske@Stud.TU-Ilmenau.DE>
Reply-To: Martin Kaeske <Martin.Kaeske@Stud.TU-Ilmenau.DE>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] bug in ad1816.c stops sound playback
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         37932
>Category:       kern
>Synopsis:       [PATCH] bug in ad1816.c stops sound playback
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    hm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 10 10:00:02 PDT 2002
>Closed-Date:    Sun Jun 09 07:24:25 PDT 2002
>Last-Modified:  Sun Jun 09 07:24:25 PDT 2002
>Originator:     Martin Kaeske
>Release:        FreeBSD 4.6-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD walnut.hh59.local 4.6-PRERELEASE FreeBSD 4.6-PRERELEASE #5: Fri May 10 16:51:12 CEST 2002 martin@walnut.hh59.local:/usr/obj/usr/src/sys/BSD4_5 i386

>Description:
	There is a problem inside ad1816.c that prevents any access to
        /dev/dsp and /dev/audio. During opening of /dev/dsp the function
	chn_reset is called that itself calls chn_setformat. That results
	in ad1816chan_setformat to be called. ad1816chan_setformat returns
	one of its parameters (u_int32_t format) but chn_setformat expects
	to get "0" if everything went okay (actually its chn_tryformat
	that calls ad1816chan_setformat). Since format is not "0"
	chn_setformat comes to the conclusion that there was an error
	and as a result dsp_open returns ENODEV. I've looked at the
	other drivers inside sys/dev/sound/isa and they return "0" as
	the result of a setformat call so i think its a good idea
	to change ad1816.c to also return "0". Furthermore returning
	format doesn't make much sense, because it is not changed and
	is no error indicator.
	Another interesting thing i saw was that only the very first
	attempt to open /dev/dsp results in ENODEV any subsequent tries
	gave me EBUSY, maybe this is related to kern/35004.
>How-To-Repeat:
	any read/write access to /dev/dsp (/dev/audio as well) fails
>Fix:
	apply attached patch

--- ad1816.patch begins here ---
--- ad1816.c.orig	Fri May 10 18:26:58 2002
+++ ad1816.c	Fri May 10 18:28:29 2002
@@ -368,7 +368,7 @@
     	if (format & AFMT_STEREO) fmt |= AD1816_STEREO;
     	io_wr(ad1816, reg, fmt);
 	ad1816_unlock(ad1816);
-    	return format;
+	return 0;
 }
 
 static int
--- ad1816.patch ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: hm 
State-Changed-When: Sun Jun 9 07:21:15 PDT 2002 
State-Changed-Why:  
I have tested the patch on my -current machine and i was able to get my 
soundcard working again. Committed the patch to -current and will MFC 
it after the code freeze for 4.6 to -stable. 


Responsible-Changed-From-To: freebsd-bugs->hm 
Responsible-Changed-By: hm 
Responsible-Changed-When: Sun Jun 9 07:21:15 PDT 2002 
Responsible-Changed-Why:  
I have tested the patch on my -current machine and i was able to get my 
soundcard working again. Committed the patch to -current and will MFC 
it after the code freeze for 4.6 to -stable. 

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