Skip to content

Commit bdf4644

Browse files
committed
ALSA: rawmidi: Expose the tied device number in info ioctl
The UMP legacy rawmidi is derived from the UMP rawmidi, but currently there is no way to know which device is involved in other side. This patch extends the rawmidi info ioctl to show the tied device number. As default it stores -1, indicating that no tied device. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250110155943.31578-2-tiwai@suse.de
1 parent 7579790 commit bdf4644

5 files changed

Lines changed: 15 additions & 1 deletion

File tree

Documentation/sound/designs/midi-2.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ Rawmidi API Extensions
293293
status 0x05). When UMP core receives such a message, it updates the
294294
UMP EP info and the corresponding sequencer clients as well.
295295

296+
* The legacy rawmidi device number is found in the new `tied_device`
297+
field of the rawmidi info.
298+
On the other hand, the UMP rawmidi device number is found in
299+
`tied_device` field of the legacy rawmidi info, too.
300+
296301

297302
Control API Extensions
298303
======================

include/sound/rawmidi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct snd_rawmidi {
118118
struct list_head list;
119119
unsigned int device; /* device number */
120120
unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */
121+
unsigned int tied_device;
121122
char id[64];
122123
char name[80];
123124

include/uapi/sound/asound.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ enum {
729729
#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004
730730
#define SNDRV_RAWMIDI_INFO_UMP 0x00000008
731731

732+
#define SNDRV_RAWMIDI_DEVICE_UNKNOWN -1
733+
732734
struct snd_rawmidi_info {
733735
unsigned int device; /* RO/WR (control): device number */
734736
unsigned int subdevice; /* RO/WR (control): subdevice number */
@@ -740,7 +742,8 @@ struct snd_rawmidi_info {
740742
unsigned char subname[32]; /* name of active or selected subdevice */
741743
unsigned int subdevices_count;
742744
unsigned int subdevices_avail;
743-
unsigned char reserved[64]; /* reserved for future use */
745+
int tied_device; /* R: tied rawmidi device (UMP/legacy) */
746+
unsigned char reserved[60]; /* reserved for future use */
744747
};
745748

746749
#define SNDRV_RAWMIDI_MODE_FRAMING_MASK (7<<0)

sound/core/rawmidi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream,
635635
info->subdevices_count = substream->pstr->substream_count;
636636
info->subdevices_avail = (substream->pstr->substream_count -
637637
substream->pstr->substream_opened);
638+
info->tied_device = rmidi->tied_device;
638639
return 0;
639640
}
640641

@@ -1834,6 +1835,7 @@ int snd_rawmidi_init(struct snd_rawmidi *rmidi,
18341835
INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams);
18351836
INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams);
18361837
rmidi->info_flags = info_flags;
1838+
rmidi->tied_device = SNDRV_RAWMIDI_DEVICE_UNKNOWN;
18371839

18381840
if (id != NULL)
18391841
strscpy(rmidi->id, id, sizeof(rmidi->id));

sound/core/ump.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,9 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
13141314
ump->legacy_rmidi = rmidi;
13151315
update_legacy_names(ump);
13161316

1317+
rmidi->tied_device = ump->core.device;
1318+
ump->core.tied_device = rmidi->device;
1319+
13171320
ump_dbg(ump, "Created a legacy rawmidi #%d (%s)\n", device, id);
13181321
return 0;
13191322
}

0 commit comments

Comments
 (0)