Skip to content

ALSA: ump: Fix RPN/NRPN handling at MIDI 1.0 CC conversion

HyeongJun An linux-sound lkml stable 1 version Applied

Status from this message: Applied all patches to for-next branch now. Thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4ALSA: ump: Clear stale RPN selector on NRPN changesound/core/ump_convert.c+4 -00 replies
2/4ALSA: seq: ump: Clear stale selectors in sequencer conversionsound/core/seq/seq_ump_convert.c+6 -00 replies
3/4ALSA: ump: Fix RPN/NRPN state handling at MIDI 1.0 CC conversionsound/core/ump_convert.c+20 -40 replies
4/4ALSA: seq: ump: Fix RPN/NRPN state handling at MIDI 1.0 CC conversionsound/core/seq/seq_ump_convert.c+22 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] ALSA: ump: Fix RPN/NRPN handling at MIDI 1.0 CC conversion

Hello Takashi,

As you asked in [1], this puts Alyandra's selector fix and my fixes for the other RPN/NRPN cases into one series, for both the UMP core converter and the sequencer.

Patches 1 and 2 are Alyandra's [2], without the KUnit test. Selecting an RPN now clears the NRPN selection and vice versa. Patches 3 and 4 keep the selection after a send and clear only the data, drop data when nothing is selected, and handle a Null NRPN like a Null RPN.

What a MIDI 2.0 receiver gets, before and after the series:

  Input                                    Before             After
  Null RPN, Data Entry, select RPN 0/1     RPN 0/0 = 0x40     nothing
  Data Entry, select RPN 0/1               RPN 0/0 = 0x40     nothing
  RPN 0/2 + data, data again, RPN 0/1      0/2, then 0/0      0/2, 0/2
  Null RPN, Data Entry, select NRPN 0/5    NRPN 0/0 = 0x40    nothing
  select RPN 0/0, NRPN 1/2 + data          RPN 0/0            NRPN 1/2
  Null NRPN, Data Entry                    NRPN 127/127       nothing
  select RPN 0/127, Null RPN, data         RPN 0/127          nothing
  RPN 0/1 + data, CC 38, select RPN 0/2    0/1, then 0/0      0/1, 0/1
  RPN 1/1 + data, RPN LSB 2, data          1/1, then 0/2      1/1, 1/2
  Null RPN, RPN MSB 5, data                RPN 5/0            RPN 5/127
  RPN 0/1 + data (unchanged)               RPN 0/1            RPN 0/1

The 0/127 row and the last two changes come from holding the RPN/NRPN numbers, as a MIDI 1.0 receiver does.

I checked the core converter with a local KUnit test over 35 input sequences. The 17 that changed are all of the kinds above, and the others give the same packets as before. The sequencer side was run with a legacy client sending CC and CONTROL14 events to a MIDI 2.0 client on a patched kernel under qemu. That test will become the selftest, with Alyandra's cases added, as a separate patch.

Two cases are left as they were. A CC 6 alone waits for a CC 38 or the next CC 98 to 101, so a second CC 6 replaces the first instead of sending it. A CC 38 alone after a send waits the same way, and when the next CC 98 to 101 flushes it, it still goes out with MSB 0, now under the kept selection. Changing those would be a separate patch.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Prepared with Claude Code (Claude Opus 5.5). Tested on x86_64.

Best regards,
HyeongJun An

Alyandra Zahran Nadhir (2):
ALSA: ump: Clear stale RPN selector on NRPN change
ALSA: seq: ump: Clear stale selectors in sequencer conversion

HyeongJun An (2):
ALSA: ump: Fix RPN/NRPN state handling at MIDI 1.0 CC conversion
ALSA: seq: ump: Fix RPN/NRPN state handling at MIDI 1.0 CC conversion

 sound/core/seq/seq_ump_convert.c | 32 ++++++++++++++++++++++++++++----
 sound/core/ump_convert.c         | 28 ++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0