ALSA: usb-audio: Whitespace cleanups for sound/usb/midi.*
Signed-off-by: Adam Goode <agoode@google.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
f7881e5e8e
commit
a509574e5e
2 changed files with 211 additions and 166 deletions
131
sound/usb/midi.c
131
sound/usb/midi.c
|
@ -221,8 +221,8 @@ static int snd_usbmidi_urb_error(const struct urb *urb)
|
|||
/*
|
||||
* Receives a chunk of MIDI data.
|
||||
*/
|
||||
static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint* ep, int portidx,
|
||||
uint8_t* data, int length)
|
||||
static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint *ep,
|
||||
int portidx, uint8_t *data, int length)
|
||||
{
|
||||
struct usbmidi_in_port *port = &ep->ports[portidx];
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -405,7 +406,8 @@ static void snd_usbmidi_standard_input(struct snd_usb_midi_in_endpoint* ep,
|
|||
if (buffer[i] != 0) {
|
||||
int cable = buffer[i] >> 4;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -458,7 +460,8 @@ static void snd_usbmidi_maudio_broken_running_status_input(
|
|||
* doesn't use this format.)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,10 +483,12 @@ static void snd_usbmidi_cme_input(struct snd_usb_midi_in_endpoint *ep,
|
|||
* Adds one USB MIDI packet to the output buffer.
|
||||
*/
|
||||
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[1] = p1;
|
||||
buf[2] = p2;
|
||||
|
@ -495,10 +500,12 @@ static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0,
|
|||
* Adds one Midiman packet to the output buffer.
|
||||
*/
|
||||
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[1] = p2;
|
||||
buf[2] = p3;
|
||||
|
@ -547,10 +554,12 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port,
|
|||
output_packet(urb, p0 | 0x05, 0xf7, 0, 0);
|
||||
break;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
port->state = STATE_UNKNOWN;
|
||||
|
@ -596,7 +605,8 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port,
|
|||
port->state = STATE_SYSEX_2;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -1051,7 +1061,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
|
|||
if (!umidi->opened[0] && !umidi->opened[1]) {
|
||||
if (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,
|
||||
SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
|
||||
update_roland_altsetting(umidi);
|
||||
|
@ -1067,7 +1078,8 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
|
|||
if (!umidi->opened[0] && !umidi->opened[1]) {
|
||||
if (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,
|
||||
SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
|
||||
}
|
||||
|
@ -1106,9 +1118,11 @@ static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
|
|||
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;
|
||||
if (up) {
|
||||
|
@ -1164,7 +1178,8 @@ static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream)
|
|||
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;
|
||||
|
||||
|
@ -1453,11 +1468,13 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
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)
|
||||
return substream;
|
||||
}
|
||||
|
@ -1666,9 +1683,11 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi,
|
|||
struct port_info *port_info;
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1692,13 +1711,15 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi,
|
|||
|
||||
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
|
||||
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]);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
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]);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
@ -1706,12 +1727,16 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi,
|
|||
|
||||
for (j = 0; j < 0x10; ++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);
|
||||
++out_ports;
|
||||
}
|
||||
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);
|
||||
++in_ports;
|
||||
}
|
||||
|
@ -1783,7 +1808,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
|
|||
* ESI MIDI Mate that try to use them anyway.
|
||||
*/
|
||||
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",
|
||||
ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
|
||||
} else {
|
||||
|
@ -1799,7 +1825,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
|
|||
endpoints[epidx].in_interval = ep->bInterval;
|
||||
else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW)
|
||||
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",
|
||||
ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
|
||||
}
|
||||
|
@ -1864,8 +1891,10 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi)
|
|||
hostif = &intf->altsetting[1];
|
||||
intfd = get_iface_desc(hostif);
|
||||
if (intfd->bNumEndpoints != 2 ||
|
||||
(get_endpoint(hostif, 0)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK ||
|
||||
(get_endpoint(hostif, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
|
||||
(get_endpoint(hostif, 0)->bmAttributes &
|
||||
USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK ||
|
||||
(get_endpoint(hostif, 1)->bmAttributes &
|
||||
USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
|
||||
return;
|
||||
|
||||
dev_dbg(&umidi->dev->dev, "switching to altsetting %d with int ep\n",
|
||||
|
@ -1972,9 +2001,11 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi,
|
|||
cs_desc += cs_desc[0]) {
|
||||
if (cs_desc[1] == USB_DT_CS_INTERFACE) {
|
||||
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)
|
||||
endpoint->out_cables = (endpoint->out_cables << 1) | 1;
|
||||
endpoint->out_cables =
|
||||
(endpoint->out_cables << 1) | 1;
|
||||
}
|
||||
}
|
||||
if (!endpoint->in_cables && !endpoint->out_cables)
|
||||
|
@ -2068,39 +2099,50 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
|
|||
epd = get_endpoint(hostif, 4);
|
||||
if (!usb_endpoint_dir_out(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;
|
||||
}
|
||||
}
|
||||
|
||||
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_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)
|
||||
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_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)
|
||||
return err;
|
||||
|
||||
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;
|
||||
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)
|
||||
return err;
|
||||
}
|
||||
|
||||
for (cable = 0; cable < 0x10; ++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);
|
||||
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);
|
||||
}
|
||||
return 0;
|
||||
|
@ -2128,8 +2170,10 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi,
|
|||
rmidi->ops = &snd_usbmidi_ops;
|
||||
rmidi->private_data = umidi;
|
||||
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_INPUT, &snd_usbmidi_input_ops);
|
||||
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
|
||||
&snd_usbmidi_output_ops);
|
||||
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
|
||||
&snd_usbmidi_input_ops);
|
||||
|
||||
umidi->rmidi = rmidi;
|
||||
return 0;
|
||||
|
@ -2320,7 +2364,8 @@ int snd_usbmidi_create(struct snd_card *card,
|
|||
err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue