Skip to content

Commit 6a8b480

Browse files
committed
ALSA: seq: ump: Notify UMP protocol change to sequencer
UMP v1.1 supports the protocol switch via a UMP Stream message. When it's received, we need to take care of the midi_version field in the corresponding sequencer client, too. This patch introduces a new ops to notify the protocol change to snd_seq_ump_ops for handling it. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 174a6df commit 6a8b480

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

include/sound/ump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct snd_seq_ump_ops {
7272
const u32 *data, int words);
7373
int (*notify_fb_change)(struct snd_ump_endpoint *ump,
7474
struct snd_ump_block *fb);
75+
int (*switch_protocol)(struct snd_ump_endpoint *ump);
7576
};
7677

7778
struct snd_ump_block {

sound/core/seq/seq_ump_client.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,19 @@ static int seq_ump_notify_fb_change(struct snd_ump_endpoint *ump,
439439
return 0;
440440
}
441441

442+
/* UMP protocol change notification; just update the midi_version field */
443+
static int seq_ump_switch_protocol(struct snd_ump_endpoint *ump)
444+
{
445+
if (!ump->seq_client)
446+
return -ENODEV;
447+
setup_client_midi_version(ump->seq_client);
448+
return 0;
449+
}
450+
442451
static const struct snd_seq_ump_ops seq_ump_ops = {
443452
.input_receive = seq_ump_input_receive,
444453
.notify_fb_change = seq_ump_notify_fb_change,
454+
.switch_protocol = seq_ump_switch_protocol,
445455
};
446456

447457
/* create a sequencer client and ports for the given UMP endpoint */

sound/core/ump.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,14 +657,27 @@ static int ump_handle_product_id_msg(struct snd_ump_endpoint *ump,
657657
buf->raw, 2);
658658
}
659659

660+
/* notify the protocol change to sequencer */
661+
static void seq_notify_protocol(struct snd_ump_endpoint *ump)
662+
{
663+
#if IS_ENABLED(CONFIG_SND_SEQUENCER)
664+
if (ump->seq_ops && ump->seq_ops->switch_protocol)
665+
ump->seq_ops->switch_protocol(ump);
666+
#endif /* CONFIG_SND_SEQUENCER */
667+
}
668+
660669
/* handle EP stream config message; update the UMP protocol */
661670
static int ump_handle_stream_cfg_msg(struct snd_ump_endpoint *ump,
662671
const union snd_ump_stream_msg *buf)
663672
{
673+
unsigned int old_protocol = ump->info.protocol;
674+
664675
ump->info.protocol =
665676
(buf->stream_cfg.protocol << 8) | buf->stream_cfg.jrts;
666677
ump_dbg(ump, "Current protocol = %x (caps = %x)\n",
667678
ump->info.protocol, ump->info.protocol_caps);
679+
if (ump->parsed && ump->info.protocol != old_protocol)
680+
seq_notify_protocol(ump);
668681
return 1; /* finished */
669682
}
670683

0 commit comments

Comments
 (0)