Skip to content

Commit b8fefed

Browse files
committed
ALSA: rawmidi: Show substream activity in info ioctl
The UMP legacy rawmidi may turn on/off the substream dynamically depending on the UMP Function Block information. So far, there was no direct way to know whether the substream is disabled (inactive) or not; at most one can take a look at the substream name string or try to open and get -ENODEV. This patch extends the rawmidi info ioctl to show the current inactive state of the given substream. When the selected substream is inactive, info flags field contains the new bit flag SNDRV_RAWMIDI_INFO_STREAM_INACTIVE. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250110155943.31578-3-tiwai@suse.de
1 parent bdf4644 commit b8fefed

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

Documentation/sound/designs/midi-2.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ Rawmidi API Extensions
298298
On the other hand, the UMP rawmidi device number is found in
299299
`tied_device` field of the legacy rawmidi info, too.
300300

301+
* Each substream of the legacy rawmidi may be enabled / disabled
302+
dynamically depending on the UMP FB state.
303+
When the selected substream is inactive, it's indicated by the bit
304+
0x10 (`SNDRV_RAWMIDI_INFO_STREAM_INACTIVE`) in the `flags` field of
305+
the legacy rawmidi info.
306+
301307

302308
Control API Extensions
303309
======================

include/sound/rawmidi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct snd_rawmidi_substream {
8989
unsigned int framing; /* whether to frame input data */
9090
unsigned int clock_type; /* clock source to use for input framing */
9191
int use_count; /* use counter (for output) */
92+
bool inactive; /* inactive substream (for UMP legacy) */
9293
size_t bytes;
9394
spinlock_t lock;
9495
struct snd_rawmidi *rmidi;

include/uapi/sound/asound.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ enum {
728728
#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002
729729
#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004
730730
#define SNDRV_RAWMIDI_INFO_UMP 0x00000008
731+
#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010
731732

732733
#define SNDRV_RAWMIDI_DEVICE_UNKNOWN -1
733734

sound/core/rawmidi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream,
629629
info->subdevice = substream->number;
630630
info->stream = substream->stream;
631631
info->flags = rmidi->info_flags;
632+
if (substream->inactive)
633+
info->flags |= SNDRV_RAWMIDI_INFO_STREAM_INACTIVE;
632634
strcpy(info->id, rmidi->id);
633635
strcpy(info->name, rmidi->name);
634636
strcpy(info->subname, substream->name);

sound/core/ump.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,8 @@ static int fill_legacy_mapping(struct snd_ump_endpoint *ump)
12501250
return num;
12511251
}
12521252

1253-
static void fill_substream_names(struct snd_ump_endpoint *ump,
1254-
struct snd_rawmidi *rmidi, int dir)
1253+
static void update_legacy_substreams(struct snd_ump_endpoint *ump,
1254+
struct snd_rawmidi *rmidi, int dir)
12551255
{
12561256
struct snd_rawmidi_substream *s;
12571257
const char *name;
@@ -1265,15 +1265,16 @@ static void fill_substream_names(struct snd_ump_endpoint *ump,
12651265
scnprintf(s->name, sizeof(s->name), "Group %d (%.16s)%s",
12661266
idx + 1, name,
12671267
ump->groups[idx].active ? "" : " [Inactive]");
1268+
s->inactive = !ump->groups[idx].active;
12681269
}
12691270
}
12701271

12711272
static void update_legacy_names(struct snd_ump_endpoint *ump)
12721273
{
12731274
struct snd_rawmidi *rmidi = ump->legacy_rmidi;
12741275

1275-
fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_INPUT);
1276-
fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT);
1276+
update_legacy_substreams(ump, rmidi, SNDRV_RAWMIDI_STREAM_INPUT);
1277+
update_legacy_substreams(ump, rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT);
12771278
}
12781279

12791280
int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,

0 commit comments

Comments
 (0)