ALSA: ump: Preliminary changes for gadget driver
cover ALSA: ump: Preliminary changes for gadget driver
Hi,
this is a small patch set to change the UMP core for the upcoming gadget driver support. Basically exporting a couple of helper functions and adding a flag to suppress the internal UMP handling. No functional changes by those alone.
Takashi
===
Takashi Iwai (3):
ALSA: ump: Add helper to change MIDI protocol
ALSA: ump: Add no_process_stream flag
ALSA: ump: Export snd_ump_receive_ump_val()
include/sound/ump.h | 4 ++++ sound/core/ump.c | 46 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 10 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/3 ALSA: ump: Add helper to change MIDI protocol
This is a preliminary patch for MIDI 2.0 USB gadget driver. Export a new helper to allow changing the current MIDI protocol from the outside.
--- include/sound/ump.h | 2 ++ sound/core/ump.c | 31 ++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-)
include/sound/ump.h +2 -0
@@ -108,6 +108,8 @@ static inline int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump, }#endif +int snd_ump_switch_protocol (struct snd_ump_endpoint *ump,unsigned int protocol); +/* * Some definitions for UMP */
sound/core/ump.c +24 -7
@@ -671,18 +671,35 @@ static void seq_notify_protocol(struct snd_ump_endpoint *ump)#endif /* CONFIG_SND_SEQUENCER */ } +/** +* snd_ump_switch_protocol - switch MIDI protocol +* @ump: UMP endpoint +* @protocol: protocol to switch to +* +* Returns 1 if the protocol is actually switched, 0 if unchanged +*/ +int snd_ump_switch_protocol (struct snd_ump_endpoint *ump,unsigned int protocol) +{ + protocol &= ump->info.protocol_caps; +if (protocol == ump->info.protocol) +return 0 ; + + ump->info.protocol = protocol; +ump_dbg (ump,"New protocol = %x (caps = %x)\n" , + protocol, ump->info.protocol_caps); +seq_notify_protocol (ump); +return 1 ; +} +EXPORT_SYMBOL_GPL (snd_ump_switch_protocol); +/* handle EP stream config message; update the UMP protocol */ static int ump_handle_stream_cfg_msg (struct snd_ump_endpoint *ump,const union snd_ump_stream_msg *buf) { -unsigned int old_protocol = ump->info.protocol; - - ump->info.protocol = +unsigned int protocol = (buf->stream_cfg.protocol <<8 ) | buf->stream_cfg.jrts; -ump_dbg (ump,"Current protocol = %x (caps = %x)\n" , - ump->info.protocol, ump->info.protocol_caps); -if (ump->parsed && ump->info.protocol != old_protocol) -seq_notify_protocol (ump); + +snd_ump_switch_protocol (ump, protocol);return 1 ;/* finished */ }
Signature · 1 line
2.35.3
PATCH 2/3 ALSA: ump: Add no_process_stream flag
In reply to Takashi IwaiThis is another preliminary patch for USB MIDI 2.0 gadget driver. Add a new flag, no_process_stream, to snd_ump for suppressing the UMP Stream message handling in UMP core.
--- include/sound/ump.h | 1 + sound/core/ump.c | 4 ++++ 2 files changed, 5 insertions(+)
include/sound/ump.h +1 -0
@@ -28,6 +28,7 @@ struct snd_ump_endpoint {u32 stream_wait_for;/* expected stream message status */ bool stream_finished;/* set when message has been processed */ bool parsed;/* UMP / FB parse finished? */ +bool no_process_stream;/* suppress UMP stream messages handling */ wait_queue_head_t stream_wait;struct snd_rawmidi_file stream_rfile;
sound/core/ump.c +4 -0
@@ -854,6 +854,10 @@ static void ump_handle_stream_msg(struct snd_ump_endpoint *ump,unsigned int status;int ret; +/* UMP stream message suppressed (for gadget UMP)? */ +if (ump->no_process_stream) +return ; +BUILD_BUG_ON (sizeof (*msg) !=16 );ump_dbg (ump,"Stream msg: %08x %08x %08x %08x\n" , buf[0 ], buf[1 ], buf[2 ], buf[3 ]);
Signature · 1 line
2.35.3
PATCH 3/3 ALSA: ump: Export snd_ump_receive_ump_val()
In reply to Takashi IwaiThis is another preliminary patch for USB MIDI 2.0 gadget driver. Export the currently local snd_ump_receive_ump_val(). It can be used by the gadget driver for processing the UMP data.
--- include/sound/ump.h | 1 + sound/core/ump.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
include/sound/ump.h +1 -0
@@ -109,6 +109,7 @@ static inline int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump, }#endif +int snd_ump_receive_ump_val (struct snd_ump_endpoint *ump,u32 val);int snd_ump_switch_protocol (struct snd_ump_endpoint *ump,unsigned int protocol);/*
sound/core/ump.c +8 -3
@@ -263,12 +263,16 @@ static unsigned char ump_packet_words[0x10] = {1 ,1 ,1 ,2 ,2 ,4 ,1 ,1 ,2 ,2 ,2 ,3 ,3 ,4 ,4 ,4 }; -/* parse the UMP packet data; -* the data is copied onto ump->input_buf[]. +/** +* snd_ump_receive_ump_val - parse the UMP packet data +* @ump: UMP endpoint +* @val: UMP packet data +* +* The data is copied onto ump->input_buf[]. * When a full packet is completed, returns the number of words (from 1 to 4). * OTOH, if the packet is incomplete, returns 0. */ -static int snd_ump_receive_ump_val (struct snd_ump_endpoint *ump,u32 val) +int snd_ump_receive_ump_val (struct snd_ump_endpoint *ump,u32 val) {int words;
@@ -284,6 +288,7 @@ static int snd_ump_receive_ump_val(struct snd_ump_endpoint *ump, u32 val) }return 0 ; } +EXPORT_SYMBOL_GPL (snd_ump_receive_ump_val);/** * snd_ump_receive - transfer UMP packets from the device
Signature · 1 line
2.35.3