Commit 43223da1 authored by Takashi Iwai's avatar Takashi Iwai Committed by Wen Zhiwei
Browse files

ALSA: ump: Update legacy substream names upon FB info update

stable inclusion
from stable-v6.6.70
commit 8d891c866cf714b54165d56ad2afc3b4d708d053
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBOHV1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8d891c866cf714b54165d56ad2afc3b4d708d053

--------------------------------

[ Upstream commit edad3f9519fcacb926d0e3f3217aecaf628a593f ]

The legacy rawmidi substreams should be updated when UMP FB Info or
UMP FB Name are received, too.

Link: https://patch.msgid.link/20241129094546.32119-4-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent f7348c5e
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -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 = {
@@ -850,6 +854,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);
		}
	}
@@ -882,6 +887,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;
@@ -1251,6 +1257,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)
{
@@ -1287,10 +1301,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;