linux/include/sound/ump_convert.h
Takashi Iwai e6ce8a28c7 ALSA: ump: Transmit RPN/NRPN message at each MSB/LSB data reception
The UMP 1.1 spec says that an RPN/NRPN should be sent when one of the
following occurs:
* a CC 38 is received
* a subsequent CC 6 is received
* a CC 98, 99, 100, and 101 is received, indicating the last RPN/NRPN
  message has ended and a new one has started

That said, we should send a partial data even if it's not fully
filled.  Let's change the UMP conversion helper code to follow that
rule.

Link: https://patch.msgid.link/20240731130528.12600-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-07-31 15:08:18 +02:00

48 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef __SOUND_UMP_CONVERT_H
#define __SOUND_UMP_CONVERT_H
#include <sound/ump_msg.h>
/* context for converting from legacy control messages to UMP packet */
struct ump_cvt_to_ump_bank {
bool rpn_set;
bool nrpn_set;
bool bank_set;
unsigned char cc_rpn_msb, cc_rpn_lsb;
unsigned char cc_nrpn_msb, cc_nrpn_lsb;
unsigned char cc_data_msb, cc_data_lsb;
unsigned char cc_bank_msb, cc_bank_lsb;
bool cc_data_msb_set, cc_data_lsb_set;
};
/* context for converting from MIDI1 byte stream to UMP packet */
struct ump_cvt_to_ump {
/* MIDI1 intermediate buffer */
unsigned char buf[4];
int len;
int cmd_bytes;
/* UMP output packet */
u32 ump[4];
int ump_bytes;
/* various status */
unsigned int in_sysex;
struct ump_cvt_to_ump_bank bank[16]; /* per channel */
};
int snd_ump_convert_from_ump(const u32 *data, unsigned char *dst,
unsigned char *group_ret);
void snd_ump_convert_to_ump(struct ump_cvt_to_ump *cvt, unsigned char group,
unsigned int protocol, unsigned char c);
/* reset the converter context, called at each open to ump */
static inline void snd_ump_convert_reset(struct ump_cvt_to_ump *ctx)
{
memset(ctx, 0, sizeof(*ctx));
}
#endif /* __SOUND_UMP_CONVERT_H */