MLK-20277-1: ASoC: imx-pcm-rpmsg: reset the period index at stop
authorShengjiu Wang <shengjiu.wang@nxp.com>
Thu, 8 Nov 2018 07:07:13 +0000 (15:07 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
With the case that underrun happened, the aplay will trigger
stop and start, if the period index is not reset at stop, the
counter of period will be wrong

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
sound/soc/fsl/imx-pcm-rpmsg.c

index 0b55935..4fda493 100644 (file)
@@ -451,6 +451,7 @@ static int imx_rpmsg_terminate_all(struct snd_pcm_substream *substream)
        struct i2s_info            *i2s_info =  &rpmsg_i2s->i2s_info;
        struct i2s_rpmsg     *rpmsg;
        u8 index = i2s_info->work_index;
+       int cmd;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                rpmsg = &i2s_info->rpmsg[I2S_TX_TERMINATE];
@@ -468,6 +469,18 @@ static int imx_rpmsg_terminate_all(struct snd_pcm_substream *substream)
        i2s_info->work_index++;
        i2s_info->work_index %= WORK_MAX_NUM;
 
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               cmd = I2S_TX_PERIOD_DONE + I2S_TYPE_A_NUM;
+               i2s_info->rpmsg[cmd].send_msg.param.buffer_tail = 0;
+               i2s_info->rpmsg[cmd].recv_msg.param.buffer_tail = 0;
+               i2s_info->rpmsg[I2S_TX_POINTER].recv_msg.param.buffer_offset = 0;
+       } else {
+               cmd = I2S_RX_PERIOD_DONE + I2S_TYPE_A_NUM;
+               i2s_info->rpmsg[cmd].send_msg.param.buffer_tail = 0;
+               i2s_info->rpmsg[cmd].recv_msg.param.buffer_tail = 0;
+               i2s_info->rpmsg[I2S_RX_POINTER].recv_msg.param.buffer_offset = 0;
+       }
+
        del_timer(&i2s_info->stream_timer[substream->stream]);
        return 0;
 }