aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-08-05 05:17:04 -0400
committerTakashi Iwai <tiwai@suse.de>2010-08-05 05:17:04 -0400
commit74bf40f0793fed9e01eb6164c2ce63e8c27ca205 (patch)
treef41312c0943978842ac258873b29da04d72d0625 /sound/usb
parente71981343ad29b5d929f82ac56c0b27b8ea0e540 (diff)
parentc4685849b4d725ab80cd29f5e09f5f128b4724b5 (diff)
Merge branch 'topic/misc' into for-linus
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/card.c2
-rw-r--r--sound/usb/clock.c59
-rw-r--r--sound/usb/clock.h4
-rw-r--r--sound/usb/endpoint.c5
-rw-r--r--sound/usb/format.c9
-rw-r--r--sound/usb/midi.c14
-rw-r--r--sound/usb/mixer.c77
-rw-r--r--sound/usb/mixer.h1
-rw-r--r--sound/usb/pcm.h3
-rw-r--r--sound/usb/quirks-table.h30
-rw-r--r--sound/usb/quirks.c1
11 files changed, 106 insertions, 99 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 7a8ac1d81be7..9feb00c831a0 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -217,7 +217,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
217 217
218 switch (protocol) { 218 switch (protocol) {
219 case UAC_VERSION_1: { 219 case UAC_VERSION_1: {
220 struct uac_ac_header_descriptor_v1 *h1 = control_header; 220 struct uac1_ac_header_descriptor *h1 = control_header;
221 221
222 if (!h1->bInCollection) { 222 if (!h1->bInCollection) {
223 snd_printk(KERN_INFO "skipping empty audio interface (v1)\n"); 223 snd_printk(KERN_INFO "skipping empty audio interface (v1)\n");
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index b5855114667e..b853f8df794f 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -19,33 +19,19 @@
19 19
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/list.h>
23#include <linux/slab.h>
24#include <linux/string.h> 22#include <linux/string.h>
25#include <linux/usb.h> 23#include <linux/usb.h>
26#include <linux/moduleparam.h>
27#include <linux/mutex.h>
28#include <linux/usb/audio.h> 24#include <linux/usb/audio.h>
29#include <linux/usb/audio-v2.h> 25#include <linux/usb/audio-v2.h>
30 26
31#include <sound/core.h> 27#include <sound/core.h>
32#include <sound/info.h> 28#include <sound/info.h>
33#include <sound/pcm.h> 29#include <sound/pcm.h>
34#include <sound/pcm_params.h>
35#include <sound/initval.h>
36 30
37#include "usbaudio.h" 31#include "usbaudio.h"
38#include "card.h" 32#include "card.h"
39#include "midi.h"
40#include "mixer.h"
41#include "proc.h"
42#include "quirks.h"
43#include "endpoint.h"
44#include "helper.h" 33#include "helper.h"
45#include "debug.h" 34#include "clock.h"
46#include "pcm.h"
47#include "urb.h"
48#include "format.h"
49 35
50static struct uac_clock_source_descriptor * 36static struct uac_clock_source_descriptor *
51 snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface, 37 snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface,
@@ -134,10 +120,7 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
134 return !!data; 120 return !!data;
135} 121}
136 122
137/* Try to find the clock source ID of a given clock entity */
138
139static int __uac_clock_find_source(struct snd_usb_audio *chip, 123static int __uac_clock_find_source(struct snd_usb_audio *chip,
140 struct usb_host_interface *host_iface,
141 int entity_id, unsigned long *visited) 124 int entity_id, unsigned long *visited)
142{ 125{
143 struct uac_clock_source_descriptor *source; 126 struct uac_clock_source_descriptor *source;
@@ -154,11 +137,11 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
154 } 137 }
155 138
156 /* first, see if the ID we're looking for is a clock source already */ 139 /* first, see if the ID we're looking for is a clock source already */
157 source = snd_usb_find_clock_source(host_iface, entity_id); 140 source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id);
158 if (source) 141 if (source)
159 return source->bClockID; 142 return source->bClockID;
160 143
161 selector = snd_usb_find_clock_selector(host_iface, entity_id); 144 selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id);
162 if (selector) { 145 if (selector) {
163 int ret; 146 int ret;
164 147
@@ -168,6 +151,8 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
168 if (ret < 0) 151 if (ret < 0)
169 return ret; 152 return ret;
170 153
154 /* Selector values are one-based */
155
171 if (ret > selector->bNrInPins || ret < 1) { 156 if (ret > selector->bNrInPins || ret < 1) {
172 printk(KERN_ERR 157 printk(KERN_ERR
173 "%s(): selector reported illegal value, id %d, ret %d\n", 158 "%s(): selector reported illegal value, id %d, ret %d\n",
@@ -176,27 +161,35 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
176 return -EINVAL; 161 return -EINVAL;
177 } 162 }
178 163
179 return __uac_clock_find_source(chip, host_iface, 164 return __uac_clock_find_source(chip, selector->baCSourceID[ret-1],
180 selector->baCSourceID[ret-1],
181 visited); 165 visited);
182 } 166 }
183 167
184 /* FIXME: multipliers only act as pass-thru element for now */ 168 /* FIXME: multipliers only act as pass-thru element for now */
185 multiplier = snd_usb_find_clock_multiplier(host_iface, entity_id); 169 multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id);
186 if (multiplier) 170 if (multiplier)
187 return __uac_clock_find_source(chip, host_iface, 171 return __uac_clock_find_source(chip, multiplier->bCSourceID,
188 multiplier->bCSourceID, visited); 172 visited);
189 173
190 return -EINVAL; 174 return -EINVAL;
191} 175}
192 176
193int snd_usb_clock_find_source(struct snd_usb_audio *chip, 177/*
194 struct usb_host_interface *host_iface, 178 * For all kinds of sample rate settings and other device queries,
195 int entity_id) 179 * the clock source (end-leaf) must be used. However, clock selectors,
180 * clock multipliers and sample rate converters may be specified as
181 * clock source input to terminal. This functions walks the clock path
182 * to its end and tries to find the source.
183 *
184 * The 'visited' bitfield is used internally to detect recursive loops.
185 *
186 * Returns the clock source UnitID (>=0) on success, or an error.
187 */
188int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id)
196{ 189{
197 DECLARE_BITMAP(visited, 256); 190 DECLARE_BITMAP(visited, 256);
198 memset(visited, 0, sizeof(visited)); 191 memset(visited, 0, sizeof(visited));
199 return __uac_clock_find_source(chip, host_iface, entity_id, visited); 192 return __uac_clock_find_source(chip, entity_id, visited);
200} 193}
201 194
202static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, 195static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
@@ -211,11 +204,8 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
211 ep = get_endpoint(alts, 0)->bEndpointAddress; 204 ep = get_endpoint(alts, 0)->bEndpointAddress;
212 205
213 /* if endpoint doesn't have sampling rate control, bail out */ 206 /* if endpoint doesn't have sampling rate control, bail out */
214 if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) { 207 if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE))
215 snd_printk(KERN_WARNING "%d:%d:%d: endpoint lacks sample rate attribute bit, cannot set.\n",
216 dev->devnum, iface, fmt->altsetting);
217 return 0; 208 return 0;
218 }
219 209
220 data[0] = rate; 210 data[0] = rate;
221 data[1] = rate >> 8; 211 data[1] = rate >> 8;
@@ -254,12 +244,13 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
254 struct usb_device *dev = chip->dev; 244 struct usb_device *dev = chip->dev;
255 unsigned char data[4]; 245 unsigned char data[4];
256 int err, crate; 246 int err, crate;
257 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fmt->clock); 247 int clock = snd_usb_clock_find_source(chip, fmt->clock);
258 248
259 if (clock < 0) 249 if (clock < 0)
260 return clock; 250 return clock;
261 251
262 if (!uac_clock_source_is_valid(chip, clock)) { 252 if (!uac_clock_source_is_valid(chip, clock)) {
253 /* TODO: should we try to find valid clock setups by ourself? */
263 snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n", 254 snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n",
264 dev->devnum, iface, fmt->altsetting, clock); 255 dev->devnum, iface, fmt->altsetting, clock);
265 return -ENXIO; 256 return -ENXIO;
diff --git a/sound/usb/clock.h b/sound/usb/clock.h
index beb253684e2d..46630936d31f 100644
--- a/sound/usb/clock.h
+++ b/sound/usb/clock.h
@@ -5,8 +5,6 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
5 struct usb_host_interface *alts, 5 struct usb_host_interface *alts,
6 struct audioformat *fmt, int rate); 6 struct audioformat *fmt, int rate);
7 7
8int snd_usb_clock_find_source(struct snd_usb_audio *chip, 8int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id);
9 struct usb_host_interface *host_iface,
10 int entity_id);
11 9
12#endif /* __USBAUDIO_CLOCK_H */ 10#endif /* __USBAUDIO_CLOCK_H */
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 6f6596cf2b19..1a701f1e8f50 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -33,6 +33,7 @@
33#include "pcm.h" 33#include "pcm.h"
34#include "helper.h" 34#include "helper.h"
35#include "format.h" 35#include "format.h"
36#include "clock.h"
36 37
37/* 38/*
38 * free a substream 39 * free a substream
@@ -275,7 +276,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
275 /* get audio formats */ 276 /* get audio formats */
276 switch (protocol) { 277 switch (protocol) {
277 case UAC_VERSION_1: { 278 case UAC_VERSION_1: {
278 struct uac_as_header_descriptor_v1 *as = 279 struct uac1_as_header_descriptor *as =
279 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); 280 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
280 281
281 if (!as) { 282 if (!as) {
@@ -297,7 +298,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
297 case UAC_VERSION_2: { 298 case UAC_VERSION_2: {
298 struct uac2_input_terminal_descriptor *input_term; 299 struct uac2_input_terminal_descriptor *input_term;
299 struct uac2_output_terminal_descriptor *output_term; 300 struct uac2_output_terminal_descriptor *output_term;
300 struct uac_as_header_descriptor_v2 *as = 301 struct uac2_as_header_descriptor *as =
301 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); 302 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
302 303
303 if (!as) { 304 if (!as) {
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 30364aba79cc..4387f54d73db 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -264,13 +264,12 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
264 * on the audioformat table (audio class v2). 264 * on the audioformat table (audio class v2).
265 */ 265 */
266static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, 266static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
267 struct audioformat *fp, 267 struct audioformat *fp)
268 struct usb_host_interface *iface)
269{ 268{
270 struct usb_device *dev = chip->dev; 269 struct usb_device *dev = chip->dev;
271 unsigned char tmp[2], *data; 270 unsigned char tmp[2], *data;
272 int nr_triplets, data_size, ret = 0; 271 int nr_triplets, data_size, ret = 0;
273 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); 272 int clock = snd_usb_clock_find_source(chip, fp->clock);
274 273
275 if (clock < 0) { 274 if (clock < 0) {
276 snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n", 275 snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n",
@@ -391,7 +390,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
391 break; 390 break;
392 case UAC_VERSION_2: 391 case UAC_VERSION_2:
393 /* fp->channels is already set in this case */ 392 /* fp->channels is already set in this case */
394 ret = parse_audio_format_rates_v2(chip, fp, iface); 393 ret = parse_audio_format_rates_v2(chip, fp);
395 break; 394 break;
396 } 395 }
397 396
@@ -450,7 +449,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
450 framesize = le16_to_cpu(fmt->wSamplesPerFrame); 449 framesize = le16_to_cpu(fmt->wSamplesPerFrame);
451 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); 450 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
452 fp->frame_size = framesize; 451 fp->frame_size = framesize;
453 ret = parse_audio_format_rates_v2(chip, fp, iface); 452 ret = parse_audio_format_rates_v2(chip, fp);
454 break; 453 break;
455 } 454 }
456 } 455 }
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 46785643c66d..b9c2bc65f51a 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -434,7 +434,7 @@ static void snd_usbmidi_maudio_broken_running_status_input(
434 u8 cin = buffer[i] & 0x0f; 434 u8 cin = buffer[i] & 0x0f;
435 struct usbmidi_in_port *port = &ep->ports[cable]; 435 struct usbmidi_in_port *port = &ep->ports[cable];
436 int length; 436 int length;
437 437
438 length = snd_usbmidi_cin_length[cin]; 438 length = snd_usbmidi_cin_length[cin];
439 if (cin == 0xf && buffer[i + 1] >= 0xf8) 439 if (cin == 0xf && buffer[i + 1] >= 0xf8)
440 ; /* realtime msg: no running status change */ 440 ; /* realtime msg: no running status change */
@@ -628,13 +628,13 @@ static struct usb_protocol_ops snd_usbmidi_standard_ops = {
628 628
629static struct usb_protocol_ops snd_usbmidi_midiman_ops = { 629static struct usb_protocol_ops snd_usbmidi_midiman_ops = {
630 .input = snd_usbmidi_midiman_input, 630 .input = snd_usbmidi_midiman_input,
631 .output = snd_usbmidi_standard_output, 631 .output = snd_usbmidi_standard_output,
632 .output_packet = snd_usbmidi_output_midiman_packet, 632 .output_packet = snd_usbmidi_output_midiman_packet,
633}; 633};
634 634
635static struct usb_protocol_ops snd_usbmidi_maudio_broken_running_status_ops = { 635static struct usb_protocol_ops snd_usbmidi_maudio_broken_running_status_ops = {
636 .input = snd_usbmidi_maudio_broken_running_status_input, 636 .input = snd_usbmidi_maudio_broken_running_status_input,
637 .output = snd_usbmidi_standard_output, 637 .output = snd_usbmidi_standard_output,
638 .output_packet = snd_usbmidi_output_standard_packet, 638 .output_packet = snd_usbmidi_output_standard_packet,
639}; 639};
640 640
@@ -1248,7 +1248,7 @@ static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep
1248 */ 1248 */
1249static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, 1249static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
1250 struct snd_usb_midi_endpoint_info* ep_info, 1250 struct snd_usb_midi_endpoint_info* ep_info,
1251 struct snd_usb_midi_endpoint* rep) 1251 struct snd_usb_midi_endpoint* rep)
1252{ 1252{
1253 struct snd_usb_midi_out_endpoint* ep; 1253 struct snd_usb_midi_out_endpoint* ep;
1254 unsigned int i; 1254 unsigned int i;
@@ -1398,7 +1398,7 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi)
1398} 1398}
1399 1399
1400static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, 1400static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi,
1401 int stream, int number) 1401 int stream, int number)
1402{ 1402{
1403 struct list_head* list; 1403 struct list_head* list;
1404 1404
@@ -1811,7 +1811,7 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi,
1811 snd_usbmidi_switch_roland_altsetting(umidi); 1811 snd_usbmidi_switch_roland_altsetting(umidi);
1812 1812
1813 if (endpoint[0].out_ep || endpoint[0].in_ep) 1813 if (endpoint[0].out_ep || endpoint[0].in_ep)
1814 return 0; 1814 return 0;
1815 1815
1816 intf = umidi->iface; 1816 intf = umidi->iface;
1817 if (!intf || intf->num_altsetting < 1) 1817 if (!intf || intf->num_altsetting < 1)
@@ -1849,7 +1849,7 @@ static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi* umidi,
1849 struct snd_usb_midi_endpoint_info* endpoints) 1849 struct snd_usb_midi_endpoint_info* endpoints)
1850{ 1850{
1851 int err, i; 1851 int err, i;
1852 1852
1853 err = snd_usbmidi_detect_endpoints(umidi, endpoints, MIDI_MAX_ENDPOINTS); 1853 err = snd_usbmidi_detect_endpoints(umidi, endpoints, MIDI_MAX_ENDPOINTS);
1854 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { 1854 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
1855 if (endpoints[i].out_ep) 1855 if (endpoints[i].out_ep)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 736d134cc03c..c166db0057d3 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>
@@ -275,28 +291,28 @@ static int get_abs_value(struct usb_mixer_elem_info *cval, int val)
275 291
276static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) 292static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
277{ 293{
294 struct snd_usb_audio *chip = cval->mixer->chip;
278 unsigned char buf[2]; 295 unsigned char buf[2];
279 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; 296 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
280 int timeout = 10; 297 int timeout = 10;
281 298
282 while (timeout-- > 0) { 299 while (timeout-- > 0) {
283 if (snd_usb_ctl_msg(cval->mixer->chip->dev, 300 if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request,
284 usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
285 request,
286 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 301 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
287 validx, cval->mixer->ctrlif | (cval->id << 8), 302 validx, snd_usb_ctrl_intf(chip) | (cval->id << 8),
288 buf, val_len, 100) >= val_len) { 303 buf, val_len, 100) >= val_len) {
289 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); 304 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
290 return 0; 305 return 0;
291 } 306 }
292 } 307 }
293 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 308 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
294 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); 309 request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type);
295 return -EINVAL; 310 return -EINVAL;
296} 311}
297 312
298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) 313static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
299{ 314{
315 struct snd_usb_audio *chip = cval->mixer->chip;
300 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ 316 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */
301 unsigned char *val; 317 unsigned char *val;
302 int ret, size; 318 int ret, size;
@@ -312,16 +328,14 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
312 328
313 memset(buf, 0, sizeof(buf)); 329 memset(buf, 0, sizeof(buf));
314 330
315 ret = snd_usb_ctl_msg(cval->mixer->chip->dev, 331 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest,
316 usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
317 bRequest,
318 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 332 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
319 validx, cval->mixer->ctrlif | (cval->id << 8), 333 validx, snd_usb_ctrl_intf(chip) | (cval->id << 8),
320 buf, size, 1000); 334 buf, size, 1000);
321 335
322 if (ret < 0) { 336 if (ret < 0) {
323 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 337 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
324 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); 338 request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type);
325 return ret; 339 return ret;
326 } 340 }
327 341
@@ -397,6 +411,7 @@ static int get_cur_mix_value(struct usb_mixer_elem_info *cval,
397int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, 411int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
398 int request, int validx, int value_set) 412 int request, int validx, int value_set)
399{ 413{
414 struct snd_usb_audio *chip = cval->mixer->chip;
400 unsigned char buf[2]; 415 unsigned char buf[2];
401 int val_len, timeout = 10; 416 int val_len, timeout = 10;
402 417
@@ -419,15 +434,14 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
419 buf[0] = value_set & 0xff; 434 buf[0] = value_set & 0xff;
420 buf[1] = (value_set >> 8) & 0xff; 435 buf[1] = (value_set >> 8) & 0xff;
421 while (timeout-- > 0) 436 while (timeout-- > 0)
422 if (snd_usb_ctl_msg(cval->mixer->chip->dev, 437 if (snd_usb_ctl_msg(chip->dev,
423 usb_sndctrlpipe(cval->mixer->chip->dev, 0), 438 usb_sndctrlpipe(chip->dev, 0), request,
424 request,
425 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, 439 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
426 validx, cval->mixer->ctrlif | (cval->id << 8), 440 validx, snd_usb_ctrl_intf(chip) | (cval->id << 8),
427 buf, val_len, 100) >= 0) 441 buf, val_len, 100) >= 0)
428 return 0; 442 return 0;
429 snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", 443 snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n",
430 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]); 444 request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type, buf[0], buf[1]);
431 return -EINVAL; 445 return -EINVAL;
432} 446}
433 447
@@ -582,9 +596,9 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm
582 switch (iterm->type >> 16) { 596 switch (iterm->type >> 16) {
583 case UAC_SELECTOR_UNIT: 597 case UAC_SELECTOR_UNIT:
584 strcpy(name, "Selector"); return 8; 598 strcpy(name, "Selector"); return 8;
585 case UAC_PROCESSING_UNIT_V1: 599 case UAC1_PROCESSING_UNIT:
586 strcpy(name, "Process Unit"); return 12; 600 strcpy(name, "Process Unit"); return 12;
587 case UAC_EXTENSION_UNIT_V1: 601 case UAC1_EXTENSION_UNIT:
588 strcpy(name, "Ext Unit"); return 8; 602 strcpy(name, "Ext Unit"); return 8;
589 case UAC_MIXER_UNIT: 603 case UAC_MIXER_UNIT:
590 strcpy(name, "Mixer"); return 5; 604 strcpy(name, "Mixer"); return 5;
@@ -672,8 +686,8 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
672 term->name = uac_selector_unit_iSelector(d); 686 term->name = uac_selector_unit_iSelector(d);
673 return 0; 687 return 0;
674 } 688 }
675 case UAC_PROCESSING_UNIT_V1: 689 case UAC1_PROCESSING_UNIT:
676 case UAC_EXTENSION_UNIT_V1: { 690 case UAC1_EXTENSION_UNIT: {
677 struct uac_processing_unit_descriptor *d = p1; 691 struct uac_processing_unit_descriptor *d = p1;
678 if (d->bNrInPins) { 692 if (d->bNrInPins) {
679 id = d->baSourceID[0]; 693 id = d->baSourceID[0];
@@ -745,6 +759,8 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
745 */ 759 */
746static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) 760static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
747{ 761{
762 struct snd_usb_audio *chip = cval->mixer->chip;
763
748 /* for failsafe */ 764 /* for failsafe */
749 cval->min = default_min; 765 cval->min = default_min;
750 cval->max = cval->min + 1; 766 cval->max = cval->min + 1;
@@ -767,7 +783,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
767 if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || 783 if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 ||
768 get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { 784 get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) {
769 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", 785 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n",
770 cval->id, cval->mixer->ctrlif, cval->control, cval->id); 786 cval->id, snd_usb_ctrl_intf(chip), cval->control, cval->id);
771 return -EINVAL; 787 return -EINVAL;
772 } 788 }
773 if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { 789 if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) {
@@ -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
@@ -1855,13 +1863,13 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
1855 return parse_audio_selector_unit(state, unitid, p1); 1863 return parse_audio_selector_unit(state, unitid, p1);
1856 case UAC_FEATURE_UNIT: 1864 case UAC_FEATURE_UNIT:
1857 return parse_audio_feature_unit(state, unitid, p1); 1865 return parse_audio_feature_unit(state, unitid, p1);
1858 case UAC_PROCESSING_UNIT_V1: 1866 case UAC1_PROCESSING_UNIT:
1859 /* UAC2_EFFECT_UNIT has the same value */ 1867 /* UAC2_EFFECT_UNIT has the same value */
1860 if (state->mixer->protocol == UAC_VERSION_1) 1868 if (state->mixer->protocol == UAC_VERSION_1)
1861 return parse_audio_processing_unit(state, unitid, p1); 1869 return parse_audio_processing_unit(state, unitid, p1);
1862 else 1870 else
1863 return 0; /* FIXME - effect units not implemented yet */ 1871 return 0; /* FIXME - effect units not implemented yet */
1864 case UAC_EXTENSION_UNIT_V1: 1872 case UAC1_EXTENSION_UNIT:
1865 /* UAC2_PROCESSING_UNIT_V2 has the same value */ 1873 /* UAC2_PROCESSING_UNIT_V2 has the same value */
1866 if (state->mixer->protocol == UAC_VERSION_1) 1874 if (state->mixer->protocol == UAC_VERSION_1)
1867 return parse_audio_extension_unit(state, unitid, p1); 1875 return parse_audio_extension_unit(state, unitid, p1);
@@ -1905,7 +1913,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
1905 struct usb_host_interface *hostif; 1913 struct usb_host_interface *hostif;
1906 void *p; 1914 void *p;
1907 1915
1908 hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; 1916 hostif = mixer->chip->ctrl_intf;
1909 memset(&state, 0, sizeof(state)); 1917 memset(&state, 0, sizeof(state));
1910 state.chip = mixer->chip; 1918 state.chip = mixer->chip;
1911 state.mixer = mixer; 1919 state.mixer = mixer;
@@ -1925,7 +1933,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
1925 p = NULL; 1933 p = NULL;
1926 while ((p = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, p, UAC_OUTPUT_TERMINAL)) != NULL) { 1934 while ((p = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, p, UAC_OUTPUT_TERMINAL)) != NULL) {
1927 if (mixer->protocol == UAC_VERSION_1) { 1935 if (mixer->protocol == UAC_VERSION_1) {
1928 struct uac_output_terminal_descriptor_v1 *desc = p; 1936 struct uac1_output_terminal_descriptor *desc = p;
1929 1937
1930 if (desc->bLength < sizeof(*desc)) 1938 if (desc->bLength < sizeof(*desc))
1931 continue; /* invalid descriptor? */ 1939 continue; /* invalid descriptor? */
@@ -1997,7 +2005,7 @@ static void snd_usb_mixer_proc_read(struct snd_info_entry *entry,
1997 list_for_each_entry(mixer, &chip->mixer_list, list) { 2005 list_for_each_entry(mixer, &chip->mixer_list, list) {
1998 snd_iprintf(buffer, 2006 snd_iprintf(buffer,
1999 "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", 2007 "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n",
2000 chip->usb_id, mixer->ctrlif, 2008 chip->usb_id, snd_usb_ctrl_intf(chip),
2001 mixer->ignore_ctl_error); 2009 mixer->ignore_ctl_error);
2002 snd_iprintf(buffer, "Card: %s\n", chip->card->longname); 2010 snd_iprintf(buffer, "Card: %s\n", chip->card->longname);
2003 for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { 2011 for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) {
@@ -2115,7 +2123,7 @@ static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer)
2115 int buffer_length; 2123 int buffer_length;
2116 unsigned int epnum; 2124 unsigned int epnum;
2117 2125
2118 hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; 2126 hostif = mixer->chip->ctrl_intf;
2119 /* we need one interrupt input endpoint */ 2127 /* we need one interrupt input endpoint */
2120 if (get_iface_desc(hostif)->bNumEndpoints < 1) 2128 if (get_iface_desc(hostif)->bNumEndpoints < 1)
2121 return 0; 2129 return 0;
@@ -2158,7 +2166,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
2158 if (!mixer) 2166 if (!mixer)
2159 return -ENOMEM; 2167 return -ENOMEM;
2160 mixer->chip = chip; 2168 mixer->chip = chip;
2161 mixer->ctrlif = ctrlif;
2162 mixer->ignore_ctl_error = ignore_error; 2169 mixer->ignore_ctl_error = ignore_error;
2163 mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), 2170 mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems),
2164 GFP_KERNEL); 2171 GFP_KERNEL);
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index a7cf1007fbb0..26c636c5c93a 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -3,7 +3,6 @@
3 3
4struct usb_mixer_interface { 4struct usb_mixer_interface {
5 struct snd_usb_audio *chip; 5 struct snd_usb_audio *chip;
6 unsigned int ctrlif;
7 struct list_head list; 6 struct list_head list;
8 unsigned int ignore_ctl_error; 7 unsigned int ignore_ctl_error;
9 struct urb *urb; 8 struct urb *urb;
diff --git a/sound/usb/pcm.h b/sound/usb/pcm.h
index 1c931b68f3b5..ed3e283f618d 100644
--- a/sound/usb/pcm.h
+++ b/sound/usb/pcm.h
@@ -7,8 +7,5 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
7 struct usb_host_interface *alts, 7 struct usb_host_interface *alts,
8 struct audioformat *fmt); 8 struct audioformat *fmt);
9 9
10int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
11 struct usb_host_interface *alts,
12 struct audioformat *fmt, int rate);
13 10
14#endif /* __USBAUDIO_PCM_H */ 11#endif /* __USBAUDIO_PCM_H */
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index f8797f61a24b..2e8003f98fca 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -2152,7 +2152,21 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2152 } 2152 }
2153}, 2153},
2154{ 2154{
2155 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7201), 2155 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7240),
2156 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2157 USB_DEVICE_ID_MATCH_INT_CLASS |
2158 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2159 .bInterfaceClass = USB_CLASS_AUDIO,
2160 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2161 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2162 .vendor_name = "Hauppauge",
2163 .product_name = "HVR-850",
2164 .ifnum = QUIRK_ANY_INTERFACE,
2165 .type = QUIRK_AUDIO_ALIGN_TRANSFER,
2166 }
2167},
2168{
2169 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7210),
2156 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2170 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2157 USB_DEVICE_ID_MATCH_INT_CLASS | 2171 USB_DEVICE_ID_MATCH_INT_CLASS |
2158 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2172 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2166,7 +2180,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2166 } 2180 }
2167}, 2181},
2168{ 2182{
2169 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7202), 2183 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7217),
2170 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2184 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2171 USB_DEVICE_ID_MATCH_INT_CLASS | 2185 USB_DEVICE_ID_MATCH_INT_CLASS |
2172 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2186 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2180,7 +2194,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2180 } 2194 }
2181}, 2195},
2182{ 2196{
2183 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7203), 2197 USB_DEVICE_VENDOR_SPEC(0x2040, 0x721b),
2184 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2198 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2185 USB_DEVICE_ID_MATCH_INT_CLASS | 2199 USB_DEVICE_ID_MATCH_INT_CLASS |
2186 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2200 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2194,7 +2208,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2194 } 2208 }
2195}, 2209},
2196{ 2210{
2197 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7204), 2211 USB_DEVICE_VENDOR_SPEC(0x2040, 0x721e),
2198 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2212 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2199 USB_DEVICE_ID_MATCH_INT_CLASS | 2213 USB_DEVICE_ID_MATCH_INT_CLASS |
2200 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2214 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2208,7 +2222,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2208 } 2222 }
2209}, 2223},
2210{ 2224{
2211 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7205), 2225 USB_DEVICE_VENDOR_SPEC(0x2040, 0x721f),
2212 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2226 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2213 USB_DEVICE_ID_MATCH_INT_CLASS | 2227 USB_DEVICE_ID_MATCH_INT_CLASS |
2214 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2228 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2222,7 +2236,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2222 } 2236 }
2223}, 2237},
2224{ 2238{
2225 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7250), 2239 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7280),
2226 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2240 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2227 USB_DEVICE_ID_MATCH_INT_CLASS | 2241 USB_DEVICE_ID_MATCH_INT_CLASS |
2228 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2242 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2236,7 +2250,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2236 } 2250 }
2237}, 2251},
2238{ 2252{
2239 USB_DEVICE_VENDOR_SPEC(0x2040, 0x7230), 2253 USB_DEVICE_VENDOR_SPEC(0x0fd9, 0x0008),
2240 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2254 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2241 USB_DEVICE_ID_MATCH_INT_CLASS | 2255 USB_DEVICE_ID_MATCH_INT_CLASS |
2242 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2256 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
@@ -2244,7 +2258,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2244 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2258 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2245 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2259 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2246 .vendor_name = "Hauppauge", 2260 .vendor_name = "Hauppauge",
2247 .product_name = "HVR-850", 2261 .product_name = "HVR-950Q",
2248 .ifnum = QUIRK_ANY_INTERFACE, 2262 .ifnum = QUIRK_ANY_INTERFACE,
2249 .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2263 .type = QUIRK_AUDIO_ALIGN_TRANSFER,
2250 } 2264 }
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index b45e54c09ba2..9a9da09586a5 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -32,6 +32,7 @@
32#include "helper.h" 32#include "helper.h"
33#include "endpoint.h" 33#include "endpoint.h"
34#include "pcm.h" 34#include "pcm.h"
35#include "clock.h"
35 36
36/* 37/*
37 * handle the quirks for the contained interfaces 38 * handle the quirks for the contained interfaces