From david@catwhisker.org  Wed Apr 25 12:46:47 2001
Return-Path: <david@catwhisker.org>
Received: from bunrab.catwhisker.org (adsl-63-193-123-122.dsl.snfc21.pacbell.net [63.193.123.122])
	by hub.freebsd.org (Postfix) with ESMTP id C2AF237B423
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 25 Apr 2001 12:46:46 -0700 (PDT)
	(envelope-from david@catwhisker.org)
Received: (from david@localhost)
	by bunrab.catwhisker.org (8.10.0/8.10.0) id f3PJkdS12676;
	Wed, 25 Apr 2001 12:46:39 -0700 (PDT)
Message-Id: <200104251946.f3PJkdS12676@bunrab.catwhisker.org>
Date: Wed, 25 Apr 2001 12:46:39 -0700 (PDT)
From: David Wolfskill <david@catwhisker.org>
Reply-To: david@catwhisker.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: Fix for hardware mute for ESS Technology Maestro-2E on Compal N38W2
X-Send-Pr-Version: 3.2

>Number:         26854
>Category:       kern
>Synopsis:       [sound] [patch] Better fix for ESS Technology Maestro-2E hardware mute
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-multimedia
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 25 12:50:00 PDT 2001
>Closed-Date:    Sun Sep 11 12:43:13 GMT 2005
>Last-Modified:  Sun Sep 11 12:43:13 GMT 2005
>Originator:     David Wolfskill
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
Wolfskill and Dowling Residence
>Environment:
System: FreeBSD m147.whistle.com 4.3-STABLE FreeBSD 4.3-STABLE #30: Wed Apr 25 06:43:02 PDT 2001 root@dhcp-140.catwhisker.org:/common/S1/obj/usr/src/sys/LAPTOP_30W i386

(I also use the same fix on the same hardware running 5.0-CURRENT.  I've
been tracking -STABLE daily, and -CURRENT nearly so (didn't build a
couple of days ago, for example).)

Hardware is a laptop made by Compal, model N38W2; it is sold by various
vendors, and since it shares the same BIOS as the Dell Inspiron 5000e, I
suspect that folks using those would also be affected (and jhb has, if I
recall correctly, reported that it works for him -- though the current
code (without that attached patch also works for him, but not for me)).

Sound ("pcm" driver in kernel) shows up in dmesg:

pcm0: <ESS Technology Maestro-2E> port 0x1400-0x14ff irq 7 at device 8.0 on pci0


There are a couple of (hardware) ways to toggle the "mute" switch for
sound:  there's a keyboard chord (Fn+End), and there are a couple of
buttons under the left-hand lid latch:  normally, one of these increases
volume and the other decreases it.  With this patch, pressing both will
toggle mute.


>Description:

Without the (below) patch, hitting a "mute" chord generates the message:

Mar 26 18:50:21 localhost /kernel: pcm0: pcm0: unknown HWVOL event 0x77

and the attempt to modify the mute setting fails.

(Please see
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=52506+0+archive/2001/freebsd-mobile/20010401.freebsd-mobile
and its follow-on messages for additional details and context.)

>How-To-Repeat:

	Get one of these laptops (more on the laptop is at
	http://www.catwhisker.org/~david/FreeBSD/laptop.html).  Install
	FreeBSD on it.  Try hitting a "mute" chord.

>Fix:
	
(The below patch may also be found in
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=60957+0+archive/2001/freebsd-mobile/20010401.freebsd-mobile.
Please note jhb's comment on the patch in
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=82193+0+/usr/local/www/db/text/2001/freebsd-mobile/20010401.freebsd-mobile,
as well as the one in
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=91616+0+archive/2001/freebsd-mobile/20010401.freebsd-mobile.)

From taku@cent.saitama-u.ac.jp Mon Mar 26 23:53:10 2001
Return-Path: <taku@cent.saitama-u.ac.jp>
Received: from janus.catwhisker.org (janus.catwhisker.org [172.16.8.1])
	by bunrab.catwhisker.org (8.10.0/8.10.0) with ESMTP id f2R7r9x14088
	for <david@mail.catwhisker.org>; Mon, 26 Mar 2001 23:53:09 -0800 (PST)
Received: from maestro (dhcp-1.cent.saitama-u.ac.jp [133.38.4.27])
	by janus.catwhisker.org (8.10.0/8.10.0) with ESMTP id f2R7r1B82859
	for <david@catwhisker.org>; Mon, 26 Mar 2001 23:53:03 -0800 (PST)
Received: from dhcp-1.cent.saitama-u.ac.jp (localhost [127.0.0.1])
	by maestro (8.11.3/8.11.2) with ESMTP id f2R7qX758863;
	Tue, 27 Mar 2001 16:52:41 +0900 (JST)
	(envelope-from taku@cent.saitama-u.ac.jp)
Date: Tue, 27 Mar 2001 16:52:31 +0900
Message-ID: <rtg1yrjvebk.wl@dhcp-1.cent.saitama-u.ac.jp>
From: Taku YAMAMOTO <taku@cent.saitama-u.ac.jp>
To: David Wolfskill <david@catwhisker.org>
Cc: mobile@freebsd.org
Subject: Re: Reality check on ESS Technology Maestro-2E h/w "mute" function?
In-Reply-To: <200103270658.f2R6w2c13898@bunrab.catwhisker.org>
References: <200103270658.f2R6w2c13898@bunrab.catwhisker.org>
User-Agent: Wanderlust/2.4.0 (Rio) WEMI/1.13.7 (Shimada) FLIM/1.13.2 (Kasanui) MULE XEmacs/21.1 (patch 12) (Channel Islands) (i386--freebsd)
Organization: Advanced Computer and Communication Enginerring Studies Society
MIME-Version: 1.0 (generated by WEMI 1.13.7 - "Shimada")
Content-Type: multipart/mixed;
 boundary="Multipart_Tue_Mar_27_16:52:31_2001-1"
Status: RO

--Multipart_Tue_Mar_27_16:52:31_2001-1
Content-Type: text/plain; charset=US-ASCII

According to datasheets, HWVOL_MUTE (== 0x99) came from HWVOL_NOP | 0x11,
where 0x11 means "mute button pressed".

But, since mute button is actually choded into UP-and-DOWN simultaneously,
it may happen to misunderstand MUTE button as if an independent
UP/DOWN event came first. (It is nothing more than my imagination, though.)

So, perhaps 0x77 came from HWVOL_DOWN | 0x11, I imagine.
Attached diff will make both 0x77 and 0x99 to be recognized as MUTE.
(And, hopefully, 0xbb --- HWVOL_UP | 0x11 --- , too)

-- 
YAMAMOTO, Taku <taku@cent.saitama-u.ac.jp>
Member of Advanced Computer and Communication Studies Society
(ACCESS for short), Information Processing Center, Saitama Univ.

--Multipart_Tue_Mar_27_16:52:31_2001-1
Content-Type: text/plain; type=patch; charset=US-ASCII
Content-Disposition: attachment; filename="hwvol.diff"
Content-Transfer-Encoding: 7bit

--- sys/dev/sound/pci/maestro.c.orig	Mon Mar 26 02:29:35 2001
+++ sys/dev/sound/pci/maestro.c	Tue Mar 27 16:28:06 2001
@@ -850,9 +850,6 @@
 
 		event = bus_space_read_1(ess->st, ess->sh, PORT_HWVOL_MASTER);
 		switch (event) {
-		case HWVOL_MUTE:
-			mixer_hwvol_mute(ess->dev);
-			break;
 		case HWVOL_UP:
 			mixer_hwvol_step(ess->dev, 1, 1);
 			break;
@@ -862,6 +859,10 @@
 		case HWVOL_NOP:
 			break;
 		default:
+			if (event & HWVOL_MUTE) {
+				mixer_hwvol_mute(ess->dev);
+				break;
+			}
 			device_printf(ess->dev, "%s: unknown HWVOL event 0x%x\n",
 			    device_get_nameunit(ess->dev), event);
 		}
--- sys/dev/sound/pci/maestro_reg.h.orig	Wed Jan  3 10:32:57 2001
+++ sys/dev/sound/pci/maestro_reg.h	Tue Mar 27 16:28:29 2001
@@ -140,7 +140,7 @@
 #define PORT_HWVOL_MASTER_SHADOW 0x1e	/* BYTE RW */
 #define PORT_HWVOL_MASTER	0x1f	/* BYTE RW */
 #define HWVOL_NOP		0x88
-#define HWVOL_MUTE		0x99
+#define HWVOL_MUTE		0x11
 #define HWVOL_UP		0xaa
 #define HWVOL_DOWN		0x66
 

--Multipart_Tue_Mar_27_16:52:31_2001-1--

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: asmodai 
State-Changed-When: Sun Apr 7 08:16:01 PDT 2002 
State-Changed-Why:  
David, did this actually work for you? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26854 
State-Changed-From-To: feedback->analyzed 
State-Changed-By: asmodai 
State-Changed-When: Sun Apr 7 09:29:20 PDT 2002 
State-Changed-Why:  
Problem and fix identified. 


Responsible-Changed-From-To: freebsd-bugs->sounds 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Sun Apr 7 09:29:20 PDT 2002 
Responsible-Changed-Why:  
Talked with Cameron Grant, he has changes for the sound system which 
include this fix. 

Change to sound@ as a reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26854 
Responsible-Changed-From-To: sounds->sound 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Sun Apr 7 09:30:53 PDT 2002 
Responsible-Changed-Why:  
Spell sound correctly. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26854 
State-Changed-From-To: analyzed->closed 
State-Changed-By: netchild 
State-Changed-When: Sun Sep 11 12:42:50 GMT 2005 
State-Changed-Why:  
This seems to be in the current sound code. 

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