Skip to content

Commit f4487c4

Browse files
committed
ALSA: usb-audio: Inform inconsistent protocols in GTBs
When parsing Group Terminal Blocks, we overwrote the preferred protocol and the protocol capabilities silently from the last parsed GTB. This patch adds the information print indicating the unexpected overrides instead of silent action. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20230523075358.9672-17-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent ec362b6 commit f4487c4

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

sound/usb/midi2.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,31 +581,48 @@ static int parse_group_terminal_block(struct snd_usb_midi2_ump *rmidi,
581581
const struct usb_ms20_gr_trm_block_descriptor *desc)
582582
{
583583
struct snd_ump_endpoint *ump = rmidi->ump;
584+
unsigned int protocol, protocol_caps;
584585

585586
/* set default protocol */
586587
switch (desc->bMIDIProtocol) {
587588
case USB_MS_MIDI_PROTO_1_0_64:
588589
case USB_MS_MIDI_PROTO_1_0_64_JRTS:
589590
case USB_MS_MIDI_PROTO_1_0_128:
590591
case USB_MS_MIDI_PROTO_1_0_128_JRTS:
591-
ump->info.protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI1;
592+
protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI1;
592593
break;
593594
case USB_MS_MIDI_PROTO_2_0:
594595
case USB_MS_MIDI_PROTO_2_0_JRTS:
595-
ump->info.protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI2;
596+
protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI2;
596597
break;
598+
default:
599+
return 0;
597600
}
598601

599-
ump->info.protocol_caps = ump->info.protocol;
602+
if (ump->info.protocol && ump->info.protocol != protocol)
603+
usb_audio_info(rmidi->umidi->chip,
604+
"Overriding preferred MIDI protocol in GTB %d: %x -> %x\n",
605+
rmidi->usb_block_id, ump->info.protocol,
606+
protocol);
607+
ump->info.protocol = protocol;
608+
609+
protocol_caps = protocol;
600610
switch (desc->bMIDIProtocol) {
601611
case USB_MS_MIDI_PROTO_1_0_64_JRTS:
602612
case USB_MS_MIDI_PROTO_1_0_128_JRTS:
603613
case USB_MS_MIDI_PROTO_2_0_JRTS:
604-
ump->info.protocol_caps |= SNDRV_UMP_EP_INFO_PROTO_JRTS_TX |
614+
protocol_caps |= SNDRV_UMP_EP_INFO_PROTO_JRTS_TX |
605615
SNDRV_UMP_EP_INFO_PROTO_JRTS_RX;
606616
break;
607617
}
608618

619+
if (ump->info.protocol_caps && ump->info.protocol_caps != protocol_caps)
620+
usb_audio_info(rmidi->umidi->chip,
621+
"Overriding MIDI protocol caps in GTB %d: %x -> %x\n",
622+
rmidi->usb_block_id, ump->info.protocol_caps,
623+
protocol_caps);
624+
ump->info.protocol_caps = protocol_caps;
625+
609626
return 0;
610627
}
611628

0 commit comments

Comments
 (0)