Commit 35a7086e authored by Ravulapati Vishnu vardhan rao's avatar Ravulapati Vishnu vardhan rao Committed by Mark Brown

ASoC: amd: Reporting accurate hw_ptr for acp3x dma

acp3x dma pointer callback has issues in reporting hw_ptr.
Modified logic to use linear position registers to
retrieve accurate hw_ptr.
Signed-off-by: default avatarRavulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
Signed-off-by: default avatarVijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 261e9082
...@@ -32,6 +32,7 @@ struct i2s_stream_instance { ...@@ -32,6 +32,7 @@ struct i2s_stream_instance {
u16 channels; u16 channels;
u32 xfer_resolution; u32 xfer_resolution;
struct page *pg; struct page *pg;
u64 bytescount;
void __iomem *acp3x_base; void __iomem *acp3x_base;
}; };
...@@ -317,6 +318,24 @@ static int acp3x_dma_open(struct snd_pcm_substream *substream) ...@@ -317,6 +318,24 @@ static int acp3x_dma_open(struct snd_pcm_substream *substream)
return 0; return 0;
} }
static u64 acp_get_byte_count(struct i2s_stream_instance *rtd, int direction)
{
u64 byte_count;
if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
byte_count = rv_readl(rtd->acp3x_base +
mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH);
byte_count |= rv_readl(rtd->acp3x_base +
mmACP_BT_TX_LINEARPOSITIONCNTR_LOW);
} else {
byte_count = rv_readl(rtd->acp3x_base +
mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH);
byte_count |= rv_readl(rtd->acp3x_base +
mmACP_BT_RX_LINEARPOSITIONCNTR_LOW);
}
return byte_count;
}
static int acp3x_dma_hw_params(struct snd_pcm_substream *substream, static int acp3x_dma_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
...@@ -350,18 +369,17 @@ static int acp3x_dma_hw_params(struct snd_pcm_substream *substream, ...@@ -350,18 +369,17 @@ static int acp3x_dma_hw_params(struct snd_pcm_substream *substream,
static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_pcm_substream *substream)
{ {
u32 pos = 0; u32 pos = 0;
struct i2s_stream_instance *rtd = substream->runtime->private_data; u32 buffersize = 0;
u64 bytescount = 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) struct i2s_stream_instance *rtd =
pos = rv_readl(rtd->acp3x_base + substream->runtime->private_data;
mmACP_BT_TX_LINKPOSITIONCNTR);
else buffersize = frames_to_bytes(substream->runtime,
pos = rv_readl(rtd->acp3x_base + substream->runtime->buffer_size);
mmACP_BT_RX_LINKPOSITIONCNTR); bytescount = acp_get_byte_count(rtd, substream->stream);
if (bytescount > rtd->bytescount)
if (pos >= MAX_BUFFER) bytescount -= rtd->bytescount;
pos = 0; pos = do_div(bytescount, buffersize);
return bytes_to_frames(substream->runtime, pos); return bytes_to_frames(substream->runtime, pos);
} }
...@@ -521,6 +539,7 @@ static int acp3x_dai_i2s_trigger(struct snd_pcm_substream *substream, ...@@ -521,6 +539,7 @@ static int acp3x_dai_i2s_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
rtd->bytescount = acp_get_byte_count(rtd, substream->stream);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
rv_writel(period_bytes, rtd->acp3x_base + rv_writel(period_bytes, rtd->acp3x_base +
mmACP_BT_TX_INTR_WATERMARK_SIZE); mmACP_BT_TX_INTR_WATERMARK_SIZE);
......
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