diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-05-04 10:00:16 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-05-04 10:00:16 -0400 |
commit | 3a20ac2c52b1317f5a5f0bd9cd3cbe8495ddd026 (patch) | |
tree | 9a912f2609cefb9698b5cce09cd240bd6dbd09fb /sound/usb | |
parent | 18cc8d8d9b74c446832336d8f6e1afb145f9431b (diff) | |
parent | 3e5b50165fd0be080044586f43fcdd460ed27610 (diff) |
Merge branch 'fix/pcm-jiffies-check' into fix/asoc
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/Kconfig | 3 | ||||
-rw-r--r-- | sound/usb/caiaq/Makefile | 4 | ||||
-rw-r--r-- | sound/usb/caiaq/audio.c (renamed from sound/usb/caiaq/caiaq-audio.c) | 39 | ||||
-rw-r--r-- | sound/usb/caiaq/audio.h (renamed from sound/usb/caiaq/caiaq-audio.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/control.c (renamed from sound/usb/caiaq/caiaq-control.c) | 52 | ||||
-rw-r--r-- | sound/usb/caiaq/control.h (renamed from sound/usb/caiaq/caiaq-control.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/device.c (renamed from sound/usb/caiaq/caiaq-device.c) | 47 | ||||
-rw-r--r-- | sound/usb/caiaq/device.h (renamed from sound/usb/caiaq/caiaq-device.h) | 6 | ||||
-rw-r--r-- | sound/usb/caiaq/input.c (renamed from sound/usb/caiaq/caiaq-input.c) | 11 | ||||
-rw-r--r-- | sound/usb/caiaq/input.h (renamed from sound/usb/caiaq/caiaq-input.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.c (renamed from sound/usb/caiaq/caiaq-midi.c) | 13 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.h (renamed from sound/usb/caiaq/caiaq-midi.h) | 0 | ||||
-rw-r--r-- | sound/usb/usbaudio.c | 343 | ||||
-rw-r--r-- | sound/usb/usbmidi.c | 1 | ||||
-rw-r--r-- | sound/usb/usbmixer.c | 164 | ||||
-rw-r--r-- | sound/usb/usbmixer_maps.c | 26 | ||||
-rw-r--r-- | sound/usb/usbquirks.h | 18 | ||||
-rw-r--r-- | sound/usb/usx2y/us122l.c | 22 | ||||
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.c | 28 | ||||
-rw-r--r-- | sound/usb/usx2y/usb_stream.c | 69 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2y.c | 4 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2yaudio.c | 3 | ||||
-rw-r--r-- | sound/usb/usx2y/usx2yhwdeppcm.h | 2 |
23 files changed, 453 insertions, 402 deletions
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index 4f0eac9bff1e..523aec188ccf 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig | |||
@@ -48,7 +48,10 @@ config SND_USB_CAIAQ | |||
48 | * Native Instruments Kore Controller | 48 | * Native Instruments Kore Controller |
49 | * Native Instruments Kore Controller 2 | 49 | * Native Instruments Kore Controller 2 |
50 | * Native Instruments Audio Kontrol 1 | 50 | * Native Instruments Audio Kontrol 1 |
51 | * Native Instruments Audio 4 DJ | ||
51 | * Native Instruments Audio 8 DJ | 52 | * Native Instruments Audio 8 DJ |
53 | * Native Instruments Guitar Rig Session I/O | ||
54 | * Native Instruments Guitar Rig mobile | ||
52 | 55 | ||
53 | To compile this driver as a module, choose M here: the module | 56 | To compile this driver as a module, choose M here: the module |
54 | will be called snd-usb-caiaq. | 57 | will be called snd-usb-caiaq. |
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile index 23dadd5a11cd..388999653aaa 100644 --- a/sound/usb/caiaq/Makefile +++ b/sound/usb/caiaq/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | snd-usb-caiaq-y := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-control.o | 1 | snd-usb-caiaq-y := device.o audio.o midi.o control.o |
2 | snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += caiaq-input.o | 2 | snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += input.o |
3 | 3 | ||
4 | obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o | 4 | obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o |
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/audio.c index b3a603325835..b13ce767ac72 100644 --- a/sound/usb/caiaq/caiaq-audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -16,20 +16,14 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/spinlock.h> | ||
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
24 | #include <linux/spinlock.h> | ||
25 | #include <sound/core.h> | 22 | #include <sound/core.h> |
26 | #include <sound/initval.h> | ||
27 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
28 | #include <sound/rawmidi.h> | ||
29 | #include <linux/input.h> | ||
30 | 24 | ||
31 | #include "caiaq-device.h" | 25 | #include "device.h" |
32 | #include "caiaq-audio.h" | 26 | #include "audio.h" |
33 | 27 | ||
34 | #define N_URBS 32 | 28 | #define N_URBS 32 |
35 | #define CLOCK_DRIFT_TOLERANCE 5 | 29 | #define CLOCK_DRIFT_TOLERANCE 5 |
@@ -114,6 +108,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev) | |||
114 | dev->output_panic = 0; | 108 | dev->output_panic = 0; |
115 | dev->first_packet = 1; | 109 | dev->first_packet = 1; |
116 | dev->streaming = 1; | 110 | dev->streaming = 1; |
111 | dev->warned = 0; | ||
117 | 112 | ||
118 | for (i = 0; i < N_URBS; i++) { | 113 | for (i = 0; i < N_URBS; i++) { |
119 | ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); | 114 | ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); |
@@ -200,11 +195,14 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
200 | 195 | ||
201 | debug("%s(%p)\n", __func__, substream); | 196 | debug("%s(%p)\n", __func__, substream); |
202 | 197 | ||
203 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 198 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
199 | dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; | ||
204 | dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; | 200 | dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; |
205 | else | 201 | } else { |
202 | dev->period_in_count[index] = BYTES_PER_SAMPLE; | ||
206 | dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE; | 203 | dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE; |
207 | 204 | } | |
205 | |||
208 | if (dev->streaming) | 206 | if (dev->streaming) |
209 | return 0; | 207 | return 0; |
210 | 208 | ||
@@ -305,8 +303,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | |||
305 | if (!sub) | 303 | if (!sub) |
306 | continue; | 304 | continue; |
307 | 305 | ||
308 | pb = frames_to_bytes(sub->runtime, | 306 | pb = snd_pcm_lib_period_bytes(sub); |
309 | sub->runtime->period_size); | ||
310 | cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | 307 | cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? |
311 | &dev->period_out_count[stream] : | 308 | &dev->period_out_count[stream] : |
312 | &dev->period_in_count[stream]; | 309 | &dev->period_in_count[stream]; |
@@ -376,6 +373,9 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | |||
376 | 373 | ||
377 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 374 | for (stream = 0; stream < dev->n_streams; stream++, i++) { |
378 | sub = dev->sub_capture[stream]; | 375 | sub = dev->sub_capture[stream]; |
376 | if (dev->input_panic) | ||
377 | usb_buf[i] = 0; | ||
378 | |||
379 | if (sub) { | 379 | if (sub) { |
380 | struct snd_pcm_runtime *rt = sub->runtime; | 380 | struct snd_pcm_runtime *rt = sub->runtime; |
381 | char *audio_buf = rt->dma_area; | 381 | char *audio_buf = rt->dma_area; |
@@ -397,6 +397,9 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev, | |||
397 | if (!dev->streaming) | 397 | if (!dev->streaming) |
398 | return; | 398 | return; |
399 | 399 | ||
400 | if (iso->actual_length < dev->bpp) | ||
401 | return; | ||
402 | |||
400 | switch (dev->spec.data_alignment) { | 403 | switch (dev->spec.data_alignment) { |
401 | case 0: | 404 | case 0: |
402 | read_in_urb_mode0(dev, urb, iso); | 405 | read_in_urb_mode0(dev, urb, iso); |
@@ -406,10 +409,11 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev, | |||
406 | break; | 409 | break; |
407 | } | 410 | } |
408 | 411 | ||
409 | if (dev->input_panic || dev->output_panic) { | 412 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { |
410 | debug("streaming error detected %s %s\n", | 413 | debug("streaming error detected %s %s\n", |
411 | dev->input_panic ? "(input)" : "", | 414 | dev->input_panic ? "(input)" : "", |
412 | dev->output_panic ? "(output)" : ""); | 415 | dev->output_panic ? "(output)" : ""); |
416 | dev->warned = 1; | ||
413 | } | 417 | } |
414 | } | 418 | } |
415 | 419 | ||
@@ -638,9 +642,10 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
638 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 642 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
639 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 643 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
640 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): | 644 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): |
641 | dev->samplerates |= SNDRV_PCM_RATE_88200; | 645 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): |
642 | dev->samplerates |= SNDRV_PCM_RATE_192000; | 646 | dev->samplerates |= SNDRV_PCM_RATE_192000; |
643 | break; | 647 | /* fall thru */ |
648 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | ||
644 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 649 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
645 | dev->samplerates |= SNDRV_PCM_RATE_88200; | 650 | dev->samplerates |= SNDRV_PCM_RATE_88200; |
646 | break; | 651 | break; |
diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/audio.h index 8ab1f8d9529e..8ab1f8d9529e 100644 --- a/sound/usb/caiaq/caiaq-audio.h +++ b/sound/usb/caiaq/audio.h | |||
diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/control.c index ccd763dd7167..537102ba6b9d 100644 --- a/sound/usb/caiaq/caiaq-control.c +++ b/sound/usb/caiaq/control.c | |||
@@ -18,17 +18,13 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
22 | #include <sound/control.h> | ||
23 | #include <sound/core.h> | 23 | #include <sound/core.h> |
24 | #include <sound/initval.h> | ||
25 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
26 | #include <sound/rawmidi.h> | ||
27 | #include <sound/control.h> | ||
28 | #include <linux/input.h> | ||
29 | 25 | ||
30 | #include "caiaq-device.h" | 26 | #include "device.h" |
31 | #include "caiaq-control.h" | 27 | #include "control.h" |
32 | 28 | ||
33 | #define CNT_INTVAL 0x10000 | 29 | #define CNT_INTVAL 0x10000 |
34 | 30 | ||
@@ -39,12 +35,12 @@ static int control_info(struct snd_kcontrol *kcontrol, | |||
39 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 35 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); |
40 | int pos = kcontrol->private_value; | 36 | int pos = kcontrol->private_value; |
41 | int is_intval = pos & CNT_INTVAL; | 37 | int is_intval = pos & CNT_INTVAL; |
38 | unsigned int id = dev->chip.usb_id; | ||
42 | 39 | ||
43 | uinfo->count = 1; | 40 | uinfo->count = 1; |
44 | pos &= ~CNT_INTVAL; | 41 | pos &= ~CNT_INTVAL; |
45 | 42 | ||
46 | if (dev->chip.usb_id == | 43 | if (id == USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ) |
47 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ) | ||
48 | && (pos == 0)) { | 44 | && (pos == 0)) { |
49 | /* current input mode of A8DJ */ | 45 | /* current input mode of A8DJ */ |
50 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 46 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
@@ -53,6 +49,15 @@ static int control_info(struct snd_kcontrol *kcontrol, | |||
53 | return 0; | 49 | return 0; |
54 | } | 50 | } |
55 | 51 | ||
52 | if (id == USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ) | ||
53 | && (pos == 0)) { | ||
54 | /* current input mode of A4DJ */ | ||
55 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
56 | uinfo->value.integer.min = 0; | ||
57 | uinfo->value.integer.max = 1; | ||
58 | return 0; | ||
59 | } | ||
60 | |||
56 | if (is_intval) { | 61 | if (is_intval) { |
57 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 62 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
58 | uinfo->value.integer.min = 0; | 63 | uinfo->value.integer.min = 0; |
@@ -73,6 +78,14 @@ static int control_get(struct snd_kcontrol *kcontrol, | |||
73 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 78 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); |
74 | int pos = kcontrol->private_value; | 79 | int pos = kcontrol->private_value; |
75 | 80 | ||
81 | if (dev->chip.usb_id == | ||
82 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) { | ||
83 | /* A4DJ has only one control */ | ||
84 | /* do not expose hardware input mode 0 */ | ||
85 | ucontrol->value.integer.value[0] = dev->control_state[0] - 1; | ||
86 | return 0; | ||
87 | } | ||
88 | |||
76 | if (pos & CNT_INTVAL) | 89 | if (pos & CNT_INTVAL) |
77 | ucontrol->value.integer.value[0] | 90 | ucontrol->value.integer.value[0] |
78 | = dev->control_state[pos & ~CNT_INTVAL]; | 91 | = dev->control_state[pos & ~CNT_INTVAL]; |
@@ -90,10 +103,20 @@ static int control_put(struct snd_kcontrol *kcontrol, | |||
90 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 103 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); |
91 | int pos = kcontrol->private_value; | 104 | int pos = kcontrol->private_value; |
92 | 105 | ||
106 | if (dev->chip.usb_id == | ||
107 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) { | ||
108 | /* A4DJ has only one control */ | ||
109 | /* do not expose hardware input mode 0 */ | ||
110 | dev->control_state[0] = ucontrol->value.integer.value[0] + 1; | ||
111 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, | ||
112 | dev->control_state, sizeof(dev->control_state)); | ||
113 | return 1; | ||
114 | } | ||
115 | |||
93 | if (pos & CNT_INTVAL) { | 116 | if (pos & CNT_INTVAL) { |
94 | dev->control_state[pos & ~CNT_INTVAL] | 117 | dev->control_state[pos & ~CNT_INTVAL] |
95 | = ucontrol->value.integer.value[0]; | 118 | = ucontrol->value.integer.value[0]; |
96 | snd_usb_caiaq_send_command(dev, EP1_CMD_DIMM_LEDS, | 119 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, |
97 | dev->control_state, sizeof(dev->control_state)); | 120 | dev->control_state, sizeof(dev->control_state)); |
98 | } else { | 121 | } else { |
99 | if (ucontrol->value.integer.value[0]) | 122 | if (ucontrol->value.integer.value[0]) |
@@ -243,10 +266,13 @@ static struct caiaq_controller a8dj_controller[] = { | |||
243 | { "GND lift for TC Vinyl mode", 24 + 0 }, | 266 | { "GND lift for TC Vinyl mode", 24 + 0 }, |
244 | { "GND lift for TC CD/Line mode", 24 + 1 }, | 267 | { "GND lift for TC CD/Line mode", 24 + 1 }, |
245 | { "GND lift for phono mode", 24 + 2 }, | 268 | { "GND lift for phono mode", 24 + 2 }, |
246 | { "GND lift for TC Vinyl mode", 24 + 3 }, | ||
247 | { "Software lock", 40 } | 269 | { "Software lock", 40 } |
248 | }; | 270 | }; |
249 | 271 | ||
272 | static struct caiaq_controller a4dj_controller[] = { | ||
273 | { "Current input mode", 0 | CNT_INTVAL } | ||
274 | }; | ||
275 | |||
250 | static int __devinit add_controls(struct caiaq_controller *c, int num, | 276 | static int __devinit add_controls(struct caiaq_controller *c, int num, |
251 | struct snd_usb_caiaqdev *dev) | 277 | struct snd_usb_caiaqdev *dev) |
252 | { | 278 | { |
@@ -295,6 +321,10 @@ int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev) | |||
295 | ret = add_controls(a8dj_controller, | 321 | ret = add_controls(a8dj_controller, |
296 | ARRAY_SIZE(a8dj_controller), dev); | 322 | ARRAY_SIZE(a8dj_controller), dev); |
297 | break; | 323 | break; |
324 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | ||
325 | ret = add_controls(a4dj_controller, | ||
326 | ARRAY_SIZE(a4dj_controller), dev); | ||
327 | break; | ||
298 | } | 328 | } |
299 | 329 | ||
300 | return ret; | 330 | return ret; |
diff --git a/sound/usb/caiaq/caiaq-control.h b/sound/usb/caiaq/control.h index 2e7ab1aa4fb3..2e7ab1aa4fb3 100644 --- a/sound/usb/caiaq/caiaq-control.h +++ b/sound/usb/caiaq/control.h | |||
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/device.c index 09aed2363cc9..515de1cd2a3e 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -19,38 +19,33 @@ | |||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
25 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/module.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/usb.h> | 26 | #include <linux/usb.h> |
27 | #include <linux/input.h> | ||
28 | #include <linux/spinlock.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/initval.h> | 27 | #include <sound/initval.h> |
28 | #include <sound/core.h> | ||
31 | #include <sound/pcm.h> | 29 | #include <sound/pcm.h> |
32 | #include <sound/rawmidi.h> | ||
33 | #include <sound/control.h> | ||
34 | |||
35 | #include "caiaq-device.h" | ||
36 | #include "caiaq-audio.h" | ||
37 | #include "caiaq-midi.h" | ||
38 | #include "caiaq-control.h" | ||
39 | 30 | ||
40 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 31 | #include "device.h" |
41 | #include "caiaq-input.h" | 32 | #include "audio.h" |
42 | #endif | 33 | #include "midi.h" |
34 | #include "control.h" | ||
35 | #include "input.h" | ||
43 | 36 | ||
44 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
45 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.10"); | 38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14"); |
46 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
47 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," | 40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," |
48 | "{Native Instruments, RigKontrol3}," | 41 | "{Native Instruments, RigKontrol3}," |
49 | "{Native Instruments, Kore Controller}," | 42 | "{Native Instruments, Kore Controller}," |
50 | "{Native Instruments, Kore Controller 2}," | 43 | "{Native Instruments, Kore Controller 2}," |
51 | "{Native Instruments, Audio Kontrol 1}," | 44 | "{Native Instruments, Audio Kontrol 1}," |
45 | "{Native Instruments, Audio 4 DJ}," | ||
52 | "{Native Instruments, Audio 8 DJ}," | 46 | "{Native Instruments, Audio 8 DJ}," |
53 | "{Native Instruments, Session I/O}}"); | 47 | "{Native Instruments, Session I/O}," |
48 | "{Native Instruments, GuitarRig mobile}"); | ||
54 | 49 | ||
55 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ | 50 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ |
56 | static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ | 51 | static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ |
@@ -116,6 +111,16 @@ static struct usb_device_id snd_usb_id_table[] = { | |||
116 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | 111 | .idVendor = USB_VID_NATIVEINSTRUMENTS, |
117 | .idProduct = USB_PID_SESSIONIO | 112 | .idProduct = USB_PID_SESSIONIO |
118 | }, | 113 | }, |
114 | { | ||
115 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | ||
116 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | ||
117 | .idProduct = USB_PID_GUITARRIGMOBILE | ||
118 | }, | ||
119 | { | ||
120 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | ||
121 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | ||
122 | .idProduct = USB_PID_AUDIO4DJ | ||
123 | }, | ||
119 | { /* terminator */ } | 124 | { /* terminator */ } |
120 | }; | 125 | }; |
121 | 126 | ||
@@ -239,6 +244,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
239 | 244 | ||
240 | if (dev->audio_parm_answer != 1) | 245 | if (dev->audio_parm_answer != 1) |
241 | debug("unable to set the device's audio params\n"); | 246 | debug("unable to set the device's audio params\n"); |
247 | else | ||
248 | dev->bpp = bpp; | ||
242 | 249 | ||
243 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; | 250 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; |
244 | } | 251 | } |
@@ -300,6 +307,12 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
300 | } | 307 | } |
301 | 308 | ||
302 | break; | 309 | break; |
310 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | ||
311 | /* Audio 4 DJ - default input mode to phono */ | ||
312 | dev->control_state[0] = 2; | ||
313 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, | ||
314 | dev->control_state, 1); | ||
315 | break; | ||
303 | } | 316 | } |
304 | 317 | ||
305 | if (dev->spec.num_analog_audio_out + | 318 | if (dev->spec.num_analog_audio_out + |
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/device.h index ab56e738c5fc..4cce1ad7493d 100644 --- a/sound/usb/caiaq/caiaq-device.h +++ b/sound/usb/caiaq/device.h | |||
@@ -10,8 +10,10 @@ | |||
10 | #define USB_PID_KORECONTROLLER 0x4711 | 10 | #define USB_PID_KORECONTROLLER 0x4711 |
11 | #define USB_PID_KORECONTROLLER2 0x4712 | 11 | #define USB_PID_KORECONTROLLER2 0x4712 |
12 | #define USB_PID_AK1 0x0815 | 12 | #define USB_PID_AK1 0x0815 |
13 | #define USB_PID_AUDIO4DJ 0x0839 | ||
13 | #define USB_PID_AUDIO8DJ 0x1978 | 14 | #define USB_PID_AUDIO8DJ 0x1978 |
14 | #define USB_PID_SESSIONIO 0x1915 | 15 | #define USB_PID_SESSIONIO 0x1915 |
16 | #define USB_PID_GUITARRIGMOBILE 0x0d8d | ||
15 | 17 | ||
16 | #define EP1_BUFSIZE 64 | 18 | #define EP1_BUFSIZE 64 |
17 | #define CAIAQ_USB_STR_LEN 0xff | 19 | #define CAIAQ_USB_STR_LEN 0xff |
@@ -87,9 +89,9 @@ struct snd_usb_caiaqdev { | |||
87 | int audio_out_buf_pos[MAX_STREAMS]; | 89 | int audio_out_buf_pos[MAX_STREAMS]; |
88 | int period_in_count[MAX_STREAMS]; | 90 | int period_in_count[MAX_STREAMS]; |
89 | int period_out_count[MAX_STREAMS]; | 91 | int period_out_count[MAX_STREAMS]; |
90 | int input_panic, output_panic; | 92 | int input_panic, output_panic, warned; |
91 | char *audio_in_buf, *audio_out_buf; | 93 | char *audio_in_buf, *audio_out_buf; |
92 | unsigned int samplerates; | 94 | unsigned int samplerates, bpp; |
93 | 95 | ||
94 | struct snd_pcm_substream *sub_playback[MAX_STREAMS]; | 96 | struct snd_pcm_substream *sub_playback[MAX_STREAMS]; |
95 | struct snd_pcm_substream *sub_capture[MAX_STREAMS]; | 97 | struct snd_pcm_substream *sub_capture[MAX_STREAMS]; |
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/input.c index f743847a5e5a..a48d309bd94c 100644 --- a/sound/usb/caiaq/caiaq-input.c +++ b/sound/usb/caiaq/input.c | |||
@@ -17,17 +17,12 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/input.h> | ||
23 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
24 | #include <linux/usb/input.h> | 21 | #include <linux/usb/input.h> |
25 | #include <linux/spinlock.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/rawmidi.h> | ||
28 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
29 | #include "caiaq-device.h" | 23 | |
30 | #include "caiaq-input.h" | 24 | #include "device.h" |
25 | #include "input.h" | ||
31 | 26 | ||
32 | static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; | 27 | static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; |
33 | static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, | 28 | static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, |
diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/input.h index ced535577864..ced535577864 100644 --- a/sound/usb/caiaq/caiaq-input.h +++ b/sound/usb/caiaq/input.h | |||
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/midi.c index f19fd360c936..8fa8cd88d763 100644 --- a/sound/usb/caiaq/caiaq-midi.c +++ b/sound/usb/caiaq/midi.c | |||
@@ -16,20 +16,13 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/usb.h> | 19 | #include <linux/usb.h> |
24 | #include <linux/input.h> | ||
25 | #include <linux/spinlock.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/rawmidi.h> | 20 | #include <sound/rawmidi.h> |
21 | #include <sound/core.h> | ||
28 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
29 | 23 | ||
30 | #include "caiaq-device.h" | 24 | #include "device.h" |
31 | #include "caiaq-midi.h" | 25 | #include "midi.h" |
32 | |||
33 | 26 | ||
34 | static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) | 27 | static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) |
35 | { | 28 | { |
diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/midi.h index 9d16db027fc3..9d16db027fc3 100644 --- a/sound/usb/caiaq/caiaq-midi.h +++ b/sound/usb/caiaq/midi.h | |||
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index eec32e1a3020..823296d7d578 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -107,7 +107,7 @@ MODULE_PARM_DESC(ignore_ctl_error, | |||
107 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ | 107 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ |
108 | #define MAX_URBS 8 | 108 | #define MAX_URBS 8 |
109 | #define SYNC_URBS 4 /* always four urbs for sync */ | 109 | #define SYNC_URBS 4 /* always four urbs for sync */ |
110 | #define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ | 110 | #define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */ |
111 | 111 | ||
112 | struct audioformat { | 112 | struct audioformat { |
113 | struct list_head list; | 113 | struct list_head list; |
@@ -121,6 +121,7 @@ struct audioformat { | |||
121 | unsigned char attributes; /* corresponding attributes of cs endpoint */ | 121 | unsigned char attributes; /* corresponding attributes of cs endpoint */ |
122 | unsigned char endpoint; /* endpoint */ | 122 | unsigned char endpoint; /* endpoint */ |
123 | unsigned char ep_attr; /* endpoint attributes */ | 123 | unsigned char ep_attr; /* endpoint attributes */ |
124 | unsigned char datainterval; /* log_2 of data packet interval */ | ||
124 | unsigned int maxpacksize; /* max. packet size */ | 125 | unsigned int maxpacksize; /* max. packet size */ |
125 | unsigned int rates; /* rate bitmasks */ | 126 | unsigned int rates; /* rate bitmasks */ |
126 | unsigned int rate_min, rate_max; /* min/max rates */ | 127 | unsigned int rate_min, rate_max; /* min/max rates */ |
@@ -170,7 +171,6 @@ struct snd_usb_substream { | |||
170 | unsigned int curframesize; /* current packet size in frames (for capture) */ | 171 | unsigned int curframesize; /* current packet size in frames (for capture) */ |
171 | unsigned int fill_max: 1; /* fill max packet size always */ | 172 | unsigned int fill_max: 1; /* fill max packet size always */ |
172 | unsigned int fmt_type; /* USB audio format type (1-3) */ | 173 | unsigned int fmt_type; /* USB audio format type (1-3) */ |
173 | unsigned int packs_per_ms; /* packets per millisecond (for playback) */ | ||
174 | 174 | ||
175 | unsigned int running: 1; /* running status */ | 175 | unsigned int running: 1; /* running status */ |
176 | 176 | ||
@@ -525,7 +525,7 @@ static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs) | |||
525 | /* | 525 | /* |
526 | * Prepare urb for streaming before playback starts or when paused. | 526 | * Prepare urb for streaming before playback starts or when paused. |
527 | * | 527 | * |
528 | * We don't have any data, so we send a frame of silence. | 528 | * We don't have any data, so we send silence. |
529 | */ | 529 | */ |
530 | static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, | 530 | static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, |
531 | struct snd_pcm_runtime *runtime, | 531 | struct snd_pcm_runtime *runtime, |
@@ -537,13 +537,13 @@ static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, | |||
537 | 537 | ||
538 | offs = 0; | 538 | offs = 0; |
539 | urb->dev = ctx->subs->dev; | 539 | urb->dev = ctx->subs->dev; |
540 | urb->number_of_packets = subs->packs_per_ms; | 540 | for (i = 0; i < ctx->packets; ++i) { |
541 | for (i = 0; i < subs->packs_per_ms; ++i) { | ||
542 | counts = snd_usb_audio_next_packet_size(subs); | 541 | counts = snd_usb_audio_next_packet_size(subs); |
543 | urb->iso_frame_desc[i].offset = offs * stride; | 542 | urb->iso_frame_desc[i].offset = offs * stride; |
544 | urb->iso_frame_desc[i].length = counts * stride; | 543 | urb->iso_frame_desc[i].length = counts * stride; |
545 | offs += counts; | 544 | offs += counts; |
546 | } | 545 | } |
546 | urb->number_of_packets = ctx->packets; | ||
547 | urb->transfer_buffer_length = offs * stride; | 547 | urb->transfer_buffer_length = offs * stride; |
548 | memset(urb->transfer_buffer, | 548 | memset(urb->transfer_buffer, |
549 | subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0, | 549 | subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0, |
@@ -607,9 +607,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | } | 609 | } |
610 | /* finish at the frame boundary at/after the period boundary */ | 610 | if (period_elapsed) /* finish at the period boundary */ |
611 | if (period_elapsed && | ||
612 | (i & (subs->packs_per_ms - 1)) == subs->packs_per_ms - 1) | ||
613 | break; | 611 | break; |
614 | } | 612 | } |
615 | if (subs->hwptr_done + offs > runtime->buffer_size) { | 613 | if (subs->hwptr_done + offs > runtime->buffer_size) { |
@@ -1034,9 +1032,9 @@ static void release_substream_urbs(struct snd_usb_substream *subs, int force) | |||
1034 | static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes, | 1032 | static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes, |
1035 | unsigned int rate, unsigned int frame_bits) | 1033 | unsigned int rate, unsigned int frame_bits) |
1036 | { | 1034 | { |
1037 | unsigned int maxsize, n, i; | 1035 | unsigned int maxsize, i; |
1038 | int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK; | 1036 | int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK; |
1039 | unsigned int npacks[MAX_URBS], urb_packs, total_packs, packs_per_ms; | 1037 | unsigned int urb_packs, total_packs, packs_per_ms; |
1040 | 1038 | ||
1041 | /* calculate the frequency in 16.16 format */ | 1039 | /* calculate the frequency in 16.16 format */ |
1042 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) | 1040 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) |
@@ -1067,11 +1065,9 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1067 | packs_per_ms = 8 >> subs->datainterval; | 1065 | packs_per_ms = 8 >> subs->datainterval; |
1068 | else | 1066 | else |
1069 | packs_per_ms = 1; | 1067 | packs_per_ms = 1; |
1070 | subs->packs_per_ms = packs_per_ms; | ||
1071 | 1068 | ||
1072 | if (is_playback) { | 1069 | if (is_playback) { |
1073 | urb_packs = nrpacks; | 1070 | urb_packs = max(nrpacks, 1); |
1074 | urb_packs = max(urb_packs, (unsigned int)MIN_PACKS_URB); | ||
1075 | urb_packs = min(urb_packs, (unsigned int)MAX_PACKS); | 1071 | urb_packs = min(urb_packs, (unsigned int)MAX_PACKS); |
1076 | } else | 1072 | } else |
1077 | urb_packs = 1; | 1073 | urb_packs = 1; |
@@ -1079,7 +1075,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1079 | 1075 | ||
1080 | /* decide how many packets to be used */ | 1076 | /* decide how many packets to be used */ |
1081 | if (is_playback) { | 1077 | if (is_playback) { |
1082 | unsigned int minsize; | 1078 | unsigned int minsize, maxpacks; |
1083 | /* determine how small a packet can be */ | 1079 | /* determine how small a packet can be */ |
1084 | minsize = (subs->freqn >> (16 - subs->datainterval)) | 1080 | minsize = (subs->freqn >> (16 - subs->datainterval)) |
1085 | * (frame_bits >> 3); | 1081 | * (frame_bits >> 3); |
@@ -1088,13 +1084,17 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1088 | minsize -= minsize >> 3; | 1084 | minsize -= minsize >> 3; |
1089 | minsize = max(minsize, 1u); | 1085 | minsize = max(minsize, 1u); |
1090 | total_packs = (period_bytes + minsize - 1) / minsize; | 1086 | total_packs = (period_bytes + minsize - 1) / minsize; |
1091 | /* round up to multiple of packs_per_ms */ | ||
1092 | total_packs = (total_packs + packs_per_ms - 1) | ||
1093 | & ~(packs_per_ms - 1); | ||
1094 | /* we need at least two URBs for queueing */ | 1087 | /* we need at least two URBs for queueing */ |
1095 | if (total_packs < 2 * MIN_PACKS_URB * packs_per_ms) | 1088 | if (total_packs < 2) { |
1096 | total_packs = 2 * MIN_PACKS_URB * packs_per_ms; | 1089 | total_packs = 2; |
1090 | } else { | ||
1091 | /* and we don't want too long a queue either */ | ||
1092 | maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2); | ||
1093 | total_packs = min(total_packs, maxpacks); | ||
1094 | } | ||
1097 | } else { | 1095 | } else { |
1096 | while (urb_packs > 1 && urb_packs * maxsize >= period_bytes) | ||
1097 | urb_packs >>= 1; | ||
1098 | total_packs = MAX_URBS * urb_packs; | 1098 | total_packs = MAX_URBS * urb_packs; |
1099 | } | 1099 | } |
1100 | subs->nurbs = (total_packs + urb_packs - 1) / urb_packs; | 1100 | subs->nurbs = (total_packs + urb_packs - 1) / urb_packs; |
@@ -1102,31 +1102,11 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1102 | /* too much... */ | 1102 | /* too much... */ |
1103 | subs->nurbs = MAX_URBS; | 1103 | subs->nurbs = MAX_URBS; |
1104 | total_packs = MAX_URBS * urb_packs; | 1104 | total_packs = MAX_URBS * urb_packs; |
1105 | } | 1105 | } else if (subs->nurbs < 2) { |
1106 | n = total_packs; | ||
1107 | for (i = 0; i < subs->nurbs; i++) { | ||
1108 | npacks[i] = n > urb_packs ? urb_packs : n; | ||
1109 | n -= urb_packs; | ||
1110 | } | ||
1111 | if (subs->nurbs <= 1) { | ||
1112 | /* too little - we need at least two packets | 1106 | /* too little - we need at least two packets |
1113 | * to ensure contiguous playback/capture | 1107 | * to ensure contiguous playback/capture |
1114 | */ | 1108 | */ |
1115 | subs->nurbs = 2; | 1109 | subs->nurbs = 2; |
1116 | npacks[0] = (total_packs + 1) / 2; | ||
1117 | npacks[1] = total_packs - npacks[0]; | ||
1118 | } else if (npacks[subs->nurbs-1] < MIN_PACKS_URB * packs_per_ms) { | ||
1119 | /* the last packet is too small.. */ | ||
1120 | if (subs->nurbs > 2) { | ||
1121 | /* merge to the first one */ | ||
1122 | npacks[0] += npacks[subs->nurbs - 1]; | ||
1123 | subs->nurbs--; | ||
1124 | } else { | ||
1125 | /* divide to two */ | ||
1126 | subs->nurbs = 2; | ||
1127 | npacks[0] = (total_packs + 1) / 2; | ||
1128 | npacks[1] = total_packs - npacks[0]; | ||
1129 | } | ||
1130 | } | 1110 | } |
1131 | 1111 | ||
1132 | /* allocate and initialize data urbs */ | 1112 | /* allocate and initialize data urbs */ |
@@ -1134,7 +1114,8 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1134 | struct snd_urb_ctx *u = &subs->dataurb[i]; | 1114 | struct snd_urb_ctx *u = &subs->dataurb[i]; |
1135 | u->index = i; | 1115 | u->index = i; |
1136 | u->subs = subs; | 1116 | u->subs = subs; |
1137 | u->packets = npacks[i]; | 1117 | u->packets = (i + 1) * total_packs / subs->nurbs |
1118 | - i * total_packs / subs->nurbs; | ||
1138 | u->buffer_size = maxsize * u->packets; | 1119 | u->buffer_size = maxsize * u->packets; |
1139 | if (subs->fmt_type == USB_FORMAT_TYPE_II) | 1120 | if (subs->fmt_type == USB_FORMAT_TYPE_II) |
1140 | u->packets++; /* for transfer delimiter */ | 1121 | u->packets++; /* for transfer delimiter */ |
@@ -1292,14 +1273,14 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, | |||
1292 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, | 1273 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, |
1293 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, | 1274 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, |
1294 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { | 1275 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { |
1295 | snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n", | 1276 | snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", |
1296 | dev->devnum, iface, fmt->altsetting, rate, ep); | 1277 | dev->devnum, iface, fmt->altsetting, rate, ep); |
1297 | return err; | 1278 | return err; |
1298 | } | 1279 | } |
1299 | if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, | 1280 | if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, |
1300 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, | 1281 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, |
1301 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { | 1282 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { |
1302 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n", | 1283 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", |
1303 | dev->devnum, iface, fmt->altsetting, ep); | 1284 | dev->devnum, iface, fmt->altsetting, ep); |
1304 | return 0; /* some devices don't support reading */ | 1285 | return 0; /* some devices don't support reading */ |
1305 | } | 1286 | } |
@@ -1365,12 +1346,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1365 | subs->datapipe = usb_sndisocpipe(dev, ep); | 1346 | subs->datapipe = usb_sndisocpipe(dev, ep); |
1366 | else | 1347 | else |
1367 | subs->datapipe = usb_rcvisocpipe(dev, ep); | 1348 | subs->datapipe = usb_rcvisocpipe(dev, ep); |
1368 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH && | 1349 | subs->datainterval = fmt->datainterval; |
1369 | get_endpoint(alts, 0)->bInterval >= 1 && | ||
1370 | get_endpoint(alts, 0)->bInterval <= 4) | ||
1371 | subs->datainterval = get_endpoint(alts, 0)->bInterval - 1; | ||
1372 | else | ||
1373 | subs->datainterval = 0; | ||
1374 | subs->syncpipe = subs->syncinterval = 0; | 1350 | subs->syncpipe = subs->syncinterval = 0; |
1375 | subs->maxpacksize = fmt->maxpacksize; | 1351 | subs->maxpacksize = fmt->maxpacksize; |
1376 | subs->fill_max = 0; | 1352 | subs->fill_max = 0; |
@@ -1431,9 +1407,11 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1431 | subs->cur_audiofmt = fmt; | 1407 | subs->cur_audiofmt = fmt; |
1432 | 1408 | ||
1433 | #if 0 | 1409 | #if 0 |
1434 | printk("setting done: format = %d, rate = %d..%d, channels = %d\n", | 1410 | printk(KERN_DEBUG |
1411 | "setting done: format = %d, rate = %d..%d, channels = %d\n", | ||
1435 | fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels); | 1412 | fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels); |
1436 | printk(" datapipe = 0x%0x, syncpipe = 0x%0x\n", | 1413 | printk(KERN_DEBUG |
1414 | " datapipe = 0x%0x, syncpipe = 0x%0x\n", | ||
1437 | subs->datapipe, subs->syncpipe); | 1415 | subs->datapipe, subs->syncpipe); |
1438 | #endif | 1416 | #endif |
1439 | 1417 | ||
@@ -1468,7 +1446,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, | |||
1468 | channels = params_channels(hw_params); | 1446 | channels = params_channels(hw_params); |
1469 | fmt = find_format(subs, format, rate, channels); | 1447 | fmt = find_format(subs, format, rate, channels); |
1470 | if (!fmt) { | 1448 | if (!fmt) { |
1471 | snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n", | 1449 | snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n", |
1472 | format, rate, channels); | 1450 | format, rate, channels); |
1473 | return -EINVAL; | 1451 | return -EINVAL; |
1474 | } | 1452 | } |
@@ -1581,11 +1559,15 @@ static struct snd_pcm_hardware snd_usb_hardware = | |||
1581 | #define hwc_debug(fmt, args...) /**/ | 1559 | #define hwc_debug(fmt, args...) /**/ |
1582 | #endif | 1560 | #endif |
1583 | 1561 | ||
1584 | static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audioformat *fp) | 1562 | static int hw_check_valid_format(struct snd_usb_substream *subs, |
1563 | struct snd_pcm_hw_params *params, | ||
1564 | struct audioformat *fp) | ||
1585 | { | 1565 | { |
1586 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | 1566 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); |
1587 | struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | 1567 | struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); |
1588 | struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); | 1568 | struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
1569 | struct snd_interval *pt = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME); | ||
1570 | unsigned int ptime; | ||
1589 | 1571 | ||
1590 | /* check the format */ | 1572 | /* check the format */ |
1591 | if (!snd_mask_test(fmts, fp->format)) { | 1573 | if (!snd_mask_test(fmts, fp->format)) { |
@@ -1606,6 +1588,14 @@ static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audiof | |||
1606 | hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min); | 1588 | hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min); |
1607 | return 0; | 1589 | return 0; |
1608 | } | 1590 | } |
1591 | /* check whether the period time is >= the data packet interval */ | ||
1592 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) { | ||
1593 | ptime = 125 * (1 << fp->datainterval); | ||
1594 | if (ptime > pt->max || (ptime == pt->max && pt->openmax)) { | ||
1595 | hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max); | ||
1596 | return 0; | ||
1597 | } | ||
1598 | } | ||
1609 | return 1; | 1599 | return 1; |
1610 | } | 1600 | } |
1611 | 1601 | ||
@@ -1624,7 +1614,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, | |||
1624 | list_for_each(p, &subs->fmt_list) { | 1614 | list_for_each(p, &subs->fmt_list) { |
1625 | struct audioformat *fp; | 1615 | struct audioformat *fp; |
1626 | fp = list_entry(p, struct audioformat, list); | 1616 | fp = list_entry(p, struct audioformat, list); |
1627 | if (!hw_check_valid_format(params, fp)) | 1617 | if (!hw_check_valid_format(subs, params, fp)) |
1628 | continue; | 1618 | continue; |
1629 | if (changed++) { | 1619 | if (changed++) { |
1630 | if (rmin > fp->rate_min) | 1620 | if (rmin > fp->rate_min) |
@@ -1678,7 +1668,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, | |||
1678 | list_for_each(p, &subs->fmt_list) { | 1668 | list_for_each(p, &subs->fmt_list) { |
1679 | struct audioformat *fp; | 1669 | struct audioformat *fp; |
1680 | fp = list_entry(p, struct audioformat, list); | 1670 | fp = list_entry(p, struct audioformat, list); |
1681 | if (!hw_check_valid_format(params, fp)) | 1671 | if (!hw_check_valid_format(subs, params, fp)) |
1682 | continue; | 1672 | continue; |
1683 | if (changed++) { | 1673 | if (changed++) { |
1684 | if (rmin > fp->channels) | 1674 | if (rmin > fp->channels) |
@@ -1731,7 +1721,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, | |||
1731 | list_for_each(p, &subs->fmt_list) { | 1721 | list_for_each(p, &subs->fmt_list) { |
1732 | struct audioformat *fp; | 1722 | struct audioformat *fp; |
1733 | fp = list_entry(p, struct audioformat, list); | 1723 | fp = list_entry(p, struct audioformat, list); |
1734 | if (!hw_check_valid_format(params, fp)) | 1724 | if (!hw_check_valid_format(subs, params, fp)) |
1735 | continue; | 1725 | continue; |
1736 | fbits |= (1ULL << fp->format); | 1726 | fbits |= (1ULL << fp->format); |
1737 | } | 1727 | } |
@@ -1749,95 +1739,42 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, | |||
1749 | return changed; | 1739 | return changed; |
1750 | } | 1740 | } |
1751 | 1741 | ||
1752 | #define MAX_MASK 64 | 1742 | static int hw_rule_period_time(struct snd_pcm_hw_params *params, |
1753 | 1743 | struct snd_pcm_hw_rule *rule) | |
1754 | /* | ||
1755 | * check whether the registered audio formats need special hw-constraints | ||
1756 | */ | ||
1757 | static int check_hw_params_convention(struct snd_usb_substream *subs) | ||
1758 | { | 1744 | { |
1759 | int i; | 1745 | struct snd_usb_substream *subs = rule->private; |
1760 | u32 *channels; | 1746 | struct audioformat *fp; |
1761 | u32 *rates; | 1747 | struct snd_interval *it; |
1762 | u32 cmaster, rmaster; | 1748 | unsigned char min_datainterval; |
1763 | u32 rate_min = 0, rate_max = 0; | 1749 | unsigned int pmin; |
1764 | struct list_head *p; | 1750 | int changed; |
1765 | int err = 1; | ||
1766 | |||
1767 | channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL); | ||
1768 | rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL); | ||
1769 | if (!channels || !rates) { | ||
1770 | err = -ENOMEM; | ||
1771 | goto __out; | ||
1772 | } | ||
1773 | 1751 | ||
1774 | list_for_each(p, &subs->fmt_list) { | 1752 | it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME); |
1775 | struct audioformat *f; | 1753 | hwc_debug("hw_rule_period_time: (%u,%u)\n", it->min, it->max); |
1776 | f = list_entry(p, struct audioformat, list); | 1754 | min_datainterval = 0xff; |
1777 | /* unconventional channels? */ | 1755 | list_for_each_entry(fp, &subs->fmt_list, list) { |
1778 | if (f->channels > 32) | 1756 | if (!hw_check_valid_format(subs, params, fp)) |
1779 | goto __out; | ||
1780 | /* continuous rate min/max matches? */ | ||
1781 | if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) { | ||
1782 | if (rate_min && f->rate_min != rate_min) | ||
1783 | goto __out; | ||
1784 | if (rate_max && f->rate_max != rate_max) | ||
1785 | goto __out; | ||
1786 | rate_min = f->rate_min; | ||
1787 | rate_max = f->rate_max; | ||
1788 | } | ||
1789 | /* combination of continuous rates and fixed rates? */ | ||
1790 | if (rates[f->format] & SNDRV_PCM_RATE_CONTINUOUS) { | ||
1791 | if (f->rates != rates[f->format]) | ||
1792 | goto __out; | ||
1793 | } | ||
1794 | if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) { | ||
1795 | if (rates[f->format] && rates[f->format] != f->rates) | ||
1796 | goto __out; | ||
1797 | } | ||
1798 | channels[f->format] |= (1 << f->channels); | ||
1799 | rates[f->format] |= f->rates; | ||
1800 | /* needs knot? */ | ||
1801 | if (f->rates & SNDRV_PCM_RATE_KNOT) | ||
1802 | goto __out; | ||
1803 | } | ||
1804 | /* check whether channels and rates match for all formats */ | ||
1805 | cmaster = rmaster = 0; | ||
1806 | for (i = 0; i < MAX_MASK; i++) { | ||
1807 | if (cmaster != channels[i] && cmaster && channels[i]) | ||
1808 | goto __out; | ||
1809 | if (rmaster != rates[i] && rmaster && rates[i]) | ||
1810 | goto __out; | ||
1811 | if (channels[i]) | ||
1812 | cmaster = channels[i]; | ||
1813 | if (rates[i]) | ||
1814 | rmaster = rates[i]; | ||
1815 | } | ||
1816 | /* check whether channels match for all distinct rates */ | ||
1817 | memset(channels, 0, MAX_MASK * sizeof(u32)); | ||
1818 | list_for_each(p, &subs->fmt_list) { | ||
1819 | struct audioformat *f; | ||
1820 | f = list_entry(p, struct audioformat, list); | ||
1821 | if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) | ||
1822 | continue; | 1757 | continue; |
1823 | for (i = 0; i < 32; i++) { | 1758 | min_datainterval = min(min_datainterval, fp->datainterval); |
1824 | if (f->rates & (1 << i)) | 1759 | } |
1825 | channels[i] |= (1 << f->channels); | 1760 | if (min_datainterval == 0xff) { |
1826 | } | 1761 | hwc_debug(" --> get emtpy\n"); |
1762 | it->empty = 1; | ||
1763 | return -EINVAL; | ||
1827 | } | 1764 | } |
1828 | cmaster = 0; | 1765 | pmin = 125 * (1 << min_datainterval); |
1829 | for (i = 0; i < 32; i++) { | 1766 | changed = 0; |
1830 | if (cmaster != channels[i] && cmaster && channels[i]) | 1767 | if (it->min < pmin) { |
1831 | goto __out; | 1768 | it->min = pmin; |
1832 | if (channels[i]) | 1769 | it->openmin = 0; |
1833 | cmaster = channels[i]; | 1770 | changed = 1; |
1834 | } | 1771 | } |
1835 | err = 0; | 1772 | if (snd_interval_checkempty(it)) { |
1836 | 1773 | it->empty = 1; | |
1837 | __out: | 1774 | return -EINVAL; |
1838 | kfree(channels); | 1775 | } |
1839 | kfree(rates); | 1776 | hwc_debug(" --> (%u,%u) (changed = %d)\n", it->min, it->max, changed); |
1840 | return err; | 1777 | return changed; |
1841 | } | 1778 | } |
1842 | 1779 | ||
1843 | /* | 1780 | /* |
@@ -1885,6 +1822,8 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, | |||
1885 | static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) | 1822 | static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) |
1886 | { | 1823 | { |
1887 | struct list_head *p; | 1824 | struct list_head *p; |
1825 | unsigned int pt, ptmin; | ||
1826 | int param_period_time_if_needed; | ||
1888 | int err; | 1827 | int err; |
1889 | 1828 | ||
1890 | runtime->hw.formats = subs->formats; | 1829 | runtime->hw.formats = subs->formats; |
@@ -1894,6 +1833,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
1894 | runtime->hw.channels_min = 256; | 1833 | runtime->hw.channels_min = 256; |
1895 | runtime->hw.channels_max = 0; | 1834 | runtime->hw.channels_max = 0; |
1896 | runtime->hw.rates = 0; | 1835 | runtime->hw.rates = 0; |
1836 | ptmin = UINT_MAX; | ||
1897 | /* check min/max rates and channels */ | 1837 | /* check min/max rates and channels */ |
1898 | list_for_each(p, &subs->fmt_list) { | 1838 | list_for_each(p, &subs->fmt_list) { |
1899 | struct audioformat *fp; | 1839 | struct audioformat *fp; |
@@ -1912,42 +1852,54 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
1912 | runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = | 1852 | runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = |
1913 | fp->frame_size; | 1853 | fp->frame_size; |
1914 | } | 1854 | } |
1855 | pt = 125 * (1 << fp->datainterval); | ||
1856 | ptmin = min(ptmin, pt); | ||
1915 | } | 1857 | } |
1916 | 1858 | ||
1917 | /* set the period time minimum 1ms */ | 1859 | param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME; |
1918 | /* FIXME: high-speed mode allows 125us minimum period, but many parts | 1860 | if (snd_usb_get_speed(subs->dev) != USB_SPEED_HIGH) |
1919 | * in the current code assume the 1ms period. | 1861 | /* full speed devices have fixed data packet interval */ |
1920 | */ | 1862 | ptmin = 1000; |
1863 | if (ptmin == 1000) | ||
1864 | /* if period time doesn't go below 1 ms, no rules needed */ | ||
1865 | param_period_time_if_needed = -1; | ||
1921 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, | 1866 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, |
1922 | 1000 * MIN_PACKS_URB, | 1867 | ptmin, UINT_MAX); |
1923 | /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); | 1868 | |
1924 | 1869 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | |
1925 | err = check_hw_params_convention(subs); | 1870 | hw_rule_rate, subs, |
1926 | if (err < 0) | 1871 | SNDRV_PCM_HW_PARAM_FORMAT, |
1872 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
1873 | param_period_time_if_needed, | ||
1874 | -1)) < 0) | ||
1927 | return err; | 1875 | return err; |
1928 | else if (err) { | 1876 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
1929 | hwc_debug("setting extra hw constraints...\n"); | 1877 | hw_rule_channels, subs, |
1930 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 1878 | SNDRV_PCM_HW_PARAM_FORMAT, |
1931 | hw_rule_rate, subs, | 1879 | SNDRV_PCM_HW_PARAM_RATE, |
1932 | SNDRV_PCM_HW_PARAM_FORMAT, | 1880 | param_period_time_if_needed, |
1933 | SNDRV_PCM_HW_PARAM_CHANNELS, | 1881 | -1)) < 0) |
1934 | -1)) < 0) | 1882 | return err; |
1935 | return err; | 1883 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, |
1936 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | 1884 | hw_rule_format, subs, |
1937 | hw_rule_channels, subs, | 1885 | SNDRV_PCM_HW_PARAM_RATE, |
1938 | SNDRV_PCM_HW_PARAM_FORMAT, | 1886 | SNDRV_PCM_HW_PARAM_CHANNELS, |
1939 | SNDRV_PCM_HW_PARAM_RATE, | 1887 | param_period_time_if_needed, |
1940 | -1)) < 0) | 1888 | -1)) < 0) |
1941 | return err; | 1889 | return err; |
1942 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, | 1890 | if (param_period_time_if_needed >= 0) { |
1943 | hw_rule_format, subs, | 1891 | err = snd_pcm_hw_rule_add(runtime, 0, |
1944 | SNDRV_PCM_HW_PARAM_RATE, | 1892 | SNDRV_PCM_HW_PARAM_PERIOD_TIME, |
1945 | SNDRV_PCM_HW_PARAM_CHANNELS, | 1893 | hw_rule_period_time, subs, |
1946 | -1)) < 0) | 1894 | SNDRV_PCM_HW_PARAM_FORMAT, |
1947 | return err; | 1895 | SNDRV_PCM_HW_PARAM_CHANNELS, |
1948 | if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) | 1896 | SNDRV_PCM_HW_PARAM_RATE, |
1897 | -1); | ||
1898 | if (err < 0) | ||
1949 | return err; | 1899 | return err; |
1950 | } | 1900 | } |
1901 | if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) | ||
1902 | return err; | ||
1951 | return 0; | 1903 | return 0; |
1952 | } | 1904 | } |
1953 | 1905 | ||
@@ -2160,7 +2112,8 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s | |||
2160 | fp = list_entry(p, struct audioformat, list); | 2112 | fp = list_entry(p, struct audioformat, list); |
2161 | snd_iprintf(buffer, " Interface %d\n", fp->iface); | 2113 | snd_iprintf(buffer, " Interface %d\n", fp->iface); |
2162 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); | 2114 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); |
2163 | snd_iprintf(buffer, " Format: 0x%x\n", fp->format); | 2115 | snd_iprintf(buffer, " Format: %#x (%d bits)\n", |
2116 | fp->format, snd_pcm_format_width(fp->format)); | ||
2164 | snd_iprintf(buffer, " Channels: %d\n", fp->channels); | 2117 | snd_iprintf(buffer, " Channels: %d\n", fp->channels); |
2165 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", | 2118 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", |
2166 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, | 2119 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, |
@@ -2179,8 +2132,11 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s | |||
2179 | } | 2132 | } |
2180 | snd_iprintf(buffer, "\n"); | 2133 | snd_iprintf(buffer, "\n"); |
2181 | } | 2134 | } |
2135 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) | ||
2136 | snd_iprintf(buffer, " Data packet interval: %d us\n", | ||
2137 | 125 * (1 << fp->datainterval)); | ||
2182 | // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); | 2138 | // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); |
2183 | // snd_iprintf(buffer, " EP Attribute = 0x%x\n", fp->attributes); | 2139 | // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes); |
2184 | } | 2140 | } |
2185 | } | 2141 | } |
2186 | 2142 | ||
@@ -2524,7 +2480,6 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2524 | * build the rate table and bitmap flags | 2480 | * build the rate table and bitmap flags |
2525 | */ | 2481 | */ |
2526 | int r, idx; | 2482 | int r, idx; |
2527 | unsigned int nonzero_rates = 0; | ||
2528 | 2483 | ||
2529 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); | 2484 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); |
2530 | if (fp->rate_table == NULL) { | 2485 | if (fp->rate_table == NULL) { |
@@ -2532,24 +2487,27 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2532 | return -1; | 2487 | return -1; |
2533 | } | 2488 | } |
2534 | 2489 | ||
2535 | fp->nr_rates = nr_rates; | 2490 | fp->nr_rates = 0; |
2536 | fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); | 2491 | fp->rate_min = fp->rate_max = 0; |
2537 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { | 2492 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { |
2538 | unsigned int rate = combine_triple(&fmt[idx]); | 2493 | unsigned int rate = combine_triple(&fmt[idx]); |
2494 | if (!rate) | ||
2495 | continue; | ||
2539 | /* C-Media CM6501 mislabels its 96 kHz altsetting */ | 2496 | /* C-Media CM6501 mislabels its 96 kHz altsetting */ |
2540 | if (rate == 48000 && nr_rates == 1 && | 2497 | if (rate == 48000 && nr_rates == 1 && |
2541 | chip->usb_id == USB_ID(0x0d8c, 0x0201) && | 2498 | (chip->usb_id == USB_ID(0x0d8c, 0x0201) || |
2499 | chip->usb_id == USB_ID(0x0d8c, 0x0102)) && | ||
2542 | fp->altsetting == 5 && fp->maxpacksize == 392) | 2500 | fp->altsetting == 5 && fp->maxpacksize == 392) |
2543 | rate = 96000; | 2501 | rate = 96000; |
2544 | fp->rate_table[r] = rate; | 2502 | fp->rate_table[fp->nr_rates] = rate; |
2545 | nonzero_rates |= rate; | 2503 | if (!fp->rate_min || rate < fp->rate_min) |
2546 | if (rate < fp->rate_min) | ||
2547 | fp->rate_min = rate; | 2504 | fp->rate_min = rate; |
2548 | else if (rate > fp->rate_max) | 2505 | if (!fp->rate_max || rate > fp->rate_max) |
2549 | fp->rate_max = rate; | 2506 | fp->rate_max = rate; |
2550 | fp->rates |= snd_pcm_rate_to_rate_bit(rate); | 2507 | fp->rates |= snd_pcm_rate_to_rate_bit(rate); |
2508 | fp->nr_rates++; | ||
2551 | } | 2509 | } |
2552 | if (!nonzero_rates) { | 2510 | if (!fp->nr_rates) { |
2553 | hwc_debug("All rates were zero. Skipping format!\n"); | 2511 | hwc_debug("All rates were zero. Skipping format!\n"); |
2554 | return -1; | 2512 | return -1; |
2555 | } | 2513 | } |
@@ -2619,7 +2577,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat | |||
2619 | fp->format = SNDRV_PCM_FORMAT_MPEG; | 2577 | fp->format = SNDRV_PCM_FORMAT_MPEG; |
2620 | break; | 2578 | break; |
2621 | default: | 2579 | default: |
2622 | snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", | 2580 | snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected. processed as MPEG.\n", |
2623 | chip->dev->devnum, fp->iface, fp->altsetting, format); | 2581 | chip->dev->devnum, fp->iface, fp->altsetting, format); |
2624 | fp->format = SNDRV_PCM_FORMAT_MPEG; | 2582 | fp->format = SNDRV_PCM_FORMAT_MPEG; |
2625 | break; | 2583 | break; |
@@ -2670,6 +2628,17 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp | |||
2670 | return 0; | 2628 | return 0; |
2671 | } | 2629 | } |
2672 | 2630 | ||
2631 | static unsigned char parse_datainterval(struct snd_usb_audio *chip, | ||
2632 | struct usb_host_interface *alts) | ||
2633 | { | ||
2634 | if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH && | ||
2635 | get_endpoint(alts, 0)->bInterval >= 1 && | ||
2636 | get_endpoint(alts, 0)->bInterval <= 4) | ||
2637 | return get_endpoint(alts, 0)->bInterval - 1; | ||
2638 | else | ||
2639 | return 0; | ||
2640 | } | ||
2641 | |||
2673 | static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, | 2642 | static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, |
2674 | int iface, int altno); | 2643 | int iface, int altno); |
2675 | static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | 2644 | static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) |
@@ -2775,6 +2744,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2775 | fp->altset_idx = i; | 2744 | fp->altset_idx = i; |
2776 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 2745 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
2777 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 2746 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
2747 | fp->datainterval = parse_datainterval(chip, alts); | ||
2778 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 2748 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
2779 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) | 2749 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) |
2780 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) | 2750 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) |
@@ -2817,7 +2787,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2817 | continue; | 2787 | continue; |
2818 | } | 2788 | } |
2819 | 2789 | ||
2820 | snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, altno, fp->endpoint); | 2790 | snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint); |
2821 | err = add_audio_endpoint(chip, stream, fp); | 2791 | err = add_audio_endpoint(chip, stream, fp); |
2822 | if (err < 0) { | 2792 | if (err < 0) { |
2823 | kfree(fp->rate_table); | 2793 | kfree(fp->rate_table); |
@@ -2966,6 +2936,8 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, | |||
2966 | return -EINVAL; | 2936 | return -EINVAL; |
2967 | } | 2937 | } |
2968 | alts = &iface->altsetting[fp->altset_idx]; | 2938 | alts = &iface->altsetting[fp->altset_idx]; |
2939 | fp->datainterval = parse_datainterval(chip, alts); | ||
2940 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
2969 | usb_set_interface(chip->dev, fp->iface, 0); | 2941 | usb_set_interface(chip->dev, fp->iface, 0); |
2970 | init_usb_pitch(chip->dev, fp->iface, alts, fp); | 2942 | init_usb_pitch(chip->dev, fp->iface, alts, fp); |
2971 | init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max); | 2943 | init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max); |
@@ -3059,6 +3031,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, | |||
3059 | fp->iface = altsd->bInterfaceNumber; | 3031 | fp->iface = altsd->bInterfaceNumber; |
3060 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 3032 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
3061 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 3033 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
3034 | fp->datainterval = 0; | ||
3062 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 3035 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
3063 | 3036 | ||
3064 | switch (fp->maxpacksize) { | 3037 | switch (fp->maxpacksize) { |
@@ -3126,6 +3099,7 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip, | |||
3126 | fp->iface = altsd->bInterfaceNumber; | 3099 | fp->iface = altsd->bInterfaceNumber; |
3127 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 3100 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
3128 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 3101 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
3102 | fp->datainterval = parse_datainterval(chip, alts); | ||
3129 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 3103 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
3130 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); | 3104 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); |
3131 | 3105 | ||
@@ -3178,6 +3152,7 @@ static int create_ua101_quirk(struct snd_usb_audio *chip, | |||
3178 | fp->iface = altsd->bInterfaceNumber; | 3152 | fp->iface = altsd->bInterfaceNumber; |
3179 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 3153 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
3180 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 3154 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
3155 | fp->datainterval = parse_datainterval(chip, alts); | ||
3181 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 3156 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
3182 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); | 3157 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); |
3183 | 3158 | ||
@@ -3763,7 +3738,7 @@ static int usb_audio_resume(struct usb_interface *intf) | |||
3763 | 3738 | ||
3764 | static int __init snd_usb_audio_init(void) | 3739 | static int __init snd_usb_audio_init(void) |
3765 | { | 3740 | { |
3766 | if (nrpacks < MIN_PACKS_URB || nrpacks > MAX_PACKS) { | 3741 | if (nrpacks < 1 || nrpacks > MAX_PACKS) { |
3767 | printk(KERN_WARNING "invalid nrpacks value.\n"); | 3742 | printk(KERN_WARNING "invalid nrpacks value.\n"); |
3768 | return -EINVAL; | 3743 | return -EINVAL; |
3769 | } | 3744 | } |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 320641ab5be7..26bad373fe65 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -1625,6 +1625,7 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi, | |||
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | 1627 | ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; |
1628 | ep_info.out_interval = 0; | ||
1628 | ep_info.out_cables = endpoint->out_cables & 0x5555; | 1629 | ep_info.out_cables = endpoint->out_cables & 0x5555; |
1629 | err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); | 1630 | err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); |
1630 | if (err < 0) | 1631 | if (err < 0) |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 00397c8a765b..ecb58e7a6245 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -66,6 +66,7 @@ static const struct rc_config { | |||
66 | { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */ | 66 | { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */ |
67 | { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */ | 67 | { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */ |
68 | { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ | 68 | { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ |
69 | { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ | ||
69 | }; | 70 | }; |
70 | 71 | ||
71 | struct usb_mixer_interface { | 72 | struct usb_mixer_interface { |
@@ -78,7 +79,6 @@ struct usb_mixer_interface { | |||
78 | 79 | ||
79 | /* Sound Blaster remote control stuff */ | 80 | /* Sound Blaster remote control stuff */ |
80 | const struct rc_config *rc_cfg; | 81 | const struct rc_config *rc_cfg; |
81 | unsigned long rc_hwdep_open; | ||
82 | u32 rc_code; | 82 | u32 rc_code; |
83 | wait_queue_head_t rc_waitq; | 83 | wait_queue_head_t rc_waitq; |
84 | struct urb *rc_urb; | 84 | struct urb *rc_urb; |
@@ -110,6 +110,8 @@ struct mixer_build { | |||
110 | const struct usbmix_selector_map *selector_map; | 110 | const struct usbmix_selector_map *selector_map; |
111 | }; | 111 | }; |
112 | 112 | ||
113 | #define MAX_CHANNELS 10 /* max logical channels */ | ||
114 | |||
113 | struct usb_mixer_elem_info { | 115 | struct usb_mixer_elem_info { |
114 | struct usb_mixer_interface *mixer; | 116 | struct usb_mixer_interface *mixer; |
115 | struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */ | 117 | struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */ |
@@ -120,6 +122,8 @@ struct usb_mixer_elem_info { | |||
120 | int channels; | 122 | int channels; |
121 | int val_type; | 123 | int val_type; |
122 | int min, max, res; | 124 | int min, max, res; |
125 | int cached; | ||
126 | int cache_val[MAX_CHANNELS]; | ||
123 | u8 initialized; | 127 | u8 initialized; |
124 | }; | 128 | }; |
125 | 129 | ||
@@ -181,8 +185,6 @@ enum { | |||
181 | USB_PROC_DCR_RELEASE = 6, | 185 | USB_PROC_DCR_RELEASE = 6, |
182 | }; | 186 | }; |
183 | 187 | ||
184 | #define MAX_CHANNELS 10 /* max logical channels */ | ||
185 | |||
186 | 188 | ||
187 | /* | 189 | /* |
188 | * manual mapping of mixer names | 190 | * manual mapping of mixer names |
@@ -219,7 +221,10 @@ static int check_ignored_ctl(struct mixer_build *state, int unitid, int control) | |||
219 | for (p = state->map; p->id; p++) { | 221 | for (p = state->map; p->id; p++) { |
220 | if (p->id == unitid && ! p->name && | 222 | if (p->id == unitid && ! p->name && |
221 | (! control || ! p->control || control == p->control)) { | 223 | (! control || ! p->control || control == p->control)) { |
222 | // printk("ignored control %d:%d\n", unitid, control); | 224 | /* |
225 | printk(KERN_DEBUG "ignored control %d:%d\n", | ||
226 | unitid, control); | ||
227 | */ | ||
223 | return 1; | 228 | return 1; |
224 | } | 229 | } |
225 | } | 230 | } |
@@ -376,11 +381,35 @@ static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int * | |||
376 | } | 381 | } |
377 | 382 | ||
378 | /* channel = 0: master, 1 = first channel */ | 383 | /* channel = 0: master, 1 = first channel */ |
379 | static inline int get_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int *value) | 384 | static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, |
385 | int channel, int *value) | ||
380 | { | 386 | { |
381 | return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); | 387 | return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); |
382 | } | 388 | } |
383 | 389 | ||
390 | static int get_cur_mix_value(struct usb_mixer_elem_info *cval, | ||
391 | int channel, int index, int *value) | ||
392 | { | ||
393 | int err; | ||
394 | |||
395 | if (cval->cached & (1 << channel)) { | ||
396 | *value = cval->cache_val[index]; | ||
397 | return 0; | ||
398 | } | ||
399 | err = get_cur_mix_raw(cval, channel, value); | ||
400 | if (err < 0) { | ||
401 | if (!cval->mixer->ignore_ctl_error) | ||
402 | snd_printd(KERN_ERR "cannot get current value for " | ||
403 | "control %d ch %d: err = %d\n", | ||
404 | cval->control, channel, err); | ||
405 | return err; | ||
406 | } | ||
407 | cval->cached |= 1 << channel; | ||
408 | cval->cache_val[index] = *value; | ||
409 | return 0; | ||
410 | } | ||
411 | |||
412 | |||
384 | /* | 413 | /* |
385 | * set a mixer value | 414 | * set a mixer value |
386 | */ | 415 | */ |
@@ -412,9 +441,17 @@ static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int v | |||
412 | return set_ctl_value(cval, SET_CUR, validx, value); | 441 | return set_ctl_value(cval, SET_CUR, validx, value); |
413 | } | 442 | } |
414 | 443 | ||
415 | static inline int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int value) | 444 | static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, |
445 | int index, int value) | ||
416 | { | 446 | { |
417 | return set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, value); | 447 | int err; |
448 | err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, | ||
449 | value); | ||
450 | if (err < 0) | ||
451 | return err; | ||
452 | cval->cached |= 1 << channel; | ||
453 | cval->cache_val[index] = value; | ||
454 | return 0; | ||
418 | } | 455 | } |
419 | 456 | ||
420 | /* | 457 | /* |
@@ -718,7 +755,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
718 | if (cval->min + cval->res < cval->max) { | 755 | if (cval->min + cval->res < cval->max) { |
719 | int last_valid_res = cval->res; | 756 | int last_valid_res = cval->res; |
720 | int saved, test, check; | 757 | int saved, test, check; |
721 | get_cur_mix_value(cval, minchn, &saved); | 758 | get_cur_mix_raw(cval, minchn, &saved); |
722 | for (;;) { | 759 | for (;;) { |
723 | test = saved; | 760 | test = saved; |
724 | if (test < cval->max) | 761 | if (test < cval->max) |
@@ -726,8 +763,8 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
726 | else | 763 | else |
727 | test -= cval->res; | 764 | test -= cval->res; |
728 | if (test < cval->min || test > cval->max || | 765 | if (test < cval->min || test > cval->max || |
729 | set_cur_mix_value(cval, minchn, test) || | 766 | set_cur_mix_value(cval, minchn, 0, test) || |
730 | get_cur_mix_value(cval, minchn, &check)) { | 767 | get_cur_mix_raw(cval, minchn, &check)) { |
731 | cval->res = last_valid_res; | 768 | cval->res = last_valid_res; |
732 | break; | 769 | break; |
733 | } | 770 | } |
@@ -735,7 +772,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
735 | break; | 772 | break; |
736 | cval->res *= 2; | 773 | cval->res *= 2; |
737 | } | 774 | } |
738 | set_cur_mix_value(cval, minchn, saved); | 775 | set_cur_mix_value(cval, minchn, 0, saved); |
739 | } | 776 | } |
740 | 777 | ||
741 | cval->initialized = 1; | 778 | cval->initialized = 1; |
@@ -775,35 +812,25 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
775 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 812 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
776 | int c, cnt, val, err; | 813 | int c, cnt, val, err; |
777 | 814 | ||
815 | ucontrol->value.integer.value[0] = cval->min; | ||
778 | if (cval->cmask) { | 816 | if (cval->cmask) { |
779 | cnt = 0; | 817 | cnt = 0; |
780 | for (c = 0; c < MAX_CHANNELS; c++) { | 818 | for (c = 0; c < MAX_CHANNELS; c++) { |
781 | if (cval->cmask & (1 << c)) { | 819 | if (!(cval->cmask & (1 << c))) |
782 | err = get_cur_mix_value(cval, c + 1, &val); | 820 | continue; |
783 | if (err < 0) { | 821 | err = get_cur_mix_value(cval, c + 1, cnt, &val); |
784 | if (cval->mixer->ignore_ctl_error) { | 822 | if (err < 0) |
785 | ucontrol->value.integer.value[0] = cval->min; | 823 | return cval->mixer->ignore_ctl_error ? 0 : err; |
786 | return 0; | 824 | val = get_relative_value(cval, val); |
787 | } | 825 | ucontrol->value.integer.value[cnt] = val; |
788 | snd_printd(KERN_ERR "cannot get current value for control %d ch %d: err = %d\n", cval->control, c + 1, err); | 826 | cnt++; |
789 | return err; | ||
790 | } | ||
791 | val = get_relative_value(cval, val); | ||
792 | ucontrol->value.integer.value[cnt] = val; | ||
793 | cnt++; | ||
794 | } | ||
795 | } | 827 | } |
828 | return 0; | ||
796 | } else { | 829 | } else { |
797 | /* master channel */ | 830 | /* master channel */ |
798 | err = get_cur_mix_value(cval, 0, &val); | 831 | err = get_cur_mix_value(cval, 0, 0, &val); |
799 | if (err < 0) { | 832 | if (err < 0) |
800 | if (cval->mixer->ignore_ctl_error) { | 833 | return cval->mixer->ignore_ctl_error ? 0 : err; |
801 | ucontrol->value.integer.value[0] = cval->min; | ||
802 | return 0; | ||
803 | } | ||
804 | snd_printd(KERN_ERR "cannot get current value for control %d master ch: err = %d\n", cval->control, err); | ||
805 | return err; | ||
806 | } | ||
807 | val = get_relative_value(cval, val); | 834 | val = get_relative_value(cval, val); |
808 | ucontrol->value.integer.value[0] = val; | 835 | ucontrol->value.integer.value[0] = val; |
809 | } | 836 | } |
@@ -820,34 +847,28 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
820 | if (cval->cmask) { | 847 | if (cval->cmask) { |
821 | cnt = 0; | 848 | cnt = 0; |
822 | for (c = 0; c < MAX_CHANNELS; c++) { | 849 | for (c = 0; c < MAX_CHANNELS; c++) { |
823 | if (cval->cmask & (1 << c)) { | 850 | if (!(cval->cmask & (1 << c))) |
824 | err = get_cur_mix_value(cval, c + 1, &oval); | 851 | continue; |
825 | if (err < 0) { | 852 | err = get_cur_mix_value(cval, c + 1, cnt, &oval); |
826 | if (cval->mixer->ignore_ctl_error) | 853 | if (err < 0) |
827 | return 0; | 854 | return cval->mixer->ignore_ctl_error ? 0 : err; |
828 | return err; | 855 | val = ucontrol->value.integer.value[cnt]; |
829 | } | 856 | val = get_abs_value(cval, val); |
830 | val = ucontrol->value.integer.value[cnt]; | 857 | if (oval != val) { |
831 | val = get_abs_value(cval, val); | 858 | set_cur_mix_value(cval, c + 1, cnt, val); |
832 | if (oval != val) { | 859 | changed = 1; |
833 | set_cur_mix_value(cval, c + 1, val); | ||
834 | changed = 1; | ||
835 | } | ||
836 | get_cur_mix_value(cval, c + 1, &val); | ||
837 | cnt++; | ||
838 | } | 860 | } |
861 | cnt++; | ||
839 | } | 862 | } |
840 | } else { | 863 | } else { |
841 | /* master channel */ | 864 | /* master channel */ |
842 | err = get_cur_mix_value(cval, 0, &oval); | 865 | err = get_cur_mix_value(cval, 0, 0, &oval); |
843 | if (err < 0 && cval->mixer->ignore_ctl_error) | ||
844 | return 0; | ||
845 | if (err < 0) | 866 | if (err < 0) |
846 | return err; | 867 | return cval->mixer->ignore_ctl_error ? 0 : err; |
847 | val = ucontrol->value.integer.value[0]; | 868 | val = ucontrol->value.integer.value[0]; |
848 | val = get_abs_value(cval, val); | 869 | val = get_abs_value(cval, val); |
849 | if (val != oval) { | 870 | if (val != oval) { |
850 | set_cur_mix_value(cval, 0, val); | 871 | set_cur_mix_value(cval, 0, 0, val); |
851 | changed = 1; | 872 | changed = 1; |
852 | } | 873 | } |
853 | } | 874 | } |
@@ -1706,7 +1727,8 @@ static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer, | |||
1706 | break; | 1727 | break; |
1707 | /* live24ext: 4 = line-in jack */ | 1728 | /* live24ext: 4 = line-in jack */ |
1708 | case 3: /* hp-out jack (may actuate Mute) */ | 1729 | case 3: /* hp-out jack (may actuate Mute) */ |
1709 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) | 1730 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
1731 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) | ||
1710 | snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id); | 1732 | snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id); |
1711 | break; | 1733 | break; |
1712 | default: | 1734 | default: |
@@ -1797,24 +1819,6 @@ static void snd_usb_soundblaster_remote_complete(struct urb *urb) | |||
1797 | wake_up(&mixer->rc_waitq); | 1819 | wake_up(&mixer->rc_waitq); |
1798 | } | 1820 | } |
1799 | 1821 | ||
1800 | static int snd_usb_sbrc_hwdep_open(struct snd_hwdep *hw, struct file *file) | ||
1801 | { | ||
1802 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1803 | |||
1804 | if (test_and_set_bit(0, &mixer->rc_hwdep_open)) | ||
1805 | return -EBUSY; | ||
1806 | return 0; | ||
1807 | } | ||
1808 | |||
1809 | static int snd_usb_sbrc_hwdep_release(struct snd_hwdep *hw, struct file *file) | ||
1810 | { | ||
1811 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1812 | |||
1813 | clear_bit(0, &mixer->rc_hwdep_open); | ||
1814 | smp_mb__after_clear_bit(); | ||
1815 | return 0; | ||
1816 | } | ||
1817 | |||
1818 | static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, | 1822 | static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, |
1819 | long count, loff_t *offset) | 1823 | long count, loff_t *offset) |
1820 | { | 1824 | { |
@@ -1867,9 +1871,8 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) | |||
1867 | hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; | 1871 | hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; |
1868 | hwdep->private_data = mixer; | 1872 | hwdep->private_data = mixer; |
1869 | hwdep->ops.read = snd_usb_sbrc_hwdep_read; | 1873 | hwdep->ops.read = snd_usb_sbrc_hwdep_read; |
1870 | hwdep->ops.open = snd_usb_sbrc_hwdep_open; | ||
1871 | hwdep->ops.release = snd_usb_sbrc_hwdep_release; | ||
1872 | hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; | 1874 | hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; |
1875 | hwdep->exclusive = 1; | ||
1873 | 1876 | ||
1874 | mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); | 1877 | mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); |
1875 | if (!mixer->rc_urb) | 1878 | if (!mixer->rc_urb) |
@@ -1956,8 +1959,9 @@ static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer) | |||
1956 | int i, err; | 1959 | int i, err; |
1957 | 1960 | ||
1958 | for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { | 1961 | for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { |
1959 | if (i > 1 && /* Live24ext has 2 LEDs only */ | 1962 | if (i > 1 && /* Live24ext has 2 LEDs only */ |
1960 | mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) | 1963 | (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
1964 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048))) | ||
1961 | break; | 1965 | break; |
1962 | err = snd_ctl_add(mixer->chip->card, | 1966 | err = snd_ctl_add(mixer->chip->card, |
1963 | snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); | 1967 | snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); |
@@ -1994,7 +1998,8 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, | |||
1994 | snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); | 1998 | snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); |
1995 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) | 1999 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) |
1996 | jacks = jacks_audigy2nx; | 2000 | jacks = jacks_audigy2nx; |
1997 | else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) | 2001 | else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
2002 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) | ||
1998 | jacks = jacks_live24ext; | 2003 | jacks = jacks_live24ext; |
1999 | else | 2004 | else |
2000 | return; | 2005 | return; |
@@ -2044,7 +2049,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2044 | goto _error; | 2049 | goto _error; |
2045 | 2050 | ||
2046 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || | 2051 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || |
2047 | mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) { | 2052 | mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
2053 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) { | ||
2048 | struct snd_info_entry *entry; | 2054 | struct snd_info_entry *entry; |
2049 | 2055 | ||
2050 | if ((err = snd_audigy2nx_controls_create(mixer)) < 0) | 2056 | if ((err = snd_audigy2nx_controls_create(mixer)) < 0) |
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c index d755be0ad811..3e5d66cf1f5a 100644 --- a/sound/usb/usbmixer_maps.c +++ b/sound/usb/usbmixer_maps.c | |||
@@ -261,6 +261,22 @@ static struct usbmix_name_map aureon_51_2_map[] = { | |||
261 | {} /* terminator */ | 261 | {} /* terminator */ |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static struct usbmix_name_map scratch_live_map[] = { | ||
265 | /* 1: IT Line 1 (USB streaming) */ | ||
266 | /* 2: OT Line 1 (Speaker) */ | ||
267 | /* 3: IT Line 1 (Line connector) */ | ||
268 | { 4, "Line 1 In" }, /* FU */ | ||
269 | /* 5: OT Line 1 (USB streaming) */ | ||
270 | /* 6: IT Line 2 (USB streaming) */ | ||
271 | /* 7: OT Line 2 (Speaker) */ | ||
272 | /* 8: IT Line 2 (Line connector) */ | ||
273 | { 9, "Line 2 In" }, /* FU */ | ||
274 | /* 10: OT Line 2 (USB streaming) */ | ||
275 | /* 11: IT Mic (Line connector) */ | ||
276 | /* 12: OT Mic (USB streaming) */ | ||
277 | { 0 } /* terminator */ | ||
278 | }; | ||
279 | |||
264 | /* | 280 | /* |
265 | * Control map entries | 281 | * Control map entries |
266 | */ | 282 | */ |
@@ -285,6 +301,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { | |||
285 | .map = live24ext_map, | 301 | .map = live24ext_map, |
286 | }, | 302 | }, |
287 | { | 303 | { |
304 | .id = USB_ID(0x041e, 0x3048), | ||
305 | .map = audigy2nx_map, | ||
306 | .selector_map = audigy2nx_selectors, | ||
307 | }, | ||
308 | { | ||
288 | /* Hercules DJ Console (Windows Edition) */ | 309 | /* Hercules DJ Console (Windows Edition) */ |
289 | .id = USB_ID(0x06f8, 0xb000), | 310 | .id = USB_ID(0x06f8, 0xb000), |
290 | .ignore_ctl_error = 1, | 311 | .ignore_ctl_error = 1, |
@@ -311,6 +332,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { | |||
311 | .id = USB_ID(0x0ccd, 0x0028), | 332 | .id = USB_ID(0x0ccd, 0x0028), |
312 | .map = aureon_51_2_map, | 333 | .map = aureon_51_2_map, |
313 | }, | 334 | }, |
335 | { | ||
336 | .id = USB_ID(0x13e5, 0x0001), | ||
337 | .map = scratch_live_map, | ||
338 | .ignore_ctl_error = 1, | ||
339 | }, | ||
314 | { 0 } /* terminator */ | 340 | { 0 } /* terminator */ |
315 | }; | 341 | }; |
316 | 342 | ||
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index 92115755d98e..647ef5029651 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h | |||
@@ -39,6 +39,16 @@ | |||
39 | .idProduct = prod, \ | 39 | .idProduct = prod, \ |
40 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC | 40 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC |
41 | 41 | ||
42 | /* Creative/Toshiba Multimedia Center SB-0500 */ | ||
43 | { | ||
44 | USB_DEVICE(0x041e, 0x3048), | ||
45 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
46 | .vendor_name = "Toshiba", | ||
47 | .product_name = "SB-0500", | ||
48 | .ifnum = QUIRK_NO_INTERFACE | ||
49 | } | ||
50 | }, | ||
51 | |||
42 | /* Creative/E-Mu devices */ | 52 | /* Creative/E-Mu devices */ |
43 | { | 53 | { |
44 | USB_DEVICE(0x041e, 0x3010), | 54 | USB_DEVICE(0x041e, 0x3010), |
@@ -128,6 +138,14 @@ | |||
128 | .bInterfaceClass = USB_CLASS_AUDIO, | 138 | .bInterfaceClass = USB_CLASS_AUDIO, |
129 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 139 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL |
130 | }, | 140 | }, |
141 | { | ||
142 | USB_DEVICE(0x046d, 0x0990), | ||
143 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
144 | .vendor_name = "Logitech, Inc.", | ||
145 | .product_name = "QuickCam Pro 9000", | ||
146 | .ifnum = QUIRK_NO_INTERFACE | ||
147 | } | ||
148 | }, | ||
131 | 149 | ||
132 | /* | 150 | /* |
133 | * Yamaha devices | 151 | * Yamaha devices |
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 98276aafefe6..a5aae9d67f31 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
@@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, | |||
349 | if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) | 349 | if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) |
350 | return -ENOTTY; | 350 | return -ENOTTY; |
351 | 351 | ||
352 | cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); | 352 | cfg = memdup_user((void *)arg, sizeof(*cfg)); |
353 | if (!cfg) | 353 | if (IS_ERR(cfg)) |
354 | return -ENOMEM; | 354 | return PTR_ERR(cfg); |
355 | 355 | ||
356 | if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) { | ||
357 | err = -EFAULT; | ||
358 | goto free; | ||
359 | } | ||
360 | if (cfg->version != USB_STREAM_INTERFACE_VERSION) { | 356 | if (cfg->version != USB_STREAM_INTERFACE_VERSION) { |
361 | err = -ENXIO; | 357 | err = -ENXIO; |
362 | goto free; | 358 | goto free; |
@@ -478,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card) | |||
478 | return true; | 474 | return true; |
479 | } | 475 | } |
480 | 476 | ||
477 | static void snd_us122l_free(struct snd_card *card) | ||
478 | { | ||
479 | struct us122l *us122l = US122L(card); | ||
480 | int index = us122l->chip.index; | ||
481 | if (index >= 0 && index < SNDRV_CARDS) | ||
482 | snd_us122l_card_used[index] = 0; | ||
483 | } | ||
484 | |||
481 | static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) | 485 | static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) |
482 | { | 486 | { |
483 | int dev; | 487 | int dev; |
@@ -494,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
494 | if (err < 0) | 498 | if (err < 0) |
495 | return err; | 499 | return err; |
496 | snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; | 500 | snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; |
497 | 501 | card->private_free = snd_us122l_free; | |
498 | US122L(card)->chip.dev = device; | 502 | US122L(card)->chip.dev = device; |
499 | US122L(card)->chip.card = card; | 503 | US122L(card)->chip.card = card; |
500 | mutex_init(&US122L(card)->mutex); | 504 | mutex_init(&US122L(card)->mutex); |
@@ -588,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf) | |||
588 | } | 592 | } |
589 | 593 | ||
590 | usb_put_intf(intf); | 594 | usb_put_intf(intf); |
591 | usb_put_dev(US122L(card)->chip.dev); | 595 | usb_put_dev(us122l->chip.dev); |
592 | 596 | ||
593 | while (atomic_read(&us122l->mmap_count)) | 597 | while (atomic_read(&us122l->mmap_count)) |
594 | msleep(500); | 598 | msleep(500); |
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 1558a5c4094f..f3d8f71265dd 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -30,9 +30,6 @@ | |||
30 | #include "usbusx2y.h" | 30 | #include "usbusx2y.h" |
31 | #include "usX2Yhwdep.h" | 31 | #include "usX2Yhwdep.h" |
32 | 32 | ||
33 | int usX2Y_hwdep_pcm_new(struct snd_card *card); | ||
34 | |||
35 | |||
36 | static int snd_us428ctls_vm_fault(struct vm_area_struct *area, | 33 | static int snd_us428ctls_vm_fault(struct vm_area_struct *area, |
37 | struct vm_fault *vmf) | 34 | struct vm_fault *vmf) |
38 | { | 35 | { |
@@ -106,16 +103,6 @@ static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, | |||
106 | } | 103 | } |
107 | 104 | ||
108 | 105 | ||
109 | static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file) | ||
110 | { | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file) | ||
115 | { | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, | 106 | static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, |
120 | struct snd_hwdep_dsp_status *info) | 107 | struct snd_hwdep_dsp_status *info) |
121 | { | 108 | { |
@@ -216,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, | |||
216 | 203 | ||
217 | if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { | 204 | if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { |
218 | struct usb_device* dev = priv->chip.dev; | 205 | struct usb_device* dev = priv->chip.dev; |
219 | char *buf = kmalloc(dsp->length, GFP_KERNEL); | 206 | char *buf; |
220 | if (!buf) | 207 | |
221 | return -ENOMEM; | 208 | buf = memdup_user(dsp->image, dsp->length); |
222 | if (copy_from_user(buf, dsp->image, dsp->length)) { | 209 | if (IS_ERR(buf)) |
223 | kfree(buf); | 210 | return PTR_ERR(buf); |
224 | return -EFAULT; | 211 | |
225 | } | ||
226 | err = usb_set_interface(dev, 0, 1); | 212 | err = usb_set_interface(dev, 0, 1); |
227 | if (err) | 213 | if (err) |
228 | snd_printk(KERN_ERR "usb_set_interface error \n"); | 214 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
@@ -267,8 +253,6 @@ int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device) | |||
267 | 253 | ||
268 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y; | 254 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y; |
269 | hw->private_data = usX2Y(card); | 255 | hw->private_data = usX2Y(card); |
270 | hw->ops.open = snd_usX2Y_hwdep_open; | ||
271 | hw->ops.release = snd_usX2Y_hwdep_release; | ||
272 | hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; | 256 | hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; |
273 | hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; | 257 | hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; |
274 | hw->ops.mmap = snd_us428ctls_mmap; | 258 | hw->ops.mmap = snd_us428ctls_mmap; |
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c index 70b96355ca4c..12ae0340adc0 100644 --- a/sound/usb/usx2y/usb_stream.c +++ b/sound/usb/usx2y/usb_stream.c | |||
@@ -33,32 +33,26 @@ static unsigned usb_stream_next_packet_size(struct usb_stream_kernel *sk) | |||
33 | static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb) | 33 | static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb) |
34 | { | 34 | { |
35 | struct usb_stream *s = sk->s; | 35 | struct usb_stream *s = sk->s; |
36 | unsigned l = 0; | 36 | int pack, lb = 0; |
37 | int pack; | 37 | |
38 | 38 | for (pack = 0; pack < sk->n_o_ps; pack++) { | |
39 | urb->iso_frame_desc[0].offset = 0; | 39 | int l = usb_stream_next_packet_size(sk); |
40 | urb->iso_frame_desc[0].length = usb_stream_next_packet_size(sk); | 40 | if (s->idle_outsize + lb + l > s->period_size) |
41 | sk->out_phase = sk->out_phase_peeked; | ||
42 | urb->transfer_buffer_length = urb->iso_frame_desc[0].length; | ||
43 | |||
44 | for (pack = 1; pack < sk->n_o_ps; pack++) { | ||
45 | l = usb_stream_next_packet_size(sk); | ||
46 | if (s->idle_outsize + urb->transfer_buffer_length + l > | ||
47 | s->period_size) | ||
48 | goto check; | 41 | goto check; |
49 | 42 | ||
50 | sk->out_phase = sk->out_phase_peeked; | 43 | sk->out_phase = sk->out_phase_peeked; |
51 | urb->iso_frame_desc[pack].offset = urb->transfer_buffer_length; | 44 | urb->iso_frame_desc[pack].offset = lb; |
52 | urb->iso_frame_desc[pack].length = l; | 45 | urb->iso_frame_desc[pack].length = l; |
53 | urb->transfer_buffer_length += l; | 46 | lb += l; |
54 | } | 47 | } |
55 | snd_printdd(KERN_DEBUG "%i\n", urb->transfer_buffer_length); | 48 | snd_printdd(KERN_DEBUG "%i\n", lb); |
56 | 49 | ||
57 | check: | 50 | check: |
58 | urb->number_of_packets = pack; | 51 | urb->number_of_packets = pack; |
59 | s->idle_outsize += urb->transfer_buffer_length - s->period_size; | 52 | urb->transfer_buffer_length = lb; |
53 | s->idle_outsize += lb - s->period_size; | ||
60 | snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, | 54 | snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, |
61 | urb->transfer_buffer_length, s->period_size); | 55 | lb, s->period_size); |
62 | } | 56 | } |
63 | 57 | ||
64 | static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize, | 58 | static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize, |
@@ -282,21 +276,20 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk, | |||
282 | struct usb_stream *s = sk->s; | 276 | struct usb_stream *s = sk->s; |
283 | struct urb *io; | 277 | struct urb *io; |
284 | struct usb_iso_packet_descriptor *id, *od; | 278 | struct usb_iso_packet_descriptor *id, *od; |
285 | int p, l = 0; | 279 | int p = 0, lb = 0, l = 0; |
286 | 280 | ||
287 | io = sk->idle_outurb; | 281 | io = sk->idle_outurb; |
288 | od = io->iso_frame_desc; | 282 | od = io->iso_frame_desc; |
289 | io->transfer_buffer_length = 0; | ||
290 | 283 | ||
291 | for (p = 0; s->sync_packet < 0; ++p, ++s->sync_packet) { | 284 | for (; s->sync_packet < 0; ++p, ++s->sync_packet) { |
292 | struct urb *ii = sk->completed_inurb; | 285 | struct urb *ii = sk->completed_inurb; |
293 | id = ii->iso_frame_desc + | 286 | id = ii->iso_frame_desc + |
294 | ii->number_of_packets + s->sync_packet; | 287 | ii->number_of_packets + s->sync_packet; |
295 | l = id->actual_length; | 288 | l = id->actual_length; |
296 | 289 | ||
297 | od[p].length = l; | 290 | od[p].length = l; |
298 | od[p].offset = io->transfer_buffer_length; | 291 | od[p].offset = lb; |
299 | io->transfer_buffer_length += l; | 292 | lb += l; |
300 | } | 293 | } |
301 | 294 | ||
302 | for (; | 295 | for (; |
@@ -304,38 +297,38 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk, | |||
304 | ++p, ++s->sync_packet) { | 297 | ++p, ++s->sync_packet) { |
305 | l = inurb->iso_frame_desc[s->sync_packet].actual_length; | 298 | l = inurb->iso_frame_desc[s->sync_packet].actual_length; |
306 | 299 | ||
307 | if (s->idle_outsize + io->transfer_buffer_length + l > | 300 | if (s->idle_outsize + lb + l > s->period_size) |
308 | s->period_size) | ||
309 | goto check_ok; | 301 | goto check_ok; |
310 | 302 | ||
311 | od[p].length = l; | 303 | od[p].length = l; |
312 | od[p].offset = io->transfer_buffer_length; | 304 | od[p].offset = lb; |
313 | io->transfer_buffer_length += l; | 305 | lb += l; |
314 | } | 306 | } |
315 | 307 | ||
316 | check_ok: | 308 | check_ok: |
317 | s->sync_packet -= inurb->number_of_packets; | 309 | s->sync_packet -= inurb->number_of_packets; |
318 | if (s->sync_packet < -2 || s->sync_packet > 0) { | 310 | if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) { |
319 | snd_printk(KERN_WARNING "invalid sync_packet = %i;" | 311 | snd_printk(KERN_WARNING "invalid sync_packet = %i;" |
320 | " p=%i nop=%i %i %x %x %x > %x\n", | 312 | " p=%i nop=%i %i %x %x %x > %x\n", |
321 | s->sync_packet, p, inurb->number_of_packets, | 313 | s->sync_packet, p, inurb->number_of_packets, |
322 | s->idle_outsize + io->transfer_buffer_length + l, | 314 | s->idle_outsize + lb + l, |
323 | s->idle_outsize, io->transfer_buffer_length, l, | 315 | s->idle_outsize, lb, l, |
324 | s->period_size); | 316 | s->period_size); |
325 | return -1; | 317 | return -1; |
326 | } | 318 | } |
327 | if (io->transfer_buffer_length % s->cfg.frame_size) { | 319 | if (unlikely(lb % s->cfg.frame_size)) { |
328 | snd_printk(KERN_WARNING"invalid outsize = %i\n", | 320 | snd_printk(KERN_WARNING"invalid outsize = %i\n", |
329 | io->transfer_buffer_length); | 321 | lb); |
330 | return -1; | 322 | return -1; |
331 | } | 323 | } |
332 | s->idle_outsize += io->transfer_buffer_length - s->period_size; | 324 | s->idle_outsize += lb - s->period_size; |
333 | io->number_of_packets = p; | 325 | io->number_of_packets = p; |
334 | if (s->idle_outsize > 0) { | 326 | io->transfer_buffer_length = lb; |
335 | snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); | 327 | if (s->idle_outsize <= 0) |
336 | return -1; | 328 | return 0; |
337 | } | 329 | |
338 | return 0; | 330 | snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); |
331 | return -1; | ||
339 | } | 332 | } |
340 | 333 | ||
341 | static void prepare_inurb(int number_of_packets, struct urb *iu) | 334 | static void prepare_inurb(int number_of_packets, struct urb *iu) |
@@ -557,7 +550,7 @@ static void stream_start(struct usb_stream_kernel *sk, | |||
557 | s->idle_insize -= max_diff - max_diff_0; | 550 | s->idle_insize -= max_diff - max_diff_0; |
558 | s->idle_insize += urb_size - s->period_size; | 551 | s->idle_insize += urb_size - s->period_size; |
559 | if (s->idle_insize < 0) { | 552 | if (s->idle_insize < 0) { |
560 | snd_printk("%i %i %i\n", | 553 | snd_printk(KERN_WARNING "%i %i %i\n", |
561 | s->idle_insize, urb_size, s->period_size); | 554 | s->idle_insize, urb_size, s->period_size); |
562 | return; | 555 | return; |
563 | } else if (s->idle_insize == 0) { | 556 | } else if (s->idle_insize == 0) { |
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index af8b84954054..5ce0da23ee96 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
@@ -227,9 +227,9 @@ static void i_usX2Y_In04Int(struct urb *urb) | |||
227 | 227 | ||
228 | if (usX2Y->US04) { | 228 | if (usX2Y->US04) { |
229 | if (0 == usX2Y->US04->submitted) | 229 | if (0 == usX2Y->US04->submitted) |
230 | do | 230 | do { |
231 | err = usb_submit_urb(usX2Y->US04->urb[usX2Y->US04->submitted++], GFP_ATOMIC); | 231 | err = usb_submit_urb(usX2Y->US04->urb[usX2Y->US04->submitted++], GFP_ATOMIC); |
232 | while (!err && usX2Y->US04->submitted < usX2Y->US04->len); | 232 | } while (!err && usX2Y->US04->submitted < usX2Y->US04->len); |
233 | } else | 233 | } else |
234 | if (us428ctls && us428ctls->p4outLast >= 0 && us428ctls->p4outLast < N_us428_p4out_BUFS) { | 234 | if (us428ctls && us428ctls->p4outLast >= 0 && us428ctls->p4outLast < N_us428_p4out_BUFS) { |
235 | if (us428ctls->p4outLast != us428ctls->p4outSent) { | 235 | if (us428ctls->p4outLast != us428ctls->p4outSent) { |
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 9a608fa85155..dd1ab6177840 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
@@ -870,7 +870,8 @@ static struct snd_pcm_hardware snd_usX2Y_2c = | |||
870 | { | 870 | { |
871 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 871 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
872 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 872 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
873 | SNDRV_PCM_INFO_MMAP_VALID), | 873 | SNDRV_PCM_INFO_MMAP_VALID | |
874 | SNDRV_PCM_INFO_BATCH), | ||
874 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE, | 875 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE, |
875 | .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, | 876 | .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, |
876 | .rate_min = 44100, | 877 | .rate_min = 44100, |
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.h b/sound/usb/usx2y/usx2yhwdeppcm.h index c3382fdc386b..9c4fb84b2aa0 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.h +++ b/sound/usb/usx2y/usx2yhwdeppcm.h | |||
@@ -18,3 +18,5 @@ struct snd_usX2Y_hwdep_pcm_shm { | |||
18 | volatile unsigned captured_iso_frames; | 18 | volatile unsigned captured_iso_frames; |
19 | int capture_iso_start; | 19 | int capture_iso_start; |
20 | }; | 20 | }; |
21 | |||
22 | int usX2Y_hwdep_pcm_new(struct snd_card *card); | ||