2022-08-29 08:07:25

by Chancel Liu

[permalink] [raw]
Subject: [PATCH 0/5] Create a new sound card to access MICFIL based on rpmsg channel

At a previous time, we have successfully created a virtual sound card
based on rpmsg. The sound card works under this mechanism Cortex-A core
tells the Cortex-M core the format, rate, channel, .etc configuration
of the PCM parameters and Cortex-M controls real hardware devices such
as SAI and DMA. From the view of Linux side, the sound card is bound to
a rpmsg channel through which it can access SAI.

Here these patches are introduced to create a new virtual sound card to
access MICFIL based on a new created rpmsg channel. It's easy to create
a new rpmsg channel for MICFIL through rpmsg name service announcment.
Also the other ASoC components bound to this rpmsg MICFIL sound card
will be registered with these patches.

If other sound cards using different hardware devices needs to be
created over rpmsg in the future, these patches can be referred.

Chancel Liu (5):
ASoC: dt-bindings: fsl_rpmsg: Add a property to assign platform driver
name
ASoC: imx-audio-rpmsg: Create rpmsg channel for MICFIL
ASoC: imx-pcm-rpmsg: Register different platform drivers
ASoC: fsl_rpmsg: Register different CPU DAI drivers
ASoC: imx-rpmsg: Assign platform driver used by machine driver to link
with

.../devicetree/bindings/sound/fsl,rpmsg.yaml | 34 +++++++++++++++++--
sound/soc/fsl/fsl_rpmsg.c | 2 +-
sound/soc/fsl/imx-audio-rpmsg.c | 3 +-
sound/soc/fsl/imx-pcm-rpmsg.c | 10 ++++--
sound/soc/fsl/imx-rpmsg.c | 6 +++-
5 files changed, 47 insertions(+), 8 deletions(-)

--
2.25.1


2022-08-29 08:21:40

by Chancel Liu

[permalink] [raw]
Subject: [PATCH 3/5] ASoC: imx-pcm-rpmsg: Register different platform drivers

This patch can register different ASoC platform drivers in reference
to "fsl,platform" property of the corresponding node in dts. So sound
cards based on different rpmsg channels can link to their respective
platform drivers.

Signed-off-by: Chancel Liu <[email protected]>
---
sound/soc/fsl/imx-pcm-rpmsg.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
index 35049043e532..2f310994f7ee 100644
--- a/sound/soc/fsl/imx-pcm-rpmsg.c
+++ b/sound/soc/fsl/imx-pcm-rpmsg.c
@@ -178,7 +178,7 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component,
msg->s_msg.param.channels = RPMSG_CH_STEREO;
break;
default:
- ret = -EINVAL;
+ msg->s_msg.param.channels = params_channels(params);
break;
}

@@ -684,7 +684,7 @@ static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
info->rpdev = container_of(pdev->dev.parent, struct rpmsg_device, dev);
info->dev = &pdev->dev;
/* Setup work queue */
- info->rpmsg_wq = alloc_ordered_workqueue("rpmsg_audio",
+ info->rpmsg_wq = alloc_ordered_workqueue(info->rpdev->id.name,
WQ_HIGHPRI |
WQ_UNBOUND |
WQ_FREEZABLE);
@@ -723,11 +723,15 @@ static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
if (ret)
goto fail;

- component = snd_soc_lookup_component(&pdev->dev, IMX_PCM_DRV_NAME);
+ component = snd_soc_lookup_component(&pdev->dev, NULL);
if (!component) {
ret = -EINVAL;
goto fail;
}
+
+ /* platform component name is used by machine driver to link with */
+ component->name = info->rpdev->id.name;
+
#ifdef CONFIG_DEBUG_FS
component->debugfs_prefix = "rpmsg";
#endif
--
2.25.1

2022-08-29 08:22:15

by Chancel Liu

[permalink] [raw]
Subject: [PATCH 4/5] ASoC: fsl_rpmsg: Register different CPU DAI drivers

This patch can register different ASoC CPU DAI drivers. So sound
cards based on different rpmsg channels can link to their respective
CPU DAI drivers.

Signed-off-by: Chancel Liu <[email protected]>
---
sound/soc/fsl/fsl_rpmsg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_rpmsg.c b/sound/soc/fsl/fsl_rpmsg.c
index bf94838bdbef..fde3d5006ce0 100644
--- a/sound/soc/fsl/fsl_rpmsg.c
+++ b/sound/soc/fsl/fsl_rpmsg.c
@@ -235,7 +235,7 @@ static int fsl_rpmsg_probe(struct platform_device *pdev)

rpmsg->card_pdev = platform_device_register_data(&pdev->dev,
"imx-audio-rpmsg",
- PLATFORM_DEVID_NONE,
+ PLATFORM_DEVID_AUTO,
NULL,
0);
if (IS_ERR(rpmsg->card_pdev)) {
--
2.25.1

2022-08-29 08:26:39

by Chancel Liu

[permalink] [raw]
Subject: [PATCH 2/5] ASoC: imx-audio-rpmsg: Create rpmsg channel for MICFIL

Rpmsg channel for MICFIL can also be created through rpmsg name
service announcement. If this driver is probed, Cortex-A can access
MICFIL which is actually controlled by Cortex-M through rpmsg channel
for MICFIL.

Signed-off-by: Chancel Liu <[email protected]>
---
sound/soc/fsl/imx-audio-rpmsg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/imx-audio-rpmsg.c b/sound/soc/fsl/imx-audio-rpmsg.c
index 905c3a071300..d5234ac4b09b 100644
--- a/sound/soc/fsl/imx-audio-rpmsg.c
+++ b/sound/soc/fsl/imx-audio-rpmsg.c
@@ -88,7 +88,7 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
/* Register platform driver for rpmsg routine */
data->rpmsg_pdev = platform_device_register_data(&rpdev->dev,
IMX_PCM_DRV_NAME,
- PLATFORM_DEVID_NONE,
+ PLATFORM_DEVID_AUTO,
NULL, 0);
if (IS_ERR(data->rpmsg_pdev)) {
dev_err(&rpdev->dev, "failed to register rpmsg platform.\n");
@@ -110,6 +110,7 @@ static void imx_audio_rpmsg_remove(struct rpmsg_device *rpdev)

static struct rpmsg_device_id imx_audio_rpmsg_id_table[] = {
{ .name = "rpmsg-audio-channel" },
+ { .name = "rpmsg-micfil-channel" },
{ },
};

--
2.25.1

2022-08-30 06:59:27

by Shengjiu Wang

[permalink] [raw]
Subject: RE: [PATCH 3/5] ASoC: imx-pcm-rpmsg: Register different platform drivers

>
> This patch can register different ASoC platform drivers in reference to
> "fsl,platform" property of the corresponding node in dts. So sound cards
> based on different rpmsg channels can link to their respective platform
> drivers.
>
> Signed-off-by: Chancel Liu <[email protected]>
> ---
> sound/soc/fsl/imx-pcm-rpmsg.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-
> rpmsg.c index 35049043e532..2f310994f7ee 100644
> --- a/sound/soc/fsl/imx-pcm-rpmsg.c
> +++ b/sound/soc/fsl/imx-pcm-rpmsg.c
> @@ -178,7 +178,7 @@ static int imx_rpmsg_pcm_hw_params(struct
> snd_soc_component *component,
> msg->s_msg.param.channels = RPMSG_CH_STEREO;
> break;
> default:
> - ret = -EINVAL;
> + msg->s_msg.param.channels = params_channels(params);

Please use separate commit for this change, I think the fsl_rpmsg_dai. channels_max
Should be updated also?

Best regards
Wang shengjiug

> break;
> }
>
> @@ -684,7 +684,7 @@ static int imx_rpmsg_pcm_probe(struct
> platform_device *pdev)
> info->rpdev = container_of(pdev->dev.parent, struct rpmsg_device,
> dev);
> info->dev = &pdev->dev;
> /* Setup work queue */
> - info->rpmsg_wq = alloc_ordered_workqueue("rpmsg_audio",
> + info->rpmsg_wq = alloc_ordered_workqueue(info->rpdev->id.name,
> WQ_HIGHPRI |
> WQ_UNBOUND |
> WQ_FREEZABLE);
> @@ -723,11 +723,15 @@ static int imx_rpmsg_pcm_probe(struct
> platform_device *pdev)
> if (ret)
> goto fail;
>
> - component = snd_soc_lookup_component(&pdev->dev,
> IMX_PCM_DRV_NAME);
> + component = snd_soc_lookup_component(&pdev->dev, NULL);
> if (!component) {
> ret = -EINVAL;
> goto fail;
> }
> +
> + /* platform component name is used by machine driver to link with
> */
> + component->name = info->rpdev->id.name;
> +
> #ifdef CONFIG_DEBUG_FS
> component->debugfs_prefix = "rpmsg";
> #endif
> --
> 2.25.1