xref: /linux/drivers/usb/gadget/function/u_midi2.h (revision fd7d598270724cc787982ea48bbe17ad383a8b7f)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Utility definitions for MIDI 2.0 function
4  */
5 
6 #ifndef U_MIDI2_H
7 #define U_MIDI2_H
8 
9 #include <linux/usb/composite.h>
10 #include <sound/asound.h>
11 
12 struct f_midi2_opts;
13 struct f_midi2_ep_opts;
14 struct f_midi2_block_opts;
15 
16 /* UMP Function Block info */
17 struct f_midi2_block_info {
18 	unsigned int direction;		/* FB direction: 1-3 */
19 	unsigned int first_group;	/* first UMP group: 0-15 */
20 	unsigned int num_groups;	/* number of UMP groups: 1-16 */
21 	unsigned int midi1_first_group;	/* first UMP group for MIDI 1.0 */
22 	unsigned int midi1_num_groups;	/* number of UMP groups for MIDI 1.0 */
23 	unsigned int ui_hint;		/* UI-hint: 0-3 */
24 	unsigned int midi_ci_version;	/* MIDI-CI version: 0-255 */
25 	unsigned int sysex8_streams;	/* number of sysex8 streams: 0-255 */
26 	unsigned int is_midi1;		/* MIDI 1.0 port: 0-2 */
27 	bool active;			/* FB active flag: bool */
28 	const char *name;		/* FB name */
29 };
30 
31 /* UMP Endpoint info */
32 struct f_midi2_ep_info {
33 	unsigned int protocol_caps;	/* protocol capabilities: 1-3 */
34 	unsigned int protocol;		/* default protocol: 1-2 */
35 	unsigned int manufacturer;	/* manufacturer id: 0-0xffffff */
36 	unsigned int family;		/* device family id: 0-0xffff */
37 	unsigned int model;		/* device model id: 0x-0xffff */
38 	unsigned int sw_revision;	/* software revision: 32bit */
39 
40 	const char *ep_name;		/* Endpoint name */
41 	const char *product_id;		/* Product ID */
42 };
43 
44 struct f_midi2_card_info {
45 	bool process_ump;		/* process UMP stream: bool */
46 	bool static_block;		/* static FBs: bool */
47 	unsigned int req_buf_size;	/* request buffer size */
48 	unsigned int num_reqs;		/* number of requests */
49 	const char *iface_name;		/* interface name */
50 };
51 
52 struct f_midi2_block_opts {
53 	struct config_group group;
54 	unsigned int id;
55 	struct f_midi2_block_info info;
56 	struct f_midi2_ep_opts *ep;
57 };
58 
59 struct f_midi2_ep_opts {
60 	struct config_group group;
61 	unsigned int index;
62 	struct f_midi2_ep_info info;
63 	struct f_midi2_block_opts *blks[SNDRV_UMP_MAX_BLOCKS];
64 	struct f_midi2_opts *opts;
65 };
66 
67 #define MAX_UMP_EPS		4
68 #define MAX_CABLES		16
69 
70 struct f_midi2_opts {
71 	struct usb_function_instance func_inst;
72 	struct mutex lock;
73 	int refcnt;
74 
75 	struct f_midi2_card_info info;
76 
77 	unsigned int num_eps;
78 	struct f_midi2_ep_opts *eps[MAX_UMP_EPS];
79 };
80 
81 #endif /* U_MIDI2_H */
82