Commit 6a8b4800 authored by Takashi Iwai's avatar Takashi Iwai

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/20230612081054.17200-9-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 174a6dfb
...@@ -72,6 +72,7 @@ struct snd_seq_ump_ops { ...@@ -72,6 +72,7 @@ struct snd_seq_ump_ops {
const u32 *data, int words); const u32 *data, int words);
int (*notify_fb_change)(struct snd_ump_endpoint *ump, int (*notify_fb_change)(struct snd_ump_endpoint *ump,
struct snd_ump_block *fb); struct snd_ump_block *fb);
int (*switch_protocol)(struct snd_ump_endpoint *ump);
}; };
struct snd_ump_block { struct snd_ump_block {
......
...@@ -439,9 +439,19 @@ static int seq_ump_notify_fb_change(struct snd_ump_endpoint *ump, ...@@ -439,9 +439,19 @@ static int seq_ump_notify_fb_change(struct snd_ump_endpoint *ump,
return 0; return 0;
} }
/* UMP protocol change notification; just update the midi_version field */
static int seq_ump_switch_protocol(struct snd_ump_endpoint *ump)
{
if (!ump->seq_client)
return -ENODEV;
setup_client_midi_version(ump->seq_client);
return 0;
}
static const struct snd_seq_ump_ops seq_ump_ops = { static const struct snd_seq_ump_ops seq_ump_ops = {
.input_receive = seq_ump_input_receive, .input_receive = seq_ump_input_receive,
.notify_fb_change = seq_ump_notify_fb_change, .notify_fb_change = seq_ump_notify_fb_change,
.switch_protocol = seq_ump_switch_protocol,
}; };
/* create a sequencer client and ports for the given UMP endpoint */ /* create a sequencer client and ports for the given UMP endpoint */
......
...@@ -657,14 +657,27 @@ static int ump_handle_product_id_msg(struct snd_ump_endpoint *ump, ...@@ -657,14 +657,27 @@ static int ump_handle_product_id_msg(struct snd_ump_endpoint *ump,
buf->raw, 2); buf->raw, 2);
} }
/* notify the protocol change to sequencer */
static void seq_notify_protocol(struct snd_ump_endpoint *ump)
{
#if IS_ENABLED(CONFIG_SND_SEQUENCER)
if (ump->seq_ops && ump->seq_ops->switch_protocol)
ump->seq_ops->switch_protocol(ump);
#endif /* CONFIG_SND_SEQUENCER */
}
/* handle EP stream config message; update the UMP protocol */ /* handle EP stream config message; update the UMP protocol */
static int ump_handle_stream_cfg_msg(struct snd_ump_endpoint *ump, static int ump_handle_stream_cfg_msg(struct snd_ump_endpoint *ump,
const union snd_ump_stream_msg *buf) const union snd_ump_stream_msg *buf)
{ {
unsigned int old_protocol = ump->info.protocol;
ump->info.protocol = ump->info.protocol =
(buf->stream_cfg.protocol << 8) | buf->stream_cfg.jrts; (buf->stream_cfg.protocol << 8) | buf->stream_cfg.jrts;
ump_dbg(ump, "Current protocol = %x (caps = %x)\n", ump_dbg(ump, "Current protocol = %x (caps = %x)\n",
ump->info.protocol, ump->info.protocol_caps); ump->info.protocol, ump->info.protocol_caps);
if (ump->parsed && ump->info.protocol != old_protocol)
seq_notify_protocol(ump);
return 1; /* finished */ return 1; /* finished */
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment