History

ALSA: rawmidi: introduce SNDRV_RAWMIDI_IOCTL_USER_PVERSION

The new framing mode causes the user space regression, because the alsa-lib code does not initialize the reserved space in the params structure when the device is opened. This change adds SNDRV_RAWMIDI_IOCTL_USER_PVERSION like we do for the PCM interface for the protocol acknowledgment.

Jaroslav Kysela committed 5 years ago

Commit 09d23171 parent cb1bcf53 files · +11 −0Browse files

Unified · Split

3 files
  1. include/sound/rawmidi.h +1 −0
  2. include/uapi/sound/asound.h +1 −0
  3. sound/core/rawmidi.c +9 −0
include/sound/rawmidi.h+1−0
@@ -98,6 +98,7 @@ struct snd_rawmidi_file { · 97 unmodified lines
9898 struct snd_rawmidi *rmidi;
9999 struct snd_rawmidi_substream *input;
100100 struct snd_rawmidi_substream *output;
101+ unsigned int user_pversion; /* supported protocol version */
101102 };
102103
103104 struct snd_rawmidi_str {
include/uapi/sound/asound.h+1−0
@@ -784,6 +784,7 @@ struct snd_rawmidi_status { · 783 unmodified lines
784784
785785 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
786786 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
787+#define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int)
787788 #define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params)
788789 #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status)
789790 #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)
sound/core/rawmidi.c+9−0
@@ -873,12 +873,21 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long · 872 unmodified lines
873873 return -EINVAL;
874874 }
875875 }
876+ case SNDRV_RAWMIDI_IOCTL_USER_PVERSION:
877+ if (get_user(rfile->user_pversion, (unsigned int __user *)arg))
878+ return -EFAULT;
879+ return 0;
880+
876881 case SNDRV_RAWMIDI_IOCTL_PARAMS:
877882 {
878883 struct snd_rawmidi_params params;
879884
880885 if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params)))
881886 return -EFAULT;
887+ if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) {
888+ params.mode = 0;
889+ memset(params.reserved, 0, sizeof(params.reserved));
890+ }
882891 switch (params.stream) {
883892 case SNDRV_RAWMIDI_STREAM_OUTPUT:
884893 if (rfile->output == NULL)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t