ALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag
[sfrench/cifs-2.6.git] / sound / core / pcm_native.c
index dc9fa312faddfb27bec0b134b5f78498ca15f9a5..d233cb3b41d8ba0fae692c61942b91258b563c24 100644 (file)
@@ -3621,6 +3621,12 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file
 
 static bool pcm_status_mmap_allowed(struct snd_pcm_file *pcm_file)
 {
+       /* If drivers require the explicit sync (typically for non-coherent
+        * pages), we have to disable the mmap of status and control data
+        * to enforce the control via SYNC_PTR ioctl.
+        */
+       if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC)
+               return false;
        /* See pcm_control_mmap_allowed() below.
         * Since older alsa-lib requires both status and control mmaps to be
         * coupled, we have to disable the status mmap for old alsa-lib, too.
@@ -3635,6 +3641,9 @@ static bool pcm_control_mmap_allowed(struct snd_pcm_file *pcm_file)
 {
        if (pcm_file->no_compat_mmap)
                return false;
+       /* see above */
+       if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC)
+               return false;
        /* Disallow the control mmap when SYNC_APPLPTR flag is set;
         * it enforces the user-space to fall back to snd_pcm_sync_ptr(),
         * thus it effectively assures the manual update of appl_ptr.