MLK-22340-2: ASoC: imx-pcm-rpmsg: drop the cmd I2S_TX_POINTER
authorShengjiu Wang <shengjiu.wang@nxp.com>
Mon, 29 Jul 2019 06:33:08 +0000 (14:33 +0800)
committerShengjiu Wang <shengjiu.wang@nxp.com>
Fri, 16 Aug 2019 05:26:03 +0000 (13:26 +0800)
There is error log for short period size:

[ 6977.102062] i2s_rpmsg virtio0.rpmsg-audio-channel.-1.1: rpmsg_send cmd 22 timeout!

We use the I2S_TX_POINTER(cmd 22) to get the consumed period
index from M4 every period time, and m4 should send feedback
to A53. When the period time is small, there will too much
cmd send to m4, m4 may not handle it quickly that cause
timeout.

This patch is to remove the I2S_TX_POINTER cmd, m4 should
send notification to A53 every period time to be compatible
with this change. with the patch the loading of this rpmsg
channel is reduced.

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

sound/soc/fsl/imx-pcm-rpmsg.c

index 65a63a2..ca2d0a9 100644 (file)
@@ -109,12 +109,11 @@ static snd_pcm_uframes_t imx_rpmsg_pcm_pointer(
        int buffer_tail = 0;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               rpmsg = &i2s_info->rpmsg[I2S_TX_POINTER];
+               rpmsg = &i2s_info->rpmsg[I2S_TX_PERIOD_DONE + I2S_TYPE_A_NUM];
        else
-               rpmsg = &i2s_info->rpmsg[I2S_RX_POINTER];
+               rpmsg = &i2s_info->rpmsg[I2S_RX_PERIOD_DONE + I2S_TYPE_A_NUM];
 
-       buffer_tail = rpmsg->recv_msg.param.buffer_offset /
-                               snd_pcm_lib_period_bytes(substream);
+       buffer_tail = rpmsg->recv_msg.param.buffer_tail;
        pos = buffer_tail * snd_pcm_lib_period_bytes(substream);
 
        return bytes_to_frames(substream->runtime, pos);
@@ -135,14 +134,14 @@ static void imx_rpmsg_timer_callback(struct timer_list *t)
        int time_msec;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               rpmsg = &i2s_info->rpmsg[I2S_TX_POINTER];
+               rpmsg = &i2s_info->rpmsg[I2S_TX_PERIOD_DONE + I2S_TYPE_A_NUM];
        else
-               rpmsg = &i2s_info->rpmsg[I2S_RX_POINTER];
+               rpmsg = &i2s_info->rpmsg[I2S_RX_PERIOD_DONE + I2S_TYPE_A_NUM];
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               rpmsg->send_msg.header.cmd = I2S_TX_POINTER;
+               rpmsg->send_msg.header.cmd = I2S_TX_PERIOD_DONE;
        else
-               rpmsg->send_msg.header.cmd = I2S_RX_POINTER;
+               rpmsg->send_msg.header.cmd = I2S_RX_PERIOD_DONE;
 
        if (i2s_info->work_write_index != i2s_info->work_read_index) {
                memcpy(&i2s_info->work_list[index].msg, rpmsg,
@@ -158,8 +157,6 @@ static void imx_rpmsg_timer_callback(struct timer_list *t)
                mod_timer(&i2s_info->stream_timer[substream->stream].timer,
                             jiffies + msecs_to_jiffies(time_msec));
        }
-
-       snd_pcm_period_elapsed(substream);
 }
 
 static int imx_rpmsg_pcm_open(struct snd_pcm_substream *substream)
@@ -300,19 +297,7 @@ static void imx_rpmsg_pcm_dma_complete(void *arg)
        struct snd_soc_dai   *cpu_dai = rtd->cpu_dai;
        struct fsl_rpmsg_i2s *rpmsg_i2s = dev_get_drvdata(cpu_dai->dev);
        struct i2s_info      *i2s_info =  &rpmsg_i2s->i2s_info;
-       struct i2s_rpmsg *rpmsg, *rpmsg2;
-
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               rpmsg = &i2s_info->rpmsg[I2S_TX_POINTER];
-               rpmsg2 = &i2s_info->rpmsg[I2S_TX_PERIOD_DONE + I2S_TYPE_A_NUM];
-       } else {
-               rpmsg = &i2s_info->rpmsg[I2S_RX_POINTER];
-               rpmsg2 = &i2s_info->rpmsg[I2S_RX_PERIOD_DONE + I2S_TYPE_A_NUM];
-       }
 
-       rpmsg->recv_msg.param.buffer_offset =
-               rpmsg2->recv_msg.param.buffer_tail
-                               * snd_pcm_lib_period_bytes(substream);
        /*
         * With suspend state, which is not running state, M4 will trigger
         * system resume with PERIOD_DONE command, at this moment, the