]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: rawmidi: Expose the tied device number in info ioctl
authorTakashi Iwai <tiwai@suse.de>
Fri, 10 Jan 2025 15:59:34 +0000 (16:59 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sun, 12 Jan 2025 12:12:20 +0000 (13:12 +0100)
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
Documentation/sound/designs/midi-2.0.rst
include/sound/rawmidi.h
include/uapi/sound/asound.h
sound/core/rawmidi.c
sound/core/ump.c

index 086487ca7ab11905a8374437d31f12c29f84a402..d525bc2805f7224715ff0e2ffc5f66f77398323e 100644 (file)
@@ -293,6 +293,11 @@ Rawmidi API Extensions
   status 0x05).  When UMP core receives such a message, it updates the
   UMP EP info and the corresponding sequencer clients as well.
 
+* The legacy rawmidi device number is found in the new `tied_device`
+  field of the rawmidi info.
+  On the other hand, the UMP rawmidi device number is found in
+  `tied_device` field of the legacy rawmidi info, too.
+
 
 Control API Extensions
 ======================
index f31cabf0158c988aa89e63e10676ec08fea37439..7f1fec786b72fc7a893e358f2611d1d29f185ad5 100644 (file)
@@ -118,6 +118,7 @@ struct snd_rawmidi {
        struct list_head list;
        unsigned int device;            /* device number */
        unsigned int info_flags;        /* SNDRV_RAWMIDI_INFO_XXXX */
+       unsigned int tied_device;
        char id[64];
        char name[80];
 
index 4cd513215bcd8f74b56fbff8376d0b891babb22d..1fcff031b5e390066b5b84b4d60787705aed5bd9 100644 (file)
@@ -729,6 +729,8 @@ enum {
 #define SNDRV_RAWMIDI_INFO_DUPLEX              0x00000004
 #define SNDRV_RAWMIDI_INFO_UMP                 0x00000008
 
+#define SNDRV_RAWMIDI_DEVICE_UNKNOWN           -1
+
 struct snd_rawmidi_info {
        unsigned int device;            /* RO/WR (control): device number */
        unsigned int subdevice;         /* RO/WR (control): subdevice number */
@@ -740,7 +742,8 @@ struct snd_rawmidi_info {
        unsigned char subname[32];      /* name of active or selected subdevice */
        unsigned int subdevices_count;
        unsigned int subdevices_avail;
-       unsigned char reserved[64];     /* reserved for future use */
+       int tied_device;                /* R: tied rawmidi device (UMP/legacy) */
+       unsigned char reserved[60];     /* reserved for future use */
 };
 
 #define SNDRV_RAWMIDI_MODE_FRAMING_MASK                (7<<0)
index 348ce1b7725ea22124afc3146972f556c88c14e9..858878fe487ae8259c89e97dc1f8219f0471e284 100644 (file)
@@ -635,6 +635,7 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream,
        info->subdevices_count = substream->pstr->substream_count;
        info->subdevices_avail = (substream->pstr->substream_count -
                                  substream->pstr->substream_opened);
+       info->tied_device = rmidi->tied_device;
        return 0;
 }
 
@@ -1834,6 +1835,7 @@ int snd_rawmidi_init(struct snd_rawmidi *rmidi,
        INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams);
        INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams);
        rmidi->info_flags = info_flags;
+       rmidi->tied_device = SNDRV_RAWMIDI_DEVICE_UNKNOWN;
 
        if (id != NULL)
                strscpy(rmidi->id, id, sizeof(rmidi->id));
index 9198bff4768ce4596f97ff5519c9b501885d6a24..0bfab84eaafb643f2ba9ab8bf5059d8316ff2aa4 100644 (file)
@@ -1314,6 +1314,9 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
        ump->legacy_rmidi = rmidi;
        update_legacy_names(ump);
 
+       rmidi->tied_device = ump->core.device;
+       ump->core.tied_device = rmidi->device;
+
        ump_dbg(ump, "Created a legacy rawmidi #%d (%s)\n", device, id);
        return 0;
 }