Merge remote-tracking branch 'asoc/fix/wm2200' into asoc-next
[platform/adaptation/renesas_rcar/renesas_kernel.git] / sound / firewire / amdtp.c
index 3284ee9..ea995af 100644 (file)
@@ -178,6 +178,7 @@ void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s)
        tasklet_kill(&s->period_tasklet);
        s->pcm_buffer_pointer = 0;
        s->pcm_period_pointer = 0;
+       s->pointer_flush = true;
 }
 EXPORT_SYMBOL(amdtp_out_stream_pcm_prepare);
 
@@ -393,6 +394,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
                s->pcm_period_pointer += data_blocks;
                if (s->pcm_period_pointer >= pcm->runtime->period_size) {
                        s->pcm_period_pointer -= pcm->runtime->period_size;
+                       s->pointer_flush = false;
                        tasklet_hi_schedule(&s->period_tasklet);
                }
        }
@@ -532,6 +534,24 @@ err_unlock:
 EXPORT_SYMBOL(amdtp_out_stream_start);
 
 /**
+ * amdtp_out_stream_pcm_pointer - get the PCM buffer position
+ * @s: the AMDTP output stream that transports the PCM data
+ *
+ * Returns the current buffer position, in frames.
+ */
+unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s)
+{
+       /* this optimization is allowed to be racy */
+       if (s->pointer_flush)
+               fw_iso_context_flush_completions(s->context);
+       else
+               s->pointer_flush = true;
+
+       return ACCESS_ONCE(s->pcm_buffer_pointer);
+}
+EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
+
+/**
  * amdtp_out_stream_update - update the stream after a bus reset
  * @s: the AMDTP output stream
  */