From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 08/10] ALSA: seq: ump: Notify UMP protocol change to sequencer
Date: Mon, 12 Jun 2023 10:10:52 +0200 [thread overview]
Message-ID: <20230612081054.17200-9-tiwai@suse.de> (raw)
In-Reply-To: <20230612081054.17200-1-tiwai@suse.de>
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.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
include/sound/ump.h | 1 +
sound/core/seq/seq_ump_client.c | 10 ++++++++++
sound/core/ump.c | 13 +++++++++++++
3 files changed, 24 insertions(+)
diff --git a/include/sound/ump.h b/include/sound/ump.h
index 0e9c048346fa..68478e7be3b4 100644
--- a/include/sound/ump.h
+++ b/include/sound/ump.h
@@ -72,6 +72,7 @@ struct snd_seq_ump_ops {
const u32 *data, int words);
int (*notify_fb_change)(struct snd_ump_endpoint *ump,
struct snd_ump_block *fb);
+ int (*switch_protocol)(struct snd_ump_endpoint *ump);
};
struct snd_ump_block {
diff --git a/sound/core/seq/seq_ump_client.c b/sound/core/seq/seq_ump_client.c
index 901a670dcb36..fe21c801af74 100644
--- a/sound/core/seq/seq_ump_client.c
+++ b/sound/core/seq/seq_ump_client.c
@@ -439,9 +439,19 @@ static int seq_ump_notify_fb_change(struct snd_ump_endpoint *ump,
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 = {
.input_receive = seq_ump_input_receive,
.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 */
diff --git a/sound/core/ump.c b/sound/core/ump.c
index c0cda12bce10..f364bb290d3a 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -657,14 +657,27 @@ static int ump_handle_product_id_msg(struct snd_ump_endpoint *ump,
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 */
static int ump_handle_stream_cfg_msg(struct snd_ump_endpoint *ump,
const union snd_ump_stream_msg *buf)
{
+ unsigned int old_protocol = ump->info.protocol;
+
ump->info.protocol =
(buf->stream_cfg.protocol << 8) | buf->stream_cfg.jrts;
ump_dbg(ump, "Current protocol = %x (caps = %x)\n",
ump->info.protocol, ump->info.protocol_caps);
+ if (ump->parsed && ump->info.protocol != old_protocol)
+ seq_notify_protocol(ump);
return 1; /* finished */
}
--
2.35.3
next prev parent reply other threads:[~2023-06-12 8:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 8:10 [PATCH 00/10] ALSA: Catch up MIDI 2.0 updates for UMP 1.1 Takashi Iwai
2023-06-12 8:10 ` [PATCH 01/10] ALSA: ump: Add more attributes to UMP EP and FB info Takashi Iwai
2023-06-12 8:10 ` [PATCH 02/10] ALSA: ump: Support UMP Endpoint and Function Block parsing Takashi Iwai
2023-06-12 8:10 ` [PATCH 03/10] ALSA: usb-audio: Parse UMP Endpoint and Function Blocks at first Takashi Iwai
2023-06-12 8:10 ` [PATCH 04/10] ALSA: usb-audio: Add midi2_ump_probe option Takashi Iwai
2023-06-12 8:10 ` [PATCH 05/10] ALSA: seq: ump: Handle groupless messages Takashi Iwai
2023-06-12 8:10 ` [PATCH 06/10] ALSA: seq: ump: Handle FB info update Takashi Iwai
2023-06-12 8:10 ` [PATCH 07/10] ALSA: seq: ump: Notify port changes to system port Takashi Iwai
2023-06-12 8:10 ` Takashi Iwai [this message]
2023-06-12 8:10 ` [PATCH 09/10] ALSA: ump: Add info flag bit for static blocks Takashi Iwai
2023-06-12 8:10 ` [PATCH 10/10] ALSA: docs: Update MIDI 2.0 documentation for UMP 1.1 enhancement Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230612081054.17200-9-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®