linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: Introduce function sof_of_machine_select
@ 2022-09-03  3:21 Chunxu Li
  2022-09-05  7:48 ` AngeloGioacchino Del Regno
  2022-09-05 15:38 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Chunxu Li @ 2022-09-03  3:21 UTC (permalink / raw)
  To: broonie, pierre-louis.bossart, peter.ujfalusi, lgirdwood,
	angelogioacchino.delregno, daniel.baluta
  Cc: matthias.bgg, yc.hung, linux-kernel, alsa-devel,
	sound-open-firmware, linux-arm-kernel, linux-mediatek,
	project_global_chrome_upstream_group, Chunxu Li

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

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.

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>
---
 sound/soc/sof/sof-audio.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index c18e723435bd..ea9663d448eb 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -785,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.
  */
@@ -795,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);
@@ -804,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;
-- 
2.25.1


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

* Re: [PATCH] ASoC: SOF: Introduce function sof_of_machine_select
  2022-09-03  3:21 [PATCH] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
@ 2022-09-05  7:48 ` AngeloGioacchino Del Regno
  2022-09-05 15:38 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-05  7:48 UTC (permalink / raw)
  To: Chunxu Li, broonie, pierre-louis.bossart, peter.ujfalusi,
	lgirdwood, daniel.baluta
  Cc: matthias.bgg, yc.hung, linux-kernel, alsa-devel,
	sound-open-firmware, linux-arm-kernel, linux-mediatek,
	project_global_chrome_upstream_group

Il 03/09/22 05:21, Chunxu Li ha scritto:
>  From current design in sof_machine_check the SOF can only support
> ACPI type machine.
> 
> 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.
> 
> 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>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



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

* Re: [PATCH] ASoC: SOF: Introduce function sof_of_machine_select
  2022-09-03  3:21 [PATCH] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
  2022-09-05  7:48 ` AngeloGioacchino Del Regno
@ 2022-09-05 15:38 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-09-05 15:38 UTC (permalink / raw)
  To: lgirdwood, angelogioacchino.delregno, daniel.baluta,
	pierre-louis.bossart, Chunxu Li, peter.ujfalusi
  Cc: sound-open-firmware, linux-arm-kernel, yc.hung,
	project_global_chrome_upstream_group, linux-mediatek, alsa-devel,
	matthias.bgg, linux-kernel

On Sat, 3 Sep 2022 11:21:51 +0800, Chunxu Li wrote:
> From current design in sof_machine_check the SOF can only support
> ACPI type machine.
> 
> 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.
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: SOF: Introduce function sof_of_machine_select
      commit: 354f6008b730a217a3e6ad982eda42e90e6f7473

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] 3+ messages in thread

end of thread, other threads:[~2022-09-05 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-03  3:21 [PATCH] ASoC: SOF: Introduce function sof_of_machine_select Chunxu Li
2022-09-05  7:48 ` AngeloGioacchino Del Regno
2022-09-05 15:38 ` 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).