@@ -263,12 +263,16 @@ static unsigned char ump_packet_words[0x10] = {
263263 1 , 1 , 1 , 2 , 2 , 4 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 4 , 4 , 4
264264};
265265
266- /* parse the UMP packet data;
267- * the data is copied onto ump->input_buf[].
266+ /**
267+ * snd_ump_receive_ump_val - parse the UMP packet data
268+ * @ump: UMP endpoint
269+ * @val: UMP packet data
270+ *
271+ * The data is copied onto ump->input_buf[].
268272 * When a full packet is completed, returns the number of words (from 1 to 4).
269273 * OTOH, if the packet is incomplete, returns 0.
270274 */
271- static int snd_ump_receive_ump_val (struct snd_ump_endpoint * ump , u32 val )
275+ int snd_ump_receive_ump_val (struct snd_ump_endpoint * ump , u32 val )
272276{
273277 int words ;
274278
@@ -284,6 +288,7 @@ static int snd_ump_receive_ump_val(struct snd_ump_endpoint *ump, u32 val)
284288 }
285289 return 0 ;
286290}
291+ EXPORT_SYMBOL_GPL (snd_ump_receive_ump_val );
287292
288293/**
289294 * snd_ump_receive - transfer UMP packets from the device
@@ -671,18 +676,35 @@ static void seq_notify_protocol(struct snd_ump_endpoint *ump)
671676#endif /* CONFIG_SND_SEQUENCER */
672677}
673678
679+ /**
680+ * snd_ump_switch_protocol - switch MIDI protocol
681+ * @ump: UMP endpoint
682+ * @protocol: protocol to switch to
683+ *
684+ * Returns 1 if the protocol is actually switched, 0 if unchanged
685+ */
686+ int snd_ump_switch_protocol (struct snd_ump_endpoint * ump , unsigned int protocol )
687+ {
688+ protocol &= ump -> info .protocol_caps ;
689+ if (protocol == ump -> info .protocol )
690+ return 0 ;
691+
692+ ump -> info .protocol = protocol ;
693+ ump_dbg (ump , "New protocol = %x (caps = %x)\n" ,
694+ protocol , ump -> info .protocol_caps );
695+ seq_notify_protocol (ump );
696+ return 1 ;
697+ }
698+ EXPORT_SYMBOL_GPL (snd_ump_switch_protocol );
699+
674700/* handle EP stream config message; update the UMP protocol */
675701static int ump_handle_stream_cfg_msg (struct snd_ump_endpoint * ump ,
676702 const union snd_ump_stream_msg * buf )
677703{
678- unsigned int old_protocol = ump -> info .protocol ;
679-
680- ump -> info .protocol =
704+ unsigned int protocol =
681705 (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 );
706+
707+ snd_ump_switch_protocol (ump , protocol );
686708 return 1 ; /* finished */
687709}
688710
@@ -837,6 +859,10 @@ static void ump_handle_stream_msg(struct snd_ump_endpoint *ump,
837859 unsigned int status ;
838860 int ret ;
839861
862+ /* UMP stream message suppressed (for gadget UMP)? */
863+ if (ump -> no_process_stream )
864+ return ;
865+
840866 BUILD_BUG_ON (sizeof (* msg ) != 16 );
841867 ump_dbg (ump , "Stream msg: %08x %08x %08x %08x\n" ,
842868 buf [0 ], buf [1 ], buf [2 ], buf [3 ]);
0 commit comments