aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/caiaq/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/caiaq/device.c')
-rw-r--r--sound/usb/caiaq/device.c123
1 files changed, 68 insertions, 55 deletions
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 515de1cd2a3e..83e6c1312d47 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -35,13 +35,14 @@
35#include "input.h" 35#include "input.h"
36 36
37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14"); 38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.19");
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
41 "{Native Instruments, RigKontrol3}," 41 "{Native Instruments, RigKontrol3},"
42 "{Native Instruments, Kore Controller}," 42 "{Native Instruments, Kore Controller},"
43 "{Native Instruments, Kore Controller 2}," 43 "{Native Instruments, Kore Controller 2},"
44 "{Native Instruments, Audio Kontrol 1}," 44 "{Native Instruments, Audio Kontrol 1},"
45 "{Native Instruments, Audio 2 DJ},"
45 "{Native Instruments, Audio 4 DJ}," 46 "{Native Instruments, Audio 4 DJ},"
46 "{Native Instruments, Audio 8 DJ}," 47 "{Native Instruments, Audio 8 DJ},"
47 "{Native Instruments, Session I/O}," 48 "{Native Instruments, Session I/O},"
@@ -79,7 +80,7 @@ static struct usb_device_id snd_usb_id_table[] = {
79 { 80 {
80 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 81 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
81 .idVendor = USB_VID_NATIVEINSTRUMENTS, 82 .idVendor = USB_VID_NATIVEINSTRUMENTS,
82 .idProduct = USB_PID_RIGKONTROL2 83 .idProduct = USB_PID_RIGKONTROL2
83 }, 84 },
84 { 85 {
85 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 86 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
@@ -121,6 +122,11 @@ static struct usb_device_id snd_usb_id_table[] = {
121 .idVendor = USB_VID_NATIVEINSTRUMENTS, 122 .idVendor = USB_VID_NATIVEINSTRUMENTS,
122 .idProduct = USB_PID_AUDIO4DJ 123 .idProduct = USB_PID_AUDIO4DJ
123 }, 124 },
125 {
126 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
127 .idVendor = USB_VID_NATIVEINSTRUMENTS,
128 .idProduct = USB_PID_AUDIO2DJ
129 },
124 { /* terminator */ } 130 { /* terminator */ }
125}; 131};
126 132
@@ -197,7 +203,7 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
197 203
198 if (buffer && len > 0) 204 if (buffer && len > 0)
199 memcpy(dev->ep1_out_buf+1, buffer, len); 205 memcpy(dev->ep1_out_buf+1, buffer, len);
200 206
201 dev->ep1_out_buf[0] = command; 207 dev->ep1_out_buf[0] = command;
202 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), 208 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
203 dev->ep1_out_buf, len+1, &actual_len, 200); 209 dev->ep1_out_buf, len+1, &actual_len, 200);
@@ -208,7 +214,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
208{ 214{
209 int ret; 215 int ret;
210 char tmp[5]; 216 char tmp[5];
211 217
212 switch (rate) { 218 switch (rate) {
213 case 44100: tmp[0] = SAMPLERATE_44100; break; 219 case 44100: tmp[0] = SAMPLERATE_44100; break;
214 case 48000: tmp[0] = SAMPLERATE_48000; break; 220 case 48000: tmp[0] = SAMPLERATE_48000; break;
@@ -237,12 +243,12 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
237 243
238 if (ret) 244 if (ret)
239 return ret; 245 return ret;
240 246
241 if (!wait_event_timeout(dev->ep1_wait_queue, 247 if (!wait_event_timeout(dev->ep1_wait_queue,
242 dev->audio_parm_answer >= 0, HZ)) 248 dev->audio_parm_answer >= 0, HZ))
243 return -EPIPE; 249 return -EPIPE;
244 250
245 if (dev->audio_parm_answer != 1) 251 if (dev->audio_parm_answer != 1)
246 debug("unable to set the device's audio params\n"); 252 debug("unable to set the device's audio params\n");
247 else 253 else
248 dev->bpp = bpp; 254 dev->bpp = bpp;
@@ -250,8 +256,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
250 return dev->audio_parm_answer == 1 ? 0 : -EINVAL; 256 return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
251} 257}
252 258
253int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, 259int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev,
254 int digital, int analog, int erp) 260 int digital, int analog, int erp)
255{ 261{
256 char tmp[3] = { digital, analog, erp }; 262 char tmp[3] = { digital, analog, erp };
257 return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, 263 return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG,
@@ -262,7 +268,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
262{ 268{
263 int ret; 269 int ret;
264 char val[4]; 270 char val[4];
265 271
266 /* device-specific startup specials */ 272 /* device-specific startup specials */
267 switch (dev->chip.usb_id) { 273 switch (dev->chip.usb_id) {
268 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): 274 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
@@ -314,7 +320,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
314 dev->control_state, 1); 320 dev->control_state, 1);
315 break; 321 break;
316 } 322 }
317 323
318 if (dev->spec.num_analog_audio_out + 324 if (dev->spec.num_analog_audio_out +
319 dev->spec.num_analog_audio_in + 325 dev->spec.num_analog_audio_in +
320 dev->spec.num_digital_audio_out + 326 dev->spec.num_digital_audio_out +
@@ -323,7 +329,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
323 if (ret < 0) 329 if (ret < 0)
324 log("Unable to set up audio system (ret=%d)\n", ret); 330 log("Unable to set up audio system (ret=%d)\n", ret);
325 } 331 }
326 332
327 if (dev->spec.num_midi_in + 333 if (dev->spec.num_midi_in +
328 dev->spec.num_midi_out > 0) { 334 dev->spec.num_midi_out > 0) {
329 ret = snd_usb_caiaq_midi_init(dev); 335 ret = snd_usb_caiaq_midi_init(dev);
@@ -349,7 +355,9 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
349 log("Unable to set up control system (ret=%d)\n", ret); 355 log("Unable to set up control system (ret=%d)\n", ret);
350} 356}
351 357
352static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) 358static int create_card(struct usb_device *usb_dev,
359 struct usb_interface *intf,
360 struct snd_card **cardp)
353{ 361{
354 int devnum; 362 int devnum;
355 int err; 363 int err;
@@ -363,7 +371,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
363 if (devnum >= SNDRV_CARDS) 371 if (devnum >= SNDRV_CARDS)
364 return -ENODEV; 372 return -ENODEV;
365 373
366 err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, 374 err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
367 sizeof(struct snd_usb_caiaqdev), &card); 375 sizeof(struct snd_usb_caiaqdev), &card);
368 if (err < 0) 376 if (err < 0)
369 return err; 377 return err;
@@ -374,7 +382,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
374 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), 382 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
375 le16_to_cpu(usb_dev->descriptor.idProduct)); 383 le16_to_cpu(usb_dev->descriptor.idProduct));
376 spin_lock_init(&dev->spinlock); 384 spin_lock_init(&dev->spinlock);
377 snd_card_set_dev(card, &usb_dev->dev); 385 snd_card_set_dev(card, &intf->dev);
378 386
379 *cardp = card; 387 *cardp = card;
380 return 0; 388 return 0;
@@ -382,11 +390,11 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
382 390
383static int __devinit init_card(struct snd_usb_caiaqdev *dev) 391static int __devinit init_card(struct snd_usb_caiaqdev *dev)
384{ 392{
385 char *c; 393 char *c, usbpath[32];
386 struct usb_device *usb_dev = dev->chip.dev; 394 struct usb_device *usb_dev = dev->chip.dev;
387 struct snd_card *card = dev->chip.card; 395 struct snd_card *card = dev->chip.card;
388 int err, len; 396 int err, len;
389 397
390 if (usb_set_interface(usb_dev, 0, 1) != 0) { 398 if (usb_set_interface(usb_dev, 0, 1) != 0) {
391 log("can't set alt interface.\n"); 399 log("can't set alt interface.\n");
392 return -EIO; 400 return -EIO;
@@ -395,19 +403,19 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)
395 usb_init_urb(&dev->ep1_in_urb); 403 usb_init_urb(&dev->ep1_in_urb);
396 usb_init_urb(&dev->midi_out_urb); 404 usb_init_urb(&dev->midi_out_urb);
397 405
398 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, 406 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev,
399 usb_rcvbulkpipe(usb_dev, 0x1), 407 usb_rcvbulkpipe(usb_dev, 0x1),
400 dev->ep1_in_buf, EP1_BUFSIZE, 408 dev->ep1_in_buf, EP1_BUFSIZE,
401 usb_ep1_command_reply_dispatch, dev); 409 usb_ep1_command_reply_dispatch, dev);
402 410
403 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, 411 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev,
404 usb_sndbulkpipe(usb_dev, 0x1), 412 usb_sndbulkpipe(usb_dev, 0x1),
405 dev->midi_out_buf, EP1_BUFSIZE, 413 dev->midi_out_buf, EP1_BUFSIZE,
406 snd_usb_caiaq_midi_output_done, dev); 414 snd_usb_caiaq_midi_output_done, dev);
407 415
408 init_waitqueue_head(&dev->ep1_wait_queue); 416 init_waitqueue_head(&dev->ep1_wait_queue);
409 init_waitqueue_head(&dev->prepare_wait_queue); 417 init_waitqueue_head(&dev->prepare_wait_queue);
410 418
411 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) 419 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0)
412 return -EIO; 420 return -EIO;
413 421
@@ -420,47 +428,52 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)
420 428
421 usb_string(usb_dev, usb_dev->descriptor.iManufacturer, 429 usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
422 dev->vendor_name, CAIAQ_USB_STR_LEN); 430 dev->vendor_name, CAIAQ_USB_STR_LEN);
423 431
424 usb_string(usb_dev, usb_dev->descriptor.iProduct, 432 usb_string(usb_dev, usb_dev->descriptor.iProduct,
425 dev->product_name, CAIAQ_USB_STR_LEN); 433 dev->product_name, CAIAQ_USB_STR_LEN);
426 434
427 usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, 435 strlcpy(card->driver, MODNAME, sizeof(card->driver));
428 dev->serial, CAIAQ_USB_STR_LEN); 436 strlcpy(card->shortname, dev->product_name, sizeof(card->shortname));
429 437 strlcpy(card->mixername, dev->product_name, sizeof(card->mixername));
430 /* terminate serial string at first white space occurence */ 438
431 c = strchr(dev->serial, ' '); 439 /* if the id was not passed as module option, fill it with a shortened
432 if (c) 440 * version of the product string which does not contain any
433 *c = '\0'; 441 * whitespaces */
434 442
435 strcpy(card->driver, MODNAME); 443 if (*card->id == '\0') {
436 strcpy(card->shortname, dev->product_name); 444 char id[sizeof(card->id)];
437 445
438 len = snprintf(card->longname, sizeof(card->longname), 446 memset(id, 0, sizeof(id));
439 "%s %s (serial %s, ", 447
440 dev->vendor_name, dev->product_name, dev->serial); 448 for (c = card->shortname, len = 0;
441 449 *c && len < sizeof(card->id); c++)
442 if (len < sizeof(card->longname) - 2) 450 if (*c != ' ')
443 len += usb_make_path(usb_dev, card->longname + len, 451 id[len++] = *c;
444 sizeof(card->longname) - len); 452
445 453 snd_card_set_id(card, id);
446 card->longname[len++] = ')'; 454 }
447 card->longname[len] = '\0'; 455
456 usb_make_path(usb_dev, usbpath, sizeof(usbpath));
457 snprintf(card->longname, sizeof(card->longname),
458 "%s %s (%s)",
459 dev->vendor_name, dev->product_name, usbpath);
460
448 setup_card(dev); 461 setup_card(dev);
449 return 0; 462 return 0;
450} 463}
451 464
452static int __devinit snd_probe(struct usb_interface *intf, 465static int __devinit snd_probe(struct usb_interface *intf,
453 const struct usb_device_id *id) 466 const struct usb_device_id *id)
454{ 467{
455 int ret; 468 int ret;
456 struct snd_card *card; 469 struct snd_card *card;
457 struct usb_device *device = interface_to_usbdev(intf); 470 struct usb_device *device = interface_to_usbdev(intf);
458 471
459 ret = create_card(device, &card); 472 ret = create_card(device, intf, &card);
460 473
461 if (ret < 0) 474 if (ret < 0)
462 return ret; 475 return ret;
463 476
464 usb_set_intfdata(intf, card); 477 usb_set_intfdata(intf, card);
465 ret = init_card(caiaqdev(card)); 478 ret = init_card(caiaqdev(card));
466 if (ret < 0) { 479 if (ret < 0) {
@@ -468,7 +481,7 @@ static int __devinit snd_probe(struct usb_interface *intf,
468 snd_card_free(card); 481 snd_card_free(card);
469 return ret; 482 return ret;
470 } 483 }
471 484
472 return 0; 485 return 0;
473} 486}
474 487
@@ -489,10 +502,10 @@ static void snd_disconnect(struct usb_interface *intf)
489 snd_usb_caiaq_input_free(dev); 502 snd_usb_caiaq_input_free(dev);
490#endif 503#endif
491 snd_usb_caiaq_audio_free(dev); 504 snd_usb_caiaq_audio_free(dev);
492 505
493 usb_kill_urb(&dev->ep1_in_urb); 506 usb_kill_urb(&dev->ep1_in_urb);
494 usb_kill_urb(&dev->midi_out_urb); 507 usb_kill_urb(&dev->midi_out_urb);
495 508
496 snd_card_free(card); 509 snd_card_free(card);
497 usb_reset_device(interface_to_usbdev(intf)); 510 usb_reset_device(interface_to_usbdev(intf));
498} 511}