]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: ump: Update rawmidi name per EP name update
authorTakashi Iwai <tiwai@suse.de>
Fri, 10 Jan 2025 15:59:39 +0000 (16:59 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sun, 12 Jan 2025 12:12:21 +0000 (13:12 +0100)
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>
Link: https://patch.msgid.link/20250110155943.31578-7-tiwai@suse.de
sound/core/ump.c

index 5c4dc4dc9ac8f1de4c334f4faf380cf12c0a1f12..c80a0a8b7ad0cc64cb5e79eb7b27834d3e7743f8 100644 (file)
@@ -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;