Skip to content

Commit ec362b6

Browse files
committed
ALSA: usb-audio: Enable the legacy raw MIDI support
Attach the legacy rawmidi devices when enabled in Kconfig accordingly. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20230523075358.9672-16-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 0b5288f commit ec362b6

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

sound/usb/midi2.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,25 @@ static int create_blocks_from_gtb(struct snd_usb_midi2_interface *umidi)
857857
return 0;
858858
}
859859

860+
/* attach legacy rawmidis */
861+
static int attach_legacy_rawmidi(struct snd_usb_midi2_interface *umidi)
862+
{
863+
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
864+
struct snd_usb_midi2_ump *rmidi;
865+
int err;
866+
867+
list_for_each_entry(rmidi, &umidi->rawmidi_list, list) {
868+
err = snd_ump_attach_legacy_rawmidi(rmidi->ump,
869+
"Legacy MIDI",
870+
umidi->chip->num_rawmidis);
871+
if (err < 0)
872+
return err;
873+
umidi->chip->num_rawmidis++;
874+
}
875+
#endif
876+
return 0;
877+
}
878+
860879
static void snd_usb_midi_v2_free(struct snd_usb_midi2_interface *umidi)
861880
{
862881
free_all_midi2_endpoints(umidi);
@@ -922,7 +941,7 @@ static int parse_midi_2_0(struct snd_usb_midi2_interface *umidi)
922941
}
923942
}
924943

925-
return 0;
944+
return attach_legacy_rawmidi(umidi);
926945
}
927946

928947
/* is the given interface for MIDI 2.0? */
@@ -991,6 +1010,12 @@ static void set_fallback_rawmidi_names(struct snd_usb_midi2_interface *umidi)
9911010
usb_string(dev, dev->descriptor.iSerialNumber,
9921011
ump->info.product_id,
9931012
sizeof(ump->info.product_id));
1013+
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
1014+
if (ump->legacy_rmidi && !*ump->legacy_rmidi->name)
1015+
snprintf(ump->legacy_rmidi->name,
1016+
sizeof(ump->legacy_rmidi->name),
1017+
"%s (MIDI 1.0)", ump->info.name);
1018+
#endif
9941019
}
9951020
}
9961021

0 commit comments

Comments
 (0)