summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@cvs.openbsd.org>2022-02-16 06:23:43 +0000
committerAnton Lindqvist <anton@cvs.openbsd.org>2022-02-16 06:23:43 +0000
commitba93eed72096645fb3ff4322eee1d427d53bc95f (patch)
tree734f1af6f0086e85180574935b8ae68f8b3be50e /sys/dev/usb
parent6b5ed4ea8ca4b14dafdb7ce15afc72a6d756202a (diff)
Currently, wskbd_set_mixervolume() only adjusts the volume of the first
attached audio device, i.e. audio0. This approach does not work well while using additional audio devices equipped with physical volume keys since those would only affect the volume of audio0. Instead, correlate audio and ucc devices attached over USB in order to adjust the volume of the correct audio device. This is done by passing a cookie from the common point of attachment which is later used to correlate the audio and wskbd device. The same approach could be adopted for audio and wskbd devices attaching on a different bus. Keep in mind that it's of importance to make use of and increment the same global cookie identifier to avoid collisions. Makes the volume keys on my Logitech G435 Headset do the right thing. ok ratchov@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uaudio.c4
-rw-r--r--sys/dev/usb/ucc.c9
-rw-r--r--sys/dev/usb/usb_subr.c8
-rw-r--r--sys/dev/usb/usbdi.h3
4 files changed, 16 insertions, 8 deletions
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index f7afca68c8c..c37866f061f 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uaudio.c,v 1.166 2022/02/16 06:21:19 anton Exp $ */
+/* $OpenBSD: uaudio.c,v 1.167 2022/02/16 06:23:42 anton Exp $ */
/*
* Copyright (c) 2018 Alexandre Ratchov <alex@caoua.org>
*
@@ -3841,7 +3841,7 @@ uaudio_attach(struct device *parent, struct device *self, void *aux)
/* print a nice uaudio attach line */
uaudio_print(sc);
- audio_attach_mi(&uaudio_hw_if, sc, NULL, &sc->dev);
+ audio_attach_mi(&uaudio_hw_if, sc, arg->cookie, &sc->dev);
}
int
diff --git a/sys/dev/usb/ucc.c b/sys/dev/usb/ucc.c
index f23f32990bb..c37d703ff89 100644
--- a/sys/dev/usb/ucc.c
+++ b/sys/dev/usb/ucc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ucc.c,v 1.29 2022/01/09 05:43:00 jsg Exp $ */
+/* $OpenBSD: ucc.c,v 1.30 2022/02/16 06:23:42 anton Exp $ */
/*
* Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org>
@@ -104,7 +104,7 @@ void ucc_attach(struct device *, struct device *, void *);
int ucc_detach(struct device *, int);
void ucc_intr(struct uhidev *, void *, u_int);
-void ucc_attach_wskbd(struct ucc_softc *);
+void ucc_attach_wskbd(struct ucc_softc *, void *);
int ucc_enable(void *, int);
void ucc_set_leds(void *, int);
int ucc_ioctl(void *, u_long, caddr_t, int, struct proc *);
@@ -680,7 +680,7 @@ ucc_attach(struct device *parent, struct device *self, void *aux)
/* Cannot load an empty map. */
if (sc->sc_maplen > 0)
- ucc_attach_wskbd(sc);
+ ucc_attach_wskbd(sc, uha->uaa->cookie);
}
int
@@ -772,7 +772,7 @@ unknown:
}
void
-ucc_attach_wskbd(struct ucc_softc *sc)
+ucc_attach_wskbd(struct ucc_softc *sc, void *cookie)
{
static const struct wskbd_accessops accessops = {
.enable = ucc_enable,
@@ -784,6 +784,7 @@ ucc_attach_wskbd(struct ucc_softc *sc)
.keymap = &sc->sc_keymap,
.accessops = &accessops,
.accesscookie = sc,
+ .audiocookie = cookie,
};
sc->sc_keydesc[0].name = KB_US;
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 7d8480f0f01..9cbbf7f0368 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.157 2022/01/09 05:43:02 jsg Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.158 2022/02/16 06:23:42 anton Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -839,6 +839,11 @@ usbd_status
usbd_probe_and_attach(struct device *parent, struct usbd_device *dev, int port,
int addr)
{
+ /*
+ * Used to correlate audio and wskbd devices as this is the common point
+ * of attachment between the two.
+ */
+ static char *cookie = 0;
struct usb_attach_arg uaa;
usb_device_descriptor_t *dd = &dev->ddesc;
int i, confi, nifaces;
@@ -860,6 +865,7 @@ usbd_probe_and_attach(struct device *parent, struct usbd_device *dev, int port,
uaa.vendor = UGETW(dd->idVendor);
uaa.product = UGETW(dd->idProduct);
uaa.release = UGETW(dd->bcdDevice);
+ uaa.cookie = ++cookie;
/* First try with device specific drivers. */
DPRINTF(("usbd_probe_and_attach trying device specific drivers\n"));
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 05209bcb809..030a6a5cdb6 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.h,v 1.71 2021/02/01 09:21:51 mglocker Exp $ */
+/* $OpenBSD: usbdi.h,v 1.72 2022/02/16 06:23:42 anton Exp $ */
/* $NetBSD: usbdi.h,v 1.62 2002/07/11 21:14:35 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -227,6 +227,7 @@ struct usb_attach_arg {
int usegeneric;
struct usbd_interface **ifaces;/* all interfaces */
int nifaces; /* number of interfaces */
+ void *cookie;
};
/* Match codes. */