Sunday, July 07, 2024

Make ucc(4) pass audio cookie to wskbd(4)

Index: dev/hid/hidcc.c
===================================================================
RCS file: /cvs/src/sys/dev/hid/hidcc.c,v
diff -u -r1.5 hidcc.c
--- dev/hid/hidcc.c 14 Nov 2022 00:16:44 -0000 1.5
+++ dev/hid/hidcc.c 7 Jul 2024 15:42:13 -0000
@@ -593,7 +593,7 @@
#undef N
};

-void hidcc_attach_wskbd(struct hidcc *);
+void hidcc_attach_wskbd(struct hidcc *, void *);
int hidcc_enable(void *, int);
void hidcc_set_leds(void *, int);
int hidcc_ioctl(void *, u_long, caddr_t, int, struct proc *);
@@ -667,7 +667,7 @@

/* Cannot load an empty map. */
if (sc->sc_maplen > 0)
- hidcc_attach_wskbd(sc);
+ hidcc_attach_wskbd(sc, hca->audio_cookie);

return sc;
}
@@ -755,7 +755,7 @@
}

void
-hidcc_attach_wskbd(struct hidcc *sc)
+hidcc_attach_wskbd(struct hidcc *sc, void *audio_cookie)
{
static const struct wskbd_accessops accessops = {
.enable = hidcc_enable,
@@ -767,7 +767,7 @@
.keymap = &sc->sc_keymap,
.accessops = &accessops,
.accesscookie = sc,
- .audiocookie = NULL, /* XXX audio_cookie */
+ .audiocookie = audio_cookie
};

sc->sc_keydesc[0].name = KB_US;
Hi,

I recently bought a JBL USB-C wired headphones for my 2020 Apple MacBook
Air to enjoy audio without disturbing my family. The headphones is
exposed via uaudio(4) as audio1 to the system. The headphones come with
a simple consumer control keyboard supported by ucc(4) and wskbd(4). The
keyboard exposes 2 volume control keys and an unmapped key. The relevant
dmesg(8) lines are:

uaudio0 at uhub1 port 1 configuration 1 interface 1 "KTMICRO JBL TUNE
310C USB-C" rev 2.00/0.03 addr 2
uaudio0: class v1, full-speed, sync, channels: 2 play, 1 rec, 5 ctls
audio1 at uaudio0
uhidev0 at uhub1 port 1 configuration 1 interface 3 "KTMICRO JBL TUNE
310C USB-C" rev 2.00/0.03 addr 2
uhidev0: iclass 3/0, 84 report ids
ucc0 at uhidev0 reportid 1: 4 usages, 3 keys, enum
wskbd1 at ucc0 mux 1
wskbd1: connecting to wsdisplay0
uhid0 at uhidev0 reportid 75: input=10, output=10, feature=0
uhid1 at uhidev0 reportid 84: input=10, output=10, feature=0

The volume control keys unfortunately can only control audio0 in an
OpenBSD 7.5-stable system as sys/dev/hid/hidcc.c does not currently pass
the audio cookie it receives from ucc(4) on to wskbd(4). The attached
hidcc_c.patch is a (simple) attempt at fixing this issue. It allows me
to control the volume on my headphones using the consumer control
keyboard, a good quality of life improvement.

Cheers,

Mark

No comments:

Post a Comment