Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Weed out duplicate sample rates and add comment ...
details: https://anonhg.NetBSD.org/src/rev/de9022868f0c
branches: trunk
changeset: 374442:de9022868f0c
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Apr 23 06:13:35 2023 +0000
description:
Weed out duplicate sample rates and add comment about UAC2 clocks.
diffstat:
sys/dev/usb/uaudio.c | 33 ++++++++++++++++++++++++++++-----
1 files changed, 28 insertions(+), 5 deletions(-)
diffs (61 lines):
diff -r f18d5e4c87db -r de9022868f0c sys/dev/usb/uaudio.c
--- a/sys/dev/usb/uaudio.c Sun Apr 23 02:01:33 2023 +0000
+++ b/sys/dev/usb/uaudio.c Sun Apr 23 06:13:35 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uaudio.c,v 1.179 2023/04/16 19:26:20 mlelstv Exp $ */
+/* $NetBSD: uaudio.c,v 1.180 2023/04/23 06:13:35 mlelstv Exp $ */
/*
* Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.179 2023/04/16 19:26:20 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.180 2023/04/23 06:13:35 mlelstv Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2479,9 +2479,20 @@ Static u_int
uaudio_get_rates(struct uaudio_softc *sc, int mode, u_int *freqs, u_int len)
{
struct mixerctl *mc;
- u_int n, freq, start, end, step;
- int j, k, count;
-
+ u_int freq, start, end, step;
+ u_int i, n;
+ u_int k, count;
+ int j;
+
+ /*
+ * With UAC2 the sample rate isn't part of the data format,
+ * instead, you have separate clock sources that may be
+ * assigned to individual terminals (inputs, outputs).
+ *
+ * For audio(4) we only distinguish between input and output
+ * formats and collect the unique rates from all possible clock
+ * sources.
+ */
n = 0;
for (j = 0; j < sc->sc_nratectls; ++j) {
@@ -2499,6 +2510,18 @@ uaudio_get_rates(struct uaudio_softc *sc
end = (u_int) mc->ranges[k].maxval;
step = (u_int) mc->ranges[k].resval;
for (freq = start; freq <= end; freq += step) {
+ /* remove duplicates */
+ for (i = 0; i < n; ++i) {
+ if (freqs[i] == freq)
+ break;
+ }
+ if (i < n) {
+ if (step == 0)
+ break;
+ continue;
+ }
+
+ /* store or count */
if (len != 0) {
if (n >= len)
goto done;
Home |
Main Index |
Thread Index |
Old Index