snd-usb-line6-y := \
- audio.o \
capture.o \
driver.o \
midi.o \
+++ /dev/null
-/*
- * Line6 Linux USB driver - 0.9.1beta
- *
- * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, version 2.
- *
- */
-
-#include <sound/core.h>
-#include <sound/initval.h>
-#include <linux/export.h>
-
-#include "driver.h"
-#include "audio.h"
-
-/*
- Initialize the Line6 USB audio system.
-*/
-int line6_init_audio(struct usb_line6 *line6)
-{
- struct snd_card *card;
- int err;
-
- err = snd_card_new(line6->ifcdev,
- SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
- THIS_MODULE, 0, &card);
- if (err < 0)
- return err;
-
- line6->card = card;
-
- strcpy(card->id, line6->properties->id);
- strcpy(card->driver, DRIVER_NAME);
- strcpy(card->shortname, line6->properties->name);
- /* longname is 80 chars - see asound.h */
- sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
- dev_name(line6->ifcdev));
- return 0;
-}
-EXPORT_SYMBOL_GPL(line6_init_audio);
-
-/*
- Register the Line6 USB audio system.
-*/
-int line6_register_audio(struct usb_line6 *line6)
-{
- int err;
-
- err = snd_card_register(line6->card);
- if (err < 0)
- return err;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(line6_register_audio);
-
-/*
- Cleanup the Line6 USB audio system.
-*/
-void line6_cleanup_audio(struct usb_line6 *line6)
-{
- struct snd_card *card = line6->card;
-
- if (card == NULL)
- return;
-
- snd_card_disconnect(card);
- snd_card_free(card);
- line6->card = NULL;
-}
-EXPORT_SYMBOL_GPL(line6_cleanup_audio);
+++ /dev/null
-/*
- * Line6 Linux USB driver - 0.9.1beta
- *
- * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, version 2.
- *
- */
-
-#ifndef AUDIO_H
-#define AUDIO_H
-
-#include "driver.h"
-
-extern void line6_cleanup_audio(struct usb_line6 *);
-extern int line6_init_audio(struct usb_line6 *);
-extern int line6_register_audio(struct usb_line6 *);
-
-#endif
#include <sound/pcm.h>
#include <sound/pcm_params.h>
-#include "audio.h"
#include "capture.h"
#include "driver.h"
#include "pcm.h"
#include <linux/slab.h>
#include <linux/usb.h>
-#include "audio.h"
+#include <sound/core.h>
+#include <sound/initval.h>
+
#include "capture.h"
#include "driver.h"
#include "midi.h"
EXPORT_SYMBOL_GPL(line6_nop_read);
/*
- Generic destructor.
+ Card destructor.
*/
-static void line6_destruct(struct usb_interface *interface)
+static void line6_destruct(struct snd_card *card)
{
- struct usb_line6 *line6;
+ struct usb_line6 *line6 = card->private_data;
+ struct usb_device *usbdev;
- if (interface == NULL)
- return;
- line6 = usb_get_intfdata(interface);
- if (line6 == NULL)
+ if (!line6)
return;
+ usbdev = line6->usbdev;
/* free buffer memory first: */
kfree(line6->buffer_message);
/* then free URBs: */
usb_free_urb(line6->urb_listen);
- /* make sure the device isn't destructed twice: */
- usb_set_intfdata(interface, NULL);
+ /* free interface data: */
+ kfree(line6);
+
+ /* decrement reference counters: */
+ usb_put_dev(usbdev);
}
/*
int (*private_init)(struct usb_interface *, struct usb_line6 *))
{
struct usb_device *usbdev;
+ struct snd_card *card;
int interface_number;
int ret;
}
}
+ ret = snd_card_new(line6->ifcdev,
+ SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+ THIS_MODULE, 0, &card);
+ if (ret < 0)
+ goto err_put;
+
+ line6->card = card;
+ strcpy(card->id, line6->properties->id);
+ strcpy(card->driver, DRIVER_NAME);
+ strcpy(card->shortname, line6->properties->name);
+ sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
+ dev_name(line6->ifcdev));
+ card->private_data = line6;
+ card->private_free = line6_destruct;
+
usb_set_intfdata(interface, line6);
+ /* increment reference counters: */
+ usb_get_dev(usbdev);
+
if (properties->capabilities & LINE6_CAP_CONTROL) {
/* initialize USB buffers: */
line6->buffer_listen =
dev_info(&interface->dev, "Line6 %s now attached\n",
line6->properties->name);
- /* increment reference counters: */
- usb_get_intf(interface);
- usb_get_dev(usbdev);
-
return 0;
-err_destruct:
- line6_destruct(interface);
-err_put:
+ err_destruct:
+ snd_card_free(card);
+ err_put:
return ret;
}
EXPORT_SYMBOL_GPL(line6_probe);
interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
line6 = usb_get_intfdata(interface);
+ if (!line6)
+ return;
- if (line6 != NULL) {
- if (line6->urb_listen != NULL)
- line6_stop_listen(line6);
+ if (line6->urb_listen != NULL)
+ line6_stop_listen(line6);
- if (usbdev != line6->usbdev)
- dev_err(line6->ifcdev,
- "driver bug: inconsistent usb device\n");
+ if (usbdev != line6->usbdev)
+ dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n");
+ snd_card_disconnect(line6->card);
+ if (line6->disconnect)
line6->disconnect(interface);
- dev_info(&interface->dev, "Line6 %s now disconnected\n",
- line6->properties->name);
- }
-
- line6_destruct(interface);
+ dev_info(&interface->dev, "Line6 %s now disconnected\n",
+ line6->properties->name);
- /* free interface data: */
- kfree(line6);
+ /* make sure the device isn't destructed twice: */
+ usb_set_intfdata(interface, NULL);
- /* decrement reference counters: */
- usb_put_intf(interface);
- usb_put_dev(usbdev);
+ snd_card_free_when_closed(line6->card);
}
EXPORT_SYMBOL_GPL(line6_disconnect);
#include <sound/core.h>
#include <sound/rawmidi.h>
-#include "audio.h"
#include "driver.h"
#include "midi.h"
#include "usbdefs.h"
#include <sound/pcm.h>
#include <sound/pcm_params.h>
-#include "audio.h"
#include "capture.h"
#include "driver.h"
#include "playback.h"
#include <sound/pcm.h>
#include <sound/pcm_params.h>
-#include "audio.h"
#include "capture.h"
#include "driver.h"
#include "pcm.h"
#include <sound/core.h>
#include <sound/control.h>
-#include "audio.h"
#include "capture.h"
#include "driver.h"
#include "playback.h"
line6_read_serial_number(&pod->line6, &pod->serial_number);
/* ALSA audio interface: */
- line6_register_audio(line6);
+ snd_card_register(line6->card);
}
/* POD special files: */
.put = snd_pod_control_monitor_put
};
-/*
- POD destructor.
-*/
-static void pod_destruct(struct usb_interface *interface)
-{
- struct usb_line6_pod *pod = usb_get_intfdata(interface);
-
- if (pod == NULL)
- return;
- line6_cleanup_audio(&pod->line6);
-
- del_timer(&pod->startup_timer);
- cancel_work_sync(&pod->startup_work);
-}
-
/*
POD device disconnected.
*/
pod = usb_get_intfdata(interface);
if (pod != NULL) {
- struct snd_line6_pcm *line6pcm = pod->line6.line6pcm;
struct device *dev = &interface->dev;
- if (line6pcm != NULL)
- line6_pcm_disconnect(line6pcm);
-
if (dev != NULL) {
/* remove sysfs entries: */
device_remove_file(dev, &dev_attr_device_id);
device_remove_file(dev, &dev_attr_firmware_version);
device_remove_file(dev, &dev_attr_serial_number);
}
- }
- pod_destruct(interface);
+ del_timer_sync(&pod->startup_timer);
+ cancel_work_sync(&pod->startup_work);
+ }
}
/*
/*
Try to init POD device.
*/
-static int pod_try_init(struct usb_interface *interface,
- struct usb_line6 *line6)
+static int pod_init(struct usb_interface *interface,
+ struct usb_line6 *line6)
{
int err;
struct usb_line6_pod *pod = (struct usb_line6_pod *) line6;
if (err < 0)
return err;
- /* initialize audio system: */
- err = line6_init_audio(line6);
- if (err < 0)
- return err;
-
/* initialize MIDI subsystem: */
err = line6_init_midi(line6);
if (err < 0)
return 0;
}
-/*
- Init POD device (and clean up in case of failure).
-*/
-static int pod_init(struct usb_interface *interface,
- struct usb_line6 *line6)
-{
- int err = pod_try_init(interface, line6);
-
- if (err < 0)
- pod_destruct(interface);
-
- return err;
-}
-
#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod)
#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n)
const struct usb_device_id *id)
{
struct usb_line6_pod *pod;
- int err;
pod = kzalloc(sizeof(*pod), GFP_KERNEL);
if (!pod)
return -ENODEV;
- err = line6_probe(interface, &pod->line6,
- &pod_properties_table[id->driver_info],
- pod_init);
- if (err < 0)
- kfree(pod);
- return err;
+ return line6_probe(interface, &pod->line6,
+ &pod_properties_table[id->driver_info],
+ pod_init);
}
static struct usb_driver pod_driver = {
#include <sound/core.h>
#include <sound/pcm.h>
-#include "audio.h"
#include "driver.h"
#include "pcm.h"
#include "usbdefs.h"
.bytes_per_frame = PODHD_BYTES_PER_FRAME
};
-/*
- POD HD destructor.
-*/
-static void podhd_destruct(struct usb_interface *interface)
-{
- struct usb_line6_podhd *podhd = usb_get_intfdata(interface);
-
- if (podhd == NULL)
- return;
- line6_cleanup_audio(&podhd->line6);
-}
-
-/*
- POD HD device disconnected.
-*/
-static void line6_podhd_disconnect(struct usb_interface *interface)
-{
- struct usb_line6_podhd *podhd;
-
- if (interface == NULL)
- return;
- podhd = usb_get_intfdata(interface);
-
- if (podhd != NULL) {
- struct snd_line6_pcm *line6pcm = podhd->line6.line6pcm;
-
- if (line6pcm != NULL)
- line6_pcm_disconnect(line6pcm);
- }
-
- podhd_destruct(interface);
-}
-
/*
Try to init POD HD device.
*/
-static int podhd_try_init(struct usb_interface *interface,
- struct usb_line6_podhd *podhd)
+static int podhd_init(struct usb_interface *interface,
+ struct usb_line6 *line6)
{
+ struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6;
int err;
- struct usb_line6 *line6 = &podhd->line6;
if ((interface == NULL) || (podhd == NULL))
return -ENODEV;
- line6->disconnect = line6_podhd_disconnect;
-
- /* initialize audio system: */
- err = line6_init_audio(line6);
- if (err < 0)
- return err;
-
/* initialize MIDI subsystem: */
err = line6_init_midi(line6);
if (err < 0)
return err;
/* register USB audio system: */
- err = line6_register_audio(line6);
- return err;
+ return snd_card_register(line6->card);
}
#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod)
},
};
-/*
- Init POD HD device (and clean up in case of failure).
-*/
-static int podhd_init(struct usb_interface *interface,
- struct usb_line6 *line6)
-{
- struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6;
- int err = podhd_try_init(interface, podhd);
-
- if (err < 0)
- podhd_destruct(interface);
-
- return err;
-}
-
/*
Probe USB device.
*/
const struct usb_device_id *id)
{
struct usb_line6_podhd *podhd;
- int err;
podhd = kzalloc(sizeof(*podhd), GFP_KERNEL);
if (!podhd)
return -ENODEV;
- err = line6_probe(interface, &podhd->line6,
- &podhd_properties_table[id->driver_info],
- podhd_init);
- if (err < 0)
- kfree(podhd);
- return err;
+ return line6_probe(interface, &podhd->line6,
+ &podhd_properties_table[id->driver_info],
+ podhd_init);
}
static struct usb_driver podhd_driver = {
#include <sound/core.h>
#include <sound/control.h>
-#include "audio.h"
#include "capture.h"
#include "driver.h"
#include "playback.h"
.put = snd_toneport_source_put
};
-/*
- Toneport destructor.
-*/
-static void toneport_destruct(struct usb_interface *interface)
-{
- struct usb_line6_toneport *toneport = usb_get_intfdata(interface);
-
- if (toneport == NULL)
- return;
- line6_cleanup_audio(&toneport->line6);
-}
-
/*
Setup Toneport device.
*/
device_remove_file(&interface->dev, &dev_attr_led_red);
device_remove_file(&interface->dev, &dev_attr_led_green);
}
-
- if (toneport != NULL) {
- struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm;
-
- if (line6pcm != NULL) {
- line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
- line6_pcm_disconnect(line6pcm);
- }
- }
-
- toneport_destruct(interface);
}
/*
Try to init Toneport device.
*/
-static int toneport_try_init(struct usb_interface *interface,
- struct usb_line6 *line6)
+static int toneport_init(struct usb_interface *interface,
+ struct usb_line6 *line6)
{
int err;
struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6;
line6->disconnect = line6_toneport_disconnect;
- /* initialize audio system: */
- err = line6_init_audio(line6);
- if (err < 0)
- return err;
-
/* initialize PCM subsystem: */
err = line6_init_pcm(line6, &toneport_pcm_properties);
if (err < 0)
break;
}
- /* register audio system: */
- err = line6_register_audio(line6);
- if (err < 0)
- return err;
-
line6_read_serial_number(line6, &toneport->serial_number);
line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
(unsigned long)toneport);
mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
- return 0;
-}
-
-/*
- Init Toneport device (and clean up in case of failure).
-*/
-static int toneport_init(struct usb_interface *interface,
- struct usb_line6 *line6)
-{
- int err = toneport_try_init(interface, line6);
-
- if (err < 0)
- toneport_destruct(interface);
-
- return err;
+ /* register audio system: */
+ return snd_card_register(line6->card);
}
#ifdef CONFIG_PM
const struct usb_device_id *id)
{
struct usb_line6_toneport *toneport;
- int err;
toneport = kzalloc(sizeof(*toneport), GFP_KERNEL);
if (!toneport)
return -ENODEV;
toneport->type = id->driver_info;
- err = line6_probe(interface, &toneport->line6,
- &toneport_properties_table[id->driver_info],
- toneport_init);
- if (err < 0)
- kfree(toneport);
- return err;
+ return line6_probe(interface, &toneport->line6,
+ &toneport_properties_table[id->driver_info],
+ toneport_init);
}
static struct usb_driver toneport_driver = {
#include <linux/module.h>
#include <sound/core.h>
-#include "audio.h"
#include "driver.h"
#include "usbdefs.h"
CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP);
/* ALSA audio interface: */
- line6_register_audio(&variax->line6);
+ snd_card_register(variax->line6.card);
}
/*
/*
Variax destructor.
*/
-static void variax_destruct(struct usb_interface *interface)
+static void line6_variax_disconnect(struct usb_interface *interface)
{
- struct usb_line6_variax *variax = usb_get_intfdata(interface);
+ struct usb_line6_variax *variax;
+
+ if (!interface)
+ return;
- if (variax == NULL)
+ variax = usb_get_intfdata(interface);
+ if (!variax)
return;
- line6_cleanup_audio(&variax->line6);
del_timer(&variax->startup_timer1);
del_timer(&variax->startup_timer2);
kfree(variax->buffer_activate);
}
-/*
- Workbench device disconnected.
-*/
-static void line6_variax_disconnect(struct usb_interface *interface)
-{
- if (interface == NULL)
- return;
-
- variax_destruct(interface);
-}
-
/*
Try to init workbench device.
*/
-static int variax_try_init(struct usb_interface *interface,
- struct usb_line6 *line6)
+static int variax_init(struct usb_interface *interface,
+ struct usb_line6 *line6)
{
struct usb_line6_variax *variax = (struct usb_line6_variax *) line6;
int err;
if (variax->buffer_activate == NULL)
return -ENOMEM;
- /* initialize audio system: */
- err = line6_init_audio(&variax->line6);
- if (err < 0)
- return err;
-
/* initialize MIDI subsystem: */
err = line6_init_midi(&variax->line6);
if (err < 0)
return 0;
}
-/*
- Init workbench device (and clean up in case of failure).
-*/
-static int variax_init(struct usb_interface *interface,
- struct usb_line6 *line6)
-{
- int err = variax_try_init(interface, line6);
-
- if (err < 0)
- variax_destruct(interface);
-
- return err;
-}
-
#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod)
#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n)
const struct usb_device_id *id)
{
struct usb_line6_variax *variax;
- int err;
variax = kzalloc(sizeof(*variax), GFP_KERNEL);
if (!variax)
return -ENODEV;
- err = line6_probe(interface, &variax->line6,
- &variax_properties_table[id->driver_info],
- variax_init);
- if (err < 0)
- kfree(variax);
- return err;
+ return line6_probe(interface, &variax->line6,
+ &variax_properties_table[id->driver_info],
+ variax_init);
}
static struct usb_driver variax_driver = {