diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-06-10 01:26:23 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-06-10 01:26:23 -0400 |
commit | ab2f06cb6b7cc4cb782387a19fbfed3dfe8a8436 (patch) | |
tree | 05daa9670d9cf1a474eb9cee948532f5f4afc8f0 | |
parent | a963203c18e5988506bd173b75ca002df528ed48 (diff) | |
parent | c6e24d4db824d277303201811e88626778c59999 (diff) |
Merge branch 'topic/caiaq' into for-linus
* topic/caiaq:
ALSA: snd_usb_caiaq: bump version number
ALSA: snd_usb_caiaq: give better shortname
ALSA: Core - add snd_card_set_id() function
ALSA: snd_usb_caiaq: give better longname
ALSA: snd_usb_caiaq: use strlcpy
ALSA: snd_usb_caiaq: clean whitespaces
-rw-r--r-- | include/sound/core.h | 1 | ||||
-rw-r--r-- | sound/core/init.c | 62 | ||||
-rw-r--r-- | sound/usb/caiaq/audio.c | 88 | ||||
-rw-r--r-- | sound/usb/caiaq/device.c | 108 | ||||
-rw-r--r-- | sound/usb/caiaq/device.h | 1 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.c | 24 |
6 files changed, 152 insertions, 132 deletions
diff --git a/include/sound/core.h b/include/sound/core.h index 3dea79829acc..0e8ae10155ab 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -313,6 +313,7 @@ struct snd_card *snd_card_new(int idx, const char *id, | |||
313 | int snd_card_disconnect(struct snd_card *card); | 313 | int snd_card_disconnect(struct snd_card *card); |
314 | int snd_card_free(struct snd_card *card); | 314 | int snd_card_free(struct snd_card *card); |
315 | int snd_card_free_when_closed(struct snd_card *card); | 315 | int snd_card_free_when_closed(struct snd_card *card); |
316 | void snd_card_set_id(struct snd_card *card, const char *id); | ||
316 | int snd_card_register(struct snd_card *card); | 317 | int snd_card_register(struct snd_card *card); |
317 | int snd_card_info_init(void); | 318 | int snd_card_info_init(void); |
318 | int snd_card_info_done(void); | 319 | int snd_card_info_done(void); |
diff --git a/sound/core/init.c b/sound/core/init.c index fd56afe846ed..6557dd85e191 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -152,15 +152,8 @@ int snd_card_create(int idx, const char *xid, | |||
152 | card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); | 152 | card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); |
153 | if (!card) | 153 | if (!card) |
154 | return -ENOMEM; | 154 | return -ENOMEM; |
155 | if (xid) { | 155 | if (xid) |
156 | if (!snd_info_check_reserved_words(xid)) { | 156 | snd_card_set_id(card, xid); |
157 | snd_printk(KERN_ERR | ||
158 | "given id string '%s' is reserved.\n", xid); | ||
159 | err = -EBUSY; | ||
160 | goto __error; | ||
161 | } | ||
162 | strlcpy(card->id, xid, sizeof(card->id)); | ||
163 | } | ||
164 | err = 0; | 157 | err = 0; |
165 | mutex_lock(&snd_card_mutex); | 158 | mutex_lock(&snd_card_mutex); |
166 | if (idx < 0) { | 159 | if (idx < 0) { |
@@ -483,22 +476,39 @@ int snd_card_free(struct snd_card *card) | |||
483 | 476 | ||
484 | EXPORT_SYMBOL(snd_card_free); | 477 | EXPORT_SYMBOL(snd_card_free); |
485 | 478 | ||
486 | static void choose_default_id(struct snd_card *card) | 479 | /** |
480 | * snd_card_set_id - set card identification name | ||
481 | * @card: soundcard structure | ||
482 | * @nid: new identification string | ||
483 | * | ||
484 | * This function sets the card identification and checks for name | ||
485 | * collisions. | ||
486 | */ | ||
487 | void snd_card_set_id(struct snd_card *card, const char *nid) | ||
487 | { | 488 | { |
488 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; | 489 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; |
489 | char *id, *spos; | 490 | const char *spos, *src; |
491 | char *id; | ||
490 | 492 | ||
491 | id = spos = card->shortname; | 493 | /* check if user specified own card->id */ |
492 | while (*id != '\0') { | 494 | if (card->id[0] != '\0') |
493 | if (*id == ' ') | 495 | return; |
494 | spos = id + 1; | 496 | if (nid == NULL) { |
495 | id++; | 497 | id = card->shortname; |
498 | spos = src = id; | ||
499 | while (*id != '\0') { | ||
500 | if (*id == ' ') | ||
501 | spos = id + 1; | ||
502 | id++; | ||
503 | } | ||
504 | } else { | ||
505 | spos = src = nid; | ||
496 | } | 506 | } |
497 | id = card->id; | 507 | id = card->id; |
498 | while (*spos != '\0' && !isalnum(*spos)) | 508 | while (*spos != '\0' && !isalnum(*spos)) |
499 | spos++; | 509 | spos++; |
500 | if (isdigit(*spos)) | 510 | if (isdigit(*spos)) |
501 | *id++ = isalpha(card->shortname[0]) ? card->shortname[0] : 'D'; | 511 | *id++ = isalpha(src[0]) ? src[0] : 'D'; |
502 | while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { | 512 | while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { |
503 | if (isalnum(*spos)) | 513 | if (isalnum(*spos)) |
504 | *id++ = *spos; | 514 | *id++ = *spos; |
@@ -513,16 +523,20 @@ static void choose_default_id(struct snd_card *card) | |||
513 | 523 | ||
514 | while (1) { | 524 | while (1) { |
515 | if (loops-- == 0) { | 525 | if (loops-- == 0) { |
516 | snd_printk(KERN_ERR "unable to choose default card id (%s)\n", id); | 526 | snd_printk(KERN_ERR "unable to set card id (%s)\n", id); |
517 | strcpy(card->id, card->proc_root->name); | 527 | strcpy(card->id, card->proc_root->name); |
518 | return; | 528 | return; |
519 | } | 529 | } |
520 | if (!snd_info_check_reserved_words(id)) | 530 | if (!snd_info_check_reserved_words(id)) |
521 | goto __change; | 531 | goto __change; |
532 | mutex_lock(&snd_card_mutex); | ||
522 | for (i = 0; i < snd_ecards_limit; i++) { | 533 | for (i = 0; i < snd_ecards_limit; i++) { |
523 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, id)) | 534 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, id)) { |
535 | mutex_unlock(&snd_card_mutex); | ||
524 | goto __change; | 536 | goto __change; |
537 | } | ||
525 | } | 538 | } |
539 | mutex_unlock(&snd_card_mutex); | ||
526 | break; | 540 | break; |
527 | 541 | ||
528 | __change: | 542 | __change: |
@@ -539,14 +553,16 @@ static void choose_default_id(struct snd_card *card) | |||
539 | spos = id + len - 2; | 553 | spos = id + len - 2; |
540 | if ((size_t)len <= sizeof(card->id) - 2) | 554 | if ((size_t)len <= sizeof(card->id) - 2) |
541 | spos++; | 555 | spos++; |
542 | *spos++ = '_'; | 556 | *(char *)spos++ = '_'; |
543 | *spos++ = '1'; | 557 | *(char *)spos++ = '1'; |
544 | *spos++ = '\0'; | 558 | *(char *)spos++ = '\0'; |
545 | idx_flag++; | 559 | idx_flag++; |
546 | } | 560 | } |
547 | } | 561 | } |
548 | } | 562 | } |
549 | 563 | ||
564 | EXPORT_SYMBOL(snd_card_set_id); | ||
565 | |||
550 | #ifndef CONFIG_SYSFS_DEPRECATED | 566 | #ifndef CONFIG_SYSFS_DEPRECATED |
551 | static ssize_t | 567 | static ssize_t |
552 | card_id_show_attr(struct device *dev, | 568 | card_id_show_attr(struct device *dev, |
@@ -641,7 +657,7 @@ int snd_card_register(struct snd_card *card) | |||
641 | return 0; | 657 | return 0; |
642 | } | 658 | } |
643 | if (card->id[0] == '\0') | 659 | if (card->id[0] == '\0') |
644 | choose_default_id(card); | 660 | snd_card_set_id(card, NULL); |
645 | snd_cards[card->number] = card; | 661 | snd_cards[card->number] = card; |
646 | mutex_unlock(&snd_card_mutex); | 662 | mutex_unlock(&snd_card_mutex); |
647 | init_info_for_card(card); | 663 | init_info_for_card(card); |
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index b13ce767ac72..b14451342166 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -42,10 +42,10 @@ | |||
42 | (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) | 42 | (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) |
43 | 43 | ||
44 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { | 44 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { |
45 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 45 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
46 | SNDRV_PCM_INFO_BLOCK_TRANSFER), | 46 | SNDRV_PCM_INFO_BLOCK_TRANSFER), |
47 | .formats = SNDRV_PCM_FMTBIT_S24_3BE, | 47 | .formats = SNDRV_PCM_FMTBIT_S24_3BE, |
48 | .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | | 48 | .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | |
49 | SNDRV_PCM_RATE_96000), | 49 | SNDRV_PCM_RATE_96000), |
50 | .rate_min = 44100, | 50 | .rate_min = 44100, |
51 | .rate_max = 0, /* will overwrite later */ | 51 | .rate_max = 0, /* will overwrite later */ |
@@ -68,7 +68,7 @@ activate_substream(struct snd_usb_caiaqdev *dev, | |||
68 | dev->sub_capture[sub->number] = sub; | 68 | dev->sub_capture[sub->number] = sub; |
69 | } | 69 | } |
70 | 70 | ||
71 | static void | 71 | static void |
72 | deactivate_substream(struct snd_usb_caiaqdev *dev, | 72 | deactivate_substream(struct snd_usb_caiaqdev *dev, |
73 | struct snd_pcm_substream *sub) | 73 | struct snd_pcm_substream *sub) |
74 | { | 74 | { |
@@ -118,7 +118,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev) | |||
118 | return -EPIPE; | 118 | return -EPIPE; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
@@ -129,7 +129,7 @@ static void stream_stop(struct snd_usb_caiaqdev *dev) | |||
129 | debug("%s(%p)\n", __func__, dev); | 129 | debug("%s(%p)\n", __func__, dev); |
130 | if (!dev->streaming) | 130 | if (!dev->streaming) |
131 | return; | 131 | return; |
132 | 132 | ||
133 | dev->streaming = 0; | 133 | dev->streaming = 0; |
134 | 134 | ||
135 | for (i = 0; i < N_URBS; i++) { | 135 | for (i = 0; i < N_URBS; i++) { |
@@ -154,7 +154,7 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) | |||
154 | debug("%s(%p)\n", __func__, substream); | 154 | debug("%s(%p)\n", __func__, substream); |
155 | if (all_substreams_zero(dev->sub_playback) && | 155 | if (all_substreams_zero(dev->sub_playback) && |
156 | all_substreams_zero(dev->sub_capture)) { | 156 | all_substreams_zero(dev->sub_capture)) { |
157 | /* when the last client has stopped streaming, | 157 | /* when the last client has stopped streaming, |
158 | * all sample rates are allowed again */ | 158 | * all sample rates are allowed again */ |
159 | stream_stop(dev); | 159 | stream_stop(dev); |
160 | dev->pcm_info.rates = dev->samplerates; | 160 | dev->pcm_info.rates = dev->samplerates; |
@@ -194,7 +194,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
194 | struct snd_pcm_runtime *runtime = substream->runtime; | 194 | struct snd_pcm_runtime *runtime = substream->runtime; |
195 | 195 | ||
196 | debug("%s(%p)\n", __func__, substream); | 196 | debug("%s(%p)\n", __func__, substream); |
197 | 197 | ||
198 | 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; | 199 | dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; |
200 | dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; | 200 | dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; |
@@ -205,19 +205,19 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
205 | 205 | ||
206 | if (dev->streaming) | 206 | if (dev->streaming) |
207 | return 0; | 207 | return 0; |
208 | 208 | ||
209 | /* the first client that opens a stream defines the sample rate | 209 | /* the first client that opens a stream defines the sample rate |
210 | * setting for all subsequent calls, until the last client closed. */ | 210 | * setting for all subsequent calls, until the last client closed. */ |
211 | for (i=0; i < ARRAY_SIZE(rates); i++) | 211 | for (i=0; i < ARRAY_SIZE(rates); i++) |
212 | if (runtime->rate == rates[i]) | 212 | if (runtime->rate == rates[i]) |
213 | dev->pcm_info.rates = 1 << i; | 213 | dev->pcm_info.rates = 1 << i; |
214 | 214 | ||
215 | snd_pcm_limit_hw_rates(runtime); | 215 | snd_pcm_limit_hw_rates(runtime); |
216 | 216 | ||
217 | bytes_per_sample = BYTES_PER_SAMPLE; | 217 | bytes_per_sample = BYTES_PER_SAMPLE; |
218 | if (dev->spec.data_alignment == 2) | 218 | if (dev->spec.data_alignment == 2) |
219 | bytes_per_sample++; | 219 | bytes_per_sample++; |
220 | 220 | ||
221 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) | 221 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) |
222 | * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; | 222 | * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; |
223 | 223 | ||
@@ -232,7 +232,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
232 | ret = stream_start(dev); | 232 | ret = stream_start(dev); |
233 | if (ret) | 233 | if (ret) |
234 | return ret; | 234 | return ret; |
235 | 235 | ||
236 | dev->output_running = 0; | 236 | dev->output_running = 0; |
237 | wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); | 237 | wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); |
238 | if (!dev->output_running) { | 238 | if (!dev->output_running) { |
@@ -273,7 +273,7 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) | |||
273 | return SNDRV_PCM_POS_XRUN; | 273 | return SNDRV_PCM_POS_XRUN; |
274 | 274 | ||
275 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 275 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
276 | return bytes_to_frames(sub->runtime, | 276 | return bytes_to_frames(sub->runtime, |
277 | dev->audio_out_buf_pos[index]); | 277 | dev->audio_out_buf_pos[index]); |
278 | else | 278 | else |
279 | return bytes_to_frames(sub->runtime, | 279 | return bytes_to_frames(sub->runtime, |
@@ -291,7 +291,7 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = { | |||
291 | .trigger = snd_usb_caiaq_pcm_trigger, | 291 | .trigger = snd_usb_caiaq_pcm_trigger, |
292 | .pointer = snd_usb_caiaq_pcm_pointer | 292 | .pointer = snd_usb_caiaq_pcm_pointer |
293 | }; | 293 | }; |
294 | 294 | ||
295 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | 295 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, |
296 | struct snd_pcm_substream **subs) | 296 | struct snd_pcm_substream **subs) |
297 | { | 297 | { |
@@ -333,7 +333,7 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, | |||
333 | struct snd_pcm_runtime *rt = sub->runtime; | 333 | struct snd_pcm_runtime *rt = sub->runtime; |
334 | char *audio_buf = rt->dma_area; | 334 | char *audio_buf = rt->dma_area; |
335 | int sz = frames_to_bytes(rt, rt->buffer_size); | 335 | int sz = frames_to_bytes(rt, rt->buffer_size); |
336 | audio_buf[dev->audio_in_buf_pos[stream]++] | 336 | audio_buf[dev->audio_in_buf_pos[stream]++] |
337 | = usb_buf[i]; | 337 | = usb_buf[i]; |
338 | dev->period_in_count[stream]++; | 338 | dev->period_in_count[stream]++; |
339 | if (dev->audio_in_buf_pos[stream] == sz) | 339 | if (dev->audio_in_buf_pos[stream] == sz) |
@@ -354,14 +354,14 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | |||
354 | 354 | ||
355 | for (i = 0; i < iso->actual_length;) { | 355 | for (i = 0; i < iso->actual_length;) { |
356 | if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { | 356 | if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { |
357 | for (stream = 0; | 357 | for (stream = 0; |
358 | stream < dev->n_streams; | 358 | stream < dev->n_streams; |
359 | stream++, i++) { | 359 | stream++, i++) { |
360 | if (dev->first_packet) | 360 | if (dev->first_packet) |
361 | continue; | 361 | continue; |
362 | 362 | ||
363 | check_byte = MAKE_CHECKBYTE(dev, stream, i); | 363 | check_byte = MAKE_CHECKBYTE(dev, stream, i); |
364 | 364 | ||
365 | if ((usb_buf[i] & 0x3f) != check_byte) | 365 | if ((usb_buf[i] & 0x3f) != check_byte) |
366 | dev->input_panic = 1; | 366 | dev->input_panic = 1; |
367 | 367 | ||
@@ -410,21 +410,21 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev, | |||
410 | } | 410 | } |
411 | 411 | ||
412 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { | 412 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { |
413 | debug("streaming error detected %s %s\n", | 413 | debug("streaming error detected %s %s\n", |
414 | dev->input_panic ? "(input)" : "", | 414 | dev->input_panic ? "(input)" : "", |
415 | dev->output_panic ? "(output)" : ""); | 415 | dev->output_panic ? "(output)" : ""); |
416 | dev->warned = 1; | 416 | dev->warned = 1; |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
420 | static void fill_out_urb(struct snd_usb_caiaqdev *dev, | 420 | static void fill_out_urb(struct snd_usb_caiaqdev *dev, |
421 | struct urb *urb, | 421 | struct urb *urb, |
422 | const struct usb_iso_packet_descriptor *iso) | 422 | const struct usb_iso_packet_descriptor *iso) |
423 | { | 423 | { |
424 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; | 424 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; |
425 | struct snd_pcm_substream *sub; | 425 | struct snd_pcm_substream *sub; |
426 | int stream, i; | 426 | int stream, i; |
427 | 427 | ||
428 | for (i = 0; i < iso->length;) { | 428 | for (i = 0; i < iso->length;) { |
429 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 429 | for (stream = 0; stream < dev->n_streams; stream++, i++) { |
430 | sub = dev->sub_playback[stream]; | 430 | sub = dev->sub_playback[stream]; |
@@ -444,7 +444,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev, | |||
444 | 444 | ||
445 | /* fill in the check bytes */ | 445 | /* fill in the check bytes */ |
446 | if (dev->spec.data_alignment == 2 && | 446 | if (dev->spec.data_alignment == 2 && |
447 | i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == | 447 | i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == |
448 | (dev->n_streams * CHANNELS_PER_STREAM)) | 448 | (dev->n_streams * CHANNELS_PER_STREAM)) |
449 | for (stream = 0; stream < dev->n_streams; stream++, i++) | 449 | for (stream = 0; stream < dev->n_streams; stream++, i++) |
450 | usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); | 450 | usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); |
@@ -453,7 +453,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev, | |||
453 | 453 | ||
454 | static void read_completed(struct urb *urb) | 454 | static void read_completed(struct urb *urb) |
455 | { | 455 | { |
456 | struct snd_usb_caiaq_cb_info *info = urb->context; | 456 | struct snd_usb_caiaq_cb_info *info = urb->context; |
457 | struct snd_usb_caiaqdev *dev; | 457 | struct snd_usb_caiaqdev *dev; |
458 | struct urb *out; | 458 | struct urb *out; |
459 | int frame, len, send_it = 0, outframe = 0; | 459 | int frame, len, send_it = 0, outframe = 0; |
@@ -478,7 +478,7 @@ static void read_completed(struct urb *urb) | |||
478 | out->iso_frame_desc[outframe].length = len; | 478 | out->iso_frame_desc[outframe].length = len; |
479 | out->iso_frame_desc[outframe].actual_length = 0; | 479 | out->iso_frame_desc[outframe].actual_length = 0; |
480 | out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame; | 480 | out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame; |
481 | 481 | ||
482 | if (len > 0) { | 482 | if (len > 0) { |
483 | spin_lock(&dev->spinlock); | 483 | spin_lock(&dev->spinlock); |
484 | fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); | 484 | fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); |
@@ -497,14 +497,14 @@ static void read_completed(struct urb *urb) | |||
497 | out->transfer_flags = URB_ISO_ASAP; | 497 | out->transfer_flags = URB_ISO_ASAP; |
498 | usb_submit_urb(out, GFP_ATOMIC); | 498 | usb_submit_urb(out, GFP_ATOMIC); |
499 | } | 499 | } |
500 | 500 | ||
501 | /* re-submit inbound urb */ | 501 | /* re-submit inbound urb */ |
502 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { | 502 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { |
503 | urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame; | 503 | urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame; |
504 | urb->iso_frame_desc[frame].length = BYTES_PER_FRAME; | 504 | urb->iso_frame_desc[frame].length = BYTES_PER_FRAME; |
505 | urb->iso_frame_desc[frame].actual_length = 0; | 505 | urb->iso_frame_desc[frame].actual_length = 0; |
506 | } | 506 | } |
507 | 507 | ||
508 | urb->number_of_packets = FRAMES_PER_URB; | 508 | urb->number_of_packets = FRAMES_PER_URB; |
509 | urb->transfer_flags = URB_ISO_ASAP; | 509 | urb->transfer_flags = URB_ISO_ASAP; |
510 | usb_submit_urb(urb, GFP_ATOMIC); | 510 | usb_submit_urb(urb, GFP_ATOMIC); |
@@ -528,7 +528,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
528 | struct usb_device *usb_dev = dev->chip.dev; | 528 | struct usb_device *usb_dev = dev->chip.dev; |
529 | unsigned int pipe; | 529 | unsigned int pipe; |
530 | 530 | ||
531 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? | 531 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? |
532 | usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : | 532 | usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : |
533 | usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); | 533 | usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); |
534 | 534 | ||
@@ -547,25 +547,25 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
547 | return urbs; | 547 | return urbs; |
548 | } | 548 | } |
549 | 549 | ||
550 | urbs[i]->transfer_buffer = | 550 | urbs[i]->transfer_buffer = |
551 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); | 551 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); |
552 | if (!urbs[i]->transfer_buffer) { | 552 | if (!urbs[i]->transfer_buffer) { |
553 | log("unable to kmalloc() transfer buffer, OOM!?\n"); | 553 | log("unable to kmalloc() transfer buffer, OOM!?\n"); |
554 | *ret = -ENOMEM; | 554 | *ret = -ENOMEM; |
555 | return urbs; | 555 | return urbs; |
556 | } | 556 | } |
557 | 557 | ||
558 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { | 558 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { |
559 | struct usb_iso_packet_descriptor *iso = | 559 | struct usb_iso_packet_descriptor *iso = |
560 | &urbs[i]->iso_frame_desc[frame]; | 560 | &urbs[i]->iso_frame_desc[frame]; |
561 | 561 | ||
562 | iso->offset = BYTES_PER_FRAME * frame; | 562 | iso->offset = BYTES_PER_FRAME * frame; |
563 | iso->length = BYTES_PER_FRAME; | 563 | iso->length = BYTES_PER_FRAME; |
564 | } | 564 | } |
565 | 565 | ||
566 | urbs[i]->dev = usb_dev; | 566 | urbs[i]->dev = usb_dev; |
567 | urbs[i]->pipe = pipe; | 567 | urbs[i]->pipe = pipe; |
568 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB | 568 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB |
569 | * BYTES_PER_FRAME; | 569 | * BYTES_PER_FRAME; |
570 | urbs[i]->context = &dev->data_cb_info[i]; | 570 | urbs[i]->context = &dev->data_cb_info[i]; |
571 | urbs[i]->interval = 1; | 571 | urbs[i]->interval = 1; |
@@ -589,7 +589,7 @@ static void free_urbs(struct urb **urbs) | |||
589 | for (i = 0; i < N_URBS; i++) { | 589 | for (i = 0; i < N_URBS; i++) { |
590 | if (!urbs[i]) | 590 | if (!urbs[i]) |
591 | continue; | 591 | continue; |
592 | 592 | ||
593 | usb_kill_urb(urbs[i]); | 593 | usb_kill_urb(urbs[i]); |
594 | kfree(urbs[i]->transfer_buffer); | 594 | kfree(urbs[i]->transfer_buffer); |
595 | usb_free_urb(urbs[i]); | 595 | usb_free_urb(urbs[i]); |
@@ -602,11 +602,11 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
602 | { | 602 | { |
603 | int i, ret; | 603 | int i, ret; |
604 | 604 | ||
605 | dev->n_audio_in = max(dev->spec.num_analog_audio_in, | 605 | dev->n_audio_in = max(dev->spec.num_analog_audio_in, |
606 | dev->spec.num_digital_audio_in) / | 606 | dev->spec.num_digital_audio_in) / |
607 | CHANNELS_PER_STREAM; | 607 | CHANNELS_PER_STREAM; |
608 | dev->n_audio_out = max(dev->spec.num_analog_audio_out, | 608 | dev->n_audio_out = max(dev->spec.num_analog_audio_out, |
609 | dev->spec.num_digital_audio_out) / | 609 | dev->spec.num_digital_audio_out) / |
610 | CHANNELS_PER_STREAM; | 610 | CHANNELS_PER_STREAM; |
611 | dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); | 611 | dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); |
612 | 612 | ||
@@ -619,7 +619,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
619 | return -EINVAL; | 619 | return -EINVAL; |
620 | } | 620 | } |
621 | 621 | ||
622 | ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, | 622 | ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, |
623 | dev->n_audio_out, dev->n_audio_in, &dev->pcm); | 623 | dev->n_audio_out, dev->n_audio_in, &dev->pcm); |
624 | 624 | ||
625 | if (ret < 0) { | 625 | if (ret < 0) { |
@@ -632,7 +632,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
632 | 632 | ||
633 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); | 633 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); |
634 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); | 634 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); |
635 | 635 | ||
636 | memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, | 636 | memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, |
637 | sizeof(snd_usb_caiaq_pcm_hardware)); | 637 | sizeof(snd_usb_caiaq_pcm_hardware)); |
638 | 638 | ||
@@ -651,9 +651,9 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
651 | break; | 651 | break; |
652 | } | 652 | } |
653 | 653 | ||
654 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, | 654 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, |
655 | &snd_usb_caiaq_ops); | 655 | &snd_usb_caiaq_ops); |
656 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, | 656 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, |
657 | &snd_usb_caiaq_ops); | 657 | &snd_usb_caiaq_ops); |
658 | 658 | ||
659 | snd_pcm_lib_preallocate_pages_for_all(dev->pcm, | 659 | snd_pcm_lib_preallocate_pages_for_all(dev->pcm, |
@@ -662,7 +662,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
662 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); | 662 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); |
663 | 663 | ||
664 | dev->data_cb_info = | 664 | dev->data_cb_info = |
665 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, | 665 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, |
666 | GFP_KERNEL); | 666 | GFP_KERNEL); |
667 | 667 | ||
668 | if (!dev->data_cb_info) | 668 | if (!dev->data_cb_info) |
@@ -672,14 +672,14 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
672 | dev->data_cb_info[i].dev = dev; | 672 | dev->data_cb_info[i].dev = dev; |
673 | dev->data_cb_info[i].index = i; | 673 | dev->data_cb_info[i].index = i; |
674 | } | 674 | } |
675 | 675 | ||
676 | dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); | 676 | dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); |
677 | if (ret < 0) { | 677 | if (ret < 0) { |
678 | kfree(dev->data_cb_info); | 678 | kfree(dev->data_cb_info); |
679 | free_urbs(dev->data_urbs_in); | 679 | free_urbs(dev->data_urbs_in); |
680 | return ret; | 680 | return ret; |
681 | } | 681 | } |
682 | 682 | ||
683 | dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); | 683 | dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); |
684 | if (ret < 0) { | 684 | if (ret < 0) { |
685 | kfree(dev->data_cb_info); | 685 | kfree(dev->data_cb_info); |
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 515de1cd2a3e..b9a2b312b83e 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include "input.h" | 35 | #include "input.h" |
36 | 36 | ||
37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14"); | 38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.15"); |
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," | 40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," |
41 | "{Native Instruments, RigKontrol3}," | 41 | "{Native Instruments, RigKontrol3}," |
@@ -79,7 +79,7 @@ static struct usb_device_id snd_usb_id_table[] = { | |||
79 | { | 79 | { |
80 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | 80 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
81 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | 81 | .idVendor = USB_VID_NATIVEINSTRUMENTS, |
82 | .idProduct = USB_PID_RIGKONTROL2 | 82 | .idProduct = USB_PID_RIGKONTROL2 |
83 | }, | 83 | }, |
84 | { | 84 | { |
85 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | 85 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
@@ -197,7 +197,7 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | |||
197 | 197 | ||
198 | if (buffer && len > 0) | 198 | if (buffer && len > 0) |
199 | memcpy(dev->ep1_out_buf+1, buffer, len); | 199 | memcpy(dev->ep1_out_buf+1, buffer, len); |
200 | 200 | ||
201 | dev->ep1_out_buf[0] = command; | 201 | dev->ep1_out_buf[0] = command; |
202 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), | 202 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), |
203 | dev->ep1_out_buf, len+1, &actual_len, 200); | 203 | dev->ep1_out_buf, len+1, &actual_len, 200); |
@@ -208,7 +208,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
208 | { | 208 | { |
209 | int ret; | 209 | int ret; |
210 | char tmp[5]; | 210 | char tmp[5]; |
211 | 211 | ||
212 | switch (rate) { | 212 | switch (rate) { |
213 | case 44100: tmp[0] = SAMPLERATE_44100; break; | 213 | case 44100: tmp[0] = SAMPLERATE_44100; break; |
214 | case 48000: tmp[0] = SAMPLERATE_48000; break; | 214 | case 48000: tmp[0] = SAMPLERATE_48000; break; |
@@ -237,12 +237,12 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
237 | 237 | ||
238 | if (ret) | 238 | if (ret) |
239 | return ret; | 239 | return ret; |
240 | 240 | ||
241 | if (!wait_event_timeout(dev->ep1_wait_queue, | 241 | if (!wait_event_timeout(dev->ep1_wait_queue, |
242 | dev->audio_parm_answer >= 0, HZ)) | 242 | dev->audio_parm_answer >= 0, HZ)) |
243 | return -EPIPE; | 243 | return -EPIPE; |
244 | 244 | ||
245 | if (dev->audio_parm_answer != 1) | 245 | if (dev->audio_parm_answer != 1) |
246 | debug("unable to set the device's audio params\n"); | 246 | debug("unable to set the device's audio params\n"); |
247 | else | 247 | else |
248 | dev->bpp = bpp; | 248 | dev->bpp = bpp; |
@@ -250,8 +250,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
250 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; | 250 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; |
251 | } | 251 | } |
252 | 252 | ||
253 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, | 253 | int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev, |
254 | int digital, int analog, int erp) | 254 | int digital, int analog, int erp) |
255 | { | 255 | { |
256 | char tmp[3] = { digital, analog, erp }; | 256 | char tmp[3] = { digital, analog, erp }; |
257 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, | 257 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, |
@@ -262,7 +262,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
262 | { | 262 | { |
263 | int ret; | 263 | int ret; |
264 | char val[4]; | 264 | char val[4]; |
265 | 265 | ||
266 | /* device-specific startup specials */ | 266 | /* device-specific startup specials */ |
267 | switch (dev->chip.usb_id) { | 267 | switch (dev->chip.usb_id) { |
268 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 268 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
@@ -314,7 +314,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
314 | dev->control_state, 1); | 314 | dev->control_state, 1); |
315 | break; | 315 | break; |
316 | } | 316 | } |
317 | 317 | ||
318 | if (dev->spec.num_analog_audio_out + | 318 | if (dev->spec.num_analog_audio_out + |
319 | dev->spec.num_analog_audio_in + | 319 | dev->spec.num_analog_audio_in + |
320 | dev->spec.num_digital_audio_out + | 320 | dev->spec.num_digital_audio_out + |
@@ -323,7 +323,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
323 | if (ret < 0) | 323 | if (ret < 0) |
324 | log("Unable to set up audio system (ret=%d)\n", ret); | 324 | log("Unable to set up audio system (ret=%d)\n", ret); |
325 | } | 325 | } |
326 | 326 | ||
327 | if (dev->spec.num_midi_in + | 327 | if (dev->spec.num_midi_in + |
328 | dev->spec.num_midi_out > 0) { | 328 | dev->spec.num_midi_out > 0) { |
329 | ret = snd_usb_caiaq_midi_init(dev); | 329 | ret = snd_usb_caiaq_midi_init(dev); |
@@ -363,7 +363,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | |||
363 | if (devnum >= SNDRV_CARDS) | 363 | if (devnum >= SNDRV_CARDS) |
364 | return -ENODEV; | 364 | return -ENODEV; |
365 | 365 | ||
366 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, | 366 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, |
367 | sizeof(struct snd_usb_caiaqdev), &card); | 367 | sizeof(struct snd_usb_caiaqdev), &card); |
368 | if (err < 0) | 368 | if (err < 0) |
369 | return err; | 369 | return err; |
@@ -382,11 +382,11 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | |||
382 | 382 | ||
383 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) | 383 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) |
384 | { | 384 | { |
385 | char *c; | 385 | char *c, usbpath[32]; |
386 | struct usb_device *usb_dev = dev->chip.dev; | 386 | struct usb_device *usb_dev = dev->chip.dev; |
387 | struct snd_card *card = dev->chip.card; | 387 | struct snd_card *card = dev->chip.card; |
388 | int err, len; | 388 | int err, len; |
389 | 389 | ||
390 | if (usb_set_interface(usb_dev, 0, 1) != 0) { | 390 | if (usb_set_interface(usb_dev, 0, 1) != 0) { |
391 | log("can't set alt interface.\n"); | 391 | log("can't set alt interface.\n"); |
392 | return -EIO; | 392 | return -EIO; |
@@ -395,19 +395,19 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev) | |||
395 | usb_init_urb(&dev->ep1_in_urb); | 395 | usb_init_urb(&dev->ep1_in_urb); |
396 | usb_init_urb(&dev->midi_out_urb); | 396 | usb_init_urb(&dev->midi_out_urb); |
397 | 397 | ||
398 | usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, | 398 | usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, |
399 | usb_rcvbulkpipe(usb_dev, 0x1), | 399 | usb_rcvbulkpipe(usb_dev, 0x1), |
400 | dev->ep1_in_buf, EP1_BUFSIZE, | 400 | dev->ep1_in_buf, EP1_BUFSIZE, |
401 | usb_ep1_command_reply_dispatch, dev); | 401 | usb_ep1_command_reply_dispatch, dev); |
402 | 402 | ||
403 | usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, | 403 | usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, |
404 | usb_sndbulkpipe(usb_dev, 0x1), | 404 | usb_sndbulkpipe(usb_dev, 0x1), |
405 | dev->midi_out_buf, EP1_BUFSIZE, | 405 | dev->midi_out_buf, EP1_BUFSIZE, |
406 | snd_usb_caiaq_midi_output_done, dev); | 406 | snd_usb_caiaq_midi_output_done, dev); |
407 | 407 | ||
408 | init_waitqueue_head(&dev->ep1_wait_queue); | 408 | init_waitqueue_head(&dev->ep1_wait_queue); |
409 | init_waitqueue_head(&dev->prepare_wait_queue); | 409 | init_waitqueue_head(&dev->prepare_wait_queue); |
410 | 410 | ||
411 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) | 411 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) |
412 | return -EIO; | 412 | return -EIO; |
413 | 413 | ||
@@ -420,47 +420,51 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev) | |||
420 | 420 | ||
421 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, | 421 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, |
422 | dev->vendor_name, CAIAQ_USB_STR_LEN); | 422 | dev->vendor_name, CAIAQ_USB_STR_LEN); |
423 | 423 | ||
424 | usb_string(usb_dev, usb_dev->descriptor.iProduct, | 424 | usb_string(usb_dev, usb_dev->descriptor.iProduct, |
425 | dev->product_name, CAIAQ_USB_STR_LEN); | 425 | dev->product_name, CAIAQ_USB_STR_LEN); |
426 | 426 | ||
427 | usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, | 427 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); |
428 | dev->serial, CAIAQ_USB_STR_LEN); | 428 | strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); |
429 | 429 | ||
430 | /* terminate serial string at first white space occurence */ | 430 | /* if the id was not passed as module option, fill it with a shortened |
431 | c = strchr(dev->serial, ' '); | 431 | * version of the product string which does not contain any |
432 | if (c) | 432 | * whitespaces */ |
433 | *c = '\0'; | 433 | |
434 | 434 | if (*card->id == '\0') { | |
435 | strcpy(card->driver, MODNAME); | 435 | char id[sizeof(card->id)]; |
436 | strcpy(card->shortname, dev->product_name); | 436 | |
437 | 437 | memset(id, 0, sizeof(id)); | |
438 | len = snprintf(card->longname, sizeof(card->longname), | 438 | |
439 | "%s %s (serial %s, ", | 439 | for (c = card->shortname, len = 0; |
440 | dev->vendor_name, dev->product_name, dev->serial); | 440 | *c && len < sizeof(card->id); c++) |
441 | 441 | if (*c != ' ') | |
442 | if (len < sizeof(card->longname) - 2) | 442 | id[len++] = *c; |
443 | len += usb_make_path(usb_dev, card->longname + len, | 443 | |
444 | sizeof(card->longname) - len); | 444 | snd_card_set_id(card, id); |
445 | 445 | } | |
446 | card->longname[len++] = ')'; | 446 | |
447 | card->longname[len] = '\0'; | 447 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); |
448 | snprintf(card->longname, sizeof(card->longname), | ||
449 | "%s %s (%s)", | ||
450 | dev->vendor_name, dev->product_name, usbpath); | ||
451 | |||
448 | setup_card(dev); | 452 | setup_card(dev); |
449 | return 0; | 453 | return 0; |
450 | } | 454 | } |
451 | 455 | ||
452 | static int __devinit snd_probe(struct usb_interface *intf, | 456 | static int __devinit snd_probe(struct usb_interface *intf, |
453 | const struct usb_device_id *id) | 457 | const struct usb_device_id *id) |
454 | { | 458 | { |
455 | int ret; | 459 | int ret; |
456 | struct snd_card *card; | 460 | struct snd_card *card; |
457 | struct usb_device *device = interface_to_usbdev(intf); | 461 | struct usb_device *device = interface_to_usbdev(intf); |
458 | 462 | ||
459 | ret = create_card(device, &card); | 463 | ret = create_card(device, &card); |
460 | 464 | ||
461 | if (ret < 0) | 465 | if (ret < 0) |
462 | return ret; | 466 | return ret; |
463 | 467 | ||
464 | usb_set_intfdata(intf, card); | 468 | usb_set_intfdata(intf, card); |
465 | ret = init_card(caiaqdev(card)); | 469 | ret = init_card(caiaqdev(card)); |
466 | if (ret < 0) { | 470 | if (ret < 0) { |
@@ -468,7 +472,7 @@ static int __devinit snd_probe(struct usb_interface *intf, | |||
468 | snd_card_free(card); | 472 | snd_card_free(card); |
469 | return ret; | 473 | return ret; |
470 | } | 474 | } |
471 | 475 | ||
472 | return 0; | 476 | return 0; |
473 | } | 477 | } |
474 | 478 | ||
@@ -489,10 +493,10 @@ static void snd_disconnect(struct usb_interface *intf) | |||
489 | snd_usb_caiaq_input_free(dev); | 493 | snd_usb_caiaq_input_free(dev); |
490 | #endif | 494 | #endif |
491 | snd_usb_caiaq_audio_free(dev); | 495 | snd_usb_caiaq_audio_free(dev); |
492 | 496 | ||
493 | usb_kill_urb(&dev->ep1_in_urb); | 497 | usb_kill_urb(&dev->ep1_in_urb); |
494 | usb_kill_urb(&dev->midi_out_urb); | 498 | usb_kill_urb(&dev->midi_out_urb); |
495 | 499 | ||
496 | snd_card_free(card); | 500 | snd_card_free(card); |
497 | usb_reset_device(interface_to_usbdev(intf)); | 501 | usb_reset_device(interface_to_usbdev(intf)); |
498 | } | 502 | } |
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index 4cce1ad7493d..ece73514854e 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h | |||
@@ -81,7 +81,6 @@ struct snd_usb_caiaqdev { | |||
81 | 81 | ||
82 | char vendor_name[CAIAQ_USB_STR_LEN]; | 82 | char vendor_name[CAIAQ_USB_STR_LEN]; |
83 | char product_name[CAIAQ_USB_STR_LEN]; | 83 | char product_name[CAIAQ_USB_STR_LEN]; |
84 | char serial[CAIAQ_USB_STR_LEN]; | ||
85 | 84 | ||
86 | int n_streams, n_audio_in, n_audio_out; | 85 | int n_streams, n_audio_in, n_audio_out; |
87 | int streaming, first_packet, output_running; | 86 | int streaming, first_packet, output_running; |
diff --git a/sound/usb/caiaq/midi.c b/sound/usb/caiaq/midi.c index 8fa8cd88d763..538e8c00d31a 100644 --- a/sound/usb/caiaq/midi.c +++ b/sound/usb/caiaq/midi.c | |||
@@ -40,7 +40,7 @@ static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *subst | |||
40 | 40 | ||
41 | if (!dev) | 41 | if (!dev) |
42 | return; | 42 | return; |
43 | 43 | ||
44 | dev->midi_receive_substream = up ? substream : NULL; | 44 | dev->midi_receive_substream = up ? substream : NULL; |
45 | } | 45 | } |
46 | 46 | ||
@@ -64,18 +64,18 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, | |||
64 | struct snd_rawmidi_substream *substream) | 64 | struct snd_rawmidi_substream *substream) |
65 | { | 65 | { |
66 | int len, ret; | 66 | int len, ret; |
67 | 67 | ||
68 | dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; | 68 | dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; |
69 | dev->midi_out_buf[1] = 0; /* port */ | 69 | dev->midi_out_buf[1] = 0; /* port */ |
70 | len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, | 70 | len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, |
71 | EP1_BUFSIZE - 3); | 71 | EP1_BUFSIZE - 3); |
72 | 72 | ||
73 | if (len <= 0) | 73 | if (len <= 0) |
74 | return; | 74 | return; |
75 | 75 | ||
76 | dev->midi_out_buf[2] = len; | 76 | dev->midi_out_buf[2] = len; |
77 | dev->midi_out_urb.transfer_buffer_length = len+3; | 77 | dev->midi_out_urb.transfer_buffer_length = len+3; |
78 | 78 | ||
79 | ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); | 79 | ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); |
80 | if (ret < 0) | 80 | if (ret < 0) |
81 | log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," | 81 | log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," |
@@ -88,7 +88,7 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, | |||
88 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) | 88 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) |
89 | { | 89 | { |
90 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 90 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; |
91 | 91 | ||
92 | if (up) { | 92 | if (up) { |
93 | dev->midi_out_substream = substream; | 93 | dev->midi_out_substream = substream; |
94 | if (!dev->midi_out_active) | 94 | if (!dev->midi_out_active) |
@@ -113,12 +113,12 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input = | |||
113 | .trigger = snd_usb_caiaq_midi_input_trigger, | 113 | .trigger = snd_usb_caiaq_midi_input_trigger, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, | 116 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, |
117 | int port, const char *buf, int len) | 117 | int port, const char *buf, int len) |
118 | { | 118 | { |
119 | if (!dev->midi_receive_substream) | 119 | if (!dev->midi_receive_substream) |
120 | return; | 120 | return; |
121 | 121 | ||
122 | snd_rawmidi_receive(dev->midi_receive_substream, buf, len); | 122 | snd_rawmidi_receive(dev->midi_receive_substream, buf, len); |
123 | } | 123 | } |
124 | 124 | ||
@@ -142,16 +142,16 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | |||
142 | 142 | ||
143 | if (device->spec.num_midi_out > 0) { | 143 | if (device->spec.num_midi_out > 0) { |
144 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; | 144 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; |
145 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, | 145 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, |
146 | &snd_usb_caiaq_midi_output); | 146 | &snd_usb_caiaq_midi_output); |
147 | } | 147 | } |
148 | 148 | ||
149 | if (device->spec.num_midi_in > 0) { | 149 | if (device->spec.num_midi_in > 0) { |
150 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; | 150 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; |
151 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, | 151 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, |
152 | &snd_usb_caiaq_midi_input); | 152 | &snd_usb_caiaq_midi_input); |
153 | } | 153 | } |
154 | 154 | ||
155 | device->rmidi = rmidi; | 155 | device->rmidi = rmidi; |
156 | 156 | ||
157 | return 0; | 157 | return 0; |
@@ -160,7 +160,7 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | |||
160 | void snd_usb_caiaq_midi_output_done(struct urb* urb) | 160 | void snd_usb_caiaq_midi_output_done(struct urb* urb) |
161 | { | 161 | { |
162 | struct snd_usb_caiaqdev *dev = urb->context; | 162 | struct snd_usb_caiaqdev *dev = urb->context; |
163 | 163 | ||
164 | dev->midi_out_active = 0; | 164 | dev->midi_out_active = 0; |
165 | if (urb->status != 0) | 165 | if (urb->status != 0) |
166 | return; | 166 | return; |