Skip to content

Commit 5f11dd9

Browse files
committed
ALSA: usb-audio: Attach legacy rawmidi after probing all UMP EPs
The legacy rawmidi devices are the shadows of the main UMP devices, hence it's better to initialize them after all UMP Endpoints are parsed. Then, at the moment the legacy rawmidi is created, we already know the static flag or the proper EP name string, and we can fill those information at UMP core side instead of fiddling the attributes at a later point. Fixes: ec362b6 ("ALSA: usb-audio: Enable the legacy raw MIDI support") Link: https://lore.kernel.org/r/20230824075108.29958-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 67de40c commit 5f11dd9

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

sound/core/ump.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,8 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
11501150
if (output)
11511151
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
11521152
&snd_ump_legacy_output_ops);
1153+
snprintf(rmidi->name, sizeof(rmidi->name), "%s (MIDI 1.0)",
1154+
ump->info.name);
11531155
rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP;
11541156
rmidi->ops = &snd_ump_legacy_ops;
11551157
rmidi->private_data = ump;

sound/usb/midi2.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ static int parse_midi_2_0(struct snd_usb_midi2_interface *umidi)
990990
}
991991
}
992992

993-
return attach_legacy_rawmidi(umidi);
993+
return 0;
994994
}
995995

996996
/* is the given interface for MIDI 2.0? */
@@ -1059,12 +1059,6 @@ static void set_fallback_rawmidi_names(struct snd_usb_midi2_interface *umidi)
10591059
usb_string(dev, dev->descriptor.iSerialNumber,
10601060
ump->info.product_id,
10611061
sizeof(ump->info.product_id));
1062-
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
1063-
if (ump->legacy_rmidi && !*ump->legacy_rmidi->name)
1064-
snprintf(ump->legacy_rmidi->name,
1065-
sizeof(ump->legacy_rmidi->name),
1066-
"%s (MIDI 1.0)", ump->info.name);
1067-
#endif
10681062
}
10691063
}
10701064

@@ -1157,6 +1151,13 @@ int snd_usb_midi_v2_create(struct snd_usb_audio *chip,
11571151
}
11581152

11591153
set_fallback_rawmidi_names(umidi);
1154+
1155+
err = attach_legacy_rawmidi(umidi);
1156+
if (err < 0) {
1157+
usb_audio_err(chip, "Failed to create legacy rawmidi\n");
1158+
goto error;
1159+
}
1160+
11601161
return 0;
11611162

11621163
error:

0 commit comments

Comments
 (0)