--- v5
+++ v2
@@ -1,22 +1,22 @@
This driver is used to accept the message from rpmsg audio
channel, and if this driver is probed, it will help to register
the platform driver, the platform driver will use this
-audio channel to send and receive messages to and from Cortex-M
+audio channel to send and receive message to and from Cortex-M
core.
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
sound/soc/fsl/Kconfig | 4 +
sound/soc/fsl/Makefile | 1 +
- sound/soc/fsl/imx-audio-rpmsg.c | 140 ++++++++++++++++++++++++++++++++
- 3 files changed, 145 insertions(+)
+ sound/soc/fsl/imx-audio-rpmsg.c | 151 ++++++++++++++++++++++++++++++++
+ 3 files changed, 156 insertions(+)
create mode 100644 sound/soc/fsl/imx-audio-rpmsg.c
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
-index 3326f30e28f6..8dbdc0c5ba58 100644
+index a688c3c2efbc..84d9f0f1f75b 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
-@@ -129,6 +129,10 @@ config SND_SOC_IMX_PCM_DMA
+@@ -126,6 +126,10 @@ config SND_SOC_IMX_PCM_DMA
tristate
select SND_SOC_GENERIC_DMAENGINE_PCM
@@ -41,10 +41,10 @@
snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o
diff --git a/sound/soc/fsl/imx-audio-rpmsg.c b/sound/soc/fsl/imx-audio-rpmsg.c
new file mode 100644
-index 000000000000..50099bcaa9cd
+index 000000000000..145edb1492b4
--- /dev/null
+++ b/sound/soc/fsl/imx-audio-rpmsg.c
-@@ -0,0 +1,140 @@
+@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0+
+// Copyright 2017-2020 NXP
+
@@ -65,15 +65,10 @@
+ void *priv, u32 src)
+{
+ struct imx_audio_rpmsg *rpmsg = dev_get_drvdata(&rpdev->dev);
++ struct rpmsg_info *info = platform_get_drvdata(rpmsg->rpmsg_pdev);
+ struct rpmsg_r_msg *r_msg = (struct rpmsg_r_msg *)data;
-+ struct rpmsg_info *info;
+ struct rpmsg_msg *msg;
+ unsigned long flags;
-+
-+ if (!rpmsg->rpmsg_pdev)
-+ return 0;
-+
-+ info = platform_get_drvdata(rpmsg->rpmsg_pdev);
+
+ dev_dbg(&rpdev->dev, "get from%d: cmd:%d. %d\n",
+ src, r_msg->header.cmd, r_msg->param.resp);
@@ -85,8 +80,18 @@
+ case TX_PERIOD_DONE:
+ spin_lock_irqsave(&info->lock[TX], flags);
+ msg = &info->msg[TX_PERIOD_DONE + MSG_TYPE_A_NUM];
-+ msg->r_msg.param.buffer_tail =
++
++ /*
++ * Low power mode: get the buffer pointer from
++ * receive msg.
++ */
++ if (r_msg->header.major == 1 &&
++ r_msg->header.minor == 2)
++ msg->r_msg.param.buffer_tail =
+ r_msg->param.buffer_tail;
++ else
++ msg->r_msg.param.buffer_tail++;
++
+ msg->r_msg.param.buffer_tail %= info->num_period[TX];
+ spin_unlock_irqrestore(&info->lock[TX], flags);
+ info->callback[TX](info->callback_param[TX]);
@@ -94,8 +99,14 @@
+ case RX_PERIOD_DONE:
+ spin_lock_irqsave(&info->lock[RX], flags);
+ msg = &info->msg[RX_PERIOD_DONE + MSG_TYPE_A_NUM];
-+ msg->r_msg.param.buffer_tail =
++
++ if (r_msg->header.major == 1 &&
++ r_msg->header.minor == 2)
++ msg->r_msg.param.buffer_tail =
+ r_msg->param.buffer_tail;
++ else
++ msg->r_msg.param.buffer_tail++;
++
+ msg->r_msg.param.buffer_tail %= info->num_period[1];
+ spin_unlock_irqrestore(&info->lock[RX], flags);
+ info->callback[RX](info->callback_param[RX]);