* [PATCH 0/3] ALSA: ump: Fixes for legacy rawmidi handling
@ 2024-11-29 9:45 Takashi Iwai
2024-11-29 9:45 ` [PATCH 1/3] ALSA: ump: Don't open legacy substream for an inactive group Takashi Iwai
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Takashi Iwai @ 2024-11-29 9:45 UTC (permalink / raw)
To: linux-sound
This is a small collection of fixes for the UMP legacy rawmidi.
Now the access to an inactive UMP Group is restricted, the substream
names show the inactive UMP Groups, and the names are updated properly
via FB Info / Nmae notifications.
Takashi
===
Takashi Iwai (3):
ALSA: ump: Don't open legacy substream for an inactive group
ALSA: ump: Indicate the inactive group in legacy substream names
ALSA: ump: Update legacy substream names upon FB info update
sound/core/ump.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] ALSA: ump: Don't open legacy substream for an inactive group
2024-11-29 9:45 [PATCH 0/3] ALSA: ump: Fixes for legacy rawmidi handling Takashi Iwai
@ 2024-11-29 9:45 ` Takashi Iwai
2024-11-29 9:45 ` [PATCH 2/3] ALSA: ump: Indicate the inactive group in legacy substream names Takashi Iwai
2024-11-29 9:45 ` [PATCH 3/3] ALSA: ump: Update legacy substream names upon FB info update Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2024-11-29 9:45 UTC (permalink / raw)
To: linux-sound
When a UMP Group is inactive, we shouldn't allow users to access it
via the legacy MIDI access. Add the group active flag check and
return -ENODEV if it's inactive.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/ump.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/core/ump.c b/sound/core/ump.c
index 6d0aac6c763f..9f9ad106107f 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -1087,6 +1087,8 @@ static int snd_ump_legacy_open(struct snd_rawmidi_substream *substream)
guard(mutex)(&ump->open_mutex);
if (ump->legacy_substreams[dir][group])
return -EBUSY;
+ if (!ump->groups[group].active)
+ return -ENODEV;
if (dir == SNDRV_RAWMIDI_STREAM_OUTPUT) {
if (!ump->legacy_out_opens) {
err = snd_rawmidi_kernel_open(&ump->core, 0,
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] ALSA: ump: Indicate the inactive group in legacy substream names
2024-11-29 9:45 [PATCH 0/3] ALSA: ump: Fixes for legacy rawmidi handling Takashi Iwai
2024-11-29 9:45 ` [PATCH 1/3] ALSA: ump: Don't open legacy substream for an inactive group Takashi Iwai
@ 2024-11-29 9:45 ` Takashi Iwai
2024-11-29 9:45 ` [PATCH 3/3] ALSA: ump: Update legacy substream names upon FB info update Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2024-11-29 9:45 UTC (permalink / raw)
To: linux-sound
Since the legacy rawmidi has no proper way to know the inactive group,
indicate it in the rawmidi substream names with "[Inactive]" suffix
when the corresponding UMP group is inactive.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/ump.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/core/ump.c b/sound/core/ump.c
index 9f9ad106107f..7b00a957e548 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -1256,8 +1256,9 @@ static void fill_substream_names(struct snd_ump_endpoint *ump,
name = ump->groups[idx].name;
if (!*name)
name = ump->info.name;
- snprintf(s->name, sizeof(s->name), "Group %d (%.16s)",
- idx + 1, name);
+ snprintf(s->name, sizeof(s->name), "Group %d (%.16s)%s",
+ idx + 1, name,
+ ump->groups[idx].active ? "" : " [Inactive]");
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] ALSA: ump: Update legacy substream names upon FB info update
2024-11-29 9:45 [PATCH 0/3] ALSA: ump: Fixes for legacy rawmidi handling Takashi Iwai
2024-11-29 9:45 ` [PATCH 1/3] ALSA: ump: Don't open legacy substream for an inactive group Takashi Iwai
2024-11-29 9:45 ` [PATCH 2/3] ALSA: ump: Indicate the inactive group in legacy substream names Takashi Iwai
@ 2024-11-29 9:45 ` Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2024-11-29 9:45 UTC (permalink / raw)
To: linux-sound
The legacy rawmidi substreams should be updated when UMP FB Info or
UMP FB Name are received, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/ump.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/sound/core/ump.c b/sound/core/ump.c
index 7b00a957e548..d2b810eb84bc 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 update_legacy_names(struct snd_ump_endpoint *ump);
#else
static inline int process_legacy_output(struct snd_ump_endpoint *ump,
u32 *buffer, int count)
@@ -47,6 +48,9 @@ static inline void process_legacy_input(struct snd_ump_endpoint *ump,
const u32 *src, int words)
{
}
+static inline void update_legacy_names(struct snd_ump_endpoint *ump)
+{
+}
#endif
static const struct snd_rawmidi_global_ops snd_ump_rawmidi_ops = {
@@ -861,6 +865,7 @@ static int ump_handle_fb_info_msg(struct snd_ump_endpoint *ump,
fill_fb_info(ump, &fb->info, buf);
if (ump->parsed) {
snd_ump_update_group_attrs(ump);
+ update_legacy_names(ump);
seq_notify_fb_change(ump, fb);
}
}
@@ -893,6 +898,7 @@ static int ump_handle_fb_name_msg(struct snd_ump_endpoint *ump,
/* notify the FB name update to sequencer, too */
if (ret > 0 && ump->parsed) {
snd_ump_update_group_attrs(ump);
+ update_legacy_names(ump);
seq_notify_fb_change(ump, fb);
}
return ret;
@@ -1262,6 +1268,14 @@ static void fill_substream_names(struct snd_ump_endpoint *ump,
}
}
+static void update_legacy_names(struct snd_ump_endpoint *ump)
+{
+ struct snd_rawmidi *rmidi = ump->legacy_rmidi;
+
+ fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_INPUT);
+ fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT);
+}
+
int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
char *id, int device)
{
@@ -1298,10 +1312,7 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
rmidi->ops = &snd_ump_legacy_ops;
rmidi->private_data = ump;
ump->legacy_rmidi = rmidi;
- if (input)
- fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_INPUT);
- if (output)
- fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT);
+ update_legacy_names(ump);
ump_dbg(ump, "Created a legacy rawmidi #%d (%s)\n", device, id);
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-29 9:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 9:45 [PATCH 0/3] ALSA: ump: Fixes for legacy rawmidi handling Takashi Iwai
2024-11-29 9:45 ` [PATCH 1/3] ALSA: ump: Don't open legacy substream for an inactive group Takashi Iwai
2024-11-29 9:45 ` [PATCH 2/3] ALSA: ump: Indicate the inactive group in legacy substream names Takashi Iwai
2024-11-29 9:45 ` [PATCH 3/3] ALSA: ump: Update legacy substream names upon FB info update Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox