NetBSD Problem Report #58031
From andreas@pc.domain.home Tue Mar 12 07:09:30 2024
Return-Path: <andreas@pc.domain.home>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 6FBF21A923F
for <gnats-bugs@gnats.NetBSD.org>; Tue, 12 Mar 2024 07:09:30 +0000 (UTC)
Message-Id: <20240312070932.AB8E06B3AF6@pc.domain.home>
Date: Tue, 12 Mar 2024 08:09:32 +0100 (CET)
From: a.e.hecht@t-online.de
Reply-To: a.e.hecht@t-online.de
To: gnats-bugs@NetBSD.org
Subject: audio keys don't work on thinkpad X200
X-Send-Pr-Version: 3.95
>Number: 58031
>Category: kern
>Synopsis: audio keys don't work on thinkpad X200
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 12 07:10:00 +0000 2024
>Originator: Andreas Hecht
>Release: NetBSD 10.99.10
>Organization:
N/A
>Environment:
System: NetBSD pc.domain.home 10.99.10 NetBSD 10.99.10 (MYKERNEL) #89: Mon Mar 11 12:38:31 CET 2024 andreas@pc.domain.home:/home/andreas/git/netbsd/src/sys/arch/amd64/compile/obj/MYKERNEL amd64
Architecture: x86_64
Machine: amd64
>Description:
The volume up/down hotkeys on the thinkpad X200 do not work. The problem is
probably not limited to the X200 but might affect any model which has its audio
keys handled by the pckbd driver (-> see fix below).
>How-To-Repeat:
On the X200, press volume up/down key and observe the output of 'mixerctl -a':
The volume will not change.
>Fix:
The pckbd driver fails to forward the volume up (176), volume down (174) and
volume mute (160) keycodes to the wskbd driver's wskbd_input function. The
patch below (inspired by OpenBSD's implementation) fixes this.
wskbd_input calls wskbd_translate and internal_command functions in turn where
the keys get treated as internal commands:
KS_Cmd_VolumeUp, KS_Cmd_VolumeDown and KS_Cmd_VolumeToggle.
These internal commands inject
PMFE_AUDIO_VOLUME_UP, PMFE_AUDIO_VOLUME_DOWN and PMFE_AUDIO_VOLUME_TOGGLE
events via the PMF framework which, when processed, cause the audio driver's
audio_volume_up, audio_volume_down and audio_volume_toggle
functions to be called.
So, everything regarding volume control seems to be in place already
except for the volume hotkey related keycode forwarding in the pckbd
driver.
Index: sys/dev/pckbport/pckbd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pckbport/pckbd.c,v
retrieving revision 1.39
diff -u -p -r1.39 pckbd.c
--- sys/dev/pckbport/pckbd.c 9 Feb 2024 22:08:36 -0000 1.39
+++ sys/dev/pckbport/pckbd.c 11 Mar 2024 16:37:17 -0000
@@ -1010,19 +1010,27 @@ pckbd_input(void *vsc, int data)
struct pckbd_softc *sc = vsc;
int key;
u_int type;
+ bool is_decoded;
data = pckbd_scancode_translate(sc->id, data);
if (data == 0)
return;
+ is_decoded = pckbd_decode(sc->id, data, &type, &key);
+
#ifdef WSDISPLAY_COMPAT_RAWKBD
if (sc->rawkbd) {
u_char d = data;
wskbd_rawinput(sc->sc_wskbddev, &d, 1);
- return;
+
+ /*
+ * Pass audio keys to wskbd_input anyway.
+ */
+ if ((!is_decoded) || (key != 160 && key != 174 && key != 176))
+ return;
}
#endif
- if (pckbd_decode(sc->id, data, &type, &key))
+ if (is_decoded)
wskbd_input(sc->sc_wskbddev, type, key);
}
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.