aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-06-19 17:11:54 -0400
committerTakashi Iwai <tiwai@suse.de>2017-06-27 07:55:46 -0400
commit4b671f57747468d7c810caaf955f79ff1aece4d4 (patch)
tree21823a35b9aa3367ae2860b0674425ee07a40ed6 /sound/core
parent532a7784c376f2332d38c4c1576843c66343713d (diff)
ALSA: pcm: Add an ioctl to specify the supported protocol version
We have an ioctl to inform the PCM protocol version the running kernel supports, but there is no way to know which protocol version the user-space can understand. This lack of information caused headaches in the past when we tried to extend the ABI. For example, because we couldn't guarantee the validity of the reserved bytes, we had to introduce a new ioctl SNDRV_PCM_IOCTL_STATUS_EXT for assigning a few new fields in the formerly reserved bits. If we could know that it's a new alsa-lib, we could assume the availability of the new fields, thus we could have reused the existing SNDRV_PCM_IOCTL_STATUS. In order to improve the ABI extensibility, this patch adds a new ioctl for user-space to inform its supporting protocol version to the kernel. By reporting the supported protocol from user-space, the kernel can judge which feature should be provided and which not. With the addition of the new ioctl, the PCM protocol version is bumped to 2.0.14, too. User-space checks the kernel protocol version via SNDRV_PCM_INFO_PVERSION, then it sets the supported version back via SNDRV_PCM_INFO_USER_PVERSION. Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_compat.c1
-rw-r--r--sound/core/pcm_native.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 8a0f8d51e95d..10f537f4d735 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -676,6 +676,7 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
676 case SNDRV_PCM_IOCTL_INFO: 676 case SNDRV_PCM_IOCTL_INFO:
677 case SNDRV_PCM_IOCTL_TSTAMP: 677 case SNDRV_PCM_IOCTL_TSTAMP:
678 case SNDRV_PCM_IOCTL_TTSTAMP: 678 case SNDRV_PCM_IOCTL_TTSTAMP:
679 case SNDRV_PCM_IOCTL_USER_PVERSION:
679 case SNDRV_PCM_IOCTL_HWSYNC: 680 case SNDRV_PCM_IOCTL_HWSYNC:
680 case SNDRV_PCM_IOCTL_PREPARE: 681 case SNDRV_PCM_IOCTL_PREPARE:
681 case SNDRV_PCM_IOCTL_RESET: 682 case SNDRV_PCM_IOCTL_RESET:
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 9ade0c8b54a3..1c53d93e68f2 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2770,6 +2770,8 @@ static int snd_pcm_common_ioctl(struct file *file,
2770 struct snd_pcm_substream *substream, 2770 struct snd_pcm_substream *substream,
2771 unsigned int cmd, void __user *arg) 2771 unsigned int cmd, void __user *arg)
2772{ 2772{
2773 struct snd_pcm_file *pcm_file = file->private_data;
2774
2773 switch (cmd) { 2775 switch (cmd) {
2774 case SNDRV_PCM_IOCTL_PVERSION: 2776 case SNDRV_PCM_IOCTL_PVERSION:
2775 return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; 2777 return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0;
@@ -2779,6 +2781,11 @@ static int snd_pcm_common_ioctl(struct file *file,
2779 return 0; 2781 return 0;
2780 case SNDRV_PCM_IOCTL_TTSTAMP: 2782 case SNDRV_PCM_IOCTL_TTSTAMP:
2781 return snd_pcm_tstamp(substream, arg); 2783 return snd_pcm_tstamp(substream, arg);
2784 case SNDRV_PCM_IOCTL_USER_PVERSION:
2785 if (get_user(pcm_file->user_pversion,
2786 (unsigned int __user *)arg))
2787 return -EFAULT;
2788 return 0;
2782 case SNDRV_PCM_IOCTL_HW_REFINE: 2789 case SNDRV_PCM_IOCTL_HW_REFINE:
2783 return snd_pcm_hw_refine_user(substream, arg); 2790 return snd_pcm_hw_refine_user(substream, arg);
2784 case SNDRV_PCM_IOCTL_HW_PARAMS: 2791 case SNDRV_PCM_IOCTL_HW_PARAMS: