1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef __SOUND_UMP_CONVERT_H
3#define __SOUND_UMP_CONVERT_H
4
5#include <sound/ump_msg.h>
6
7/* context for converting from legacy control messages to UMP packet */
8struct ump_cvt_to_ump_bank {
9	bool rpn_set;
10	bool nrpn_set;
11	bool bank_set;
12	unsigned char cc_rpn_msb, cc_rpn_lsb;
13	unsigned char cc_nrpn_msb, cc_nrpn_lsb;
14	unsigned char cc_data_msb, cc_data_lsb;
15	unsigned char cc_bank_msb, cc_bank_lsb;
16};
17
18/* context for converting from MIDI1 byte stream to UMP packet */
19struct ump_cvt_to_ump {
20	/* MIDI1 intermediate buffer */
21	unsigned char buf[4];
22	int len;
23	int cmd_bytes;
24
25	/* UMP output packet */
26	u32 ump[4];
27	int ump_bytes;
28
29	/* various status */
30	unsigned int in_sysex;
31	struct ump_cvt_to_ump_bank bank[16];	/* per channel */
32};
33
34int snd_ump_convert_from_ump(const u32 *data, unsigned char *dst,
35			     unsigned char *group_ret);
36void snd_ump_convert_to_ump(struct ump_cvt_to_ump *cvt, unsigned char group,
37			    unsigned int protocol, unsigned char c);
38
39/* reset the converter context, called at each open to ump */
40static inline void snd_ump_convert_reset(struct ump_cvt_to_ump *ctx)
41{
42	memset(ctx, 0, sizeof(*ctx));
43
44}
45
46#endif /* __SOUND_UMP_CONVERT_H */
47