pod.c (988d350aef30b798198e7915c574f82ba173f40f) | pod.c (85a9339becf0af4d547ceb6bb16d1893b05fbce4) |
---|---|
1/* 2 * Line6 Linux USB driver - 0.9.1beta 3 * 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation, version 2. --- 4 unchanged lines hidden (view full) --- 13#include <linux/wait.h> 14#include <linux/interrupt.h> 15#include <linux/module.h> 16#include <linux/usb.h> 17 18#include <sound/core.h> 19#include <sound/control.h> 20 | 1/* 2 * Line6 Linux USB driver - 0.9.1beta 3 * 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation, version 2. --- 4 unchanged lines hidden (view full) --- 13#include <linux/wait.h> 14#include <linux/interrupt.h> 15#include <linux/module.h> 16#include <linux/usb.h> 17 18#include <sound/core.h> 19#include <sound/control.h> 20 |
21#include "audio.h" | |
22#include "capture.h" 23#include "driver.h" 24#include "playback.h" 25#include "usbdefs.h" 26 27/* 28 Locate name in binary program dump 29*/ --- 305 unchanged lines hidden (view full) --- 335 struct usb_line6 *line6 = &pod->line6; 336 337 CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_SETUP); 338 339 /* serial number: */ 340 line6_read_serial_number(&pod->line6, &pod->serial_number); 341 342 /* ALSA audio interface: */ | 21#include "capture.h" 22#include "driver.h" 23#include "playback.h" 24#include "usbdefs.h" 25 26/* 27 Locate name in binary program dump 28*/ --- 305 unchanged lines hidden (view full) --- 334 struct usb_line6 *line6 = &pod->line6; 335 336 CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_SETUP); 337 338 /* serial number: */ 339 line6_read_serial_number(&pod->line6, &pod->serial_number); 340 341 /* ALSA audio interface: */ |
343 line6_register_audio(line6); | 342 snd_card_register(line6->card); |
344} 345 346/* POD special files: */ 347static DEVICE_ATTR_RO(device_id); 348static DEVICE_ATTR_RO(firmware_version); 349static DEVICE_ATTR_RO(serial_number); 350 351/* control info callback */ --- 41 unchanged lines hidden (view full) --- 393 .index = 0, 394 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 395 .info = snd_pod_control_monitor_info, 396 .get = snd_pod_control_monitor_get, 397 .put = snd_pod_control_monitor_put 398}; 399 400/* | 343} 344 345/* POD special files: */ 346static DEVICE_ATTR_RO(device_id); 347static DEVICE_ATTR_RO(firmware_version); 348static DEVICE_ATTR_RO(serial_number); 349 350/* control info callback */ --- 41 unchanged lines hidden (view full) --- 392 .index = 0, 393 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 394 .info = snd_pod_control_monitor_info, 395 .get = snd_pod_control_monitor_get, 396 .put = snd_pod_control_monitor_put 397}; 398 399/* |
401 POD destructor. 402*/ 403static void pod_destruct(struct usb_interface *interface) 404{ 405 struct usb_line6_pod *pod = usb_get_intfdata(interface); 406 407 if (pod == NULL) 408 return; 409 line6_cleanup_audio(&pod->line6); 410 411 del_timer(&pod->startup_timer); 412 cancel_work_sync(&pod->startup_work); 413} 414 415/* | |
416 POD device disconnected. 417*/ 418static void line6_pod_disconnect(struct usb_interface *interface) 419{ 420 struct usb_line6_pod *pod; 421 422 if (interface == NULL) 423 return; 424 pod = usb_get_intfdata(interface); 425 426 if (pod != NULL) { | 400 POD device disconnected. 401*/ 402static void line6_pod_disconnect(struct usb_interface *interface) 403{ 404 struct usb_line6_pod *pod; 405 406 if (interface == NULL) 407 return; 408 pod = usb_get_intfdata(interface); 409 410 if (pod != NULL) { |
427 struct snd_line6_pcm *line6pcm = pod->line6.line6pcm; | |
428 struct device *dev = &interface->dev; 429 | 411 struct device *dev = &interface->dev; 412 |
430 if (line6pcm != NULL) 431 line6_pcm_disconnect(line6pcm); 432 | |
433 if (dev != NULL) { 434 /* remove sysfs entries: */ 435 device_remove_file(dev, &dev_attr_device_id); 436 device_remove_file(dev, &dev_attr_firmware_version); 437 device_remove_file(dev, &dev_attr_serial_number); 438 } | 413 if (dev != NULL) { 414 /* remove sysfs entries: */ 415 device_remove_file(dev, &dev_attr_device_id); 416 device_remove_file(dev, &dev_attr_firmware_version); 417 device_remove_file(dev, &dev_attr_serial_number); 418 } |
439 } | |
440 | 419 |
441 pod_destruct(interface); | 420 del_timer_sync(&pod->startup_timer); 421 cancel_work_sync(&pod->startup_work); 422 } |
442} 443 444/* 445 Create sysfs entries. 446*/ 447static int pod_create_files2(struct device *dev) 448{ 449 int err; 450 451 CHECK_RETURN(device_create_file(dev, &dev_attr_device_id)); 452 CHECK_RETURN(device_create_file(dev, &dev_attr_firmware_version)); 453 CHECK_RETURN(device_create_file(dev, &dev_attr_serial_number)); 454 return 0; 455} 456 457/* 458 Try to init POD device. 459*/ | 423} 424 425/* 426 Create sysfs entries. 427*/ 428static int pod_create_files2(struct device *dev) 429{ 430 int err; 431 432 CHECK_RETURN(device_create_file(dev, &dev_attr_device_id)); 433 CHECK_RETURN(device_create_file(dev, &dev_attr_firmware_version)); 434 CHECK_RETURN(device_create_file(dev, &dev_attr_serial_number)); 435 return 0; 436} 437 438/* 439 Try to init POD device. 440*/ |
460static int pod_try_init(struct usb_interface *interface, 461 struct usb_line6 *line6) | 441static int pod_init(struct usb_interface *interface, 442 struct usb_line6 *line6) |
462{ 463 int err; 464 struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; 465 466 line6->process_message = line6_pod_process_message; 467 line6->disconnect = line6_pod_disconnect; 468 469 init_timer(&pod->startup_timer); 470 INIT_WORK(&pod->startup_work, pod_startup4); 471 472 if ((interface == NULL) || (pod == NULL)) 473 return -ENODEV; 474 475 /* create sysfs entries: */ 476 err = pod_create_files2(&interface->dev); 477 if (err < 0) 478 return err; 479 | 443{ 444 int err; 445 struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; 446 447 line6->process_message = line6_pod_process_message; 448 line6->disconnect = line6_pod_disconnect; 449 450 init_timer(&pod->startup_timer); 451 INIT_WORK(&pod->startup_work, pod_startup4); 452 453 if ((interface == NULL) || (pod == NULL)) 454 return -ENODEV; 455 456 /* create sysfs entries: */ 457 err = pod_create_files2(&interface->dev); 458 if (err < 0) 459 return err; 460 |
480 /* initialize audio system: */ 481 err = line6_init_audio(line6); 482 if (err < 0) 483 return err; 484 | |
485 /* initialize MIDI subsystem: */ 486 err = line6_init_midi(line6); 487 if (err < 0) 488 return err; 489 490 /* initialize PCM subsystem: */ 491 err = line6_init_pcm(line6, &pod_pcm_properties); 492 if (err < 0) --- 16 unchanged lines hidden (view full) --- 509 510 /* initiate startup procedure: */ 511 pod_startup1(pod); 512 } 513 514 return 0; 515} 516 | 461 /* initialize MIDI subsystem: */ 462 err = line6_init_midi(line6); 463 if (err < 0) 464 return err; 465 466 /* initialize PCM subsystem: */ 467 err = line6_init_pcm(line6, &pod_pcm_properties); 468 if (err < 0) --- 16 unchanged lines hidden (view full) --- 485 486 /* initiate startup procedure: */ 487 pod_startup1(pod); 488 } 489 490 return 0; 491} 492 |
517/* 518 Init POD device (and clean up in case of failure). 519*/ 520static int pod_init(struct usb_interface *interface, 521 struct usb_line6 *line6) 522{ 523 int err = pod_try_init(interface, line6); 524 525 if (err < 0) 526 pod_destruct(interface); 527 528 return err; 529} 530 | |
531#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) 532#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) 533 534/* table of devices that work with this driver */ 535static const struct usb_device_id pod_id_table[] = { 536 { LINE6_DEVICE(0x4250), .driver_info = LINE6_BASSPODXT }, 537 { LINE6_DEVICE(0x4642), .driver_info = LINE6_BASSPODXTLIVE }, 538 { LINE6_DEVICE(0x4252), .driver_info = LINE6_BASSPODXTPRO }, --- 92 unchanged lines hidden (view full) --- 631 632/* 633 Probe USB device. 634*/ 635static int pod_probe(struct usb_interface *interface, 636 const struct usb_device_id *id) 637{ 638 struct usb_line6_pod *pod; | 493#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) 494#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) 495 496/* table of devices that work with this driver */ 497static const struct usb_device_id pod_id_table[] = { 498 { LINE6_DEVICE(0x4250), .driver_info = LINE6_BASSPODXT }, 499 { LINE6_DEVICE(0x4642), .driver_info = LINE6_BASSPODXTLIVE }, 500 { LINE6_DEVICE(0x4252), .driver_info = LINE6_BASSPODXTPRO }, --- 92 unchanged lines hidden (view full) --- 593 594/* 595 Probe USB device. 596*/ 597static int pod_probe(struct usb_interface *interface, 598 const struct usb_device_id *id) 599{ 600 struct usb_line6_pod *pod; |
639 int err; | |
640 641 pod = kzalloc(sizeof(*pod), GFP_KERNEL); 642 if (!pod) 643 return -ENODEV; | 601 602 pod = kzalloc(sizeof(*pod), GFP_KERNEL); 603 if (!pod) 604 return -ENODEV; |
644 err = line6_probe(interface, &pod->line6, 645 &pod_properties_table[id->driver_info], 646 pod_init); 647 if (err < 0) 648 kfree(pod); 649 return err; | 605 return line6_probe(interface, &pod->line6, 606 &pod_properties_table[id->driver_info], 607 pod_init); |
650} 651 652static struct usb_driver pod_driver = { 653 .name = KBUILD_MODNAME, 654 .probe = pod_probe, 655 .disconnect = line6_disconnect, 656#ifdef CONFIG_PM 657 .suspend = line6_suspend, 658 .resume = line6_resume, 659 .reset_resume = line6_resume, 660#endif 661 .id_table = pod_id_table, 662}; 663 664module_usb_driver(pod_driver); 665 666MODULE_DESCRIPTION("Line6 POD USB driver"); 667MODULE_LICENSE("GPL"); | 608} 609 610static struct usb_driver pod_driver = { 611 .name = KBUILD_MODNAME, 612 .probe = pod_probe, 613 .disconnect = line6_disconnect, 614#ifdef CONFIG_PM 615 .suspend = line6_suspend, 616 .resume = line6_resume, 617 .reset_resume = line6_resume, 618#endif 619 .id_table = pod_id_table, 620}; 621 622module_usb_driver(pod_driver); 623 624MODULE_DESCRIPTION("Line6 POD USB driver"); 625MODULE_LICENSE("GPL"); |