Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH 6/8] ALSA: ump: Update rawmidi name per EP name update
Date: Fri, 10 Jan 2025 16:59:39 +0100	[thread overview]
Message-ID: <20250110155943.31578-7-tiwai@suse.de> (raw)
In-Reply-To: <20250110155943.31578-1-tiwai@suse.de>

The rawmidi name string should be updated dynamically when the device
receives the UMP EP name update, too.  Both the core and legacy
rawmidi names are updated.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/ump.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/sound/core/ump.c b/sound/core/ump.c
index 5c4dc4dc9ac8..c80a0a8b7ad0 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -37,6 +37,7 @@ static int process_legacy_output(struct snd_ump_endpoint *ump,
 				 u32 *buffer, int count);
 static void process_legacy_input(struct snd_ump_endpoint *ump, const u32 *src,
 				 int words);
+static void ump_legacy_set_rawmidi_name(struct snd_ump_endpoint *ump);
 static void update_legacy_names(struct snd_ump_endpoint *ump);
 #else
 static inline int process_legacy_output(struct snd_ump_endpoint *ump,
@@ -48,6 +49,9 @@ static inline void process_legacy_input(struct snd_ump_endpoint *ump,
 					const u32 *src, int words)
 {
 }
+static inline void ump_legacy_set_rawmidi_name(struct snd_ump_endpoint *ump)
+{
+}
 static inline void update_legacy_names(struct snd_ump_endpoint *ump)
 {
 }
@@ -751,8 +755,16 @@ static void ump_set_rawmidi_name(struct snd_ump_endpoint *ump)
 static int ump_handle_ep_name_msg(struct snd_ump_endpoint *ump,
 				  const union snd_ump_stream_msg *buf)
 {
-	return ump_append_string(ump, ump->info.name, sizeof(ump->info.name),
-				 buf->raw, 2);
+	int ret;
+
+	ret = ump_append_string(ump, ump->info.name, sizeof(ump->info.name),
+				buf->raw, 2);
+	if (ret && ump->parsed) {
+		ump_set_rawmidi_name(ump);
+		ump_legacy_set_rawmidi_name(ump);
+	}
+
+	return ret;
 }
 
 /* handle EP product id stream message; update the UMP product_id string */
@@ -1308,6 +1320,14 @@ static void update_legacy_names(struct snd_ump_endpoint *ump)
 	update_legacy_substreams(ump, rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT);
 }
 
+static void ump_legacy_set_rawmidi_name(struct snd_ump_endpoint *ump)
+{
+	struct snd_rawmidi *rmidi = ump->legacy_rmidi;
+
+	snprintf(rmidi->name, sizeof(rmidi->name), "%.68s (MIDI 1.0)",
+		 ump->core.name);
+}
+
 int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
 				  char *id, int device)
 {
@@ -1338,12 +1358,11 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
 	if (output)
 		snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
 				    &snd_ump_legacy_output_ops);
-	snprintf(rmidi->name, sizeof(rmidi->name), "%.68s (MIDI 1.0)",
-		 ump->core.name);
 	rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP;
 	rmidi->ops = &snd_ump_legacy_ops;
 	rmidi->private_data = ump;
 	ump->legacy_rmidi = rmidi;
+	ump_legacy_set_rawmidi_name(ump);
 	update_legacy_names(ump);
 
 	rmidi->tied_device = ump->core.device;
-- 
2.43.0


  parent reply	other threads:[~2025-01-10 15:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 15:59 [PATCH 0/8] ALSA: Small extensions for UMP Takashi Iwai
2025-01-10 15:59 ` [PATCH 1/8] ALSA: rawmidi: Expose the tied device number in info ioctl Takashi Iwai
2025-01-14 10:25   ` Jaroslav Kysela
2025-01-14 10:37     ` Takashi Iwai
2025-01-10 15:59 ` [PATCH 2/8] ALSA: rawmidi: Show substream activity " Takashi Iwai
2025-01-10 15:59 ` [PATCH 3/8] ALSA: rawmidi: Bump protocol version to 2.0.5 Takashi Iwai
2025-01-10 15:59 ` [PATCH 4/8] ALSA: ump: Copy FB name string more safely Takashi Iwai
2025-01-10 15:59 ` [PATCH 5/8] ALSA: ump: Copy safe string name to rawmidi Takashi Iwai
2025-01-10 15:59 ` Takashi Iwai [this message]
2025-01-10 15:59 ` [PATCH 7/8] ALSA: seq: Allow system notification in atomic Takashi Iwai
2025-01-10 15:59 ` [PATCH 8/8] ALSA: seq: Notify UMP EP and FB changes Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250110155943.31578-7-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-sound@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox