From dpelleg@cs.cmu.edu  Tue Jun 11 03:24:23 2002
Return-Path: <dpelleg@cs.cmu.edu>
Received: from dpelleg.dsl.telerama.com (dpelleg.dsl.telerama.com [205.201.13.235])
	by hub.freebsd.org (Postfix) with ESMTP id D4FB337B400
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 11 Jun 2002 03:24:22 -0700 (PDT)
Received: from palraz.wburn (palraz [192.168.1.1])
	by dpelleg.dsl.telerama.com (8.12.3/8.12.3) with ESMTP id g5BAOX17002934
	(version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 11 Jun 2002 06:24:34 -0400 (EDT)
	(envelope-from dpelleg@palraz.wburn)
Received: from palraz.wburn (localhost [127.0.0.1])
	by palraz.wburn (8.12.3/8.12.3) with ESMTP id g5BAOk8T012281
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 11 Jun 2002 06:24:46 -0400 (EDT)
	(envelope-from dpelleg@palraz.wburn)
Received: (from dpelleg@localhost)
	by palraz.wburn (8.12.3/8.12.3/Submit) id g5BAOkZn012280;
	Tue, 11 Jun 2002 06:24:46 -0400 (EDT)
Message-Id: <200206111024.g5BAOkZn012280@palraz.wburn>
Date: Tue, 11 Jun 2002 06:24:46 -0400 (EDT)
From: Dan Pelleg <daniel@pelleg.org>
Reply-To: Dan Pelleg <daniel@pelleg.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: sound fails to load on some Thinkpad models
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         39146
>Category:       kern
>Synopsis:       sound fails to load on some Thinkpad models
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 11 03:30:02 PDT 2002
>Closed-Date:    Wed Jun 12 09:24:41 PDT 2002
>Last-Modified:  Wed Jun 12 09:24:41 PDT 2002
>Originator:     Dan Pelleg
>Release:        FreeBSD 4.6-RC i386
>Organization:
>Environment:
System: FreeBSD p 4.6-RC FreeBSD 4.6-RC #0: Fri Jun 7 21:01:47 EDT 2002 d@p:/P i386


	
>Description:
 Sound chip is not recognized on several Thinkpad X22 and X23 models.
>How-To-Repeat:
 build a kernel with pcm, load on a X23.
>Fix:

 This has been suggested by Colin Perkins on mobile@ at
12 Apr 2002. It works for his X22, as well as for me
and another person using a X23-2662-K1T and a X23-2662-E5U.
I don't know if it breaks anything for anyone.


--- ac97.c.patch begins here ---
--- sys/dev/sound/pcm/ac97.c.orig	Mon Jun 10 21:09:50 2002
+++ sys/dev/sound/pcm/ac97.c	Mon Jun 10 21:10:25 2002
@@ -373,7 +373,7 @@
 
 	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
 	wrcd(codec, AC97_REG_RESET, 0);
-	DELAY(100000);
+	DELAY(400000);
 	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
 
 	i = rdcd(codec, AC97_REG_RESET);
@@ -468,7 +468,7 @@
 
 	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
 	wrcd(codec, AC97_REG_RESET, 0);
-	DELAY(100000);
+	DELAY(400000);
 	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
 	i = rdcd(codec, AC97_REG_RESET);
 
--- ac97.c.patch ends here ---


>Release-Note:
>Audit-Trail:

From: Colin Perkins <csp@isi.edu>
To: freebsd-gnats-submit@FreeBSD.org
Cc: daniel@pelleg.org
Subject: Re: kern/39146: sound fails to load on some Thinkpad models
Date: Tue, 11 Jun 2002 10:02:50 -0400

 Try the following (from Orion Hodson <hodson@freebsd.org>, I just tweaked
 it to work with reinit_mixer too)
 Colin
 
 
 
 Index: ac97.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/sound/pcm/ac97.c,v
 retrieving revision 1.5.2.9
 diff -u -r1.5.2.9 ac97.c
 --- ac97.c	2002/04/22 15:49:35	1.5.2.9
 +++ ac97.c	2002/06/11 13:58:31
 @@ -373,7 +373,18 @@
  
  	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
  	wrcd(codec, AC97_REG_RESET, 0);
 -	DELAY(100000);
 +	for(i = 0; i < 500; i++) {
 +		static u_int32_t os = 0;
 +		u_int32_t s = rdcd(codec, AC97_REG_POWER) & AC97_POWER_STATUS;
 +		if (s == AC97_POWER_STATUS)
 +			break;
 +		if (s != os)
 +			device_printf(codec->dev, "status 0x%02x %d\n", s, i);
 +		os = s;
 +		DELAY(10000);
 +	}
 +	device_printf(codec->dev, "Ready at %d\n", i);
 +
  	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
  
  	i = rdcd(codec, AC97_REG_RESET);
 @@ -468,7 +479,17 @@
  
  	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
  	wrcd(codec, AC97_REG_RESET, 0);
 -	DELAY(100000);
 +	for (i = 0; i < 500; i++) {
 +		static u_int32_t os = 0;
 +		u_int32_t s = rdcd(codec, AC97_REG_POWER) & AC97_POWER_STATUS;
 +		if (s == AC97_POWER_STATUS)
 +			break;
 +		if (s != os)
 +			device_printf(codec->dev, "status 0x%02x %d\n", s, i);
 +		os = s;
 +		DELAY(10000);
 +	}
 +	device_printf(codec->dev, "Ready at %d\n", i);
  	wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
  	i = rdcd(codec, AC97_REG_RESET);
  
 Index: ac97.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/sound/pcm/ac97.h,v
 retrieving revision 1.3.2.7
 diff -u -r1.3.2.7 ac97.h
 --- ac97.h	2002/04/22 15:49:35	1.3.2.7
 +++ ac97.h	2002/06/11 13:58:54
 @@ -56,6 +56,12 @@
  #define AC97_REG_GEN	0x20
  #define AC97_REG_3D	0x22
  #define AC97_REG_POWER	0x26
 +#define		AC97_POWER_ADC		(1 << 0)
 +#define		AC97_POWER_DAC		(1 << 1)
 +#define 	AC97_POWER_ANL		(1 << 2)
 +#define 	AC97_POWER_REF		(1 << 3)
 +#define		AC97_POWER_STATUS	(AC97_POWER_ADC | AC97_POWER_DAC | \
 +					 AC97_POWER_REF | AC97_POWER_ANL )
  #define AC97_REGEXT_ID		0x28
  #define 	AC97_EXTCAP_VRA		(1 << 0)
  #define 	AC97_EXTCAP_DRA		(1 << 1)
 
State-Changed-From-To: open->closed 
State-Changed-By: orion 
State-Changed-When: Wed Jun 12 09:05:43 PDT 2002 
State-Changed-Why:  
This was fixed in -CURRENT, on April 26th, shortly before the code 
freeze for 4.6R).  I was busy elsewhere when the code freeze heads up 
was made and as a result the fix did not make into 4.6.  Since it is 
not fatal and a solution is already documented in the PR's, I did not 
feel sufficiently motivated to press for MFC after the code freeze for 
this problem. 


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