alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Introduce sof_of_machine_select
@ 2022-08-05  7:04 Chunxu Li
  2022-08-05  7:04 ` [PATCH v2 1/2] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chunxu Li @ 2022-08-05  7:04 UTC (permalink / raw)
  To: pierre-louis.bossart, peter.ujfalusi, lgirdwood, broonie,
	angelogioacchino.delregno, daniel.baluta
  Cc: alsa-devel, chunxu.li, tinghan.shen, linux-kernel,
	project_global_chrome_upstream_group, linux-mediatek, yc.hung,
	matthias.bgg, linux-arm-kernel, sound-open-firmware

From: "chunxu.li" <chunxu.li@mediatek.com>

Change since v1:
  - remove the callback of_machine_select defined in sof-priv.h
  - move sof_of_machine_select to common code, and called in
    sof_machine_check
  - rename .board field to .compatible in structure snd_sof_of_mach

In these patches, we introduce function sof_of_machine_select for SOF

Chunxu Li (2):
  ASoC: SOF: Introduce function sof_of_machine_select
  ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186

 include/sound/sof.h                    |  2 ++
 sound/soc/sof/mediatek/mt8186/mt8186.c |  9 ++++++++
 sound/soc/sof/pcm.c                    |  8 ++++++-
 sound/soc/sof/sof-audio.c              | 30 ++++++++++++++++++++++++++
 sound/soc/sof/sof-of-dev.h             |  7 ++++++
 5 files changed, 55 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] ASoC: SOF: Introduce function sof_of_machine_select
  2022-08-05  7:04 [PATCH v2 0/2] Introduce sof_of_machine_select Chunxu Li
@ 2022-08-05  7:04 ` Chunxu Li
  2022-08-05  7:04 ` [PATCH v2 2/2] ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186 Chunxu Li
  2022-08-23 18:50 ` [PATCH v2 0/2] Introduce sof_of_machine_select Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Chunxu Li @ 2022-08-05  7:04 UTC (permalink / raw)
  To: pierre-louis.bossart, peter.ujfalusi, lgirdwood, broonie,
	angelogioacchino.delregno, daniel.baluta
  Cc: alsa-devel, Chunxu Li, tinghan.shen, linux-kernel,
	project_global_chrome_upstream_group, linux-mediatek, yc.hung,
	matthias.bgg, linux-arm-kernel, sound-open-firmware

From current design in sof_machine_check and snd_sof_new_platform_drv,
the SOF can only support ACPI type machine.

1. In sof_machine_check if there is no ACPI machine exist, the function
will return -ENODEV directly, that's we don't expected if we do not
base on ACPI machine.

2. In snd_sof_new_platform_drv the component driver need a driver name
to do ignore_machine, currently the driver name is obtained from
machine->drv_name, and the type of machine is snd_soc_acpi_mach.

So we add a new function named sof_of_machine_select that we can pass
sof_machine_check and obtain info required by snd_sof_new_platform_drv.

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
---
 include/sound/sof.h        |  2 ++
 sound/soc/sof/pcm.c        |  8 +++++++-
 sound/soc/sof/sof-audio.c  | 30 ++++++++++++++++++++++++++++++
 sound/soc/sof/sof-of-dev.h |  7 +++++++
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/include/sound/sof.h b/include/sound/sof.h
index 367dccfea7ad..341fef19e612 100644
--- a/include/sound/sof.h
+++ b/include/sound/sof.h
@@ -89,6 +89,7 @@ struct snd_sof_pdata {
 	/* machine */
 	struct platform_device *pdev_mach;
 	const struct snd_soc_acpi_mach *machine;
+	const struct snd_sof_of_mach *of_machine;
 
 	void *hw_pdata;
 
@@ -102,6 +103,7 @@ struct snd_sof_pdata {
 struct sof_dev_desc {
 	/* list of machines using this configuration */
 	struct snd_soc_acpi_mach *machines;
+	struct snd_sof_of_mach *of_machines;
 
 	/* alternate list of machines using this configuration */
 	struct snd_soc_acpi_mach *alt_machines;
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 6cb6a432be5e..49f7cb049f62 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -13,6 +13,7 @@
 #include <linux/pm_runtime.h>
 #include <sound/pcm_params.h>
 #include <sound/sof.h>
+#include "sof-of-dev.h"
 #include "sof-priv.h"
 #include "sof-audio.h"
 #include "sof-utils.h"
@@ -655,7 +656,12 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
 	struct snd_sof_pdata *plat_data = sdev->pdata;
 	const char *drv_name;
 
-	drv_name = plat_data->machine->drv_name;
+	if (plat_data->machine)
+		drv_name = plat_data->machine->drv_name;
+	else if (plat_data->of_machine)
+		drv_name = plat_data->of_machine->drv_name;
+	else
+		drv_name = NULL;
 
 	pd->name = "sof-audio-component";
 	pd->probe = sof_pcm_probe;
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index 28976098a89e..ea9663d448eb 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -10,6 +10,7 @@
 
 #include <linux/bitfield.h>
 #include "sof-audio.h"
+#include "sof-of-dev.h"
 #include "ops.h"
 
 static void sof_reset_route_setup_status(struct snd_sof_dev *sdev, struct
 snd_sof_widget *widget)
@@ -784,6 +785,28 @@ int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd)
 }
 EXPORT_SYMBOL(sof_dai_get_bclk);
 
+static struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev
 *sdev)
+{
+	struct snd_sof_pdata *sof_pdata = sdev->pdata;
+	const struct sof_dev_desc *desc = sof_pdata->desc;
+	struct snd_sof_of_mach *mach = desc->of_machines;
+
+	if (!mach)
+		return NULL;
+
+	for (; mach->compatible; mach++) {
+		if (of_machine_is_compatible(mach->compatible)) {
+			sof_pdata->tplg_filename = mach->sof_tplg_filename;
+			if (mach->fw_filename)
+				sof_pdata->fw_filename = mach->fw_filename;
+
+			return mach;
+		}
+	}
+
+	return NULL;
+}
+
 /*
  * SOF Driver enumeration.
  */
@@ -794,6 +817,7 @@ int sof_machine_check(struct snd_sof_dev *sdev)
 	struct snd_soc_acpi_mach *mach;
 
 	if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
+		const struct snd_sof_of_mach *of_mach;
 
 		/* find machine */
 		mach = snd_sof_machine_select(sdev);
@@ -803,6 +827,12 @@ int sof_machine_check(struct snd_sof_dev *sdev)
 			return 0;
 		}
 
+		of_mach = sof_of_machine_select(sdev);
+		if (of_mach) {
+			sof_pdata->of_machine = of_mach;
+			return 0;
+		}
+
 		if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
 			dev_err(sdev->dev, "error: no matching ASoC machine driver found -
 aborting probe\n");
 			return -ENODEV;
diff --git a/sound/soc/sof/sof-of-dev.h b/sound/soc/sof/sof-of-dev.h
index fd950a222ba4..2948b3a0d9fe 100644
--- a/sound/soc/sof/sof-of-dev.h
+++ b/sound/soc/sof/sof-of-dev.h
@@ -9,6 +9,13 @@
 #ifndef __SOUND_SOC_SOF_OF_H
 #define __SOUND_SOC_SOF_OF_H
 
+struct snd_sof_of_mach {
+	const char *compatible;
+	const char *drv_name;
+	const char *fw_filename;
+	const char *sof_tplg_filename;
+};
+
 extern const struct dev_pm_ops sof_of_pm;
 
 int sof_of_probe(struct platform_device *pdev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186
  2022-08-05  7:04 [PATCH v2 0/2] Introduce sof_of_machine_select Chunxu Li
  2022-08-05  7:04 ` [PATCH v2 1/2] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
@ 2022-08-05  7:04 ` Chunxu Li
  2022-08-23 18:50 ` [PATCH v2 0/2] Introduce sof_of_machine_select Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Chunxu Li @ 2022-08-05  7:04 UTC (permalink / raw)
  To: pierre-louis.bossart, peter.ujfalusi, lgirdwood, broonie,
	angelogioacchino.delregno, daniel.baluta
  Cc: alsa-devel, Chunxu Li, tinghan.shen, linux-kernel,
	project_global_chrome_upstream_group, linux-mediatek, yc.hung,
	matthias.bgg, linux-arm-kernel, sound-open-firmware

Add .of_machines field sof_mt8186_machs for mt8186

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
---
 sound/soc/sof/mediatek/mt8186/mt8186.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c
 b/sound/soc/sof/mediatek/mt8186/mt8186.c
index e006532caf2f..014afe33b3d9 100644
--- a/sound/soc/sof/mediatek/mt8186/mt8186.c
+++ b/sound/soc/sof/mediatek/mt8186/mt8186.c
@@ -515,7 +515,16 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = {
 			SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
 };
 
+static struct snd_sof_of_mach sof_mt8186_machs[] = {
+	{
+		.compatible = "mediatek,mt8186",
+		.sof_tplg_filename = "sof-mt8186.tplg",
+	},
+	{}
+};
+
 static const struct sof_dev_desc sof_of_mt8186_desc = {
+	.of_machines = sof_mt8186_machs,
 	.ipc_supported_mask	= BIT(SOF_IPC),
 	.ipc_default		= SOF_IPC,
 	.default_fw_path = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Introduce sof_of_machine_select
  2022-08-05  7:04 [PATCH v2 0/2] Introduce sof_of_machine_select Chunxu Li
  2022-08-05  7:04 ` [PATCH v2 1/2] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
  2022-08-05  7:04 ` [PATCH v2 2/2] ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186 Chunxu Li
@ 2022-08-23 18:50 ` Mark Brown
  2022-09-02  3:57   ` chunxu.li
  2 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2022-08-23 18:50 UTC (permalink / raw)
  To: pierre-louis.bossart, peter.ujfalusi, daniel.baluta,
	angelogioacchino.delregno, lgirdwood, Chunxu Li
  Cc: alsa-devel, tinghan.shen, linux-kernel,
	project_global_chrome_upstream_group, linux-mediatek, yc.hung,
	matthias.bgg, linux-arm-kernel, sound-open-firmware

On Fri, 5 Aug 2022 15:04:47 +0800, Chunxu Li wrote:
> From: "chunxu.li" <chunxu.li@mediatek.com>
> 
> Change since v1:
>   - remove the callback of_machine_select defined in sof-priv.h
>   - move sof_of_machine_select to common code, and called in
>     sof_machine_check
>   - rename .board field to .compatible in structure snd_sof_of_mach
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: SOF: Introduce function sof_of_machine_select
      commit: 6ace85b9838dc0162b474dbbbb6b388e7561f6a7
[2/2] ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186
      commit: 2dec9e09e955dfc4b7843fa4f9c09e7ee8931b1d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Introduce sof_of_machine_select
  2022-08-23 18:50 ` [PATCH v2 0/2] Introduce sof_of_machine_select Mark Brown
@ 2022-09-02  3:57   ` chunxu.li
  2022-09-02 10:19     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: chunxu.li @ 2022-09-02  3:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, lgirdwood, daniel.baluta, tinghan.shen, linux-kernel,
	pierre-louis.bossart, project_global_chrome_upstream_group,
	linux-mediatek, yc.hung, matthias.bgg, angelogioacchino.delregno,
	peter.ujfalusi, linux-arm-kernel, sound-open-firmware

On Tue, 2022-08-23 at 19:50 +0100, Mark Brown wrote:
> On Fri, 5 Aug 2022 15:04:47 +0800, Chunxu Li wrote:
> > From: "chunxu.li" <chunxu.li@mediatek.com>
> > 
> > Change since v1:
> >   - remove the callback of_machine_select defined in sof-priv.h
> >   - move sof_of_machine_select to common code, and called in
> >     sof_machine_check
> >   - rename .board field to .compatible in structure snd_sof_of_mach
> > 
> > [...]
> 
> Applied to
> 
>    
> https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git__;!!CTRNKA9wMg0ARbw!wdXixJVRiZEF4J6bn68hzN7GZ5gAa67otOgycstenmVEsECqFl08ZMVP2aJBGVuvQg$
>   for-next
> 
> Thanks!
> 
> [1/2] ASoC: SOF: Introduce function sof_of_machine_select
>       commit: 6ace85b9838dc0162b474dbbbb6b388e7561f6a7
> [2/2] ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186
>       commit: 2dec9e09e955dfc4b7843fa4f9c09e7ee8931b1d
> 
> All being well this means that it will be integrated into the linux-
> next
> tree (usually sometime in the next 24 hours) and sent to Linus during
> the next merge window (or sooner if it is a bug fix), however if
> problems are discovered then the patch may be dropped or reverted.
> 
> You may get further e-mails resulting from automated or manual
> testing
> and review of the tree, please engage with people reporting problems
> and
> send followup patches addressing any issues that are reported if
> needed.
> 
> If any updates are required or you are submitting further changes
> they
> should be sent as incremental updates against current git, existing
> patches will not be replaced.
> 
> Please add any relevant lists and maintainers to the CCs when
> replying
> to this mail.
> 
> Thanks,
> Mark

Hi Mark,

It looks like the patch didn't applied success.

The patch link is 
https://patchwork.kernel.org/project/alsa-devel/patch/20220805070449.6611-2-chunxu.li@mediatek.com/

the merged link is 
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/?id=6ace85b9838dc0162b474dbbbb6b388e7561f6a7

In sound/soc/sof/sof-audio.c the changes are:

 #include <linux/bitfield.h>
 #include "sof-audio.h"
+#include "sof-of-dev.h"
 #include "ops.h"
 
 static void sof_reset_route_setup_status(struct snd_sof_dev *sdev,
struct
 snd_sof_widget *widget)
@@ -784,6 +785,28 @@  int sof_dai_get_bclk(struct snd_soc_pcm_runtime
*rtd)
 }
 EXPORT_SYMBOL(sof_dai_get_bclk);
 
+static struct snd_sof_of_mach *sof_of_machine_select(struct
snd_sof_dev
 *sdev)
+{
+	struct snd_sof_pdata *sof_pdata = sdev->pdata;
+	const struct sof_dev_desc *desc = sof_pdata->desc;
+	struct snd_sof_of_mach *mach = desc->of_machines;
+
+	if (!mach)
+		return NULL;
+
+	for (; mach->compatible; mach++) {
+		if (of_machine_is_compatible(mach->compatible)) {
+			sof_pdata->tplg_filename = mach-
>sof_tplg_filename;
+			if (mach->fw_filename)
+				sof_pdata->fw_filename = mach-
>fw_filename;
+
+			return mach;
+		}
+	}
+
+	return NULL;
+}
+
 /*
  * SOF Driver enumeration.
  */
@@ -794,6 +817,7 @@  int sof_machine_check(struct snd_sof_dev *sdev)
 	struct snd_soc_acpi_mach *mach;
 
 	if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
+		const struct snd_sof_of_mach *of_mach;
 
 		/* find machine */
 		mach = snd_sof_machine_select(sdev);
@@ -803,6 +827,12 @@  int sof_machine_check(struct snd_sof_dev *sdev)
 			return 0;
 		}
 
+		of_mach = sof_of_machine_select(sdev);
+		if (of_mach) {
+			sof_pdata->of_machine = of_mach;
+			return 0;
+		}
+


But the real applied is only one line as below.

 #include <linux/bitfield.h>
 #include "sof-audio.h"
+#include "sof-of-dev.h"
 #include "ops.h"



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Introduce sof_of_machine_select
  2022-09-02  3:57   ` chunxu.li
@ 2022-09-02 10:19     ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-09-02 10:19 UTC (permalink / raw)
  To: chunxu.li
  Cc: alsa-devel, lgirdwood, daniel.baluta, tinghan.shen, linux-kernel,
	pierre-louis.bossart, project_global_chrome_upstream_group,
	linux-mediatek, yc.hung, matthias.bgg, angelogioacchino.delregno,
	peter.ujfalusi, linux-arm-kernel, sound-open-firmware

[-- Attachment #1: Type: text/plain, Size: 704 bytes --]

On Fri, Sep 02, 2022 at 11:57:51AM +0800, chunxu.li wrote:
> On Tue, 2022-08-23 at 19:50 +0100, Mark Brown wrote:

> > If any updates are required or you are submitting further changes
> > they
> > should be sent as incremental updates against current git, existing
> > patches will not be replaced.

> It looks like the patch didn't applied success.

> The patch link is 
> https://patchwork.kernel.org/project/alsa-devel/patch/20220805070449.6611-2-chunxu.li@mediatek.com/

> the merged link is 
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/?id=6ace85b9838dc0162b474dbbbb6b388e7561f6a7

As covered above please send incremental patches fixing any issues.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-02 10:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05  7:04 [PATCH v2 0/2] Introduce sof_of_machine_select Chunxu Li
2022-08-05  7:04 ` [PATCH v2 1/2] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
2022-08-05  7:04 ` [PATCH v2 2/2] ASoC: SOF: mediatek: Add sof_mt8186_machs for mt8186 Chunxu Li
2022-08-23 18:50 ` [PATCH v2 0/2] Introduce sof_of_machine_select Mark Brown
2022-09-02  3:57   ` chunxu.li
2022-09-02 10:19     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).