xref: /linux/include/sound/ump_convert.h (revision 0808ebf2f80b962e75741a41ced372a7116f1e26)
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 */
8 struct 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 	bool cc_data_msb_set, cc_data_lsb_set;
17 };
18 
19 /* context for converting from MIDI1 byte stream to UMP packet */
20 struct ump_cvt_to_ump {
21 	/* MIDI1 intermediate buffer */
22 	unsigned char buf[4];
23 	int len;
24 	int cmd_bytes;
25 
26 	/* UMP output packet */
27 	u32 ump[4];
28 	int ump_bytes;
29 
30 	/* various status */
31 	unsigned int in_sysex;
32 	struct ump_cvt_to_ump_bank bank[16];	/* per channel */
33 };
34 
35 int snd_ump_convert_from_ump(const u32 *data, unsigned char *dst,
36 			     unsigned char *group_ret);
37 void snd_ump_convert_to_ump(struct ump_cvt_to_ump *cvt, unsigned char group,
38 			    unsigned int protocol, unsigned char c);
39 
40 /* reset the converter context, called at each open to ump */
41 static inline void snd_ump_convert_reset(struct ump_cvt_to_ump *ctx)
42 {
43 	memset(ctx, 0, sizeof(*ctx));
44 
45 }
46 
47 #endif /* __SOUND_UMP_CONVERT_H */
48