mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
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>
This commit is contained in:
parent
127ae6f6da
commit
30fc139260
@ -1178,6 +1178,8 @@ struct snd_ctl_tlv {
|
||||
#define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info)
|
||||
#define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int)
|
||||
#define SNDRV_CTL_IOCTL_UMP_NEXT_DEVICE _IOWR('U', 0x43, int)
|
||||
#define SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO _IOWR('U', 0x44, struct snd_ump_endpoint_info)
|
||||
#define SNDRV_CTL_IOCTL_UMP_BLOCK_INFO _IOWR('U', 0x45, struct snd_ump_block_info)
|
||||
#define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int)
|
||||
#define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int)
|
||||
|
||||
|
@ -1043,6 +1043,28 @@ static int snd_rawmidi_next_device(struct snd_card *card, int __user *argp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_UMP)
|
||||
/* inquiry of UMP endpoint and block info via control API */
|
||||
static int snd_rawmidi_call_ump_ioctl(struct snd_card *card, int cmd,
|
||||
void __user *argp)
|
||||
{
|
||||
struct snd_ump_endpoint_info __user *info = argp;
|
||||
struct snd_rawmidi *rmidi;
|
||||
int device, ret;
|
||||
|
||||
if (get_user(device, &info->device))
|
||||
return -EFAULT;
|
||||
mutex_lock(®ister_mutex);
|
||||
rmidi = snd_rawmidi_search(card, device);
|
||||
if (rmidi && rmidi->ops && rmidi->ops->ioctl)
|
||||
ret = rmidi->ops->ioctl(rmidi, cmd, argp);
|
||||
else
|
||||
ret = -ENXIO;
|
||||
mutex_unlock(®ister_mutex);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int snd_rawmidi_control_ioctl(struct snd_card *card,
|
||||
struct snd_ctl_file *control,
|
||||
unsigned int cmd,
|
||||
@ -1056,6 +1078,10 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card,
|
||||
#if IS_ENABLED(CONFIG_SND_UMP)
|
||||
case SNDRV_CTL_IOCTL_UMP_NEXT_DEVICE:
|
||||
return snd_rawmidi_next_device(card, argp, true);
|
||||
case SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO:
|
||||
return snd_rawmidi_call_ump_ioctl(card, SNDRV_UMP_IOCTL_ENDPOINT_INFO, argp);
|
||||
case SNDRV_CTL_IOCTL_UMP_BLOCK_INFO:
|
||||
return snd_rawmidi_call_ump_ioctl(card, SNDRV_UMP_IOCTL_BLOCK_INFO, argp);
|
||||
#endif
|
||||
case SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE:
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user