Commit ae03bbb8 authored by Dylan Reid's avatar Dylan Reid Committed by Takashi Iwai

ALSA: hda - Add codec delay to the capture time stamp.

For capture, the delay through the codec contributes to the time stamp
of the sample recorded at the A to D.  Rename the codec time stamp
function appropriately.
Signed-off-by: default avatarDylan Reid <dgreid@chromium.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ad2109d7
...@@ -1889,7 +1889,7 @@ static void azx_timecounter_init(struct snd_pcm_substream *substream, ...@@ -1889,7 +1889,7 @@ static void azx_timecounter_init(struct snd_pcm_substream *substream,
tc->cycle_last = last; tc->cycle_last = last;
} }
static u64 azx_subtract_codec_delay(struct snd_pcm_substream *substream, static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream,
u64 nsec) u64 nsec)
{ {
struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
...@@ -1903,6 +1903,9 @@ static u64 azx_subtract_codec_delay(struct snd_pcm_substream *substream, ...@@ -1903,6 +1903,9 @@ static u64 azx_subtract_codec_delay(struct snd_pcm_substream *substream,
codec_nsecs = div_u64(codec_frames * 1000000000LL, codec_nsecs = div_u64(codec_frames * 1000000000LL,
substream->runtime->rate); substream->runtime->rate);
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
return nsec + codec_nsecs;
return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0; return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
} }
...@@ -1914,7 +1917,7 @@ static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream, ...@@ -1914,7 +1917,7 @@ static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream,
nsec = timecounter_read(&azx_dev->azx_tc); nsec = timecounter_read(&azx_dev->azx_tc);
nsec = div_u64(nsec, 3); /* can be optimized */ nsec = div_u64(nsec, 3); /* can be optimized */
nsec = azx_subtract_codec_delay(substream, nsec); nsec = azx_adjust_codec_delay(substream, nsec);
*ts = ns_to_timespec(nsec); *ts = ns_to_timespec(nsec);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment