diff options
Diffstat (limited to 'sound/usb/caiaq/device.c')
-rw-r--r-- | sound/usb/caiaq/device.c | 109 |
1 files changed, 57 insertions, 52 deletions
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 515de1cd2a3..22406245a98 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.16"); |
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,52 @@ 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 | strlcpy(card->mixername, dev->product_name, sizeof(card->mixername)); | |
430 | /* terminate serial string at first white space occurence */ | 430 | |
431 | c = strchr(dev->serial, ' '); | 431 | /* if the id was not passed as module option, fill it with a shortened |
432 | if (c) | 432 | * version of the product string which does not contain any |
433 | *c = '\0'; | 433 | * whitespaces */ |
434 | 434 | ||
435 | strcpy(card->driver, MODNAME); | 435 | if (*card->id == '\0') { |
436 | strcpy(card->shortname, dev->product_name); | 436 | char id[sizeof(card->id)]; |
437 | 437 | ||
438 | len = snprintf(card->longname, sizeof(card->longname), | 438 | memset(id, 0, sizeof(id)); |
439 | "%s %s (serial %s, ", | 439 | |
440 | dev->vendor_name, dev->product_name, dev->serial); | 440 | for (c = card->shortname, len = 0; |
441 | 441 | *c && len < sizeof(card->id); c++) | |
442 | if (len < sizeof(card->longname) - 2) | 442 | if (*c != ' ') |
443 | len += usb_make_path(usb_dev, card->longname + len, | 443 | id[len++] = *c; |
444 | sizeof(card->longname) - len); | 444 | |
445 | 445 | snd_card_set_id(card, id); | |
446 | card->longname[len++] = ')'; | 446 | } |
447 | card->longname[len] = '\0'; | 447 | |
448 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); | ||
449 | snprintf(card->longname, sizeof(card->longname), | ||
450 | "%s %s (%s)", | ||
451 | dev->vendor_name, dev->product_name, usbpath); | ||
452 | |||
448 | setup_card(dev); | 453 | setup_card(dev); |
449 | return 0; | 454 | return 0; |
450 | } | 455 | } |
451 | 456 | ||
452 | static int __devinit snd_probe(struct usb_interface *intf, | 457 | static int __devinit snd_probe(struct usb_interface *intf, |
453 | const struct usb_device_id *id) | 458 | const struct usb_device_id *id) |
454 | { | 459 | { |
455 | int ret; | 460 | int ret; |
456 | struct snd_card *card; | 461 | struct snd_card *card; |
457 | struct usb_device *device = interface_to_usbdev(intf); | 462 | struct usb_device *device = interface_to_usbdev(intf); |
458 | 463 | ||
459 | ret = create_card(device, &card); | 464 | ret = create_card(device, &card); |
460 | 465 | ||
461 | if (ret < 0) | 466 | if (ret < 0) |
462 | return ret; | 467 | return ret; |
463 | 468 | ||
464 | usb_set_intfdata(intf, card); | 469 | usb_set_intfdata(intf, card); |
465 | ret = init_card(caiaqdev(card)); | 470 | ret = init_card(caiaqdev(card)); |
466 | if (ret < 0) { | 471 | if (ret < 0) { |
@@ -468,7 +473,7 @@ static int __devinit snd_probe(struct usb_interface *intf, | |||
468 | snd_card_free(card); | 473 | snd_card_free(card); |
469 | return ret; | 474 | return ret; |
470 | } | 475 | } |
471 | 476 | ||
472 | return 0; | 477 | return 0; |
473 | } | 478 | } |
474 | 479 | ||
@@ -489,10 +494,10 @@ static void snd_disconnect(struct usb_interface *intf) | |||
489 | snd_usb_caiaq_input_free(dev); | 494 | snd_usb_caiaq_input_free(dev); |
490 | #endif | 495 | #endif |
491 | snd_usb_caiaq_audio_free(dev); | 496 | snd_usb_caiaq_audio_free(dev); |
492 | 497 | ||
493 | usb_kill_urb(&dev->ep1_in_urb); | 498 | usb_kill_urb(&dev->ep1_in_urb); |
494 | usb_kill_urb(&dev->midi_out_urb); | 499 | usb_kill_urb(&dev->midi_out_urb); |
495 | 500 | ||
496 | snd_card_free(card); | 501 | snd_card_free(card); |
497 | usb_reset_device(interface_to_usbdev(intf)); | 502 | usb_reset_device(interface_to_usbdev(intf)); |
498 | } | 503 | } |