Skip to content

Commit 8b64592

Browse files
tiwaigregkh
authored andcommitted
usb: gadget: Add support for USB MIDI 2.0 function driver
This patch adds the support for USB MIDI 2.0 gadget function driver. The driver emulates a USB MIDI 2.0 interface with one or more UMP Endpoints, where each of UMP Endpoint is a pair of MIDI Endpoints for handling MIDI 2.0 UMP packets. When the function driver is bound, the driver creates an ALSA card object with UMP rawmidi devices. This is a kind of loop-back where the incoming and upcoming UMP packets from/to the MIDI 2.0 UMP Endpoints are transferred as-is. In addition, legacy (MIDI 1.0) rawmidi devices are created, so that legacy applications can work in the gadget side, too. When a USB MIDI 2.0 gadget interface appears, the connected host can use it with the snd-usb-audio driver where MIDI 2.0 support is enabled. Both gadget and connected hosts will have the similar UMP Endpoint and Function Block (or Group Terminal Block) information. Slight differences are the direction and UI-hint bits; it's due to the nature of gadget driver, and the input/output direction is swapped in both sides (the input for gadget is the output for host, and vice versa). The driver supports the brand-new UMP v1.1 feature, including the UMP Stream message handling for providing UMP Endpoint and Function Block information as well as dealing with the MIDI protocol switch. The driver responds to UMP Stream messages by itself. OTOH, MIDI-CI message handling isn't implemented in the kernel driver; it should be processed in the user-space through the loopback UMP device. As of this patch, the whole configuration is fixed, providing only one bidirectional UMP Endpoint containing a single FB/GTB with a single UMP Group. The configuration will be dynamically changeable in the following patches. The traditional MIDI 1.0 is still provided in the altset 0 (which is mandatory per spec). But it's only about the configuration, and no actual I/O will be running for the altset 0 as of this patch. The proper support MIDI 1.0 altset will follow in later patches, too. Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d6ef688 commit 8b64592

File tree

4 files changed

+1790
-0
lines changed

4 files changed

+1790
-0
lines changed

drivers/usb/gadget/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ config USB_F_UVC
208208
config USB_F_MIDI
209209
tristate
210210

211+
config USB_F_MIDI2
212+
tristate
213+
211214
config USB_F_HID
212215
tristate
213216

@@ -436,6 +439,21 @@ config USB_CONFIGFS_F_MIDI
436439
connections can then be made on the gadget system, using
437440
ALSA's aconnect utility etc.
438441

442+
config USB_CONFIGFS_F_MIDI2
443+
bool "MIDI 2.0 function"
444+
depends on USB_CONFIGFS
445+
depends on SND
446+
select USB_LIBCOMPOSITE
447+
select SND_UMP
448+
select SND_UMP_LEGACY_RAWMIDI
449+
select USB_F_MIDI2
450+
help
451+
The MIDI 2.0 function driver provides the generic emulated
452+
USB MIDI 2.0 interface, looped back to ALSA UMP rawmidi
453+
device on the gadget host. It supports UMP 1.1 spec and
454+
responds UMP Stream messages for UMP Endpoint and Function
455+
Block information / configuration.
456+
439457
config USB_CONFIGFS_F_HID
440458
bool "HID function"
441459
depends on USB_CONFIGFS

drivers/usb/gadget/function/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ usb_f_uvc-y := f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_configfs.o
4444
obj-$(CONFIG_USB_F_UVC) += usb_f_uvc.o
4545
usb_f_midi-y := f_midi.o
4646
obj-$(CONFIG_USB_F_MIDI) += usb_f_midi.o
47+
usb_f_midi2-y := f_midi2.o
48+
obj-$(CONFIG_USB_F_MIDI2) += usb_f_midi2.o
4749
usb_f_hid-y := f_hid.o
4850
obj-$(CONFIG_USB_F_HID) += usb_f_hid.o
4951
usb_f_printer-y := f_printer.o

0 commit comments

Comments
 (0)