summaryrefslogtreecommitdiff
path: root/sound/core/ump.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2024-08-06 09:00:23 +0200
committerTakashi Iwai <tiwai@suse.de>2024-08-06 09:01:23 +0200
commit0079c9d1e58a39148e6ce13bda55307ea6aa3a9e (patch)
tree6b8cc6fa3c284b298ed478be80ca12f691f9d015 /sound/core/ump.c
parenta48fee68a8fa35fc1a9b924c06d3e023d067ff41 (diff)
downloadlwn-0079c9d1e58a39148e6ce13bda55307ea6aa3a9e.tar.gz
lwn-0079c9d1e58a39148e6ce13bda55307ea6aa3a9e.zip
ALSA: ump: Handle MIDI 1.0 Function Block in MIDI 2.0 protocol
The UMP v1.1 spec says in the section 6.2.1: "If a UMP Endpoint declares MIDI 2.0 Protocol but a Function Block represents a MIDI 1.0 connection, then may optionally be used for messages to/from that Function Block." It implies that the driver can (and should) keep MIDI 1.0 CVM exceptionally for those FBs even if UMP Endpoint is running in MIDI 2.0 protocol, and the current driver lacks of it. This patch extends the sequencer port info to indicate a MIDI 1.0 port, and tries to send/receive MIDI 1.0 CVM as is when this port is the source or sink. The sequencer port flag is set by the driver at parsing FBs and GTBs although application can set it to its own user-space clients, too. Link: https://patch.msgid.link/20240806070024.14301-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/ump.c')
-rw-r--r--sound/core/ump.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sound/core/ump.c b/sound/core/ump.c
index e39e9cda4912..c7c3581bbbbc 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -538,6 +538,7 @@ static void update_group_attrs(struct snd_ump_endpoint *ump)
group->active = 0;
group->group = i;
group->valid = false;
+ group->is_midi1 = false;
}
list_for_each_entry(fb, &ump->block_list, list) {
@@ -548,6 +549,8 @@ static void update_group_attrs(struct snd_ump_endpoint *ump)
group->valid = true;
if (fb->info.active)
group->active = 1;
+ if (fb->info.flags & SNDRV_UMP_BLOCK_IS_MIDI1)
+ group->is_midi1 = true;
switch (fb->info.direction) {
case SNDRV_UMP_DIR_INPUT:
group->dir_bits |= (1 << SNDRV_RAWMIDI_STREAM_INPUT);
@@ -1156,6 +1159,7 @@ static int process_legacy_output(struct snd_ump_endpoint *ump,
struct snd_rawmidi_substream *substream;
struct ump_cvt_to_ump *ctx;
const int dir = SNDRV_RAWMIDI_STREAM_OUTPUT;
+ unsigned int protocol;
unsigned char c;
int group, size = 0;
@@ -1168,9 +1172,13 @@ static int process_legacy_output(struct snd_ump_endpoint *ump,
if (!substream)
continue;
ctx = &ump->out_cvts[group];
+ protocol = ump->info.protocol;
+ if ((protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI2) &&
+ ump->groups[group].is_midi1)
+ protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI1;
while (!ctx->ump_bytes &&
snd_rawmidi_transmit(substream, &c, 1) > 0)
- snd_ump_convert_to_ump(ctx, group, ump->info.protocol, c);
+ snd_ump_convert_to_ump(ctx, group, protocol, c);
if (ctx->ump_bytes && ctx->ump_bytes <= count) {
size = ctx->ump_bytes;
memcpy(buffer, ctx->ump, size);