From: Pan Xiuli xiuli.pan@linux.intel.com
Add posn_offset update from ipc reply in function sof_pcm_hw_params. We get the DSP reply, then check and update the PCM related posn_offset value.
Signed-off-by: Pan Xiuli xiuli.pan@linux.intel.com
--- Test with: Mininow max rt5651 and GP-MRB nocodec SOF master: 77ed88aa4a26c3ff6f479bf0894a13c87119ffdc SOF-Tool master: 3105de2481b5b5511b2fa844fe859f023f434b4c https://github.com/plbossart/sound/tree/topic/sof-v4.14: d919ea06b7f79c95ab4eb68baf05e9faf3a894c1 --- sound/soc/sof/pcm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 771625f..34b4935 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -53,6 +53,7 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_sof_pcm *spcm = rtd->sof; struct sof_ipc_pcm_params pcm; struct sof_ipc_pcm_params_reply ipc_params_reply; + int posn_offset; int ret;
/* nothing todo for BE */ @@ -132,9 +133,6 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- /* copy offset */ - //spcm->posn_offset[substream->stream] = ipc_params_reply.posn_offset; - /* firmware already configured host stream */ if (ops && ops->host_stream_prepare) { pcm.params.stream_tag = @@ -147,6 +145,18 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream, pcm.hdr.cmd, &pcm, sizeof(pcm), &ipc_params_reply, sizeof(ipc_params_reply));
+ /* validate offset */ + posn_offset = ipc_params_reply.posn_offset; + /* check if offset is overflow or it is not aligned */ + if (posn_offset > sdev->stream_box.size || + posn_offset % sizeof(struct sof_ipc_stream_posn) != 0) { + dev_err(sdev->dev, "error: got wrong posn offset 0x%x for PCM %d\n", + posn_offset, ret); + return ret; + } + spcm->posn_offset[substream->stream] = + sdev->stream_box.offset + posn_offset; + return ret; }