162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Utility definitions for MIDI 2.0 function
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef U_MIDI2_H
762306a36Sopenharmony_ci#define U_MIDI2_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/usb/composite.h>
1062306a36Sopenharmony_ci#include <sound/asound.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct f_midi2_opts;
1362306a36Sopenharmony_cistruct f_midi2_ep_opts;
1462306a36Sopenharmony_cistruct f_midi2_block_opts;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/* UMP Function Block info */
1762306a36Sopenharmony_cistruct f_midi2_block_info {
1862306a36Sopenharmony_ci	unsigned int direction;		/* FB direction: 1-3 */
1962306a36Sopenharmony_ci	unsigned int first_group;	/* first UMP group: 0-15 */
2062306a36Sopenharmony_ci	unsigned int num_groups;	/* number of UMP groups: 1-16 */
2162306a36Sopenharmony_ci	unsigned int midi1_first_group;	/* first UMP group for MIDI 1.0 */
2262306a36Sopenharmony_ci	unsigned int midi1_num_groups;	/* number of UMP groups for MIDI 1.0 */
2362306a36Sopenharmony_ci	unsigned int ui_hint;		/* UI-hint: 0-3 */
2462306a36Sopenharmony_ci	unsigned int midi_ci_version;	/* MIDI-CI version: 0-255 */
2562306a36Sopenharmony_ci	unsigned int sysex8_streams;	/* number of sysex8 streams: 0-255 */
2662306a36Sopenharmony_ci	unsigned int is_midi1;		/* MIDI 1.0 port: 0-2 */
2762306a36Sopenharmony_ci	bool active;			/* FB active flag: bool */
2862306a36Sopenharmony_ci	const char *name;		/* FB name */
2962306a36Sopenharmony_ci};
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/* UMP Endpoint info */
3262306a36Sopenharmony_cistruct f_midi2_ep_info {
3362306a36Sopenharmony_ci	unsigned int protocol_caps;	/* protocol capabilities: 1-3 */
3462306a36Sopenharmony_ci	unsigned int protocol;		/* default protocol: 1-2 */
3562306a36Sopenharmony_ci	unsigned int manufacturer;	/* manufacturer id: 0-0xffffff */
3662306a36Sopenharmony_ci	unsigned int family;		/* device family id: 0-0xffff */
3762306a36Sopenharmony_ci	unsigned int model;		/* device model id: 0x-0xffff */
3862306a36Sopenharmony_ci	unsigned int sw_revision;	/* software revision: 32bit */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci	const char *ep_name;		/* Endpoint name */
4162306a36Sopenharmony_ci	const char *product_id;		/* Product ID */
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cistruct f_midi2_card_info {
4562306a36Sopenharmony_ci	bool process_ump;		/* process UMP stream: bool */
4662306a36Sopenharmony_ci	bool static_block;		/* static FBs: bool */
4762306a36Sopenharmony_ci	unsigned int req_buf_size;	/* request buffer size */
4862306a36Sopenharmony_ci	unsigned int num_reqs;		/* number of requests */
4962306a36Sopenharmony_ci	const char *iface_name;		/* interface name */
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistruct f_midi2_block_opts {
5362306a36Sopenharmony_ci	struct config_group group;
5462306a36Sopenharmony_ci	unsigned int id;
5562306a36Sopenharmony_ci	struct f_midi2_block_info info;
5662306a36Sopenharmony_ci	struct f_midi2_ep_opts *ep;
5762306a36Sopenharmony_ci};
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_cistruct f_midi2_ep_opts {
6062306a36Sopenharmony_ci	struct config_group group;
6162306a36Sopenharmony_ci	unsigned int index;
6262306a36Sopenharmony_ci	struct f_midi2_ep_info info;
6362306a36Sopenharmony_ci	struct f_midi2_block_opts *blks[SNDRV_UMP_MAX_BLOCKS];
6462306a36Sopenharmony_ci	struct f_midi2_opts *opts;
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define MAX_UMP_EPS		4
6862306a36Sopenharmony_ci#define MAX_CABLES		16
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cistruct f_midi2_opts {
7162306a36Sopenharmony_ci	struct usb_function_instance func_inst;
7262306a36Sopenharmony_ci	struct mutex lock;
7362306a36Sopenharmony_ci	int refcnt;
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci	struct f_midi2_card_info info;
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	unsigned int num_eps;
7862306a36Sopenharmony_ci	struct f_midi2_ep_opts *eps[MAX_UMP_EPS];
7962306a36Sopenharmony_ci};
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#endif /* U_MIDI2_H */
82