@@ -671,18 +671,35 @@ static void seq_notify_protocol(struct snd_ump_endpoint *ump)
671
671
#endif /* CONFIG_SND_SEQUENCER */
672
672
}
673
673
674
+ /**
675
+ * snd_ump_switch_protocol - switch MIDI protocol
676
+ * @ump: UMP endpoint
677
+ * @protocol: protocol to switch to
678
+ *
679
+ * Returns 1 if the protocol is actually switched, 0 if unchanged
680
+ */
681
+ int snd_ump_switch_protocol (struct snd_ump_endpoint * ump , unsigned int protocol )
682
+ {
683
+ protocol &= ump -> info .protocol_caps ;
684
+ if (protocol == ump -> info .protocol )
685
+ return 0 ;
686
+
687
+ ump -> info .protocol = protocol ;
688
+ ump_dbg (ump , "New protocol = %x (caps = %x)\n" ,
689
+ protocol , ump -> info .protocol_caps );
690
+ seq_notify_protocol (ump );
691
+ return 1 ;
692
+ }
693
+ EXPORT_SYMBOL_GPL (snd_ump_switch_protocol );
694
+
674
695
/* handle EP stream config message; update the UMP protocol */
675
696
static int ump_handle_stream_cfg_msg (struct snd_ump_endpoint * ump ,
676
697
const union snd_ump_stream_msg * buf )
677
698
{
678
- unsigned int old_protocol = ump -> info .protocol ;
679
-
680
- ump -> info .protocol =
699
+ unsigned int protocol =
681
700
(buf -> stream_cfg .protocol << 8 ) | buf -> stream_cfg .jrts ;
682
- ump_dbg (ump , "Current protocol = %x (caps = %x)\n" ,
683
- ump -> info .protocol , ump -> info .protocol_caps );
684
- if (ump -> parsed && ump -> info .protocol != old_protocol )
685
- seq_notify_protocol (ump );
701
+
702
+ snd_ump_switch_protocol (ump , protocol );
686
703
return 1 ; /* finished */
687
704
}
688
705
0 commit comments