Skip to content

Commit bc42ca0

Browse files
committed
ALSA: ump: Set default protocol when not given explicitly
When an inquiry of the current protocol via UMP Stream Configuration message fails by some reason, we may leave the current protocol undefined, which may lead to unexpected behavior. Better to assume a valid protocol found in the protocol capability bits instead. For a device that doesn't support the UMP v1.2 feature, it won't reach to this code path, and USB MIDI GTB descriptor would be used for determining the protocol, instead. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent ac0d71e commit bc42ca0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sound/core/ump.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,14 @@ int snd_ump_parse_endpoint(struct snd_ump_endpoint *ump)
967967
if (err < 0)
968968
ump_dbg(ump, "Unable to get UMP EP stream config\n");
969969

970+
/* If no protocol is set by some reason, assume the valid one */
971+
if (!(ump->info.protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI_MASK)) {
972+
if (ump->info.protocol_caps & SNDRV_UMP_EP_INFO_PROTO_MIDI2)
973+
ump->info.protocol |= SNDRV_UMP_EP_INFO_PROTO_MIDI2;
974+
else if (ump->info.protocol_caps & SNDRV_UMP_EP_INFO_PROTO_MIDI1)
975+
ump->info.protocol |= SNDRV_UMP_EP_INFO_PROTO_MIDI1;
976+
}
977+
970978
/* Query and create blocks from Function Blocks */
971979
for (blk = 0; blk < ump->info.num_blocks; blk++) {
972980
err = create_block_from_fb_info(ump, blk);

0 commit comments

Comments
 (0)