<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 25, 2023 at 2:54 PM Chancel Liu <<a href="mailto:chancel.liu@nxp.com">chancel.liu@nxp.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Different PCM devices may have different PCM hardware parameters. It<br>
requires PCM hardware parameters set separately if there is more than<br>
one rpmsg sound card.<br>
<br>
Signed-off-by: Chancel Liu <<a href="mailto:chancel.liu@nxp.com" target="_blank">chancel.liu@nxp.com</a>><br></blockquote><div><br></div><div>Acked-by: Shengjiu Wang <<a href="mailto:shengjiu.wang@gmail.com">shengjiu.wang@gmail.com</a>></div><div><br></div><div>Best regards</div><div>Wang Shengjiu </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 sound/soc/fsl/imx-pcm-rpmsg.c | 12 ++++++++----<br>
 1 file changed, 8 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c<br>
index 765dad607bf6..d63782b8bdef 100644<br>
--- a/sound/soc/fsl/imx-pcm-rpmsg.c<br>
+++ b/sound/soc/fsl/imx-pcm-rpmsg.c<br>
@@ -228,6 +228,10 @@ static int imx_rpmsg_pcm_open(struct snd_soc_component *component,<br>
                              struct snd_pcm_substream *substream)<br>
 {<br>
        struct rpmsg_info *info = dev_get_drvdata(component->dev);<br>
+       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);<br>
+       struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);<br>
+       struct fsl_rpmsg *rpmsg = dev_get_drvdata(cpu_dai->dev);<br>
+       struct snd_pcm_hardware pcm_hardware;<br>
        struct rpmsg_msg *msg;<br>
        int ret = 0;<br>
        int cmd;<br>
@@ -255,10 +259,11 @@ static int imx_rpmsg_pcm_open(struct snd_soc_component *component,<br>
<br>
        info->send_message(msg, info);<br>
<br>
-       imx_rpmsg_pcm_hardware.period_bytes_max =<br>
-                       imx_rpmsg_pcm_hardware.buffer_bytes_max / 2;<br>
+       pcm_hardware = imx_rpmsg_pcm_hardware;<br>
+       pcm_hardware.buffer_bytes_max = rpmsg->buffer_size;<br>
+       pcm_hardware.period_bytes_max = pcm_hardware.buffer_bytes_max / 2;<br>
<br>
-       snd_soc_set_runtime_hwparams(substream, &imx_rpmsg_pcm_hardware);<br>
+       snd_soc_set_runtime_hwparams(substream, &pcm_hardware);<br>
<br>
        ret = snd_pcm_hw_constraint_integer(substream->runtime,<br>
                                            SNDRV_PCM_HW_PARAM_PERIODS);<br>
@@ -597,7 +602,6 @@ static int imx_rpmsg_pcm_new(struct snd_soc_component *component,<br>
        if (ret)<br>
                return ret;<br>
<br>
-       imx_rpmsg_pcm_hardware.buffer_bytes_max = rpmsg->buffer_size;<br>
        return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_WC,<br>
                                            pcm->card->dev, rpmsg->buffer_size);<br>
 }<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>