From: HyeongJun An <sammiee5311@gmail.com>
To: Takashi Iwai <tiwai@suse.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Mark Brown <broonie@kernel.org>,
Shuah Khan <shuah@kernel.org>,
linux-sound@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
HyeongJun An <sammiee5311@gmail.com>
Subject: [PATCH 2/4] selftests/alsa: Test the sequencer UMP bank and program change conversion
Date: Wed, 2 Dec 2026 16:32:13 +0900 [thread overview]
Message-ID: <20261202073215.2588603-3-sammiee5311@gmail.com> (raw)
In-Reply-To: <20261202073215.2588603-1-sammiee5311@gmail.com>
Check that a bank select from a legacy client goes to a UMP MIDI 2.0
client with the next program change, sent as CCs and as CONTROL14. For
the CCs, also check that the program change after that has no bank, and
that a later bank select LSB keeps the MSB. The latter was fixed by
commit a200df7deb31 ("ALSA: seq: Don't clear bank selection at event ->
UMP MIDI2 conversion"). Also check the bank of a program change between
UMP MIDI 1.0 and MIDI 2.0 clients.
ump_midi2_to_midi1_program fails without "ALSA: seq: ump: Don't leave
the bank LSB in a MIDI 1.0 program change".
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
tools/testing/selftests/alsa/seq-ump-test.c | 64 ++++++++++++++++++++-
1 file changed, 62 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/alsa/seq-ump-test.c b/tools/testing/selftests/alsa/seq-ump-test.c
index 7030d061dfae8..f2051777a9dc5 100644
--- a/tools/testing/selftests/alsa/seq-ump-test.c
+++ b/tools/testing/selftests/alsa/seq-ump-test.c
@@ -4,8 +4,8 @@
* packets between MIDI 1.0 and MIDI 2.0 clients.
*
* A client sends events to a UMP client, and the test checks the packets
- * that the UMP client receives. The converter keeps its RPN/NRPN state
- * per destination port and channel, so each test uses new clients.
+ * that the UMP client receives. The converter keeps its RPN/NRPN and bank
+ * state per destination port and channel, so each test uses new clients.
*/
#include <errno.h>
#include <fcntl.h>
@@ -232,6 +232,8 @@ struct event {
{ SNDRV_SEQ_EVENT_CONTROLLER, ch, param, value }
#define C14(ch, param, value) \
{ SNDRV_SEQ_EVENT_CONTROL14, ch, param, value }
+#define PGM(ch, value) \
+ { SNDRV_SEQ_EVENT_PGMCHANGE, ch, 0, value }
static int send_events(struct seq_client *src, struct seq_client *dst,
const struct event *ev, int n)
@@ -482,6 +484,26 @@ TEST_F(seq_ump, key_pressure)
EXPECT_PACKETS({ 0x40a24000, 0 });
}
+/*
+ * A bank select goes with the next program change only, and a later
+ * bank select LSB keeps the MSB
+ */
+TEST_F(seq_ump, program_bank)
+{
+ SEND(CC(0, 0, 1), CC(0, 32, 2), PGM(0, 5));
+ SEND(CC(0, 32, 3), PGM(0, 6), PGM(0, 7));
+ EXPECT_PACKETS({ 0x40c00001, 0x05000102 },
+ { 0x40c00001, 0x06000103 },
+ { 0x40c00000, 0x07000000 });
+}
+
+/* the same with the bank select sent as CONTROL14 */
+TEST_F(seq_ump, c14_program_bank)
+{
+ SEND(C14(7, 0, (3 << 7) | 4), PGM(7, 9));
+ EXPECT_PACKETS({ 0x40c70001, 0x09000304 });
+}
+
/* a UMP MIDI 1.0 client gets the CCs as they are, RPN selection included */
TEST(midi1_passthrough)
{
@@ -640,4 +662,42 @@ TEST_F(seq_pair, ump_midi2_to_midi1_rpn)
{ 0x20b10609, 0 }, { 0x20b1260d, 0 });
}
+/* UMP MIDI 1.0 to MIDI 2.0: the bank select CCs go into the program change */
+TEST_F(seq_pair, ump_midi1_to_midi2_program)
+{
+ int skip = 0;
+ int err;
+
+ err = open_pair(&self->dst, SNDRV_SEQ_CLIENT_UMP_MIDI_2_0,
+ &self->src, SNDRV_SEQ_CLIENT_UMP_MIDI_1_0, &skip);
+ if (skip)
+ SKIP(return, "UMP sequencer client unavailable: %s",
+ strerror(-err));
+ ASSERT_EQ(0, err);
+
+ SEND_UMP(0x20b00001, 0);
+ SEND_UMP(0x20b02002, 0);
+ SEND_UMP(0x20c00500, 0);
+ EXPECT_PACKETS({ 0x40c00001, 0x05000102 });
+}
+
+/* UMP MIDI 2.0 to MIDI 1.0: a program change with a bank is three messages */
+TEST_F(seq_pair, ump_midi2_to_midi1_program)
+{
+ int skip = 0;
+ int err;
+
+ err = open_pair(&self->dst, SNDRV_SEQ_CLIENT_UMP_MIDI_1_0,
+ &self->src, SNDRV_SEQ_CLIENT_UMP_MIDI_2_0, &skip);
+ if (skip)
+ SKIP(return, "UMP sequencer client unavailable: %s",
+ strerror(-err));
+ ASSERT_EQ(0, err);
+
+ SEND_UMP(0x40c00001, 0x05000102);
+ SEND_UMP(0x40c00000, 0x06000000);
+ EXPECT_MT_PACKETS(2, { 0x20b00001, 0 }, { 0x20b02002, 0 },
+ { 0x20c00500, 0 }, { 0x20c00600, 0 });
+}
+
TEST_HARNESS_MAIN
--
2.43.0
next prev parent reply other threads:[~2026-12-02 7:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 7:32 [PATCH 0/4] ALSA: seq: ump: Fix a program change and test more conversions HyeongJun An
2026-12-02 7:32 ` [PATCH 1/4] ALSA: seq: ump: Don't leave the bank LSB in a MIDI 1.0 program change HyeongJun An
2026-12-02 7:32 ` HyeongJun An [this message]
2026-12-02 7:32 ` [PATCH 3/4] selftests/alsa: Test the sequencer UMP SysEx conversion HyeongJun An
2026-12-02 7:32 ` [PATCH 4/4] selftests/alsa: Test the sequencer UMP system message conversion HyeongJun An
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=20261202073215.2588603-3-sammiee5311@gmail.com \
--to=sammiee5311@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shuah@kernel.org \
--cc=tiwai@suse.com \
/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®