2009-02-27 20:43:04 -07:00
|
|
|
/*
|
2010-08-22 17:08:25 -06:00
|
|
|
* Line6 Linux USB driver - 0.9.1beta
|
2009-02-27 20:43:04 -07:00
|
|
|
*
|
2010-08-11 17:35:30 -06:00
|
|
|
* Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
|
2009-02-27 20:43:04 -07:00
|
|
|
*
|
|
|
|
* 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 cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2010-08-11 17:35:30 -06:00
|
|
|
#include <linux/usb.h>
|
2009-02-27 20:43:04 -07:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/rawmidi.h>
|
|
|
|
|
|
|
|
#include "audio.h"
|
2010-08-11 17:35:30 -06:00
|
|
|
#include "driver.h"
|
2009-02-27 20:43:04 -07:00
|
|
|
#include "midi.h"
|
|
|
|
#include "pod.h"
|
|
|
|
#include "usbdefs.h"
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
#define line6_rawmidi_substream_midi(substream) \
|
|
|
|
((struct snd_line6_midi *)((substream)->rmidi->private_data))
|
2009-02-27 20:43:04 -07:00
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
static int send_midi_async(struct usb_line6 *line6, unsigned char *data,
|
|
|
|
int length);
|
2009-02-27 20:43:04 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
Pass data received via USB to MIDI.
|
|
|
|
*/
|
2009-02-27 23:42:55 -07:00
|
|
|
void line6_midi_receive(struct usb_line6 *line6, unsigned char *data,
|
|
|
|
int length)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
2009-02-27 23:42:55 -07:00
|
|
|
if (line6->line6midi->substream_receive)
|
|
|
|
snd_rawmidi_receive(line6->line6midi->substream_receive,
|
|
|
|
data, length);
|
2009-02-27 20:43:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Read data from MIDI buffer and transmit them via USB.
|
|
|
|
*/
|
|
|
|
static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
2010-08-22 17:08:25 -06:00
|
|
|
struct usb_line6 *line6 =
|
|
|
|
line6_rawmidi_substream_midi(substream)->line6;
|
2009-02-27 20:43:04 -07:00
|
|
|
struct snd_line6_midi *line6midi = line6->line6midi;
|
|
|
|
struct MidiBuffer *mb = &line6midi->midibuf_out;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned char chunk[line6->max_packet_size];
|
|
|
|
int req, done;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&line6->line6midi->midi_transmit_lock, flags);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
for (;;) {
|
2010-08-11 17:35:30 -06:00
|
|
|
req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size);
|
2009-02-27 20:43:04 -07:00
|
|
|
done = snd_rawmidi_transmit_peek(substream, chunk, req);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (done == 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
break;
|
|
|
|
|
2010-08-11 17:35:30 -06:00
|
|
|
#ifdef CONFIG_LINE6_USB_DUMP_MIDI
|
2009-02-27 20:43:04 -07:00
|
|
|
line6_write_hexdump(line6, 's', chunk, done);
|
|
|
|
#endif
|
2010-08-11 17:35:30 -06:00
|
|
|
line6_midibuf_write(mb, chunk, done);
|
2009-02-27 20:43:04 -07:00
|
|
|
snd_rawmidi_transmit_ack(substream, done);
|
|
|
|
}
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
for (;;) {
|
2010-08-11 17:35:30 -06:00
|
|
|
done = line6_midibuf_read(mb, chunk, line6->max_packet_size);
|
2009-02-27 20:43:04 -07:00
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (done == 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
break;
|
|
|
|
|
2010-08-22 17:08:25 -06:00
|
|
|
if (line6_midibuf_skip_message
|
|
|
|
(mb, line6midi->midi_mask_transmit))
|
2009-02-27 20:43:04 -07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
send_midi_async(line6, chunk, done);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&line6->line6midi->midi_transmit_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Notification of completion of MIDI transmission.
|
|
|
|
*/
|
2009-02-27 21:28:04 -07:00
|
|
|
static void midi_sent(struct urb *urb)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int status;
|
|
|
|
int num;
|
|
|
|
struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
|
|
|
|
|
|
|
|
status = urb->status;
|
|
|
|
kfree(urb->transfer_buffer);
|
|
|
|
usb_free_urb(urb);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (status == -ESHUTDOWN)
|
2009-02-27 20:43:04 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags);
|
|
|
|
num = --line6->line6midi->num_active_send_urbs;
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (num == 0) {
|
2009-02-27 20:43:04 -07:00
|
|
|
line6_midi_transmit(line6->line6midi->substream_transmit);
|
|
|
|
num = line6->line6midi->num_active_send_urbs;
|
|
|
|
}
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (num == 0)
|
2010-08-11 17:35:30 -06:00
|
|
|
wake_up(&line6->line6midi->send_wait);
|
2009-02-27 20:43:04 -07:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Send an asynchronous MIDI message.
|
|
|
|
Assumes that line6->line6midi->send_urb_lock is held
|
|
|
|
(i.e., this function is serialized).
|
|
|
|
*/
|
2009-02-27 23:42:55 -07:00
|
|
|
static int send_midi_async(struct usb_line6 *line6, unsigned char *data,
|
|
|
|
int length)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
struct urb *urb;
|
|
|
|
int retval;
|
|
|
|
unsigned char *transfer_buffer;
|
|
|
|
|
|
|
|
urb = usb_alloc_urb(0, GFP_ATOMIC);
|
|
|
|
|
2010-12-07 15:38:02 -07:00
|
|
|
if (urb == NULL) {
|
2009-02-27 20:43:04 -07:00
|
|
|
dev_err(line6->ifcdev, "Out of memory\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2010-08-11 17:35:30 -06:00
|
|
|
#ifdef CONFIG_LINE6_USB_DUMP_CTRL
|
2009-02-27 20:43:04 -07:00
|
|
|
line6_write_hexdump(line6, 'S', data, length);
|
|
|
|
#endif
|
|
|
|
|
2011-11-08 12:40:26 -07:00
|
|
|
transfer_buffer = kmemdup(data, length, GFP_ATOMIC);
|
2009-02-27 20:43:04 -07:00
|
|
|
|
2010-12-07 15:38:02 -07:00
|
|
|
if (transfer_buffer == NULL) {
|
2009-02-27 20:43:04 -07:00
|
|
|
usb_free_urb(urb);
|
|
|
|
dev_err(line6->ifcdev, "Out of memory\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
usb_fill_int_urb(urb, line6->usbdev,
|
|
|
|
usb_sndbulkpipe(line6->usbdev,
|
|
|
|
line6->ep_control_write),
|
|
|
|
transfer_buffer, length, midi_sent, line6,
|
|
|
|
line6->interval);
|
2009-02-27 20:43:04 -07:00
|
|
|
urb->actual_length = 0;
|
|
|
|
retval = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (retval < 0) {
|
2009-02-27 20:43:04 -07:00
|
|
|
dev_err(line6->ifcdev, "usb_submit_urb failed\n");
|
|
|
|
usb_free_urb(urb);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
++line6->line6midi->num_active_send_urbs;
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
switch (line6->usbdev->descriptor.idProduct) {
|
2009-02-27 20:43:04 -07:00
|
|
|
case LINE6_DEVID_BASSPODXT:
|
|
|
|
case LINE6_DEVID_BASSPODXTLIVE:
|
|
|
|
case LINE6_DEVID_BASSPODXTPRO:
|
|
|
|
case LINE6_DEVID_PODXT:
|
|
|
|
case LINE6_DEVID_PODXTLIVE:
|
|
|
|
case LINE6_DEVID_PODXTPRO:
|
|
|
|
case LINE6_DEVID_POCKETPOD:
|
2010-08-11 17:35:30 -06:00
|
|
|
line6_pod_midi_postprocess((struct usb_line6_pod *)line6, data,
|
|
|
|
length);
|
2009-02-27 20:43:04 -07:00
|
|
|
break;
|
|
|
|
|
2010-08-22 17:08:25 -06:00
|
|
|
case LINE6_DEVID_VARIAX:
|
2011-11-23 01:20:43 -07:00
|
|
|
case LINE6_DEVID_PODHD300:
|
2011-12-05 15:51:53 -07:00
|
|
|
case LINE6_DEVID_PODHD500:
|
2010-08-22 17:08:25 -06:00
|
|
|
break;
|
|
|
|
|
2009-02-27 20:43:04 -07:00
|
|
|
default:
|
|
|
|
MISSING_CASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int line6_midi_output_open(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int line6_midi_output_close(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream,
|
|
|
|
int up)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2010-08-22 17:08:25 -06:00
|
|
|
struct usb_line6 *line6 =
|
|
|
|
line6_rawmidi_substream_midi(substream)->line6;
|
2009-02-27 20:43:04 -07:00
|
|
|
|
|
|
|
line6->line6midi->substream_transmit = substream;
|
|
|
|
spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (line6->line6midi->num_active_send_urbs == 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
line6_midi_transmit(substream);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void line6_midi_output_drain(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
2010-08-22 17:08:25 -06:00
|
|
|
struct usb_line6 *line6 =
|
|
|
|
line6_rawmidi_substream_midi(substream)->line6;
|
2010-08-11 17:35:30 -06:00
|
|
|
struct snd_line6_midi *midi = line6->line6midi;
|
2010-08-22 17:08:25 -06:00
|
|
|
wait_event_interruptible(midi->send_wait,
|
|
|
|
midi->num_active_send_urbs == 0);
|
2009-02-27 20:43:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int line6_midi_input_open(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int line6_midi_input_close(struct snd_rawmidi_substream *substream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
static void line6_midi_input_trigger(struct snd_rawmidi_substream *substream,
|
|
|
|
int up)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
2010-08-22 17:08:25 -06:00
|
|
|
struct usb_line6 *line6 =
|
|
|
|
line6_rawmidi_substream_midi(substream)->line6;
|
2009-02-27 20:43:04 -07:00
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (up)
|
2009-02-27 20:43:04 -07:00
|
|
|
line6->line6midi->substream_receive = substream;
|
|
|
|
else
|
|
|
|
line6->line6midi->substream_receive = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct snd_rawmidi_ops line6_midi_output_ops = {
|
|
|
|
.open = line6_midi_output_open,
|
|
|
|
.close = line6_midi_output_close,
|
|
|
|
.trigger = line6_midi_output_trigger,
|
|
|
|
.drain = line6_midi_output_drain,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_rawmidi_ops line6_midi_input_ops = {
|
|
|
|
.open = line6_midi_input_open,
|
|
|
|
.close = line6_midi_input_close,
|
|
|
|
.trigger = line6_midi_input_trigger,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Cleanup the Line6 MIDI device.
|
|
|
|
*/
|
|
|
|
static void line6_cleanup_midi(struct snd_rawmidi *rmidi)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a MIDI device */
|
|
|
|
static int snd_line6_new_midi(struct snd_line6_midi *line6midi)
|
|
|
|
{
|
|
|
|
struct snd_rawmidi *rmidi;
|
|
|
|
int err;
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
err = snd_rawmidi_new(line6midi->line6->card, "Line6 MIDI", 0, 1, 1,
|
|
|
|
&rmidi);
|
|
|
|
if (err < 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
|
|
|
|
|
|
|
rmidi->private_data = line6midi;
|
|
|
|
rmidi->private_free = line6_cleanup_midi;
|
2010-08-11 17:35:30 -06:00
|
|
|
strcpy(rmidi->id, line6midi->line6->properties->id);
|
2009-02-27 20:43:04 -07:00
|
|
|
strcpy(rmidi->name, line6midi->line6->properties->name);
|
|
|
|
|
|
|
|
rmidi->info_flags =
|
2010-08-22 17:08:25 -06:00
|
|
|
SNDRV_RAWMIDI_INFO_OUTPUT |
|
|
|
|
SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX;
|
2009-02-27 20:43:04 -07:00
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
|
|
|
|
&line6_midi_output_ops);
|
|
|
|
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
|
|
|
|
&line6_midi_input_ops);
|
2009-02-27 20:43:04 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
"read" request on "midi_mask_transmit" special file.
|
|
|
|
*/
|
2009-02-27 21:25:43 -07:00
|
|
|
static ssize_t midi_get_midi_mask_transmit(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
struct usb_interface *interface = to_usb_interface(dev);
|
|
|
|
struct usb_line6 *line6 = usb_get_intfdata(interface);
|
|
|
|
return sprintf(buf, "%d\n", line6->line6midi->midi_mask_transmit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
"write" request on "midi_mask" special file.
|
|
|
|
*/
|
2009-02-27 21:25:43 -07:00
|
|
|
static ssize_t midi_set_midi_mask_transmit(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
struct usb_interface *interface = to_usb_interface(dev);
|
|
|
|
struct usb_line6 *line6 = usb_get_intfdata(interface);
|
2011-12-05 02:09:25 -07:00
|
|
|
unsigned short value;
|
2009-11-15 21:18:02 -07:00
|
|
|
int ret;
|
|
|
|
|
2011-12-05 02:09:25 -07:00
|
|
|
ret = kstrtou16(buf, 10, &value);
|
2009-11-15 21:18:02 -07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2009-02-27 20:43:04 -07:00
|
|
|
line6->line6midi->midi_mask_transmit = value;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
"read" request on "midi_mask_receive" special file.
|
|
|
|
*/
|
2009-02-27 21:25:43 -07:00
|
|
|
static ssize_t midi_get_midi_mask_receive(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
struct usb_interface *interface = to_usb_interface(dev);
|
|
|
|
struct usb_line6 *line6 = usb_get_intfdata(interface);
|
|
|
|
return sprintf(buf, "%d\n", line6->line6midi->midi_mask_receive);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
"write" request on "midi_mask" special file.
|
|
|
|
*/
|
2009-02-27 21:25:43 -07:00
|
|
|
static ssize_t midi_set_midi_mask_receive(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-02-27 20:43:04 -07:00
|
|
|
{
|
|
|
|
struct usb_interface *interface = to_usb_interface(dev);
|
|
|
|
struct usb_line6 *line6 = usb_get_intfdata(interface);
|
2011-12-05 02:10:37 -07:00
|
|
|
unsigned short value;
|
2009-11-15 21:18:02 -07:00
|
|
|
int ret;
|
|
|
|
|
2011-12-05 02:10:37 -07:00
|
|
|
ret = kstrtou16(buf, 10, &value);
|
2009-11-15 21:18:02 -07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2009-02-27 20:43:04 -07:00
|
|
|
line6->line6midi->midi_mask_receive = value;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2010-11-18 12:21:04 -07:00
|
|
|
static DEVICE_ATTR(midi_mask_transmit, S_IWUSR | S_IRUGO,
|
2010-08-22 17:08:25 -06:00
|
|
|
midi_get_midi_mask_transmit, midi_set_midi_mask_transmit);
|
2010-11-18 12:21:04 -07:00
|
|
|
static DEVICE_ATTR(midi_mask_receive, S_IWUSR | S_IRUGO,
|
2010-08-22 17:08:25 -06:00
|
|
|
midi_get_midi_mask_receive, midi_set_midi_mask_receive);
|
2009-02-27 20:43:04 -07:00
|
|
|
|
|
|
|
/* MIDI device destructor */
|
|
|
|
static int snd_line6_midi_free(struct snd_device *device)
|
|
|
|
{
|
|
|
|
struct snd_line6_midi *line6midi = device->device_data;
|
2010-08-22 17:08:25 -06:00
|
|
|
device_remove_file(line6midi->line6->ifcdev,
|
|
|
|
&dev_attr_midi_mask_transmit);
|
|
|
|
device_remove_file(line6midi->line6->ifcdev,
|
|
|
|
&dev_attr_midi_mask_receive);
|
2010-08-11 17:35:30 -06:00
|
|
|
line6_midibuf_destroy(&line6midi->midibuf_in);
|
|
|
|
line6_midibuf_destroy(&line6midi->midibuf_out);
|
2009-02-27 20:43:04 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Initialize the Line6 MIDI subsystem.
|
|
|
|
*/
|
|
|
|
int line6_init_midi(struct usb_line6 *line6)
|
|
|
|
{
|
|
|
|
static struct snd_device_ops midi_ops = {
|
|
|
|
.dev_free = snd_line6_midi_free,
|
|
|
|
};
|
|
|
|
|
|
|
|
int err;
|
|
|
|
struct snd_line6_midi *line6midi;
|
|
|
|
|
2010-09-21 17:58:00 -06:00
|
|
|
if (!(line6->properties->capabilities & LINE6_BIT_CONTROL)) {
|
|
|
|
/* skip MIDI initialization and report success */
|
|
|
|
return 0;
|
|
|
|
}
|
2009-02-27 20:43:04 -07:00
|
|
|
|
|
|
|
line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
if (line6midi == NULL)
|
2009-02-27 20:43:04 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-08-11 17:35:30 -06:00
|
|
|
err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0);
|
2011-10-24 15:41:37 -06:00
|
|
|
if (err < 0) {
|
|
|
|
kfree(line6midi);
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
2011-10-24 15:41:37 -06:00
|
|
|
}
|
2009-02-27 20:43:04 -07:00
|
|
|
|
2010-08-11 17:35:30 -06:00
|
|
|
err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1);
|
2011-10-24 15:41:37 -06:00
|
|
|
if (err < 0) {
|
|
|
|
kfree(line6midi->midibuf_in.buf);
|
|
|
|
kfree(line6midi);
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
2011-10-24 15:41:37 -06:00
|
|
|
}
|
2009-02-27 20:43:04 -07:00
|
|
|
|
|
|
|
line6midi->line6 = line6;
|
2011-12-05 15:51:53 -07:00
|
|
|
|
2012-05-05 08:31:51 -06:00
|
|
|
switch (line6->product) {
|
2011-12-05 15:51:53 -07:00
|
|
|
case LINE6_DEVID_PODHD300:
|
|
|
|
case LINE6_DEVID_PODHD500:
|
|
|
|
line6midi->midi_mask_transmit = 1;
|
|
|
|
line6midi->midi_mask_receive = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
line6midi->midi_mask_transmit = 1;
|
|
|
|
line6midi->midi_mask_receive = 4;
|
|
|
|
}
|
|
|
|
|
2009-02-27 20:43:04 -07:00
|
|
|
line6->line6midi = line6midi;
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
err = snd_device_new(line6->card, SNDRV_DEV_RAWMIDI, line6midi,
|
|
|
|
&midi_ops);
|
|
|
|
if (err < 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
|
|
|
|
|
|
|
snd_card_set_dev(line6->card, line6->ifcdev);
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
err = snd_line6_new_midi(line6midi);
|
|
|
|
if (err < 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
err = device_create_file(line6->ifcdev, &dev_attr_midi_mask_transmit);
|
|
|
|
if (err < 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
|
|
|
|
2009-02-27 23:42:55 -07:00
|
|
|
err = device_create_file(line6->ifcdev, &dev_attr_midi_mask_receive);
|
|
|
|
if (err < 0)
|
2009-02-27 20:43:04 -07:00
|
|
|
return err;
|
|
|
|
|
|
|
|
init_waitqueue_head(&line6midi->send_wait);
|
|
|
|
spin_lock_init(&line6midi->send_urb_lock);
|
|
|
|
spin_lock_init(&line6midi->midi_transmit_lock);
|
|
|
|
return 0;
|
|
|
|
}
|