From CQG00620@nifty.ne.jp  Tue Feb 27 13:02:47 2007
Return-Path: <CQG00620@nifty.ne.jp>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 07F4E16A401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Feb 2007 13:02:47 +0000 (UTC)
	(envelope-from CQG00620@nifty.ne.jp)
Received: from mail.asahi-net.or.jp (mail1.asahi-net.or.jp [202.224.39.197])
	by mx1.freebsd.org (Postfix) with ESMTP id 3C29D13C471
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Feb 2007 13:02:46 +0000 (UTC)
	(envelope-from CQG00620@nifty.ne.jp)
Received: from asahi-net.jp (h205095.ppp.asahi-net.or.jp [61.114.205.95])
	by mail.asahi-net.or.jp (Postfix) with ESMTP id 1269A2EBBC
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Feb 2007 21:44:38 +0900 (JST)
Message-Id: <20070227124438.1269A2EBBC@mail.asahi-net.or.jp>
Date: Tue, 27 Feb 2007 21:44:33 +0900
From: Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
Reply-To: Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] Cannot control treble/bass functions on YAMAHA YMF753 AC97 codec

>Number:         109599
>Category:       kern
>Synopsis:       [sound] [patch] Cannot control treble/bass functions on YAMAHA YMF753 AC97 codec
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ariff
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 27 13:10:05 GMT 2007
>Closed-Date:    Tue Mar 06 02:37:50 GMT 2007
>Last-Modified:  Thu Apr 26 08:40:04 GMT 2007
>Originator:     Watanabe Kazuhiro
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD capricorn.sign.local 7.0-CURRENT FreeBSD 7.0-CURRENT #3: Mon Feb 26 16:31:22 JST 2007 nabe@capricorn:/FreeBSD/obj/FreeBSD/HEAD/src/sys/GENERIC i386

Sound: SiS 7012 ICH controller with YAMAHA YMF753 AC97 codec
>Description:
I have a PC which uses SiS 7012 ICH controller with YAMAHA YMF753
AC'97 codec.  It works well with snd_ich driver, but cannot control
the treble/bass functions.

YAMAHA AC'97 codecs (YMF743/752/753) has treble/bass and 3D
enhancement functions.  YMF743 and YMF753 has both functions,
and YMF752 have only 3D control.

But these functions are not indicated in the Reset register (0x00).

 * AC'97 Component Specification Revision 2.2, p.50
   http://www.alsa-project.org/alsa/ftp/manuals/intel/ac97r22.pdf

 * YAMAHA YMF753 datasheet, p.6
   http://www.yamaha.co.jp/english/product/lsi/us/products/pdf/4MF753A20.pdf

>How-To-Repeat:
 * before applied the patch:

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit)
Installed devices:
pcm0: <SiS 7012> at io 0x1400, 0x1080 irq 18 bufsz 16384 kld snd_ich (1p/1r/1v c
hannels duplex default)
$ dmesg | grep ^pcm
pcm0: <SiS 7012> port 0x1400-0x14ff,0x1080-0x10ff irq 18 at device 2.7 on pci0
pcm0: Reserved 0x100 bytes for rid 0x10 type 4 at 0x1400
pcm0: Reserved 0x80 bytes for rid 0x14 type 4 at 0x1080
pcm0: [MPSAFE]
pcm0: [ITHREAD]
pcm0: <Yamaha YMF753 AC97 Codec (id = 0x594d4803)>
pcm0: Codec features 18 bit DAC, 5 bit master volume, no 3D Stereo Enhancement
pcm0: Primary codec extended features reserved 1, AMAP, reserved 4
pcm0: ac97 codec dac ready count: 0
pcm0: Mixer "vol":
pcm0: Mixer "pcm":
pcm0: Mixer "speaker":
pcm0: Mixer "line":
pcm0: Mixer "mic":
pcm0: Mixer "cd":
pcm0: Mixer "rec":
pcm0: Mixer "igain":
pcm0: Mixer "line1":
pcm0: Mixer "phin":
pcm0: Mixer "phout":
pcm0: Mixer "video":
pcm0: sndbuf_setmap e9f6000, 4000; 0xcbf08000 -> e9f6000
pcm0: sndbuf_setmap e9f2000, 4000; 0xcbf0c000 -> e9f2000
pcm0: measured ac97 link rate at 48021 Hz, will use 48000 Hz
$ mixer
Mixer vol      is currently set to  75:75
Mixer pcm      is currently set to  75:75
Mixer speaker  is currently set to  75:75
Mixer line     is currently set to  75:75
Mixer mic      is currently set to   0:0
Mixer cd       is currently set to  75:75
Mixer rec      is currently set to   0:0
Mixer igain    is currently set to   0:0
Mixer line1    is currently set to  75:75
Mixer phin     is currently set to   0:0
Mixer phout    is currently set to   0:0
Mixer video    is currently set to  75:75
Recording source: mic

 * after applied the patch:

$ dmesg | grep ^pcm
pcm0: <SiS 7012> port 0x1400-0x14ff,0x1080-0x10ff irq 18 at device 2.7 on pci0
pcm0: Reserved 0x100 bytes for rid 0x10 type 4 at 0x1400
pcm0: Reserved 0x80 bytes for rid 0x14 type 4 at 0x1080
pcm0: [MPSAFE]
pcm0: [ITHREAD]
pcm0: <Yamaha YMF753 AC97 Codec (id = 0x594d4803)>
pcm0: Codec features tone, 18 bit DAC, 5 bit master volume, Yamaha Ymersion
pcm0: Primary codec extended features reserved 1, AMAP, reserved 4
pcm0: ac97 codec dac ready count: 0
pcm0: Mixer "vol":
pcm0: Mixer "bass":
pcm0: Mixer "treble":
pcm0: Mixer "pcm":
pcm0: Mixer "speaker":
pcm0: Mixer "line":
pcm0: Mixer "mic":
pcm0: Mixer "cd":
pcm0: Mixer "rec":
pcm0: Mixer "igain":
pcm0: Mixer "line1":
pcm0: Mixer "phin":
pcm0: Mixer "phout":
pcm0: Mixer "video":
pcm0: sndbuf_setmap e9f6000, 4000; 0xcbf08000 -> e9f6000
pcm0: sndbuf_setmap e9f2000, 4000; 0xcbf0c000 -> e9f2000
pcm0: measured ac97 link rate at 48013 Hz, will use 48000 Hz
>Fix:
This patch has tested on 7-current (and 6.2-RELEASE).

Index: sys/dev/sound/pcm/ac97.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/sound/pcm/ac97.c,v
retrieving revision 1.64
diff -u -r1.64 ac97.c
--- sys/dev/sound/pcm/ac97.c	26 Nov 2006 12:24:05 -0000	1.64
+++ sys/dev/sound/pcm/ac97.c	27 Feb 2007 08:24:36 -0000
@@ -538,6 +538,23 @@
 static void
 ac97_fix_tone(struct ac97_info *codec)
 {
+	/*
+	 * YMF chips does not indicate tone and 3D enhancement capability
+	 * in the AC97_REG_RESET register.
+	 */
+	switch (codec->id) {
+		case 0x594d4800:	/* YMF743 */
+		case 0x594d4803:	/* YMF753 */
+			codec->caps |= AC97_CAP_TONE;
+			codec->se |= 0x04;
+			break;
+		case 0x594d4802:	/* YMF752 */
+			codec->se |= 0x04;
+			break;
+		default:
+			break;
+	}
+
 	/* Hide treble and bass if they don't exist */
 	if ((codec->caps & AC97_CAP_TONE) == 0) {
 		bzero(&codec->mix[SOUND_MIXER_BASS],


This code should be pushed out to a patch function (e.g. ymf_patch()).
But the patch function (codec_patch) is called after
ac97_fix_tone().  So it is a little difficult.

The similar code is also appeared in the ALSA driver.

http://alsa.cvs.sourceforge.net/alsa/alsa-kernel/pci/ac97/ac97_patch.c?r1=1.5&r2=1.6
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-multimedia 
Responsible-Changed-By: remko 
Responsible-Changed-When: Tue Feb 27 13:17:09 UTC 2007 
Responsible-Changed-Why:  
Reassign to multimedia team 


http://www.freebsd.org/cgi/query-pr.cgi?pr=109599 
Responsible-Changed-From-To: freebsd-multimedia->ariff 
Responsible-Changed-By: ariff 
Responsible-Changed-When: Tue Feb 27 14:26:55 UTC 2007 
Responsible-Changed-Why:  
I'll handle this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=109599 
State-Changed-From-To: open->closed 
State-Changed-By: ariff 
State-Changed-When: Tue Mar 6 02:37:15 UTC 2007 
State-Changed-Why:  
Committed, Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/109599: commit references a PR
Date: Tue,  6 Mar 2007 02:37:00 +0000 (UTC)

 ariff       2007-03-06 02:36:55 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/dev/sound/pcm    ac97.c 
   Log:
   Enable tone / 3D controls for YAMAHA YMF743, 753 and 752 (partially).
   
   PR:             kern/109599
   Submitted by:   Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
   
   Revision  Changes    Path
   1.65      +17 -0     src/sys/dev/sound/pcm/ac97.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/109599: commit references a PR
Date: Thu, 26 Apr 2007 08:31:00 +0000 (UTC)

 ariff       2007-04-26 08:30:52 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/dev/sound/pcm    ac97.c ac97.h ac97_patch.c ac97_patch.h 
   Log:
   MFC:
   
   - Patch for AD1981B codec to enable (automuting) headphone jack sense.
   - Enable tone / 3D controls for YAMAHA YMF743, 753 and 752 (partially) [1]
   - AC97 quirk / patch cleanups. Most quirks doesn't work in general sense
     and should only be applied on certain specific card / vendor, hence the
     addition of ac97_getsubvendor(). [2]
   - Fix low volume issue on several MSI laptops through ALC655 quirk. [2]
   
   [1]
   
   PR:                     kern/109599
   Submitted by:           Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
   
   [2]
   
   Reported/Tested by:     Christian Mueller
                           <raptor-freebsd-multimedia@xpls.de>
   
   Revision  Changes    Path
   1.53.2.4  +31 -4     src/sys/dev/sound/pcm/ac97.c
   1.16.2.2  +1 -1      src/sys/dev/sound/pcm/ac97.h
   1.3.2.2   +43 -5     src/sys/dev/sound/pcm/ac97_patch.c
   1.3.2.2   +2 -0      src/sys/dev/sound/pcm/ac97_patch.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
