Skip to content

MT-147614: Add USB midi ports to pipewire#39

Open
dnappier-mt wants to merge 2 commits into
MultiTracksDotCom:developfrom
dnappier-mt:MT-147614
Open

MT-147614: Add USB midi ports to pipewire#39
dnappier-mt wants to merge 2 commits into
MultiTracksDotCom:developfrom
dnappier-mt:MT-147614

Conversation

@dnappier-mt
Copy link
Copy Markdown

@dnappier-mt dnappier-mt commented Apr 20, 2026

MT-147614

Dev QA: @AmeNote-Michael

Currently USB midi ports are available as ALSA midi devices but they are not showing up in pipewire. You can verify that they are available in ALSA using amidi -l but that they are not available in pipewire using pw-link -i | grep -i midi

The fix is to add the snd-seq-midi subsystem to linux. Pipewire only support midi devices through /dev/snd/seq so that it can, among the other benefits of seq, connect multiple midi clients to a hardware midi device.

The other issue is that the USB driver was naming the USB midi device as the "'shortname" which ends up with both devices being named the same thing ("f_midi") so an easy change was made to include the USB id in the name to delineate which midi device belongs to which USB port.

The easiest way to test this is to connect the 2 USB midi devices together:
pw-link "Midi-Bridge:usbc0 3:(capture_0) usbc0" "Midi-Bridge:usbc1 5:(playback_0) usbc1"
pw-link "Midi-Bridge:usbc1 5:(capture_0) usbc1" "Midi-Bridge:usbc0 3:(playback_0) usbc0"

This functionally makes the routing [USB1 Midi] <---> [USB0 Midi] so you can send midi data from one IPad to another externally

Copilot AI review requested due to automatic review settings April 20, 2026 01:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make USB MIDI ports visible to PipeWire by enabling ALSA sequencer support (/dev/snd/seq) and improving gadget MIDI device naming to avoid ambiguous duplicates.

Changes:

  • Enable ALSA sequencer + seq-midi in the mt_connect arm64 defconfig.
  • Change USB gadget MIDI ALSA card shortname to prefer the instance id (to help distinguish multiple MIDI gadgets).
  • Modify /dev/kmsg ratelimit initialization and increase ARM32 COMMAND_LINE_SIZE (both appear unrelated to the stated MIDI/PipeWire goal).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
kernel/printk/printk.c Changes /dev/kmsg userspace injection ratelimit init parameters.
drivers/usb/gadget/function/f_midi.c Uses gadget instance id for ALSA card shortname to reduce name collisions.
arch/arm64/configs/mt_connect_defconfig Enables ALSA sequencer and seq-midi options needed for /dev/snd/seq.
arch/arm/include/uapi/asm/setup.h Increases ARM32 UAPI COMMAND_LINE_SIZE from 1024 to 4096.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread arch/arm/include/uapi/asm/setup.h Outdated
Comment thread arch/arm64/configs/mt_connect_defconfig
Comment thread kernel/printk/printk.c Outdated
Comment thread kernel/printk/printk.c Outdated
Comment thread drivers/usb/gadget/function/f_midi.c
Copilot AI review requested due to automatic review settings April 20, 2026 14:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* Add CONFIG_SND_SEQUENCER=y and CONFIG_SND_SEQ_MIDI=y to mt_connect_defconfig
* Sequencer creates /dev/snd/seq; snd-seq-midi bridges f_midi rawmidi
  devices to ALSA seq clients
* WirePlumber alsa-midi.lua detects /dev/snd/seq and exposes both
  USB-C f_midi ports as PipeWire MIDI nodes automatically
* Replace hardcoded shortname "f_midi" with the configfs id attribute
* id propagates to rawmidi name, ALSA sequencer client name, and
  PipeWire port name — enabling per-port identification in PipeWire
* Falls back to "f_midi" if id is not set
@AmeNote-Michael
Copy link
Copy Markdown

In devQA of this PR, discovered another issue which @dnappier-mt is looking into. Will complete this devQA when other issue addressed.

@AmeNote-Michael
Copy link
Copy Markdown

DevQA: Pass

Tested in conjunction with firmware PR #617 (Doug's userspace pipewire/wireplumber + gadget
setup side for the same ticket).

Process

  • Built linux-imx from this branch via the firmware BSP, with LINUX_IMX_SRC retargeted at
    dnappier-mt/linux-imx:MT-147614 and SRCBRANCH=MT-147614. Full kernel cleansstate + rebuild
    from this PR's source. Build exit 0.
  • Resulting kernel + 370 modules + DTB packaged into the standard fitImage path used by
    welma-image-swu.
  • Deployed to a dev unit by full uuu reflash (using the project's bmap-aware uuu script,
    mt-imxboot-zst-bmap.uuu) so the kernel landed alongside the userspace bits from PR #617.

Result

  • Device boots cleanly into the new kernel: uname -r reports 6.6.36-...-ge08afe6ff7c5
    (matches the build artifact's git SHA).
  • CONFIG_SND_SEQUENCER=y and CONFIG_SND_ALOOP=m enabled in build, confirmed by ALSA
    functioning as expected.
  • The f_midi.c patch path is exercised: ALSA card shortname / longname now reflect the
    configfs id value rather than the literal %d. With the userspace gadget setup from PR #617
    writing usbc0 and usbc1 into the function id, the kernel produces:

/proc/asound/cards
3 [usbc1 ]: MIDI Gadget - usbc1
5 [usbc0 ]: MIDI Gadget - usbc0

  • Distinct per-gadget names, in line with the patch's intent.
  • No new dmesg errors / warnings introduced by this kernel relative to develop.
  • All systemd units that depend on the kernel come up normally; pipewire imports the f_midi
    cards and exposes per-gadget MIDI ports for routing.
  • USB host/gadget role-switching on ci_hdrc.0 / ci_hdrc.1 works — iPad connect/disconnect is
    observed in dmesg, gadget functions enumerate to the iPad as expected.

Test target: i.MX8 dev unit, paired userspace from dnappier-mt/firmware:MT-147614.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants