#include <linux/bitops.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/wait.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/usb/audio.h>
#include <linux/usb/midi.h>
#include <linux/usb/midi-v2.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/ump.h>
#include "usbaudio.h"
#include "midi.h"
#include "midi2.h"
#include "helper.h"
static bool midi2_enable = …;
module_param(midi2_enable, bool, 0444);
MODULE_PARM_DESC(…) …;
static bool midi2_ump_probe = …;
module_param(midi2_ump_probe, bool, 0444);
MODULE_PARM_DESC(…) …;
enum { … };
#define NUM_URBS …
struct snd_usb_midi2_urb;
struct snd_usb_midi2_endpoint;
struct snd_usb_midi2_ump;
struct snd_usb_midi2_interface;
struct snd_usb_midi2_urb { … };
struct snd_usb_midi2_endpoint { … };
struct snd_usb_midi2_ump { … };
struct snd_usb_midi2_interface { … };
static void do_submit_urbs_locked(struct snd_usb_midi2_endpoint *ep,
int (*prepare)(struct snd_usb_midi2_endpoint *,
struct urb *))
{ … }
static int prepare_output_urb(struct snd_usb_midi2_endpoint *ep,
struct urb *urb)
{ … }
static void submit_output_urbs_locked(struct snd_usb_midi2_endpoint *ep)
{ … }
static void output_urb_complete(struct urb *urb)
{ … }
static int prepare_input_urb(struct snd_usb_midi2_endpoint *ep,
struct urb *urb)
{ … }
static void submit_input_urbs_locked(struct snd_usb_midi2_endpoint *ep)
{ … }
static void input_urb_complete(struct urb *urb)
{ … }
static void submit_io_urbs(struct snd_usb_midi2_endpoint *ep)
{ … }
static void kill_midi_urbs(struct snd_usb_midi2_endpoint *ep, bool suspending)
{ … }
static void drain_urb_queue(struct snd_usb_midi2_endpoint *ep)
{ … }
static void free_midi_urbs(struct snd_usb_midi2_endpoint *ep)
{ … }
static int alloc_midi_urbs(struct snd_usb_midi2_endpoint *ep)
{ … }
static struct snd_usb_midi2_endpoint *
ump_to_endpoint(struct snd_ump_endpoint *ump, int dir)
{ … }
static int snd_usb_midi_v2_open(struct snd_ump_endpoint *ump, int dir)
{ … }
static void snd_usb_midi_v2_close(struct snd_ump_endpoint *ump, int dir)
{ … }
static void snd_usb_midi_v2_trigger(struct snd_ump_endpoint *ump, int dir,
int up)
{ … }
static void snd_usb_midi_v2_drain(struct snd_ump_endpoint *ump, int dir)
{ … }
static int start_input_streams(struct snd_usb_midi2_interface *umidi)
{ … }
static const struct snd_ump_ops snd_usb_midi_v2_ump_ops = …;
static int create_midi2_endpoint(struct snd_usb_midi2_interface *umidi,
struct usb_host_endpoint *hostep,
const struct usb_ms20_endpoint_descriptor *ms_ep)
{ … }
static void free_midi2_endpoint(struct snd_usb_midi2_endpoint *ep)
{ … }
static void free_all_midi2_endpoints(struct snd_usb_midi2_interface *umidi)
{ … }
static void *find_usb_ms_endpoint_descriptor(struct usb_host_endpoint *hostep,
unsigned char subtype)
{ … }
static int get_group_terminal_block_descs(struct snd_usb_midi2_interface *umidi)
{ … }
static const struct usb_ms20_gr_trm_block_descriptor *
find_group_terminal_block(struct snd_usb_midi2_interface *umidi, int id)
{ … }
static int parse_group_terminal_block(struct snd_usb_midi2_ump *rmidi,
const struct usb_ms20_gr_trm_block_descriptor *desc)
{ … }
static int parse_group_terminal_blocks(struct snd_usb_midi2_interface *umidi)
{ … }
static int parse_midi_2_0_endpoints(struct snd_usb_midi2_interface *umidi)
{ … }
static void free_all_midi2_umps(struct snd_usb_midi2_interface *umidi)
{ … }
static int create_midi2_ump(struct snd_usb_midi2_interface *umidi,
struct snd_usb_midi2_endpoint *ep_in,
struct snd_usb_midi2_endpoint *ep_out,
int blk_id)
{ … }
static struct snd_usb_midi2_ump *
find_midi2_ump(struct snd_usb_midi2_interface *umidi, int blk_id)
{ … }
static int find_matching_ep_partner(struct snd_usb_midi2_interface *umidi,
struct snd_usb_midi2_endpoint *ep,
int blk_id)
{ … }
static int parse_ump_endpoints(struct snd_usb_midi2_interface *umidi)
{ … }
static int create_gtb_block(struct snd_usb_midi2_ump *rmidi, int dir, int blk)
{ … }
static int create_blocks_from_gtb(struct snd_usb_midi2_interface *umidi)
{ … }
static int attach_legacy_rawmidi(struct snd_usb_midi2_interface *umidi)
{ … }
static void snd_usb_midi_v2_free(struct snd_usb_midi2_interface *umidi)
{ … }
static int parse_midi_2_0(struct snd_usb_midi2_interface *umidi)
{ … }
static bool is_midi2_altset(struct usb_host_interface *hostif)
{ … }
static int set_altset(struct snd_usb_midi2_interface *umidi)
{ … }
static void fill_ump_ep_name(struct snd_ump_endpoint *ump,
struct usb_device *dev, int id)
{ … }
static void set_fallback_rawmidi_names(struct snd_usb_midi2_interface *umidi)
{ … }
int snd_usb_midi_v2_create(struct snd_usb_audio *chip,
struct usb_interface *iface,
const struct snd_usb_audio_quirk *quirk,
unsigned int usb_id)
{ … }
static void suspend_midi2_endpoint(struct snd_usb_midi2_endpoint *ep)
{ … }
void snd_usb_midi_v2_suspend_all(struct snd_usb_audio *chip)
{ … }
static void resume_midi2_endpoint(struct snd_usb_midi2_endpoint *ep)
{ … }
void snd_usb_midi_v2_resume_all(struct snd_usb_audio *chip)
{ … }
void snd_usb_midi_v2_disconnect_all(struct snd_usb_audio *chip)
{ … }
void snd_usb_midi_v2_free_all(struct snd_usb_audio *chip)
{ … }