MLK-21461: ASoC: fsl_rpmsg_i2s: clear buffer pointer in i2s_send_message
authorShengjiu Wang <shengjiu.wang@nxp.com>
Tue, 16 Apr 2019 07:17:06 +0000 (15:17 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Thu, 18 Apr 2019 07:21:03 +0000 (10:21 +0300)
Reset the buffer pointer to be zero in i2s_send_message, actully we have
set the buffer pointer to be zero in imx_rpmsg_terminate_all.
But if there is timer task (I2S_TX_POINTER) queued in queue, after it is
executed the buffer pointer will be changed, this is timing issue that
the task in the queue is delayed. so need to reset it with TERMINATE
command.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit 0a07dd454cbf85744677812e53fc5e86a48706bf)

sound/soc/fsl/fsl_rpmsg_i2s.c

index 5a82340..5db47a3 100644 (file)
@@ -70,6 +70,25 @@ static int i2s_send_message(struct i2s_rpmsg *msg,
                                        sizeof(struct i2s_rpmsg_r));
                memcpy(&info->rpmsg[msg->recv_msg.header.cmd].recv_msg,
                        &msg->recv_msg, sizeof(struct i2s_rpmsg_r));
+
+               /*
+                * Reset the buffer pointer to be zero, actully we have
+                * set the buffer pointer to be zero in imx_rpmsg_terminate_all
+                * But if there is timer task queued in queue, after it is
+                * executed the buffer pointer will be changed, so need to
+                * reset it again with TERMINATE command.
+                */
+
+               switch (msg->send_msg.header.cmd) {
+               case I2S_TX_TERMINATE:
+                       info->rpmsg[I2S_TX_POINTER].recv_msg.param.buffer_offset = 0;
+                       break;
+               case I2S_RX_TERMINATE:
+                       info->rpmsg[I2S_RX_POINTER].recv_msg.param.buffer_offset = 0;
+                       break;
+               default:
+                       break;
+               }
        }
 
        dev_dbg(&info->rpdev->dev, "cmd:%d, resp %d\n",