From a79807683781d3f215e9d958494e52ed70f4ad27 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 21 Jun 2023 13:02:39 +0200 Subject: 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. Link: https://lore.kernel.org/r/20230621110241.4751-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/ump.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/sound') diff --git a/include/sound/ump.h b/include/sound/ump.h index 68478e7be3b4..3c7e67475676 100644 --- a/include/sound/ump.h +++ b/include/sound/ump.h @@ -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 */ -- cgit v1.2.3 From eacd9c7f1d3ab8381a99b98b36652b5cf6ae8387 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 21 Jun 2023 13:02:40 +0200 Subject: ALSA: ump: Add no_process_stream flag This 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. Link: https://lore.kernel.org/r/20230621110241.4751-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/ump.h | 1 + sound/core/ump.c | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'include/sound') diff --git a/include/sound/ump.h b/include/sound/ump.h index 3c7e67475676..2f6a9944c6ef 100644 --- a/include/sound/ump.h +++ b/include/sound/ump.h @@ -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; diff --git a/sound/core/ump.c b/sound/core/ump.c index 4150b9c0b35b..5e73c9cf5919 100644 --- a/sound/core/ump.c +++ b/sound/core/ump.c @@ -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]); -- cgit v1.2.3 From 4dce2f076b7d0a0a99867b58eea7c212ff4e2be5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 21 Jun 2023 13:02:41 +0200 Subject: ALSA: ump: Export snd_ump_receive_ump_val() This 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. Link: https://lore.kernel.org/r/20230621110241.4751-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/ump.h | 1 + sound/core/ump.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'include/sound') diff --git a/include/sound/ump.h b/include/sound/ump.h index 2f6a9944c6ef..44d2c2fd021d 100644 --- a/include/sound/ump.h +++ b/include/sound/ump.h @@ -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); /* diff --git a/sound/core/ump.c b/sound/core/ump.c index 5e73c9cf5919..5e17351ca984 100644 --- a/sound/core/ump.c +++ b/sound/core/ump.c @@ -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 -- cgit v1.2.3