toneport.c (988d350aef30b798198e7915c574f82ba173f40f) toneport.c (85a9339becf0af4d547ceb6bb16d1893b05fbce4)
1/*
2 * Line6 Linux USB driver - 0.9.1beta
3 *
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
5 * Emil Myhrman (emil.myhrman@gmail.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
10 *
11 */
12
13#include <linux/wait.h>
14#include <linux/usb.h>
15#include <linux/slab.h>
16#include <linux/module.h>
17#include <sound/core.h>
18#include <sound/control.h>
19
1/*
2 * Line6 Linux USB driver - 0.9.1beta
3 *
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
5 * Emil Myhrman (emil.myhrman@gmail.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
10 *
11 */
12
13#include <linux/wait.h>
14#include <linux/usb.h>
15#include <linux/slab.h>
16#include <linux/module.h>
17#include <sound/core.h>
18#include <sound/control.h>
19
20#include "audio.h"
21#include "capture.h"
22#include "driver.h"
23#include "playback.h"
24#include "usbdefs.h"
25
26enum line6_device_type {
27 LINE6_GUITARPORT,
28 LINE6_PODSTUDIO_GX,

--- 297 unchanged lines hidden (view full) ---

326 .index = 0,
327 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
328 .info = snd_toneport_source_info,
329 .get = snd_toneport_source_get,
330 .put = snd_toneport_source_put
331};
332
333/*
20#include "capture.h"
21#include "driver.h"
22#include "playback.h"
23#include "usbdefs.h"
24
25enum line6_device_type {
26 LINE6_GUITARPORT,
27 LINE6_PODSTUDIO_GX,

--- 297 unchanged lines hidden (view full) ---

325 .index = 0,
326 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
327 .info = snd_toneport_source_info,
328 .get = snd_toneport_source_get,
329 .put = snd_toneport_source_put
330};
331
332/*
334 Toneport destructor.
335*/
336static void toneport_destruct(struct usb_interface *interface)
337{
338 struct usb_line6_toneport *toneport = usb_get_intfdata(interface);
339
340 if (toneport == NULL)
341 return;
342 line6_cleanup_audio(&toneport->line6);
343}
344
345/*
346 Setup Toneport device.
347*/
348static void toneport_setup(struct usb_line6_toneport *toneport)
349{
350 int ticks;
351 struct usb_line6 *line6 = &toneport->line6;
352 struct usb_device *usbdev = line6->usbdev;
353

--- 35 unchanged lines hidden (view full) ---

389 toneport = usb_get_intfdata(interface);
390 del_timer_sync(&toneport->timer);
391 idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
392
393 if (toneport_has_led(idProduct)) {
394 device_remove_file(&interface->dev, &dev_attr_led_red);
395 device_remove_file(&interface->dev, &dev_attr_led_green);
396 }
333 Setup Toneport device.
334*/
335static void toneport_setup(struct usb_line6_toneport *toneport)
336{
337 int ticks;
338 struct usb_line6 *line6 = &toneport->line6;
339 struct usb_device *usbdev = line6->usbdev;
340

--- 35 unchanged lines hidden (view full) ---

376 toneport = usb_get_intfdata(interface);
377 del_timer_sync(&toneport->timer);
378 idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
379
380 if (toneport_has_led(idProduct)) {
381 device_remove_file(&interface->dev, &dev_attr_led_red);
382 device_remove_file(&interface->dev, &dev_attr_led_green);
383 }
397
398 if (toneport != NULL) {
399 struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm;
400
401 if (line6pcm != NULL) {
402 line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
403 line6_pcm_disconnect(line6pcm);
404 }
405 }
406
407 toneport_destruct(interface);
408}
409
410
411/*
412 Try to init Toneport device.
413*/
384}
385
386
387/*
388 Try to init Toneport device.
389*/
414static int toneport_try_init(struct usb_interface *interface,
415 struct usb_line6 *line6)
390static int toneport_init(struct usb_interface *interface,
391 struct usb_line6 *line6)
416{
417 int err;
418 struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6;
419
420 if ((interface == NULL) || (toneport == NULL))
421 return -ENODEV;
422
423 line6->disconnect = line6_toneport_disconnect;
424
392{
393 int err;
394 struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6;
395
396 if ((interface == NULL) || (toneport == NULL))
397 return -ENODEV;
398
399 line6->disconnect = line6_toneport_disconnect;
400
425 /* initialize audio system: */
426 err = line6_init_audio(line6);
427 if (err < 0)
428 return err;
429
430 /* initialize PCM subsystem: */
431 err = line6_init_pcm(line6, &toneport_pcm_properties);
432 if (err < 0)
433 return err;
434
435 /* register monitor control: */
436 err = snd_ctl_add(line6->card,
437 snd_ctl_new1(&toneport_control_monitor,

--- 13 unchanged lines hidden (view full) ---

451 line6->line6pcm));
452 if (err < 0)
453 return err;
454
455 default:
456 break;
457 }
458
401 /* initialize PCM subsystem: */
402 err = line6_init_pcm(line6, &toneport_pcm_properties);
403 if (err < 0)
404 return err;
405
406 /* register monitor control: */
407 err = snd_ctl_add(line6->card,
408 snd_ctl_new1(&toneport_control_monitor,

--- 13 unchanged lines hidden (view full) ---

422 line6->line6pcm));
423 if (err < 0)
424 return err;
425
426 default:
427 break;
428 }
429
459 /* register audio system: */
460 err = line6_register_audio(line6);
461 if (err < 0)
462 return err;
463
464 line6_read_serial_number(line6, &toneport->serial_number);
465 line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
466
467 if (toneport_has_led(toneport->type)) {
468 CHECK_RETURN(device_create_file
469 (&interface->dev, &dev_attr_led_red));
470 CHECK_RETURN(device_create_file
471 (&interface->dev, &dev_attr_led_green));
472 }
473
474 toneport_setup(toneport);
475
476 setup_timer(&toneport->timer, toneport_start_pcm,
477 (unsigned long)toneport);
478 mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
479
430 line6_read_serial_number(line6, &toneport->serial_number);
431 line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
432
433 if (toneport_has_led(toneport->type)) {
434 CHECK_RETURN(device_create_file
435 (&interface->dev, &dev_attr_led_red));
436 CHECK_RETURN(device_create_file
437 (&interface->dev, &dev_attr_led_green));
438 }
439
440 toneport_setup(toneport);
441
442 setup_timer(&toneport->timer, toneport_start_pcm,
443 (unsigned long)toneport);
444 mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
445
480 return 0;
446 /* register audio system: */
447 return snd_card_register(line6->card);
481}
482
448}
449
483/*
484 Init Toneport device (and clean up in case of failure).
485*/
486static int toneport_init(struct usb_interface *interface,
487 struct usb_line6 *line6)
488{
489 int err = toneport_try_init(interface, line6);
490
491 if (err < 0)
492 toneport_destruct(interface);
493
494 return err;
495}
496
497#ifdef CONFIG_PM
498/*
499 Resume Toneport device after reset.
500*/
501static int toneport_reset_resume(struct usb_interface *interface)
502{
503 toneport_setup(usb_get_intfdata(interface));
504 return line6_resume(interface);

--- 85 unchanged lines hidden (view full) ---

590
591/*
592 Probe USB device.
593*/
594static int toneport_probe(struct usb_interface *interface,
595 const struct usb_device_id *id)
596{
597 struct usb_line6_toneport *toneport;
450#ifdef CONFIG_PM
451/*
452 Resume Toneport device after reset.
453*/
454static int toneport_reset_resume(struct usb_interface *interface)
455{
456 toneport_setup(usb_get_intfdata(interface));
457 return line6_resume(interface);

--- 85 unchanged lines hidden (view full) ---

543
544/*
545 Probe USB device.
546*/
547static int toneport_probe(struct usb_interface *interface,
548 const struct usb_device_id *id)
549{
550 struct usb_line6_toneport *toneport;
598 int err;
599
600 toneport = kzalloc(sizeof(*toneport), GFP_KERNEL);
601 if (!toneport)
602 return -ENODEV;
603 toneport->type = id->driver_info;
551
552 toneport = kzalloc(sizeof(*toneport), GFP_KERNEL);
553 if (!toneport)
554 return -ENODEV;
555 toneport->type = id->driver_info;
604 err = line6_probe(interface, &toneport->line6,
605 &toneport_properties_table[id->driver_info],
606 toneport_init);
607 if (err < 0)
608 kfree(toneport);
609 return err;
556 return line6_probe(interface, &toneport->line6,
557 &toneport_properties_table[id->driver_info],
558 toneport_init);
610}
611
612static struct usb_driver toneport_driver = {
613 .name = KBUILD_MODNAME,
614 .probe = toneport_probe,
615 .disconnect = line6_disconnect,
616#ifdef CONFIG_PM
617 .suspend = line6_suspend,
618 .resume = line6_resume,
619 .reset_resume = toneport_reset_resume,
620#endif
621 .id_table = toneport_id_table,
622};
623
624module_usb_driver(toneport_driver);
625
626MODULE_DESCRIPTION("TonePort USB driver");
627MODULE_LICENSE("GPL");
559}
560
561static struct usb_driver toneport_driver = {
562 .name = KBUILD_MODNAME,
563 .probe = toneport_probe,
564 .disconnect = line6_disconnect,
565#ifdef CONFIG_PM
566 .suspend = line6_suspend,
567 .resume = line6_resume,
568 .reset_resume = toneport_reset_resume,
569#endif
570 .id_table = toneport_id_table,
571};
572
573module_usb_driver(toneport_driver);
574
575MODULE_DESCRIPTION("TonePort USB driver");
576MODULE_LICENSE("GPL");