From mi@aldan.algebra.com  Sun May  9 09:24:19 2004
Return-Path: <mi@aldan.algebra.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 48E3716A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 May 2004 09:24:19 -0700 (PDT)
Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5F04A43D4C
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 May 2004 09:24:18 -0700 (PDT)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (mi@localhost [127.0.0.1])
	by aldan.algebra.com (8.12.11/8.12.11) with ESMTP id i49GOBAp068505
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sun, 9 May 2004 12:24:12 -0400 (EDT)
	(envelope-from mi@aldan.algebra.com)
Received: (from mi@localhost)
	by aldan.algebra.com (8.12.11/8.12.11/Submit) id i49GOAK5068504;
	Sun, 9 May 2004 12:24:10 -0400 (EDT)
	(envelope-from mi)
Message-Id: <200405091624.i49GOAK5068504@aldan.algebra.com>
Date: Sun, 9 May 2004 12:24:10 -0400 (EDT)
From: Mikhail Teterin <mi@aldan.algebra.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: FUKAUMI Naoki <naoki@fukaumi.org>, mobile@FreeBSD.org
Subject: no sound on modern Sony Vaio (PCG-TR*) [patch]
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         66422
>Category:       kern
>Synopsis:       [sound] [patch] no sound on modern Sony Vaio (PCG-TR*)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-multimedia
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 09 09:30:23 PDT 2004
>Closed-Date:    Mon Jan 09 11:23:33 GMT 2006
>Last-Modified:  Mon Jan 09 11:23:33 GMT 2006
>Originator:     Mikhail Teterin
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
Virtual Estates, Inc.
>Environment:
System: FreeBSD aldan.algebra.com 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Mon Mar 29 19:54:25 EST 2004 mi@aldan.algebra.com:/home/obj/oh/src/sys/DEBUG i386

>Description:

	The laptop uses Intel's Centrino for everything. The sound card
	is recognized by the snd_ich module, and all of the
	sound-producing programs work, but no sound ever comes out.

>How-To-Repeat:

	Boot a Vaio-TR laptop.

		kldload snd_ich
		mpg123 anything.mp3

	mpg123 honestly decodes, but there is no sound in the speakers,
	nor in the headphones.

>Fix:

	The idea is from FUKAUMI Naoki, whose e-mail I found at

		http://www.unixmagic.org/ml/netbsd/200308/msg00011.html

	reading it was impossible for me, except for the patches :-)

	The ach97.c-patch was not directly applicable to FreeBSD, but
	the idea to write AC97_POWER_EAMP while initializing turned out
	to be applicable.

	The sound on my PCG-TR2/B now works, although pushing the
	sound-controlling buttons on the laptop's keyboard and on the
	lid still has no effect.

	I'm sure, there were good reasons to conditionalize this
	based on ``codec->flags & AC97_F_EAPD_INV'', so my patch will,
	probably, break sound on some other machine. Someone with
	knowledge of the specs should carefully examine it...

	The patch is slightly bigger than it absolutely needs to be,
	because I'm replacing the 0x8000 constant with AC97_POWER_EAMP
	borrowed from NetBSD.

===================================================================
RCS file: /home/ncvs/src/sys/dev/sound/pcm/ac97.h,v
retrieving revision 1.15
diff -U2 -r1.15 ac97.h
--- sys/dev/sound/pcm/ac97.h	7 Sep 2003 16:28:03 -0000	1.15
+++ sys/dev/sound/pcm/ac97.h	9 May 2004 16:21:35 -0000
@@ -63,4 +63,5 @@
 #define		AC97_POWER_STATUS	(AC97_POWER_ADC | AC97_POWER_DAC | \
 					 AC97_POWER_REF | AC97_POWER_ANL )
+#define AC97_POWER_EAMP	0x8000
 #define AC97_REGEXT_ID		0x28
 #define 	AC97_EXTCAP_VRA		(1 << 0)
===================================================================
RCS file: /home/ncvs/src/sys/dev/sound/pcm/ac97.c,v
retrieving revision 1.50
diff -U2 -r1.50 ac97.c
--- sys/dev/sound/pcm/ac97.c	23 Jan 2004 16:38:54 -0000	1.50
+++ sys/dev/sound/pcm/ac97.c	9 May 2004 16:21:35 -0000
@@ -546,7 +546,7 @@
 	}
 
-	ac97_wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
+	ac97_wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? AC97_POWER_EAMP : 0x0000);
 	ac97_reset(codec);
-	ac97_wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
+	ac97_wrcd(codec, AC97_REG_POWER, AC97_POWER_EAMP);
 
 	i = ac97_rdcd(codec, AC97_REG_RESET);
@@ -661,7 +661,7 @@
 	}
 
-	ac97_wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
+	ac97_wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? AC97_POWER_EAMP : 0x0000);
 	ac97_reset(codec);
-	ac97_wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
+	ac97_wrcd(codec, AC97_REG_POWER, AC97_POWER_EAMP);
 
 	if (!codec->noext) {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sound 
Responsible-Changed-By: mi 
Responsible-Changed-When: Sun May 9 09:35:12 PDT 2004 
Responsible-Changed-Why:  
This is squarely in the "sound" domain. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=66422 
State-Changed-From-To: open->closed 
State-Changed-By: ariff 
State-Changed-When: Mon Jan 9 11:22:36 UTC 2006 
State-Changed-Why:  
A better fix has been committed to -current and will be MFCed to 
-stable (RELENG_6) later. Thanks. 

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