Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: ump: Add ioctls to inquiry UMP EP and Block info via control API

It'd be convenient to have ioctls to inquiry the UMP Endpoint and UMP
Block information directly via the control API without opening the
rawmidi interface, just like SNDRV_CTL_IOCTL_RAWMIDI_INFO.

This patch extends the rawmidi ioctl handler to support those; new
ioctls, SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO and
SNDRV_CTL_IOCTL_UMP_BLOCK_INFO, return the snd_ump_endpoint and
snd_ump_block data that is specified by the device field,
respectively.

Suggested-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230523075358.9672-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+28
+2
include/uapi/sound/asound.h
··· 1178 1178 #define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info) 1179 1179 #define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int) 1180 1180 #define SNDRV_CTL_IOCTL_UMP_NEXT_DEVICE _IOWR('U', 0x43, int) 1181 + #define SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO _IOWR('U', 0x44, struct snd_ump_endpoint_info) 1182 + #define SNDRV_CTL_IOCTL_UMP_BLOCK_INFO _IOWR('U', 0x45, struct snd_ump_block_info) 1181 1183 #define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int) 1182 1184 #define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int) 1183 1185
+26
sound/core/rawmidi.c
··· 1043 1043 return 0; 1044 1044 } 1045 1045 1046 + #if IS_ENABLED(CONFIG_SND_UMP) 1047 + /* inquiry of UMP endpoint and block info via control API */ 1048 + static int snd_rawmidi_call_ump_ioctl(struct snd_card *card, int cmd, 1049 + void __user *argp) 1050 + { 1051 + struct snd_ump_endpoint_info __user *info = argp; 1052 + struct snd_rawmidi *rmidi; 1053 + int device, ret; 1054 + 1055 + if (get_user(device, &info->device)) 1056 + return -EFAULT; 1057 + mutex_lock(&register_mutex); 1058 + rmidi = snd_rawmidi_search(card, device); 1059 + if (rmidi && rmidi->ops && rmidi->ops->ioctl) 1060 + ret = rmidi->ops->ioctl(rmidi, cmd, argp); 1061 + else 1062 + ret = -ENXIO; 1063 + mutex_unlock(&register_mutex); 1064 + return ret; 1065 + } 1066 + #endif 1067 + 1046 1068 static int snd_rawmidi_control_ioctl(struct snd_card *card, 1047 1069 struct snd_ctl_file *control, 1048 1070 unsigned int cmd, ··· 1078 1056 #if IS_ENABLED(CONFIG_SND_UMP) 1079 1057 case SNDRV_CTL_IOCTL_UMP_NEXT_DEVICE: 1080 1058 return snd_rawmidi_next_device(card, argp, true); 1059 + case SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO: 1060 + return snd_rawmidi_call_ump_ioctl(card, SNDRV_UMP_IOCTL_ENDPOINT_INFO, argp); 1061 + case SNDRV_CTL_IOCTL_UMP_BLOCK_INFO: 1062 + return snd_rawmidi_call_ump_ioctl(card, SNDRV_UMP_IOCTL_BLOCK_INFO, argp); 1081 1063 #endif 1082 1064 case SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE: 1083 1065 {