/* Read data from MIDI buffer and transmit them via USB. */ static void line6_midi_transmit(struct snd_rawmidi_substream *substream) { struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6; 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); for (;;) { req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); done = snd_rawmidi_transmit_peek(substream, chunk, req); if (done == 0) break; #ifdef CONFIG_LINE6_USB_DUMP_MIDI line6_write_hexdump(line6, 's', chunk, done); #endif line6_midibuf_write(mb, chunk, done); snd_rawmidi_transmit_ack(substream, done); } for (;;) { done = line6_midibuf_read(mb, chunk, line6->max_packet_size); if (done == 0) break; if (line6_midibuf_skip_message (mb, line6midi->midi_mask_transmit)) continue; send_midi_async(line6, chunk, done); } spin_unlock_irqrestore(&line6->line6midi->midi_transmit_lock, flags); }
/* Notification of data received from the Line6 device. */ static void line6_data_received(struct urb *urb) { struct usb_line6 *line6 = (struct usb_line6 *)urb->context; struct MidiBuffer *mb = &line6->line6midi->midibuf_in; int done; if (urb->status == -ESHUTDOWN) return; #ifdef CONFIG_LINE6_USB_DUMP_CTRL line6_dump_urb(urb); #endif done = line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length); if (done < urb->actual_length) { line6_midibuf_ignore(mb, done); DEBUG_MESSAGES(dev_err (line6->ifcdev, "%d %d buffer overflow - message skipped\n", done, urb->actual_length)); } for (;;) { done = line6_midibuf_read(mb, line6->buffer_message, LINE6_MESSAGE_MAXLEN); if (done == 0) break; /* MIDI input filter */ if (line6_midibuf_skip_message (mb, line6->line6midi->midi_mask_receive)) continue; line6->message_length = done; #ifdef CONFIG_LINE6_USB_DUMP_MIDI line6_write_hexdump(line6, 'r', line6->buffer_message, done); #endif line6_midi_receive(line6, line6->buffer_message, done); switch (line6->usbdev->descriptor.idProduct) { case LINE6_DEVID_BASSPODXT: case LINE6_DEVID_BASSPODXTLIVE: case LINE6_DEVID_BASSPODXTPRO: case LINE6_DEVID_PODXT: case LINE6_DEVID_PODXTPRO: case LINE6_DEVID_POCKETPOD: line6_pod_process_message((struct usb_line6_pod *) line6); break; case LINE6_DEVID_PODXTLIVE: switch (line6->interface_number) { case PODXTLIVE_INTERFACE_POD: line6_pod_process_message((struct usb_line6_pod *)line6); break; case PODXTLIVE_INTERFACE_VARIAX: line6_variax_process_message((struct usb_line6_variax *)line6); break; default: dev_err(line6->ifcdev, "PODxt Live interface %d not supported\n", line6->interface_number); } break; case LINE6_DEVID_VARIAX: line6_variax_process_message((struct usb_line6_variax *) line6); break; default: MISSING_CASE; } } line6_start_listen(line6); }