Skip to content

Commit

Permalink
ALSA: ump: Add ioctls to inquiry UMP EP and Block info via control API
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Takashi Iwai committed May 23, 2023
1 parent 127ae6f commit 30fc139
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/uapi/sound/asound.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
26 changes: 26 additions & 0 deletions sound/core/rawmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&register_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(&register_mutex);
return ret;
}
#endif

static int snd_rawmidi_control_ioctl(struct snd_card *card,
struct snd_ctl_file *control,
unsigned int cmd,
Expand All @@ -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:
{
Expand Down

0 comments on commit 30fc139

Please sign in to comment.