Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 1 | /* |
Chris Rorvick | c078a4a | 2015-01-20 02:20:50 -0600 | [diff] [blame] | 2 | * Line 6 Linux USB driver |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 3 | * |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 4 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 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. |
| 9 | * |
| 10 | */ |
| 11 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 13 | #include <linux/usb.h> |
Takashi Iwai | ccddbe4 | 2015-01-15 08:22:31 +0100 | [diff] [blame] | 14 | #include <linux/export.h> |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 15 | #include <sound/core.h> |
| 16 | #include <sound/rawmidi.h> |
| 17 | |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 18 | #include "driver.h" |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 19 | #include "midi.h" |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 20 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 21 | #define line6_rawmidi_substream_midi(substream) \ |
| 22 | ((struct snd_line6_midi *)((substream)->rmidi->private_data)) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 23 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 24 | static int send_midi_async(struct usb_line6 *line6, unsigned char *data, |
| 25 | int length); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 26 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 27 | /* |
| 28 | Pass data received via USB to MIDI. |
| 29 | */ |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 30 | void line6_midi_receive(struct usb_line6 *line6, unsigned char *data, |
| 31 | int length) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 32 | { |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 33 | if (line6->line6midi->substream_receive) |
| 34 | snd_rawmidi_receive(line6->line6midi->substream_receive, |
| 35 | data, length); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /* |
| 39 | Read data from MIDI buffer and transmit them via USB. |
| 40 | */ |
| 41 | static void line6_midi_transmit(struct snd_rawmidi_substream *substream) |
| 42 | { |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 43 | struct usb_line6 *line6 = |
| 44 | line6_rawmidi_substream_midi(substream)->line6; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 45 | struct snd_line6_midi *line6midi = line6->line6midi; |
Stefan Hajnoczi | 269edc8 | 2013-01-11 23:08:09 +0100 | [diff] [blame] | 46 | struct midi_buffer *mb = &line6midi->midibuf_out; |
Himangi Saraogi | f245920 | 2014-03-09 05:47:12 +0530 | [diff] [blame] | 47 | unsigned char chunk[LINE6_FALLBACK_MAXPACKETSIZE]; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 48 | int req, done; |
| 49 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 50 | for (;;) { |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 51 | req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 52 | done = snd_rawmidi_transmit_peek(substream, chunk, req); |
| 53 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 54 | if (done == 0) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 55 | break; |
| 56 | |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 57 | line6_midibuf_write(mb, chunk, done); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 58 | snd_rawmidi_transmit_ack(substream, done); |
| 59 | } |
| 60 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 61 | for (;;) { |
Gulsah Kose | 6461900 | 2014-03-15 23:54:42 +0200 | [diff] [blame] | 62 | done = line6_midibuf_read(mb, chunk, |
| 63 | LINE6_FALLBACK_MAXPACKETSIZE); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 64 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 65 | if (done == 0) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 66 | break; |
| 67 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 68 | send_midi_async(line6, chunk, done); |
| 69 | } |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /* |
| 73 | Notification of completion of MIDI transmission. |
| 74 | */ |
Greg Kroah-Hartman | 0c7ab15 | 2009-02-27 20:28:04 -0800 | [diff] [blame] | 75 | static void midi_sent(struct urb *urb) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 76 | { |
| 77 | unsigned long flags; |
| 78 | int status; |
| 79 | int num; |
| 80 | struct usb_line6 *line6 = (struct usb_line6 *)urb->context; |
| 81 | |
| 82 | status = urb->status; |
| 83 | kfree(urb->transfer_buffer); |
| 84 | usb_free_urb(urb); |
| 85 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 86 | if (status == -ESHUTDOWN) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 87 | return; |
| 88 | |
Takashi Iwai | bc518ba | 2015-01-23 12:39:11 +0100 | [diff] [blame] | 89 | spin_lock_irqsave(&line6->line6midi->lock, flags); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 90 | num = --line6->line6midi->num_active_send_urbs; |
| 91 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 92 | if (num == 0) { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 93 | line6_midi_transmit(line6->line6midi->substream_transmit); |
| 94 | num = line6->line6midi->num_active_send_urbs; |
| 95 | } |
| 96 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 97 | if (num == 0) |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 98 | wake_up(&line6->line6midi->send_wait); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 99 | |
Takashi Iwai | bc518ba | 2015-01-23 12:39:11 +0100 | [diff] [blame] | 100 | spin_unlock_irqrestore(&line6->line6midi->lock, flags); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | /* |
| 104 | Send an asynchronous MIDI message. |
Takashi Iwai | bc518ba | 2015-01-23 12:39:11 +0100 | [diff] [blame] | 105 | Assumes that line6->line6midi->lock is held |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 106 | (i.e., this function is serialized). |
| 107 | */ |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 108 | static int send_midi_async(struct usb_line6 *line6, unsigned char *data, |
| 109 | int length) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 110 | { |
| 111 | struct urb *urb; |
| 112 | int retval; |
| 113 | unsigned char *transfer_buffer; |
| 114 | |
| 115 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
| 116 | |
Takashi Iwai | a019f5e | 2015-01-19 15:05:10 +0100 | [diff] [blame] | 117 | if (urb == NULL) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 118 | return -ENOMEM; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 119 | |
Thomas Meyer | cff8638 | 2011-11-08 20:40:26 +0100 | [diff] [blame] | 120 | transfer_buffer = kmemdup(data, length, GFP_ATOMIC); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 121 | |
Peter Huewe | 597a1e7 | 2010-12-07 23:38:02 +0100 | [diff] [blame] | 122 | if (transfer_buffer == NULL) { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 123 | usb_free_urb(urb); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 124 | return -ENOMEM; |
| 125 | } |
| 126 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 127 | usb_fill_int_urb(urb, line6->usbdev, |
| 128 | usb_sndbulkpipe(line6->usbdev, |
Chris Rorvick | 9e165be | 2015-01-12 12:42:53 -0800 | [diff] [blame] | 129 | line6->properties->ep_ctrl_w), |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 130 | transfer_buffer, length, midi_sent, line6, |
| 131 | line6->interval); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 132 | urb->actual_length = 0; |
| 133 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 134 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 135 | if (retval < 0) { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 136 | dev_err(line6->ifcdev, "usb_submit_urb failed\n"); |
| 137 | usb_free_urb(urb); |
Ashvini Varatharaj | 88ef9b1 | 2013-10-19 21:53:37 +0530 | [diff] [blame] | 138 | return retval; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | ++line6->line6midi->num_active_send_urbs; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | static int line6_midi_output_open(struct snd_rawmidi_substream *substream) |
| 146 | { |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | static int line6_midi_output_close(struct snd_rawmidi_substream *substream) |
| 151 | { |
| 152 | return 0; |
| 153 | } |
| 154 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 155 | static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream, |
| 156 | int up) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 157 | { |
| 158 | unsigned long flags; |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 159 | struct usb_line6 *line6 = |
| 160 | line6_rawmidi_substream_midi(substream)->line6; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 161 | |
| 162 | line6->line6midi->substream_transmit = substream; |
Takashi Iwai | bc518ba | 2015-01-23 12:39:11 +0100 | [diff] [blame] | 163 | spin_lock_irqsave(&line6->line6midi->lock, flags); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 164 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 165 | if (line6->line6midi->num_active_send_urbs == 0) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 166 | line6_midi_transmit(substream); |
| 167 | |
Takashi Iwai | bc518ba | 2015-01-23 12:39:11 +0100 | [diff] [blame] | 168 | spin_unlock_irqrestore(&line6->line6midi->lock, flags); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static void line6_midi_output_drain(struct snd_rawmidi_substream *substream) |
| 172 | { |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 173 | struct usb_line6 *line6 = |
| 174 | line6_rawmidi_substream_midi(substream)->line6; |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 175 | struct snd_line6_midi *midi = line6->line6midi; |
Jerry Snitselaar | f3c5261 | 2014-04-24 00:31:48 -0700 | [diff] [blame] | 176 | |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 177 | wait_event_interruptible(midi->send_wait, |
| 178 | midi->num_active_send_urbs == 0); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | static int line6_midi_input_open(struct snd_rawmidi_substream *substream) |
| 182 | { |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | static int line6_midi_input_close(struct snd_rawmidi_substream *substream) |
| 187 | { |
| 188 | return 0; |
| 189 | } |
| 190 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 191 | static void line6_midi_input_trigger(struct snd_rawmidi_substream *substream, |
| 192 | int up) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 193 | { |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 194 | struct usb_line6 *line6 = |
| 195 | line6_rawmidi_substream_midi(substream)->line6; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 196 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 197 | if (up) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 198 | line6->line6midi->substream_receive = substream; |
| 199 | else |
Sachin Kamat | a0d6f2b | 2013-10-09 15:58:26 +0530 | [diff] [blame] | 200 | line6->line6midi->substream_receive = NULL; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | static struct snd_rawmidi_ops line6_midi_output_ops = { |
| 204 | .open = line6_midi_output_open, |
| 205 | .close = line6_midi_output_close, |
| 206 | .trigger = line6_midi_output_trigger, |
| 207 | .drain = line6_midi_output_drain, |
| 208 | }; |
| 209 | |
| 210 | static struct snd_rawmidi_ops line6_midi_input_ops = { |
| 211 | .open = line6_midi_input_open, |
| 212 | .close = line6_midi_input_close, |
| 213 | .trigger = line6_midi_input_trigger, |
| 214 | }; |
| 215 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 216 | /* Create a MIDI device */ |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 217 | static int snd_line6_new_midi(struct usb_line6 *line6, |
| 218 | struct snd_rawmidi **rmidi_ret) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 219 | { |
| 220 | struct snd_rawmidi *rmidi; |
| 221 | int err; |
| 222 | |
Chris Rorvick | c6fffce | 2015-01-20 02:20:49 -0600 | [diff] [blame] | 223 | err = snd_rawmidi_new(line6->card, "Line 6 MIDI", 0, 1, 1, rmidi_ret); |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 224 | if (err < 0) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 225 | return err; |
| 226 | |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 227 | rmidi = *rmidi_ret; |
| 228 | strcpy(rmidi->id, line6->properties->id); |
| 229 | strcpy(rmidi->name, line6->properties->name); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 230 | |
| 231 | rmidi->info_flags = |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 232 | SNDRV_RAWMIDI_INFO_OUTPUT | |
| 233 | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 234 | |
Greg Kroah-Hartman | d7e3733 | 2009-02-27 22:42:55 -0800 | [diff] [blame] | 235 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, |
| 236 | &line6_midi_output_ops); |
| 237 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, |
| 238 | &line6_midi_input_ops); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 242 | /* MIDI device destructor */ |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 243 | static void snd_line6_midi_free(struct snd_rawmidi *rmidi) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 244 | { |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 245 | struct snd_line6_midi *line6midi = rmidi->private_data; |
Jerry Snitselaar | f3c5261 | 2014-04-24 00:31:48 -0700 | [diff] [blame] | 246 | |
Markus Grabner | 1027f476 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 247 | line6_midibuf_destroy(&line6midi->midibuf_in); |
| 248 | line6_midibuf_destroy(&line6midi->midibuf_out); |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 249 | kfree(line6midi); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /* |
Chris Rorvick | c6fffce | 2015-01-20 02:20:49 -0600 | [diff] [blame] | 253 | Initialize the Line 6 MIDI subsystem. |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 254 | */ |
| 255 | int line6_init_midi(struct usb_line6 *line6) |
| 256 | { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 257 | int err; |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 258 | struct snd_rawmidi *rmidi; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 259 | struct snd_line6_midi *line6midi; |
| 260 | |
Andrej Krutak | 7811a3a | 2016-09-18 20:59:27 +0200 | [diff] [blame] | 261 | if (!(line6->properties->capabilities & LINE6_CAP_CONTROL_MIDI)) { |
Greg Kroah-Hartman | 027360c | 2010-09-21 16:58:00 -0700 | [diff] [blame] | 262 | /* skip MIDI initialization and report success */ |
| 263 | return 0; |
| 264 | } |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 265 | |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 266 | err = snd_line6_new_midi(line6, &rmidi); |
| 267 | if (err < 0) |
| 268 | return err; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 269 | |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 270 | line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL); |
| 271 | if (!line6midi) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 272 | return -ENOMEM; |
| 273 | |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 274 | rmidi->private_data = line6midi; |
| 275 | rmidi->private_free = snd_line6_midi_free; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 276 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 277 | init_waitqueue_head(&line6midi->send_wait); |
Takashi Iwai | bc518ba | 2015-01-23 12:39:11 +0100 | [diff] [blame] | 278 | spin_lock_init(&line6midi->lock); |
Takashi Iwai | aaa68d2 | 2015-01-19 14:50:31 +0100 | [diff] [blame] | 279 | line6midi->line6 = line6; |
| 280 | |
| 281 | err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0); |
| 282 | if (err < 0) |
| 283 | return err; |
| 284 | |
| 285 | err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1); |
| 286 | if (err < 0) |
| 287 | return err; |
| 288 | |
| 289 | line6->line6midi = line6midi; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 290 | return 0; |
| 291 | } |
Takashi Iwai | ccddbe4 | 2015-01-15 08:22:31 +0100 | [diff] [blame] | 292 | EXPORT_SYMBOL_GPL(line6_init_midi); |