aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/usb/audio-v2.h15
-rw-r--r--sound/usb/clock.c16
-rw-r--r--sound/usb/mixer.c24
3 files changed, 45 insertions, 10 deletions
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index 716aebe339e8..964cb603f7c7 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
@@ -18,6 +18,21 @@
18/* v1.0 and v2.0 of this standard have many things in common. For the rest 18/* v1.0 and v2.0 of this standard have many things in common. For the rest
19 * of the definitions, please refer to audio.h */ 19 * of the definitions, please refer to audio.h */
20 20
21/*
22 * bmControl field decoders
23 *
24 * From the USB Audio spec v2.0:
25 *
26 * bmaControls() is a (ch+1)-element array of 4-byte bitmaps,
27 * each containing a set of bit pairs. If a Control is present,
28 * it must be Host readable. If a certain Control is not
29 * present then the bit pair must be set to 0b00.
30 * If a Control is present but read-only, the bit pair must be
31 * set to 0b01. If a Control is also Host programmable, the bit
32 * pair must be set to 0b11. The value 0b10 is not allowed.
33 *
34 */
35
21static inline bool uac2_control_is_readable(u32 bmControls, u8 control) 36static inline bool uac2_control_is_readable(u32 bmControls, u8 control)
22{ 37{
23 return (bmControls >> (control * 2)) & 0x1; 38 return (bmControls >> (control * 2)) & 0x1;
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index 386b09c5ce73..7279d6190875 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -120,8 +120,6 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
120 return !!data; 120 return !!data;
121} 121}
122 122
123/* Try to find the clock source ID of a given clock entity */
124
125static int __uac_clock_find_source(struct snd_usb_audio *chip, 123static int __uac_clock_find_source(struct snd_usb_audio *chip,
126 struct usb_host_interface *host_iface, 124 struct usb_host_interface *host_iface,
127 int entity_id, unsigned long *visited) 125 int entity_id, unsigned long *visited)
@@ -154,6 +152,8 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
154 if (ret < 0) 152 if (ret < 0)
155 return ret; 153 return ret;
156 154
155 /* Selector values are one-based */
156
157 if (ret > selector->bNrInPins || ret < 1) { 157 if (ret > selector->bNrInPins || ret < 1) {
158 printk(KERN_ERR 158 printk(KERN_ERR
159 "%s(): selector reported illegal value, id %d, ret %d\n", 159 "%s(): selector reported illegal value, id %d, ret %d\n",
@@ -176,6 +176,17 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
176 return -EINVAL; 176 return -EINVAL;
177} 177}
178 178
179/*
180 * For all kinds of sample rate settings and other device queries,
181 * the clock source (end-leaf) must be used. However, clock selectors,
182 * clock multipliers and sample rate converters may be specified as
183 * clock source input to terminal. This functions walks the clock path
184 * to its end and tries to find the source.
185 *
186 * The 'visited' bitfield is used internally to detect recursive loops.
187 *
188 * Returns the clock source UnitID (>=0) on success, or an error.
189 */
179int snd_usb_clock_find_source(struct snd_usb_audio *chip, 190int snd_usb_clock_find_source(struct snd_usb_audio *chip,
180 struct usb_host_interface *host_iface, 191 struct usb_host_interface *host_iface,
181 int entity_id) 192 int entity_id)
@@ -246,6 +257,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
246 return clock; 257 return clock;
247 258
248 if (!uac_clock_source_is_valid(chip, clock)) { 259 if (!uac_clock_source_is_valid(chip, clock)) {
260 /* TODO: should we try to find valid clock setups by ourself? */
249 snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n", 261 snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n",
250 dev->devnum, iface, fmt->altsetting, clock); 262 dev->devnum, iface, fmt->altsetting, clock);
251 return -ENXIO; 263 return -ENXIO;
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index ba54eb6bb0c9..1163ec3ca8a0 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -26,6 +26,22 @@
26 * 26 *
27 */ 27 */
28 28
29/*
30 * TODOs, for both the mixer and the streaming interfaces:
31 *
32 * - support for UAC2 effect units
33 * - support for graphical equalizers
34 * - RANGE and MEM set commands (UAC2)
35 * - RANGE and MEM interrupt dispatchers (UAC2)
36 * - audio channel clustering (UAC2)
37 * - audio sample rate converter units (UAC2)
38 * - proper handling of clock multipliers (UAC2)
39 * - dispatch clock change notifications (UAC2)
40 * - stop PCM streams which use a clock that became invalid
41 * - stop PCM streams which use a clock selector that has changed
42 * - parse available sample rates again when clock sources changed
43 */
44
29#include <linux/bitops.h> 45#include <linux/bitops.h>
30#include <linux/init.h> 46#include <linux/init.h>
31#include <linux/list.h> 47#include <linux/list.h>
@@ -1199,14 +1215,6 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
1199 } 1215 }
1200 } else { /* UAC_VERSION_2 */ 1216 } else { /* UAC_VERSION_2 */
1201 for (i = 0; i < 30/2; i++) { 1217 for (i = 0; i < 30/2; i++) {
1202 /* From the USB Audio spec v2.0:
1203 bmaControls() is a (ch+1)-element array of 4-byte bitmaps,
1204 each containing a set of bit pairs. If a Control is present,
1205 it must be Host readable. If a certain Control is not
1206 present then the bit pair must be set to 0b00.
1207 If a Control is present but read-only, the bit pair must be
1208 set to 0b01. If a Control is also Host programmable, the bit
1209 pair must be set to 0b11. The value 0b10 is not allowed. */
1210 unsigned int ch_bits = 0; 1218 unsigned int ch_bits = 0;
1211 unsigned int ch_read_only = 0; 1219 unsigned int ch_read_only = 0;
1212 1220