diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-04-24 21:36:07 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-04-24 21:36:07 +0000 |
commit | 36cceea300723d4be0cefa94f2427a9f2584b6ac (patch) | |
tree | 4fa69b55334e342342482f79dbd1405d9ffe6640 /sys/dev | |
parent | 95ad2e73e71bef4045617a7588b4a7bff91fa678 (diff) |
Skip "all-channels" controls if there are equivalend per-channel ones
Hardware may expose per-channel controls and equivalent ones affecting
all channels, which is redundant. In this case expose only the
per-channel ones as they are more flexible.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/uaudio.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index a85fbb93073..eec17efc127 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.152 2020/04/24 21:34:00 ratchov Exp $ */ +/* $OpenBSD: uaudio.c,v 1.153 2020/04/24 21:36:06 ratchov Exp $ */ /* * Copyright (c) 2018 Alexandre Ratchov <alex@caoua.org> * @@ -1895,6 +1895,25 @@ uaudio_mixer_nchan(struct uaudio_mixent *m, struct uaudio_mixent **rnext) } /* + * Skip redundant mixer entries that we don't want to expose to userland. + * For instance if there is a mute-all-channels control and per-channel + * mute controls, we don't want both (we expose the per-channel mute) + */ +void +uaudio_mixer_skip(struct uaudio_mixent **pm) +{ + struct uaudio_mixent *m = *pm; + + if (m != NULL && + m->chan == -1 && + m->next != NULL && + strcmp(m->fname, m->next->fname) == 0) + m = m->next; + + *pm = m; +} + +/* * Return pointer to the unit and mixer entry which have the given * index exposed by the mixer(4) API. */ @@ -1911,6 +1930,7 @@ uaudio_mixer_byindex(struct uaudio_softc *sc, int index, for (u = sc->unit_list; u != NULL; u = u->unit_next) { m = u->mixent_list; while (1) { + uaudio_mixer_skip(&m); if (m == NULL) break; if (index == i) { @@ -3663,8 +3683,14 @@ uaudio_print(struct uaudio_softc *sc) int nctl = 0; for (u = sc->unit_list; u != NULL; u = u->unit_next) { - for (m = u->mixent_list; m != NULL; m = m->next) + m = u->mixent_list; + while (1) { + uaudio_mixer_skip(&m); + if (m == NULL) + break; + m = m->next; nctl++; + } } for (p = sc->params_list; p != NULL; p = p->next) { |