]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: hw: Call USER_PVERSION ioctl at open
authorTakashi Iwai <tiwai@suse.de>
Tue, 20 Jun 2017 12:21:20 +0000 (14:21 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 27 Jun 2017 09:45:22 +0000 (11:45 +0200)
Up from the new PCM protocol 2.0.14, user-space can inform the
protocol version it supports to kernel, so that the kernel may switch
its behavior depending on it.  Add this ioctl call in the PCM hw
plugin at opening.

The patch contains also the addition of SNDRV_PCM_INFO_SYNC_APPLPTR
carried from the upstream kernel commit 42f945970af9 ("ALSA: pcm: Add
the explicit appl_ptr sync support"), as well as the trivial change
(an addition of comma) to sync with the kernel asound.h.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/asound.h
src/pcm/pcm_hw.c

index fb8d7d7ef8ad0b74568b96ba63cc7aeb3cc112ba..1949923a40bf98bd8cfedc59ff67eca6dc3e1c8a 100644 (file)
@@ -111,7 +111,7 @@ enum {
        SNDRV_HWDEP_IFACE_FW_FIREFACE,  /* RME Fireface series */
 
        /* Don't forget to change the following: */
-       SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_FW_FIREFACE,
+       SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_FW_FIREFACE
 };
 
 struct snd_hwdep_info {
@@ -152,7 +152,7 @@ struct snd_hwdep_dsp_image {
  *                                                                           *
  *****************************************************************************/
 
-#define SNDRV_PCM_VERSION              SNDRV_PROTOCOL_VERSION(2, 0, 13)
+#define SNDRV_PCM_VERSION              SNDRV_PROTOCOL_VERSION(2, 0, 14)
 
 typedef unsigned long snd_pcm_uframes_t;
 typedef signed long snd_pcm_sframes_t;
@@ -268,6 +268,7 @@ typedef int __bitwise snd_pcm_subformat_t;
 #define SNDRV_PCM_INFO_MMAP_VALID      0x00000002      /* period data are valid during transfer */
 #define SNDRV_PCM_INFO_DOUBLE          0x00000004      /* Double buffering needed for PCM start/stop */
 #define SNDRV_PCM_INFO_BATCH           0x00000010      /* double buffering */
+#define SNDRV_PCM_INFO_SYNC_APPLPTR    0x00000020      /* need the explicit sync of appl_ptr update */
 #define SNDRV_PCM_INFO_INTERLEAVED     0x00000100      /* channels are interleaved */
 #define SNDRV_PCM_INFO_NONINTERLEAVED  0x00000200      /* channels are not interleaved */
 #define SNDRV_PCM_INFO_COMPLEX         0x00000400      /* complex frame organization (mmap only) */
@@ -563,6 +564,7 @@ enum {
 #define SNDRV_PCM_IOCTL_INFO           _IOR('A', 0x01, struct snd_pcm_info)
 #define SNDRV_PCM_IOCTL_TSTAMP         _IOW('A', 0x02, int)
 #define SNDRV_PCM_IOCTL_TTSTAMP                _IOW('A', 0x03, int)
+#define SNDRV_PCM_IOCTL_USER_PVERSION  _IOW('A', 0x04, int)
 #define SNDRV_PCM_IOCTL_HW_REFINE      _IOWR('A', 0x10, struct snd_pcm_hw_params)
 #define SNDRV_PCM_IOCTL_HW_PARAMS      _IOWR('A', 0x11, struct snd_pcm_hw_params)
 #define SNDRV_PCM_IOCTL_HW_FREE                _IO('A', 0x12)
index 5573fce2d43deb6391ed8b63d634438e404042c9..64188b2258d631b70c9df59a8cd98c4e9e4b0c83 100644 (file)
@@ -1494,6 +1494,16 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
        if (SNDRV_PROTOCOL_INCOMPATIBLE(ver, SNDRV_PCM_VERSION_MAX))
                return -SND_ERROR_INCOMPATIBLE_VERSION;
 
+       if (SNDRV_PROTOCOL_VERSION(2, 0, 14) <= ver) {
+               /* inform the protocol version we're supporting */
+               unsigned int user_ver = SNDRV_PCM_VERSION;
+               if (ioctl(fd, SNDRV_PCM_IOCTL_USER_PVERSION, &user_ver) < 0) {
+                       ret = -errno;
+                       SNDMSG("USER_PVERSION failed\n");
+                       return ret;
+               }
+       }
+
 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
        if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
                struct timespec timespec;