summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/function/u_midi2.h
blob: 4e7adb41dfb76e7d31937d2b1578051ccdecfffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: GPL-2.0+
/*
 * Utility definitions for MIDI 2.0 function
 */

#ifndef U_MIDI2_H
#define U_MIDI2_H

#include <linux/usb/composite.h>
#include <sound/asound.h>

struct f_midi2_opts;
struct f_midi2_ep_opts;
struct f_midi2_block_opts;

/* UMP Function Block info */
struct f_midi2_block_info {
	unsigned int direction;		/* FB direction: 1-3 */
	unsigned int first_group;	/* first UMP group: 0-15 */
	unsigned int num_groups;	/* number of UMP groups: 1-16 */
	unsigned int midi1_first_group;	/* first UMP group for MIDI 1.0 */
	unsigned int midi1_num_groups;	/* number of UMP groups for MIDI 1.0 */
	unsigned int ui_hint;		/* UI-hint: 0-3 */
	unsigned int midi_ci_version;	/* MIDI-CI version: 0-255 */
	unsigned int sysex8_streams;	/* number of sysex8 streams: 0-255 */
	unsigned int is_midi1;		/* MIDI 1.0 port: 0-2 */
	bool active;			/* FB active flag: bool */
	const char *name;		/* FB name */
};

/* UMP Endpoint info */
struct f_midi2_ep_info {
	unsigned int protocol_caps;	/* protocol capabilities: 1-3 */
	unsigned int protocol;		/* default protocol: 1-2 */
	unsigned int manufacturer;	/* manufacturer id: 0-0xffffff */
	unsigned int family;		/* device family id: 0-0xffff */
	unsigned int model;		/* device model id: 0x-0xffff */
	unsigned int sw_revision;	/* software revision: 32bit */

	const char *ep_name;		/* Endpoint name */
	const char *product_id;		/* Product ID */
};

struct f_midi2_card_info {
	bool process_ump;		/* process UMP stream: bool */
	bool static_block;		/* static FBs: bool */
	unsigned int req_buf_size;	/* request buffer size */
	unsigned int num_reqs;		/* number of requests */
	const char *iface_name;		/* interface name */
};

struct f_midi2_block_opts {
	struct config_group group;
	unsigned int id;
	struct f_midi2_block_info info;
	struct f_midi2_ep_opts *ep;
};

struct f_midi2_ep_opts {
	struct config_group group;
	unsigned int index;
	struct f_midi2_ep_info info;
	struct f_midi2_block_opts *blks[SNDRV_UMP_MAX_BLOCKS];
	struct f_midi2_opts *opts;
};

#define MAX_UMP_EPS		4
#define MAX_CABLES		16

struct f_midi2_opts {
	struct usb_function_instance func_inst;
	struct mutex lock;
	int refcnt;

	struct f_midi2_card_info info;

	unsigned int num_eps;
	struct f_midi2_ep_opts *eps[MAX_UMP_EPS];
};

#endif /* U_MIDI2_H */