Commit a509574e authored by Adam Goode's avatar Adam Goode Committed by Takashi Iwai

ALSA: usb-audio: Whitespace cleanups for sound/usb/midi.*

Signed-off-by: default avatarAdam Goode <agoode@google.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f7881e5e
...@@ -102,8 +102,8 @@ struct usb_protocol_ops { ...@@ -102,8 +102,8 @@ struct usb_protocol_ops {
void (*input)(struct snd_usb_midi_in_endpoint*, uint8_t*, int); void (*input)(struct snd_usb_midi_in_endpoint*, uint8_t*, int);
void (*output)(struct snd_usb_midi_out_endpoint *ep, struct urb *urb); void (*output)(struct snd_usb_midi_out_endpoint *ep, struct urb *urb);
void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t); void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t);
void (*init_out_endpoint)(struct snd_usb_midi_out_endpoint*); void (*init_out_endpoint)(struct snd_usb_midi_out_endpoint *);
void (*finish_out_endpoint)(struct snd_usb_midi_out_endpoint*); void (*finish_out_endpoint)(struct snd_usb_midi_out_endpoint *);
}; };
struct snd_usb_midi { struct snd_usb_midi {
...@@ -112,7 +112,7 @@ struct snd_usb_midi { ...@@ -112,7 +112,7 @@ struct snd_usb_midi {
struct usb_interface *iface; struct usb_interface *iface;
const struct snd_usb_audio_quirk *quirk; const struct snd_usb_audio_quirk *quirk;
struct snd_rawmidi *rmidi; struct snd_rawmidi *rmidi;
struct usb_protocol_ops* usb_protocol_ops; struct usb_protocol_ops *usb_protocol_ops;
struct list_head list; struct list_head list;
struct timer_list error_timer; struct timer_list error_timer;
spinlock_t disc_lock; spinlock_t disc_lock;
...@@ -134,7 +134,7 @@ struct snd_usb_midi { ...@@ -134,7 +134,7 @@ struct snd_usb_midi {
}; };
struct snd_usb_midi_out_endpoint { struct snd_usb_midi_out_endpoint {
struct snd_usb_midi* umidi; struct snd_usb_midi *umidi;
struct out_urb_context { struct out_urb_context {
struct urb *urb; struct urb *urb;
struct snd_usb_midi_out_endpoint *ep; struct snd_usb_midi_out_endpoint *ep;
...@@ -147,7 +147,7 @@ struct snd_usb_midi_out_endpoint { ...@@ -147,7 +147,7 @@ struct snd_usb_midi_out_endpoint {
spinlock_t buffer_lock; spinlock_t buffer_lock;
struct usbmidi_out_port { struct usbmidi_out_port {
struct snd_usb_midi_out_endpoint* ep; struct snd_usb_midi_out_endpoint *ep;
struct snd_rawmidi_substream *substream; struct snd_rawmidi_substream *substream;
int active; int active;
uint8_t cable; /* cable number << 4 */ uint8_t cable; /* cable number << 4 */
...@@ -167,8 +167,8 @@ struct snd_usb_midi_out_endpoint { ...@@ -167,8 +167,8 @@ struct snd_usb_midi_out_endpoint {
}; };
struct snd_usb_midi_in_endpoint { struct snd_usb_midi_in_endpoint {
struct snd_usb_midi* umidi; struct snd_usb_midi *umidi;
struct urb* urbs[INPUT_URBS]; struct urb *urbs[INPUT_URBS];
struct usbmidi_in_port { struct usbmidi_in_port {
struct snd_rawmidi_substream *substream; struct snd_rawmidi_substream *substream;
u8 running_status_length; u8 running_status_length;
...@@ -178,7 +178,7 @@ struct snd_usb_midi_in_endpoint { ...@@ -178,7 +178,7 @@ struct snd_usb_midi_in_endpoint {
int current_port; int current_port;
}; };
static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep); static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint *ep);
static const uint8_t snd_usbmidi_cin_length[] = { static const uint8_t snd_usbmidi_cin_length[] = {
0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1 0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1
...@@ -187,7 +187,7 @@ static const uint8_t snd_usbmidi_cin_length[] = { ...@@ -187,7 +187,7 @@ static const uint8_t snd_usbmidi_cin_length[] = {
/* /*
* Submits the URB, with error handling. * Submits the URB, with error handling.
*/ */
static int snd_usbmidi_submit_urb(struct urb* urb, gfp_t flags) static int snd_usbmidi_submit_urb(struct urb *urb, gfp_t flags)
{ {
int err = usb_submit_urb(urb, flags); int err = usb_submit_urb(urb, flags);
if (err < 0 && err != -ENODEV) if (err < 0 && err != -ENODEV)
...@@ -221,10 +221,10 @@ static int snd_usbmidi_urb_error(const struct urb *urb) ...@@ -221,10 +221,10 @@ static int snd_usbmidi_urb_error(const struct urb *urb)
/* /*
* Receives a chunk of MIDI data. * Receives a chunk of MIDI data.
*/ */
static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint* ep, int portidx, static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint *ep,
uint8_t* data, int length) int portidx, uint8_t *data, int length)
{ {
struct usbmidi_in_port* port = &ep->ports[portidx]; struct usbmidi_in_port *port = &ep->ports[portidx];
if (!port->substream) { if (!port->substream) {
dev_dbg(&ep->umidi->dev->dev, "unexpected port %d!\n", portidx); dev_dbg(&ep->umidi->dev->dev, "unexpected port %d!\n", portidx);
...@@ -250,9 +250,9 @@ static void dump_urb(const char *type, const u8 *data, int length) ...@@ -250,9 +250,9 @@ static void dump_urb(const char *type, const u8 *data, int length)
/* /*
* Processes the data read from the device. * Processes the data read from the device.
*/ */
static void snd_usbmidi_in_urb_complete(struct urb* urb) static void snd_usbmidi_in_urb_complete(struct urb *urb)
{ {
struct snd_usb_midi_in_endpoint* ep = urb->context; struct snd_usb_midi_in_endpoint *ep = urb->context;
if (urb->status == 0) { if (urb->status == 0) {
dump_urb("received", urb->transfer_buffer, urb->actual_length); dump_urb("received", urb->transfer_buffer, urb->actual_length);
...@@ -274,10 +274,10 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb) ...@@ -274,10 +274,10 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb)
snd_usbmidi_submit_urb(urb, GFP_ATOMIC); snd_usbmidi_submit_urb(urb, GFP_ATOMIC);
} }
static void snd_usbmidi_out_urb_complete(struct urb* urb) static void snd_usbmidi_out_urb_complete(struct urb *urb)
{ {
struct out_urb_context *context = urb->context; struct out_urb_context *context = urb->context;
struct snd_usb_midi_out_endpoint* ep = context->ep; struct snd_usb_midi_out_endpoint *ep = context->ep;
unsigned int urb_index; unsigned int urb_index;
spin_lock(&ep->buffer_lock); spin_lock(&ep->buffer_lock);
...@@ -304,10 +304,10 @@ static void snd_usbmidi_out_urb_complete(struct urb* urb) ...@@ -304,10 +304,10 @@ static void snd_usbmidi_out_urb_complete(struct urb* urb)
* This is called when some data should be transferred to the device * This is called when some data should be transferred to the device
* (from one or more substreams). * (from one or more substreams).
*/ */
static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint *ep)
{ {
unsigned int urb_index; unsigned int urb_index;
struct urb* urb; struct urb *urb;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ep->buffer_lock, flags); spin_lock_irqsave(&ep->buffer_lock, flags);
...@@ -343,7 +343,8 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) ...@@ -343,7 +343,8 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep)
static void snd_usbmidi_out_tasklet(unsigned long data) static void snd_usbmidi_out_tasklet(unsigned long data)
{ {
struct snd_usb_midi_out_endpoint* ep = (struct snd_usb_midi_out_endpoint *) data; struct snd_usb_midi_out_endpoint *ep =
(struct snd_usb_midi_out_endpoint *) data;
snd_usbmidi_do_output(ep); snd_usbmidi_do_output(ep);
} }
...@@ -375,7 +376,7 @@ static void snd_usbmidi_error_timer(unsigned long data) ...@@ -375,7 +376,7 @@ static void snd_usbmidi_error_timer(unsigned long data)
} }
/* helper function to send static data that may not DMA-able */ /* helper function to send static data that may not DMA-able */
static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep, static int send_bulk_static_data(struct snd_usb_midi_out_endpoint *ep,
const void *data, int len) const void *data, int len)
{ {
int err = 0; int err = 0;
...@@ -396,8 +397,8 @@ static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep, ...@@ -396,8 +397,8 @@ static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep,
* fourth byte in each packet, and uses length instead of CIN. * fourth byte in each packet, and uses length instead of CIN.
*/ */
static void snd_usbmidi_standard_input(struct snd_usb_midi_in_endpoint* ep, static void snd_usbmidi_standard_input(struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
int i; int i;
...@@ -405,12 +406,13 @@ static void snd_usbmidi_standard_input(struct snd_usb_midi_in_endpoint* ep, ...@@ -405,12 +406,13 @@ static void snd_usbmidi_standard_input(struct snd_usb_midi_in_endpoint* ep,
if (buffer[i] != 0) { if (buffer[i] != 0) {
int cable = buffer[i] >> 4; int cable = buffer[i] >> 4;
int length = snd_usbmidi_cin_length[buffer[i] & 0x0f]; int length = snd_usbmidi_cin_length[buffer[i] & 0x0f];
snd_usbmidi_input_data(ep, cable, &buffer[i + 1], length); snd_usbmidi_input_data(ep, cable, &buffer[i + 1],
length);
} }
} }
static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint* ep, static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
int i; int i;
...@@ -427,8 +429,8 @@ static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint* ep, ...@@ -427,8 +429,8 @@ static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint* ep,
* the data bytes but not the status byte and that is marked with CIN 4. * the data bytes but not the status byte and that is marked with CIN 4.
*/ */
static void snd_usbmidi_maudio_broken_running_status_input( static void snd_usbmidi_maudio_broken_running_status_input(
struct snd_usb_midi_in_endpoint* ep, struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
int i; int i;
...@@ -458,7 +460,8 @@ static void snd_usbmidi_maudio_broken_running_status_input( ...@@ -458,7 +460,8 @@ static void snd_usbmidi_maudio_broken_running_status_input(
* doesn't use this format.) * doesn't use this format.)
*/ */
port->running_status_length = 0; port->running_status_length = 0;
snd_usbmidi_input_data(ep, cable, &buffer[i + 1], length); snd_usbmidi_input_data(ep, cable, &buffer[i + 1],
length);
} }
} }
...@@ -479,11 +482,13 @@ static void snd_usbmidi_cme_input(struct snd_usb_midi_in_endpoint *ep, ...@@ -479,11 +482,13 @@ static void snd_usbmidi_cme_input(struct snd_usb_midi_in_endpoint *ep,
/* /*
* Adds one USB MIDI packet to the output buffer. * Adds one USB MIDI packet to the output buffer.
*/ */
static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0, static void snd_usbmidi_output_standard_packet(struct urb *urb, uint8_t p0,
uint8_t p1, uint8_t p2, uint8_t p3) uint8_t p1, uint8_t p2,
uint8_t p3)
{ {
uint8_t* buf = (uint8_t*)urb->transfer_buffer + urb->transfer_buffer_length; uint8_t *buf =
(uint8_t *)urb->transfer_buffer + urb->transfer_buffer_length;
buf[0] = p0; buf[0] = p0;
buf[1] = p1; buf[1] = p1;
buf[2] = p2; buf[2] = p2;
...@@ -494,11 +499,13 @@ static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0, ...@@ -494,11 +499,13 @@ static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0,
/* /*
* Adds one Midiman packet to the output buffer. * Adds one Midiman packet to the output buffer.
*/ */
static void snd_usbmidi_output_midiman_packet(struct urb* urb, uint8_t p0, static void snd_usbmidi_output_midiman_packet(struct urb *urb, uint8_t p0,
uint8_t p1, uint8_t p2, uint8_t p3) uint8_t p1, uint8_t p2,
uint8_t p3)
{ {
uint8_t* buf = (uint8_t*)urb->transfer_buffer + urb->transfer_buffer_length; uint8_t *buf =
(uint8_t *)urb->transfer_buffer + urb->transfer_buffer_length;
buf[0] = p1; buf[0] = p1;
buf[1] = p2; buf[1] = p2;
buf[2] = p3; buf[2] = p3;
...@@ -509,8 +516,8 @@ static void snd_usbmidi_output_midiman_packet(struct urb* urb, uint8_t p0, ...@@ -509,8 +516,8 @@ static void snd_usbmidi_output_midiman_packet(struct urb* urb, uint8_t p0,
/* /*
* Converts MIDI commands to USB MIDI packets. * Converts MIDI commands to USB MIDI packets.
*/ */
static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port, static void snd_usbmidi_transmit_byte(struct usbmidi_out_port *port,
uint8_t b, struct urb* urb) uint8_t b, struct urb *urb)
{ {
uint8_t p0 = port->cable; uint8_t p0 = port->cable;
void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t) = void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t) =
...@@ -547,10 +554,12 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port, ...@@ -547,10 +554,12 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port,
output_packet(urb, p0 | 0x05, 0xf7, 0, 0); output_packet(urb, p0 | 0x05, 0xf7, 0, 0);
break; break;
case STATE_SYSEX_1: case STATE_SYSEX_1:
output_packet(urb, p0 | 0x06, port->data[0], 0xf7, 0); output_packet(urb, p0 | 0x06, port->data[0],
0xf7, 0);
break; break;
case STATE_SYSEX_2: case STATE_SYSEX_2:
output_packet(urb, p0 | 0x07, port->data[0], port->data[1], 0xf7); output_packet(urb, p0 | 0x07, port->data[0],
port->data[1], 0xf7);
break; break;
} }
port->state = STATE_UNKNOWN; port->state = STATE_UNKNOWN;
...@@ -596,21 +605,22 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port, ...@@ -596,21 +605,22 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port,
port->state = STATE_SYSEX_2; port->state = STATE_SYSEX_2;
break; break;
case STATE_SYSEX_2: case STATE_SYSEX_2:
output_packet(urb, p0 | 0x04, port->data[0], port->data[1], b); output_packet(urb, p0 | 0x04, port->data[0],
port->data[1], b);
port->state = STATE_SYSEX_0; port->state = STATE_SYSEX_0;
break; break;
} }
} }
} }
static void snd_usbmidi_standard_output(struct snd_usb_midi_out_endpoint* ep, static void snd_usbmidi_standard_output(struct snd_usb_midi_out_endpoint *ep,
struct urb *urb) struct urb *urb)
{ {
int p; int p;
/* FIXME: lower-numbered ports can starve higher-numbered ports */ /* FIXME: lower-numbered ports can starve higher-numbered ports */
for (p = 0; p < 0x10; ++p) { for (p = 0; p < 0x10; ++p) {
struct usbmidi_out_port* port = &ep->ports[p]; struct usbmidi_out_port *port = &ep->ports[p];
if (!port->active) if (!port->active)
continue; continue;
while (urb->transfer_buffer_length + 3 < ep->max_transfer) { while (urb->transfer_buffer_length + 3 < ep->max_transfer) {
...@@ -753,18 +763,18 @@ static struct usb_protocol_ops snd_usbmidi_akai_ops = { ...@@ -753,18 +763,18 @@ static struct usb_protocol_ops snd_usbmidi_akai_ops = {
* at the third byte. * at the third byte.
*/ */
static void snd_usbmidi_novation_input(struct snd_usb_midi_in_endpoint* ep, static void snd_usbmidi_novation_input(struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
if (buffer_length < 2 || !buffer[0] || buffer_length < buffer[0] + 1) if (buffer_length < 2 || !buffer[0] || buffer_length < buffer[0] + 1)
return; return;
snd_usbmidi_input_data(ep, 0, &buffer[2], buffer[0] - 1); snd_usbmidi_input_data(ep, 0, &buffer[2], buffer[0] - 1);
} }
static void snd_usbmidi_novation_output(struct snd_usb_midi_out_endpoint* ep, static void snd_usbmidi_novation_output(struct snd_usb_midi_out_endpoint *ep,
struct urb *urb) struct urb *urb)
{ {
uint8_t* transfer_buffer; uint8_t *transfer_buffer;
int count; int count;
if (!ep->ports[0].active) if (!ep->ports[0].active)
...@@ -791,13 +801,13 @@ static struct usb_protocol_ops snd_usbmidi_novation_ops = { ...@@ -791,13 +801,13 @@ static struct usb_protocol_ops snd_usbmidi_novation_ops = {
* "raw" protocol: just move raw MIDI bytes from/to the endpoint * "raw" protocol: just move raw MIDI bytes from/to the endpoint
*/ */
static void snd_usbmidi_raw_input(struct snd_usb_midi_in_endpoint* ep, static void snd_usbmidi_raw_input(struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
snd_usbmidi_input_data(ep, 0, buffer, buffer_length); snd_usbmidi_input_data(ep, 0, buffer, buffer_length);
} }
static void snd_usbmidi_raw_output(struct snd_usb_midi_out_endpoint* ep, static void snd_usbmidi_raw_output(struct snd_usb_midi_out_endpoint *ep,
struct urb *urb) struct urb *urb)
{ {
int count; int count;
...@@ -823,8 +833,8 @@ static struct usb_protocol_ops snd_usbmidi_raw_ops = { ...@@ -823,8 +833,8 @@ static struct usb_protocol_ops snd_usbmidi_raw_ops = {
* FTDI protocol: raw MIDI bytes, but input packets have two modem status bytes. * FTDI protocol: raw MIDI bytes, but input packets have two modem status bytes.
*/ */
static void snd_usbmidi_ftdi_input(struct snd_usb_midi_in_endpoint* ep, static void snd_usbmidi_ftdi_input(struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
if (buffer_length > 2) if (buffer_length > 2)
snd_usbmidi_input_data(ep, 0, buffer + 2, buffer_length - 2); snd_usbmidi_input_data(ep, 0, buffer + 2, buffer_length - 2);
...@@ -883,7 +893,7 @@ static struct usb_protocol_ops snd_usbmidi_122l_ops = { ...@@ -883,7 +893,7 @@ static struct usb_protocol_ops snd_usbmidi_122l_ops = {
* Emagic USB MIDI protocol: raw MIDI with "F5 xx" port switching. * Emagic USB MIDI protocol: raw MIDI with "F5 xx" port switching.
*/ */
static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint* ep) static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint *ep)
{ {
static const u8 init_data[] = { static const u8 init_data[] = {
/* initialization magic: "get version" */ /* initialization magic: "get version" */
...@@ -900,7 +910,7 @@ static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint* ep) ...@@ -900,7 +910,7 @@ static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint* ep)
send_bulk_static_data(ep, init_data, sizeof(init_data)); send_bulk_static_data(ep, init_data, sizeof(init_data));
} }
static void snd_usbmidi_emagic_finish_out(struct snd_usb_midi_out_endpoint* ep) static void snd_usbmidi_emagic_finish_out(struct snd_usb_midi_out_endpoint *ep)
{ {
static const u8 finish_data[] = { static const u8 finish_data[] = {
/* switch to patch mode with last preset */ /* switch to patch mode with last preset */
...@@ -916,8 +926,8 @@ static void snd_usbmidi_emagic_finish_out(struct snd_usb_midi_out_endpoint* ep) ...@@ -916,8 +926,8 @@ static void snd_usbmidi_emagic_finish_out(struct snd_usb_midi_out_endpoint* ep)
send_bulk_static_data(ep, finish_data, sizeof(finish_data)); send_bulk_static_data(ep, finish_data, sizeof(finish_data));
} }
static void snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint* ep, static void snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint *ep,
uint8_t* buffer, int buffer_length) uint8_t *buffer, int buffer_length)
{ {
int i; int i;
...@@ -960,18 +970,18 @@ static void snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint* ep, ...@@ -960,18 +970,18 @@ static void snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint* ep,
} }
} }
static void snd_usbmidi_emagic_output(struct snd_usb_midi_out_endpoint* ep, static void snd_usbmidi_emagic_output(struct snd_usb_midi_out_endpoint *ep,
struct urb *urb) struct urb *urb)
{ {
int port0 = ep->current_port; int port0 = ep->current_port;
uint8_t* buf = urb->transfer_buffer; uint8_t *buf = urb->transfer_buffer;
int buf_free = ep->max_transfer; int buf_free = ep->max_transfer;
int length, i; int length, i;
for (i = 0; i < 0x10; ++i) { for (i = 0; i < 0x10; ++i) {
/* round-robin, starting at the last current port */ /* round-robin, starting at the last current port */
int portnum = (port0 + i) & 15; int portnum = (port0 + i) & 15;
struct usbmidi_out_port* port = &ep->ports[portnum]; struct usbmidi_out_port *port = &ep->ports[portnum];
if (!port->active) if (!port->active)
continue; continue;
...@@ -1015,7 +1025,7 @@ static struct usb_protocol_ops snd_usbmidi_emagic_ops = { ...@@ -1015,7 +1025,7 @@ static struct usb_protocol_ops snd_usbmidi_emagic_ops = {
}; };
static void update_roland_altsetting(struct snd_usb_midi* umidi) static void update_roland_altsetting(struct snd_usb_midi *umidi)
{ {
struct usb_interface *intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
...@@ -1037,7 +1047,7 @@ static void update_roland_altsetting(struct snd_usb_midi* umidi) ...@@ -1037,7 +1047,7 @@ static void update_roland_altsetting(struct snd_usb_midi* umidi)
static int substream_open(struct snd_rawmidi_substream *substream, int dir, static int substream_open(struct snd_rawmidi_substream *substream, int dir,
int open) int open)
{ {
struct snd_usb_midi* umidi = substream->rmidi->private_data; struct snd_usb_midi *umidi = substream->rmidi->private_data;
struct snd_kcontrol *ctl; struct snd_kcontrol *ctl;
down_read(&umidi->disc_rwsem); down_read(&umidi->disc_rwsem);
...@@ -1051,7 +1061,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, ...@@ -1051,7 +1061,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
if (!umidi->opened[0] && !umidi->opened[1]) { if (!umidi->opened[0] && !umidi->opened[1]) {
if (umidi->roland_load_ctl) { if (umidi->roland_load_ctl) {
ctl = umidi->roland_load_ctl; ctl = umidi->roland_load_ctl;
ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; ctl->vd[0].access |=
SNDRV_CTL_ELEM_ACCESS_INACTIVE;
snd_ctl_notify(umidi->card, snd_ctl_notify(umidi->card,
SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
update_roland_altsetting(umidi); update_roland_altsetting(umidi);
...@@ -1067,7 +1078,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, ...@@ -1067,7 +1078,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
if (!umidi->opened[0] && !umidi->opened[1]) { if (!umidi->opened[0] && !umidi->opened[1]) {
if (umidi->roland_load_ctl) { if (umidi->roland_load_ctl) {
ctl = umidi->roland_load_ctl; ctl = umidi->roland_load_ctl;
ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; ctl->vd[0].access &=
~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
snd_ctl_notify(umidi->card, snd_ctl_notify(umidi->card,
SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
} }
...@@ -1080,8 +1092,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, ...@@ -1080,8 +1092,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
{ {
struct snd_usb_midi* umidi = substream->rmidi->private_data; struct snd_usb_midi *umidi = substream->rmidi->private_data;
struct usbmidi_out_port* port = NULL; struct usbmidi_out_port *port = NULL;
int i, j; int i, j;
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
...@@ -1106,9 +1118,11 @@ static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) ...@@ -1106,9 +1118,11 @@ static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
return substream_open(substream, 0, 0); return substream_open(substream, 0, 0);
} }
static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, int up) static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream,
int up)
{ {
struct usbmidi_out_port* port = (struct usbmidi_out_port*)substream->runtime->private_data; struct usbmidi_out_port *port =
(struct usbmidi_out_port *)substream->runtime->private_data;
port->active = up; port->active = up;
if (up) { if (up) {
...@@ -1125,7 +1139,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, ...@@ -1125,7 +1139,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream,
static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream) static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream)
{ {
struct usbmidi_out_port* port = substream->runtime->private_data; struct usbmidi_out_port *port = substream->runtime->private_data;
struct snd_usb_midi_out_endpoint *ep = port->ep; struct snd_usb_midi_out_endpoint *ep = port->ep;
unsigned int drain_urbs; unsigned int drain_urbs;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
...@@ -1164,9 +1178,10 @@ static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream) ...@@ -1164,9 +1178,10 @@ static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream)
return substream_open(substream, 1, 0); return substream_open(substream, 1, 0);
} }
static void snd_usbmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) static void snd_usbmidi_input_trigger(struct snd_rawmidi_substream *substream,
int up)
{ {
struct snd_usb_midi* umidi = substream->rmidi->private_data; struct snd_usb_midi *umidi = substream->rmidi->private_data;
if (up) if (up)
set_bit(substream->number, &umidi->input_triggered); set_bit(substream->number, &umidi->input_triggered);
...@@ -1199,7 +1214,7 @@ static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb, ...@@ -1199,7 +1214,7 @@ static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb,
* Frees an input endpoint. * Frees an input endpoint.
* May be called when ep hasn't been initialized completely. * May be called when ep hasn't been initialized completely.
*/ */
static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint* ep) static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint *ep)
{ {
unsigned int i; unsigned int i;
...@@ -1213,12 +1228,12 @@ static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint* ep) ...@@ -1213,12 +1228,12 @@ static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint* ep)
/* /*
* Creates an input endpoint. * Creates an input endpoint.
*/ */
static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi, static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* ep_info, struct snd_usb_midi_endpoint_info *ep_info,
struct snd_usb_midi_endpoint* rep) struct snd_usb_midi_endpoint *rep)
{ {
struct snd_usb_midi_in_endpoint* ep; struct snd_usb_midi_in_endpoint *ep;
void* buffer; void *buffer;
unsigned int pipe; unsigned int pipe;
int length; int length;
unsigned int i; unsigned int i;
...@@ -1289,14 +1304,14 @@ static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep ...@@ -1289,14 +1304,14 @@ static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep
/* /*
* Creates an output endpoint, and initializes output ports. * Creates an output endpoint, and initializes output ports.
*/ */
static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* ep_info, struct snd_usb_midi_endpoint_info *ep_info,
struct snd_usb_midi_endpoint* rep) struct snd_usb_midi_endpoint *rep)
{ {
struct snd_usb_midi_out_endpoint* ep; struct snd_usb_midi_out_endpoint *ep;
unsigned int i; unsigned int i;
unsigned int pipe; unsigned int pipe;
void* buffer; void *buffer;
rep->out = NULL; rep->out = NULL;
ep = kzalloc(sizeof(*ep), GFP_KERNEL); ep = kzalloc(sizeof(*ep), GFP_KERNEL);
...@@ -1381,12 +1396,12 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, ...@@ -1381,12 +1396,12 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
/* /*
* Frees everything. * Frees everything.
*/ */
static void snd_usbmidi_free(struct snd_usb_midi* umidi) static void snd_usbmidi_free(struct snd_usb_midi *umidi)
{ {
int i; int i;
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
if (ep->out) if (ep->out)
snd_usbmidi_out_endpoint_delete(ep->out); snd_usbmidi_out_endpoint_delete(ep->out);
if (ep->in) if (ep->in)
...@@ -1399,9 +1414,9 @@ static void snd_usbmidi_free(struct snd_usb_midi* umidi) ...@@ -1399,9 +1414,9 @@ static void snd_usbmidi_free(struct snd_usb_midi* umidi)
/* /*
* Unlinks all URBs (must be done before the usb_device is deleted). * Unlinks all URBs (must be done before the usb_device is deleted).
*/ */
void snd_usbmidi_disconnect(struct list_head* p) void snd_usbmidi_disconnect(struct list_head *p)
{ {
struct snd_usb_midi* umidi; struct snd_usb_midi *umidi;
unsigned int i, j; unsigned int i, j;
umidi = list_entry(p, struct snd_usb_midi, list); umidi = list_entry(p, struct snd_usb_midi, list);
...@@ -1417,7 +1432,7 @@ void snd_usbmidi_disconnect(struct list_head* p) ...@@ -1417,7 +1432,7 @@ void snd_usbmidi_disconnect(struct list_head* p)
up_write(&umidi->disc_rwsem); up_write(&umidi->disc_rwsem);
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
if (ep->out) if (ep->out)
tasklet_kill(&ep->out->tasklet); tasklet_kill(&ep->out->tasklet);
if (ep->out) { if (ep->out) {
...@@ -1448,16 +1463,18 @@ EXPORT_SYMBOL(snd_usbmidi_disconnect); ...@@ -1448,16 +1463,18 @@ EXPORT_SYMBOL(snd_usbmidi_disconnect);
static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi)
{ {
struct snd_usb_midi* umidi = rmidi->private_data; struct snd_usb_midi *umidi = rmidi->private_data;
snd_usbmidi_free(umidi); snd_usbmidi_free(umidi);
} }
static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi *umidi,
int stream, int number) int stream,
int number)
{ {
struct snd_rawmidi_substream *substream; struct snd_rawmidi_substream *substream;
list_for_each_entry(substream, &umidi->rmidi->streams[stream].substreams, list) { list_for_each_entry(substream, &umidi->rmidi->streams[stream].substreams,
list) {
if (substream->number == number) if (substream->number == number)
return substream; return substream;
} }
...@@ -1633,7 +1650,7 @@ static struct port_info { ...@@ -1633,7 +1650,7 @@ static struct port_info {
SNDRV_SEQ_PORT_TYPE_SYNTHESIZER), SNDRV_SEQ_PORT_TYPE_SYNTHESIZER),
}; };
static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number) static struct port_info *find_port_info(struct snd_usb_midi *umidi, int number)
{ {
int i; int i;
...@@ -1659,16 +1676,18 @@ static void snd_usbmidi_get_port_info(struct snd_rawmidi *rmidi, int number, ...@@ -1659,16 +1676,18 @@ static void snd_usbmidi_get_port_info(struct snd_rawmidi *rmidi, int number,
} }
} }
static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi, static void snd_usbmidi_init_substream(struct snd_usb_midi *umidi,
int stream, int number, int stream, int number,
struct snd_rawmidi_substream ** rsubstream) struct snd_rawmidi_substream **rsubstream)
{ {
struct port_info *port_info; struct port_info *port_info;
const char *name_format; const char *name_format;
struct snd_rawmidi_substream *substream = snd_usbmidi_find_substream(umidi, stream, number); struct snd_rawmidi_substream *substream =
snd_usbmidi_find_substream(umidi, stream, number);
if (!substream) { if (!substream) {
dev_err(&umidi->dev->dev, "substream %d:%d not found\n", stream, number); dev_err(&umidi->dev->dev, "substream %d:%d not found\n", stream,
number);
return; return;
} }
...@@ -1684,21 +1703,23 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi, ...@@ -1684,21 +1703,23 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi,
/* /*
* Creates the endpoints and their ports. * Creates the endpoints and their ports.
*/ */
static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi, static int snd_usbmidi_create_endpoints(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoints) struct snd_usb_midi_endpoint_info *endpoints)
{ {
int i, j, err; int i, j, err;
int out_ports = 0, in_ports = 0; int out_ports = 0, in_ports = 0;
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
if (endpoints[i].out_cables) { if (endpoints[i].out_cables) {
err = snd_usbmidi_out_endpoint_create(umidi, &endpoints[i], err = snd_usbmidi_out_endpoint_create(umidi,
&endpoints[i],
&umidi->endpoints[i]); &umidi->endpoints[i]);
if (err < 0) if (err < 0)
return err; return err;
} }
if (endpoints[i].in_cables) { if (endpoints[i].in_cables) {
err = snd_usbmidi_in_endpoint_create(umidi, &endpoints[i], err = snd_usbmidi_in_endpoint_create(umidi,
&endpoints[i],
&umidi->endpoints[i]); &umidi->endpoints[i]);
if (err < 0) if (err < 0)
return err; return err;
...@@ -1706,12 +1727,16 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi, ...@@ -1706,12 +1727,16 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi,
for (j = 0; j < 0x10; ++j) { for (j = 0; j < 0x10; ++j) {
if (endpoints[i].out_cables & (1 << j)) { if (endpoints[i].out_cables & (1 << j)) {
snd_usbmidi_init_substream(umidi, SNDRV_RAWMIDI_STREAM_OUTPUT, out_ports, snd_usbmidi_init_substream(umidi,
SNDRV_RAWMIDI_STREAM_OUTPUT,
out_ports,
&umidi->endpoints[i].out->ports[j].substream); &umidi->endpoints[i].out->ports[j].substream);
++out_ports; ++out_ports;
} }
if (endpoints[i].in_cables & (1 << j)) { if (endpoints[i].in_cables & (1 << j)) {
snd_usbmidi_init_substream(umidi, SNDRV_RAWMIDI_STREAM_INPUT, in_ports, snd_usbmidi_init_substream(umidi,
SNDRV_RAWMIDI_STREAM_INPUT,
in_ports,
&umidi->endpoints[i].in->ports[j].substream); &umidi->endpoints[i].in->ports[j].substream);
++in_ports; ++in_ports;
} }
...@@ -1725,16 +1750,16 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi, ...@@ -1725,16 +1750,16 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi,
/* /*
* Returns MIDIStreaming device capabilities. * Returns MIDIStreaming device capabilities.
*/ */
static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, static int snd_usbmidi_get_ms_info(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoints) struct snd_usb_midi_endpoint_info *endpoints)
{ {
struct usb_interface* intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
struct usb_interface_descriptor* intfd; struct usb_interface_descriptor *intfd;
struct usb_ms_header_descriptor* ms_header; struct usb_ms_header_descriptor *ms_header;
struct usb_host_endpoint *hostep; struct usb_host_endpoint *hostep;
struct usb_endpoint_descriptor* ep; struct usb_endpoint_descriptor *ep;
struct usb_ms_endpoint_descriptor* ms_ep; struct usb_ms_endpoint_descriptor *ms_ep;
int i, epidx; int i, epidx;
intf = umidi->iface; intf = umidi->iface;
...@@ -1742,7 +1767,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, ...@@ -1742,7 +1767,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
return -ENXIO; return -ENXIO;
hostif = &intf->altsetting[0]; hostif = &intf->altsetting[0];
intfd = get_iface_desc(hostif); intfd = get_iface_desc(hostif);
ms_header = (struct usb_ms_header_descriptor*)hostif->extra; ms_header = (struct usb_ms_header_descriptor *)hostif->extra;
if (hostif->extralen >= 7 && if (hostif->extralen >= 7 &&
ms_header->bLength >= 7 && ms_header->bLength >= 7 &&
ms_header->bDescriptorType == USB_DT_CS_INTERFACE && ms_header->bDescriptorType == USB_DT_CS_INTERFACE &&
...@@ -1759,7 +1784,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, ...@@ -1759,7 +1784,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
ep = get_ep_desc(hostep); ep = get_ep_desc(hostep);
if (!usb_endpoint_xfer_bulk(ep) && !usb_endpoint_xfer_int(ep)) if (!usb_endpoint_xfer_bulk(ep) && !usb_endpoint_xfer_int(ep))
continue; continue;
ms_ep = (struct usb_ms_endpoint_descriptor*)hostep->extra; ms_ep = (struct usb_ms_endpoint_descriptor *)hostep->extra;
if (hostep->extralen < 4 || if (hostep->extralen < 4 ||
ms_ep->bLength < 4 || ms_ep->bLength < 4 ||
ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT ||
...@@ -1783,9 +1808,10 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, ...@@ -1783,9 +1808,10 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
* ESI MIDI Mate that try to use them anyway. * ESI MIDI Mate that try to use them anyway.
*/ */
endpoints[epidx].out_interval = 1; endpoints[epidx].out_interval = 1;
endpoints[epidx].out_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; endpoints[epidx].out_cables =
(1 << ms_ep->bNumEmbMIDIJack) - 1;
dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n", dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n",
ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack); ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
} else { } else {
if (endpoints[epidx].in_ep) { if (endpoints[epidx].in_ep) {
if (++epidx >= MIDI_MAX_ENDPOINTS) { if (++epidx >= MIDI_MAX_ENDPOINTS) {
...@@ -1799,9 +1825,10 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, ...@@ -1799,9 +1825,10 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
endpoints[epidx].in_interval = ep->bInterval; endpoints[epidx].in_interval = ep->bInterval;
else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW) else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW)
endpoints[epidx].in_interval = 1; endpoints[epidx].in_interval = 1;
endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; endpoints[epidx].in_cables =
(1 << ms_ep->bNumEmbMIDIJack) - 1;
dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n", dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n",
ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack); ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
} }
} }
return 0; return 0;
...@@ -1825,7 +1852,7 @@ static int roland_load_get(struct snd_kcontrol *kcontrol, ...@@ -1825,7 +1852,7 @@ static int roland_load_get(struct snd_kcontrol *kcontrol,
static int roland_load_put(struct snd_kcontrol *kcontrol, static int roland_load_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
struct snd_usb_midi* umidi = kcontrol->private_data; struct snd_usb_midi *umidi = kcontrol->private_data;
int changed; int changed;
if (value->value.enumerated.item[0] > 1) if (value->value.enumerated.item[0] > 1)
...@@ -1851,11 +1878,11 @@ static struct snd_kcontrol_new roland_load_ctl = { ...@@ -1851,11 +1878,11 @@ static struct snd_kcontrol_new roland_load_ctl = {
* On Roland devices, use the second alternate setting to be able to use * On Roland devices, use the second alternate setting to be able to use
* the interrupt input endpoint. * the interrupt input endpoint.
*/ */
static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi) static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi *umidi)
{ {
struct usb_interface* intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
struct usb_interface_descriptor* intfd; struct usb_interface_descriptor *intfd;
intf = umidi->iface; intf = umidi->iface;
if (!intf || intf->num_altsetting != 2) if (!intf || intf->num_altsetting != 2)
...@@ -1864,8 +1891,10 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi) ...@@ -1864,8 +1891,10 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi)
hostif = &intf->altsetting[1]; hostif = &intf->altsetting[1];
intfd = get_iface_desc(hostif); intfd = get_iface_desc(hostif);
if (intfd->bNumEndpoints != 2 || if (intfd->bNumEndpoints != 2 ||
(get_endpoint(hostif, 0)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK || (get_endpoint(hostif, 0)->bmAttributes &
(get_endpoint(hostif, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK ||
(get_endpoint(hostif, 1)->bmAttributes &
USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
return; return;
dev_dbg(&umidi->dev->dev, "switching to altsetting %d with int ep\n", dev_dbg(&umidi->dev->dev, "switching to altsetting %d with int ep\n",
...@@ -1881,14 +1910,14 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi) ...@@ -1881,14 +1910,14 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi)
/* /*
* Try to find any usable endpoints in the interface. * Try to find any usable endpoints in the interface.
*/ */
static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi, static int snd_usbmidi_detect_endpoints(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoint, struct snd_usb_midi_endpoint_info *endpoint,
int max_endpoints) int max_endpoints)
{ {
struct usb_interface* intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
struct usb_interface_descriptor* intfd; struct usb_interface_descriptor *intfd;
struct usb_endpoint_descriptor* epd; struct usb_endpoint_descriptor *epd;
int i, out_eps = 0, in_eps = 0; int i, out_eps = 0, in_eps = 0;
if (USB_ID_VENDOR(umidi->usb_id) == 0x0582) if (USB_ID_VENDOR(umidi->usb_id) == 0x0582)
...@@ -1929,8 +1958,8 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi, ...@@ -1929,8 +1958,8 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi,
/* /*
* Detects the endpoints for one-port-per-endpoint protocols. * Detects the endpoints for one-port-per-endpoint protocols.
*/ */
static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi* umidi, static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoints) struct snd_usb_midi_endpoint_info *endpoints)
{ {
int err, i; int err, i;
...@@ -1947,13 +1976,13 @@ static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi* umidi, ...@@ -1947,13 +1976,13 @@ static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi* umidi,
/* /*
* Detects the endpoints and ports of Yamaha devices. * Detects the endpoints and ports of Yamaha devices.
*/ */
static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi, static int snd_usbmidi_detect_yamaha(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoint) struct snd_usb_midi_endpoint_info *endpoint)
{ {
struct usb_interface* intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
struct usb_interface_descriptor* intfd; struct usb_interface_descriptor *intfd;
uint8_t* cs_desc; uint8_t *cs_desc;
intf = umidi->iface; intf = umidi->iface;
if (!intf) if (!intf)
...@@ -1972,9 +2001,11 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi, ...@@ -1972,9 +2001,11 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi,
cs_desc += cs_desc[0]) { cs_desc += cs_desc[0]) {
if (cs_desc[1] == USB_DT_CS_INTERFACE) { if (cs_desc[1] == USB_DT_CS_INTERFACE) {
if (cs_desc[2] == UAC_MIDI_IN_JACK) if (cs_desc[2] == UAC_MIDI_IN_JACK)
endpoint->in_cables = (endpoint->in_cables << 1) | 1; endpoint->in_cables =
(endpoint->in_cables << 1) | 1;
else if (cs_desc[2] == UAC_MIDI_OUT_JACK) else if (cs_desc[2] == UAC_MIDI_OUT_JACK)
endpoint->out_cables = (endpoint->out_cables << 1) | 1; endpoint->out_cables =
(endpoint->out_cables << 1) | 1;
} }
} }
if (!endpoint->in_cables && !endpoint->out_cables) if (!endpoint->in_cables && !endpoint->out_cables)
...@@ -1986,12 +2017,12 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi, ...@@ -1986,12 +2017,12 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi,
/* /*
* Detects the endpoints and ports of Roland devices. * Detects the endpoints and ports of Roland devices.
*/ */
static int snd_usbmidi_detect_roland(struct snd_usb_midi* umidi, static int snd_usbmidi_detect_roland(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoint) struct snd_usb_midi_endpoint_info *endpoint)
{ {
struct usb_interface* intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
u8* cs_desc; u8 *cs_desc;
intf = umidi->iface; intf = umidi->iface;
if (!intf) if (!intf)
...@@ -2024,14 +2055,14 @@ static int snd_usbmidi_detect_roland(struct snd_usb_midi* umidi, ...@@ -2024,14 +2055,14 @@ static int snd_usbmidi_detect_roland(struct snd_usb_midi* umidi,
/* /*
* Creates the endpoints and their ports for Midiman devices. * Creates the endpoints and their ports for Midiman devices.
*/ */
static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi, static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi *umidi,
struct snd_usb_midi_endpoint_info* endpoint) struct snd_usb_midi_endpoint_info *endpoint)
{ {
struct snd_usb_midi_endpoint_info ep_info; struct snd_usb_midi_endpoint_info ep_info;
struct usb_interface* intf; struct usb_interface *intf;
struct usb_host_interface *hostif; struct usb_host_interface *hostif;
struct usb_interface_descriptor* intfd; struct usb_interface_descriptor *intfd;
struct usb_endpoint_descriptor* epd; struct usb_endpoint_descriptor *epd;
int cable, err; int cable, err;
intf = umidi->iface; intf = umidi->iface;
...@@ -2068,39 +2099,50 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi, ...@@ -2068,39 +2099,50 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
epd = get_endpoint(hostif, 4); epd = get_endpoint(hostif, 4);
if (!usb_endpoint_dir_out(epd) || if (!usb_endpoint_dir_out(epd) ||
!usb_endpoint_xfer_bulk(epd)) { !usb_endpoint_xfer_bulk(epd)) {
dev_dbg(&umidi->dev->dev, "endpoint[4] isn't bulk output\n"); dev_dbg(&umidi->dev->dev,
"endpoint[4] isn't bulk output\n");
return -ENXIO; return -ENXIO;
} }
} }
ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ep_info.out_interval = 0; ep_info.out_interval = 0;
ep_info.out_cables = endpoint->out_cables & 0x5555; ep_info.out_cables = endpoint->out_cables & 0x5555;
err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); err = snd_usbmidi_out_endpoint_create(umidi, &ep_info,
&umidi->endpoints[0]);
if (err < 0) if (err < 0)
return err; return err;
ep_info.in_ep = get_endpoint(hostif, 0)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep_info.in_ep = get_endpoint(hostif, 0)->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ep_info.in_interval = get_endpoint(hostif, 0)->bInterval; ep_info.in_interval = get_endpoint(hostif, 0)->bInterval;
ep_info.in_cables = endpoint->in_cables; ep_info.in_cables = endpoint->in_cables;
err = snd_usbmidi_in_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); err = snd_usbmidi_in_endpoint_create(umidi, &ep_info,
&umidi->endpoints[0]);
if (err < 0) if (err < 0)
return err; return err;
if (endpoint->out_cables > 0x0001) { if (endpoint->out_cables > 0x0001) {
ep_info.out_ep = get_endpoint(hostif, 4)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep_info.out_ep = get_endpoint(hostif, 4)->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ep_info.out_cables = endpoint->out_cables & 0xaaaa; ep_info.out_cables = endpoint->out_cables & 0xaaaa;
err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[1]); err = snd_usbmidi_out_endpoint_create(umidi, &ep_info,
&umidi->endpoints[1]);
if (err < 0) if (err < 0)
return err; return err;
} }
for (cable = 0; cable < 0x10; ++cable) { for (cable = 0; cable < 0x10; ++cable) {
if (endpoint->out_cables & (1 << cable)) if (endpoint->out_cables & (1 << cable))
snd_usbmidi_init_substream(umidi, SNDRV_RAWMIDI_STREAM_OUTPUT, cable, snd_usbmidi_init_substream(umidi,
SNDRV_RAWMIDI_STREAM_OUTPUT,
cable,
&umidi->endpoints[cable & 1].out->ports[cable].substream); &umidi->endpoints[cable & 1].out->ports[cable].substream);
if (endpoint->in_cables & (1 << cable)) if (endpoint->in_cables & (1 << cable))
snd_usbmidi_init_substream(umidi, SNDRV_RAWMIDI_STREAM_INPUT, cable, snd_usbmidi_init_substream(umidi,
SNDRV_RAWMIDI_STREAM_INPUT,
cable,
&umidi->endpoints[0].in->ports[cable].substream); &umidi->endpoints[0].in->ports[cable].substream);
} }
return 0; return 0;
...@@ -2110,7 +2152,7 @@ static struct snd_rawmidi_global_ops snd_usbmidi_ops = { ...@@ -2110,7 +2152,7 @@ static struct snd_rawmidi_global_ops snd_usbmidi_ops = {
.get_port_info = snd_usbmidi_get_port_info, .get_port_info = snd_usbmidi_get_port_info,
}; };
static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi, static int snd_usbmidi_create_rawmidi(struct snd_usb_midi *umidi,
int out_ports, int in_ports) int out_ports, int in_ports)
{ {
struct snd_rawmidi *rmidi; struct snd_rawmidi *rmidi;
...@@ -2128,8 +2170,10 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi, ...@@ -2128,8 +2170,10 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi,
rmidi->ops = &snd_usbmidi_ops; rmidi->ops = &snd_usbmidi_ops;
rmidi->private_data = umidi; rmidi->private_data = umidi;
rmidi->private_free = snd_usbmidi_rawmidi_free; rmidi->private_free = snd_usbmidi_rawmidi_free;
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_usbmidi_output_ops); snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_usbmidi_input_ops); &snd_usbmidi_output_ops);
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
&snd_usbmidi_input_ops);
umidi->rmidi = rmidi; umidi->rmidi = rmidi;
return 0; return 0;
...@@ -2138,16 +2182,16 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi, ...@@ -2138,16 +2182,16 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi,
/* /*
* Temporarily stop input. * Temporarily stop input.
*/ */
void snd_usbmidi_input_stop(struct list_head* p) void snd_usbmidi_input_stop(struct list_head *p)
{ {
struct snd_usb_midi* umidi; struct snd_usb_midi *umidi;
unsigned int i, j; unsigned int i, j;
umidi = list_entry(p, struct snd_usb_midi, list); umidi = list_entry(p, struct snd_usb_midi, list);
if (!umidi->input_running) if (!umidi->input_running)
return; return;
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
if (ep->in) if (ep->in)
for (j = 0; j < INPUT_URBS; ++j) for (j = 0; j < INPUT_URBS; ++j)
usb_kill_urb(ep->in->urbs[j]); usb_kill_urb(ep->in->urbs[j]);
...@@ -2156,14 +2200,14 @@ void snd_usbmidi_input_stop(struct list_head* p) ...@@ -2156,14 +2200,14 @@ void snd_usbmidi_input_stop(struct list_head* p)
} }
EXPORT_SYMBOL(snd_usbmidi_input_stop); EXPORT_SYMBOL(snd_usbmidi_input_stop);
static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint *ep)
{ {
unsigned int i; unsigned int i;
if (!ep) if (!ep)
return; return;
for (i = 0; i < INPUT_URBS; ++i) { for (i = 0; i < INPUT_URBS; ++i) {
struct urb* urb = ep->urbs[i]; struct urb *urb = ep->urbs[i];
urb->dev = ep->umidi->dev; urb->dev = ep->umidi->dev;
snd_usbmidi_submit_urb(urb, GFP_KERNEL); snd_usbmidi_submit_urb(urb, GFP_KERNEL);
} }
...@@ -2172,9 +2216,9 @@ static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) ...@@ -2172,9 +2216,9 @@ static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep)
/* /*
* Resume input after a call to snd_usbmidi_input_stop(). * Resume input after a call to snd_usbmidi_input_stop().
*/ */
void snd_usbmidi_input_start(struct list_head* p) void snd_usbmidi_input_start(struct list_head *p)
{ {
struct snd_usb_midi* umidi; struct snd_usb_midi *umidi;
int i; int i;
umidi = list_entry(p, struct snd_usb_midi, list); umidi = list_entry(p, struct snd_usb_midi, list);
...@@ -2218,11 +2262,11 @@ EXPORT_SYMBOL(snd_usbmidi_resume); ...@@ -2218,11 +2262,11 @@ EXPORT_SYMBOL(snd_usbmidi_resume);
* Creates and registers everything needed for a MIDI streaming interface. * Creates and registers everything needed for a MIDI streaming interface.
*/ */
int snd_usbmidi_create(struct snd_card *card, int snd_usbmidi_create(struct snd_card *card,
struct usb_interface* iface, struct usb_interface *iface,
struct list_head *midi_list, struct list_head *midi_list,
const struct snd_usb_audio_quirk* quirk) const struct snd_usb_audio_quirk *quirk)
{ {
struct snd_usb_midi* umidi; struct snd_usb_midi *umidi;
struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS]; struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS];
int out_ports, in_ports; int out_ports, in_ports;
int i, err; int i, err;
...@@ -2320,7 +2364,8 @@ int snd_usbmidi_create(struct snd_card *card, ...@@ -2320,7 +2364,8 @@ int snd_usbmidi_create(struct snd_card *card,
err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
break; break;
default: default:
dev_err(&umidi->dev->dev, "invalid quirk type %d\n", quirk->type); dev_err(&umidi->dev->dev, "invalid quirk type %d\n",
quirk->type);
err = -ENXIO; err = -ENXIO;
break; break;
} }
......
...@@ -43,8 +43,8 @@ int snd_usbmidi_create(struct snd_card *card, ...@@ -43,8 +43,8 @@ int snd_usbmidi_create(struct snd_card *card,
struct usb_interface *iface, struct usb_interface *iface,
struct list_head *midi_list, struct list_head *midi_list,
const struct snd_usb_audio_quirk *quirk); const struct snd_usb_audio_quirk *quirk);
void snd_usbmidi_input_stop(struct list_head* p); void snd_usbmidi_input_stop(struct list_head *p);
void snd_usbmidi_input_start(struct list_head* p); void snd_usbmidi_input_start(struct list_head *p);
void snd_usbmidi_disconnect(struct list_head *p); void snd_usbmidi_disconnect(struct list_head *p);
void snd_usbmidi_suspend(struct list_head *p); void snd_usbmidi_suspend(struct list_head *p);
void snd_usbmidi_resume(struct list_head *p); void snd_usbmidi_resume(struct list_head *p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment