Skip to content

Commit

Permalink
ASoC: Intel: Fix stream position pointer.
Browse files Browse the repository at this point in the history
Read the stream offset and presentation position from DSP memory rather
than using the old estimated position. This fixes timing issues with
pulseaudio.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Liam Girdwood authored and Mark Brown committed May 2, 2014
1 parent 916152c commit 51b4e24
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
22 changes: 20 additions & 2 deletions sound/soc/intel/sst-haswell-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1547,10 +1547,28 @@ int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
}

/* Stream pointer positions */
int sst_hsw_get_dsp_position(struct sst_hsw *hsw,
u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw,
struct sst_hsw_stream *stream)
{
return stream->rpos.position;
u32 rpos;

sst_dsp_read(hsw->dsp, &rpos,
stream->reply.read_position_register_address, sizeof(rpos));

return rpos;
}

/* Stream presentation (monotonic) positions */
u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw,
struct sst_hsw_stream *stream)
{
u64 ppos;

sst_dsp_read(hsw->dsp, &ppos,
stream->reply.presentation_position_register_address,
sizeof(ppos));

return ppos;
}

int sst_hsw_stream_set_write_position(struct sst_hsw *hsw,
Expand Down
4 changes: 3 additions & 1 deletion sound/soc/intel/sst-haswell-ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ int sst_hsw_stream_get_write_pos(struct sst_hsw *hsw,
struct sst_hsw_stream *stream, u32 *position);
int sst_hsw_stream_set_write_position(struct sst_hsw *hsw,
struct sst_hsw_stream *stream, u32 stage_id, u32 position);
int sst_hsw_get_dsp_position(struct sst_hsw *hsw,
u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw,
struct sst_hsw_stream *stream);
u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw,
struct sst_hsw_stream *stream);

/* HW port config */
Expand Down
10 changes: 6 additions & 4 deletions sound/soc/intel/sst-haswell-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,14 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream)
struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd);
struct sst_hsw *hsw = pdata->hsw;
snd_pcm_uframes_t offset;
uint64_t ppos;
u32 position = sst_hsw_get_dsp_position(hsw, pcm_data->stream);

offset = bytes_to_frames(runtime,
sst_hsw_get_dsp_position(hsw, pcm_data->stream));
offset = bytes_to_frames(runtime, position);
ppos = sst_hsw_get_dsp_presentation_position(hsw, pcm_data->stream);

dev_dbg(rtd->dev, "PCM: DMA pointer %zu bytes\n",
frames_to_bytes(runtime, (u32)offset));
dev_dbg(rtd->dev, "PCM: DMA pointer %du bytes, pos %llu\n",
position, ppos);
return offset;
}

Expand Down

0 comments on commit 51b4e24

Please sign in to comment.