In Linux kernel v4.13, ALSA PCM core was improved in an aspect of updating appl_ptr at a commit 9027c4639ef1('ALSA: pcm: Call ack() whenever appl_ptr is updated'). This commit ensures a callback of 'struct snd_pcm_ops.ack()' when updating appl_ptr in process context. This callback can be done in below ioctl(2) requests: - SNDRV_PCM_IOCTL_REWIND - SNDRV_PCM_IOCTL_FORWARD - SNDRV_PCM_IOCTL_SYNC_PTR - SNDRV_PCM_IOCTL_READ[I|N]_FRAMES - SNDRV_PCM_IOCTL_WRITE[I|N]_FRAMES In a commit 875becf8412c('ALSA: firewire: process packets in 'struct snd_pcm_ops.ack' callback'), I committed implementation of .ack() callback to reduce timing gap between queueing/dequeueing PCM frames and processing packets. However, in usual mmap programming scenario of ALSA PCM applications, the above operations are not always used in event dispatcher and the commit is not necessarily effective to this engine. At the same time of the appl_ptr improvement, a new flag of PCM hardware definition was introduced at a commit 42f945970af9('ALSA: pcm: Add the explicit appl_ptr sync support'), and relevant changes were added to ALSA PCM core and alsa-lib v1.1.5. This flag expects userspace to call ioctl(2) with SNDRV_PCM_IOCTL_SYNC_PTR request per iteration of PCM frame handling in mmap programming scenario below: while (1): ->poll() ->snd_pcm_hwsync() ->ioctl(HWSYNC) ->snd_pcm_mmap_begin() (queue/dequeue PCM frames here) ->snd_pcm_mmap_commit() ->ioctl(SYNC_PTR) Although adoption of this flag to this engine increases the number of system calls in an iteration, it's useful in an aspect of packet processing. This commit adopts the flag. As a result, this engine has two chances to process packets in process context at one iteration of the above calls. while (1): ->poll() ->snd_pcm_hwsync() ->ioctl(HWSYNC) ->struct snd_pcm_ops.pointer() = amdtp_stream_pcm_pointer() ->fw_iso_context_flush_completions() ->snd_pcm_mmap_begin() (queue/dequeue PCM frames here) ->snd_pcm_mmap_commit() ->ioctl(SYNC_PTR) ->struct snd_pcm_ops.ack() = amdtp_stream_pcm_ack() ->fw_iso_context_flush_completions() Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx> --- sound/firewire/amdtp-stream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index cb9acfe60f6a..3520dc2bec61 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -156,7 +156,8 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s, SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID; + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_SYNC_APPLPTR; /* SNDRV_PCM_INFO_BATCH */ hw->periods_min = 2; -- 2.17.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel