Commit df521561 authored by Jaroslav Kysela's avatar Jaroslav Kysela Committed by Takashi Iwai

ALSA: hda: fix trigger_tstamp_latched

When the trigger_tstamp_latched flag is set, the PCM core code assumes that
the low-level driver handles the trigger timestamping itself. Ensure that
runtime->trigger_tstamp is always updated.

Buglink: https://github.com/alsa-project/alsa-lib/issues/387Reported-by: default avatarZeno Endemann <zeno.endemann@mailbox.org>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
Link: https://patch.msgid.link/20241002081306.1788405-1-perex@perex.czSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d75dba49
...@@ -590,7 +590,7 @@ void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set, ...@@ -590,7 +590,7 @@ void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set,
void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
unsigned int streams); unsigned int streams);
void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
unsigned int streams); unsigned int streams, bool start);
int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus, int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus,
struct snd_pcm_substream *substream); struct snd_pcm_substream *substream);
......
...@@ -664,7 +664,7 @@ static void azx_timecounter_init(struct hdac_stream *azx_dev, ...@@ -664,7 +664,7 @@ static void azx_timecounter_init(struct hdac_stream *azx_dev,
* updated accordingly, too. * updated accordingly, too.
*/ */
void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
unsigned int streams) unsigned int streams, bool start)
{ {
struct hdac_bus *bus = azx_dev->bus; struct hdac_bus *bus = azx_dev->bus;
struct snd_pcm_runtime *runtime = azx_dev->substream->runtime; struct snd_pcm_runtime *runtime = azx_dev->substream->runtime;
...@@ -672,6 +672,9 @@ void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, ...@@ -672,6 +672,9 @@ void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
bool inited = false; bool inited = false;
u64 cycle_last = 0; u64 cycle_last = 0;
if (!start)
goto skip;
list_for_each_entry(s, &bus->stream_list, list) { list_for_each_entry(s, &bus->stream_list, list) {
if ((streams & (1 << s->index))) { if ((streams & (1 << s->index))) {
azx_timecounter_init(s, inited, cycle_last); azx_timecounter_init(s, inited, cycle_last);
...@@ -682,6 +685,7 @@ void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, ...@@ -682,6 +685,7 @@ void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
} }
} }
skip:
snd_pcm_gettime(runtime, &runtime->trigger_tstamp); snd_pcm_gettime(runtime, &runtime->trigger_tstamp);
runtime->trigger_tstamp_latched = true; runtime->trigger_tstamp_latched = true;
} }
......
...@@ -275,8 +275,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -275,8 +275,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
spin_lock(&bus->reg_lock); spin_lock(&bus->reg_lock);
/* reset SYNC bits */ /* reset SYNC bits */
snd_hdac_stream_sync_trigger(hstr, false, sbits, sync_reg); snd_hdac_stream_sync_trigger(hstr, false, sbits, sync_reg);
if (start) snd_hdac_stream_timecounter_init(hstr, sbits, start);
snd_hdac_stream_timecounter_init(hstr, sbits);
spin_unlock(&bus->reg_lock); spin_unlock(&bus->reg_lock);
return 0; return 0;
} }
......
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