diff mbox series

[2/2] ASoC: SOF: mediatek: Add .of_machine_select field for mt8186

Message ID 20220804091359.31449-3-chunxu.li@mediatek.com (mailing list archive)
State New, archived
Headers show
Series ASoC: SOF: Introduce of_machine_select | expand

Commit Message

Chunxu Li Aug. 4, 2022, 9:13 a.m. UTC
As the mt8186 do not use ACPI type machine, the of_machine_select
is used to distinguish different machines in sof_machine_check.

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

Comments

Mark Brown Aug. 4, 2022, 12:41 p.m. UTC | #1
On Thu, Aug 04, 2022 at 05:13:59PM +0800, Chunxu Li wrote:

> +static struct snd_sof_of_mach sof_mt8186_machs[] = {
> +	{
> +		.board = "mediatek,mt8186",
> +		.sof_tplg_filename = "sof-mt8186.tplg",

The mediatek,mt8186 compatible looks like a SoC compatible not a board
compatible...
Chunxu Li Aug. 4, 2022, 1:21 p.m. UTC | #2
On Thu, 2022-08-04 at 13:41 +0100, Mark Brown wrote:
> On Thu, Aug 04, 2022 at 05:13:59PM +0800, Chunxu Li wrote:
> 
> > +static struct snd_sof_of_mach sof_mt8186_machs[] = {
> > +	{
> > +		.board = "mediatek,mt8186",
> > +		.sof_tplg_filename = "sof-mt8186.tplg",
> 
> The mediatek,mt8186 compatible looks like a SoC compatible not a
> board
> compatible...

Our dts config as below:
kingler board:
compatible = "google,corsola", "google,kingler", "mediatek,mt8186";
krabby board:
compatible = "google,corsola", "google,krabby", "mediatek,mt8186";
they all use the same sof_tplg_filename, so i use "mediatek,mt8186" to
match these.

The original code looks like the following:
static struct snd_soc_acpi_mach sof_mt8186_machs[] = {
	{
		.board = "google,kingler",
		.sof_tplg_filename = "sof-mt8186.tplg",
	},
	{
		.board = "google,krabby",
		.sof_tplg_filename = "sof-mt8186.tplg",
	},
	{}
};

Which of the two approaches do you prefer?
Mark Brown Aug. 4, 2022, 1:33 p.m. UTC | #3
On Thu, Aug 04, 2022 at 09:21:37PM +0800, chunxu.li wrote:
> On Thu, 2022-08-04 at 13:41 +0100, Mark Brown wrote:
> > On Thu, Aug 04, 2022 at 05:13:59PM +0800, Chunxu Li wrote:

> > > +		.board = "mediatek,mt8186",
> > > +		.sof_tplg_filename = "sof-mt8186.tplg",

> > The mediatek,mt8186 compatible looks like a SoC compatible not a
> > board
> > compatible...

> Our dts config as below:
> kingler board:
> compatible = "google,corsola", "google,kingler", "mediatek,mt8186";
> krabby board:
> compatible = "google,corsola", "google,krabby", "mediatek,mt8186";

So the SoC is listed as a fallback for the board and things work out
fine.

> Which of the two approaches do you prefer?

I think it would be clearer to keep what's being matched the same but
rename the .board field to be .compatible, or possibly .system_compatible
or something if it's unclear what's being matched.  That'd be more
normal for specifying a compatible string anyway.
Chunxu Li Aug. 4, 2022, 2:47 p.m. UTC | #4
On Thu, 2022-08-04 at 14:33 +0100, Mark Brown wrote:
> On Thu, Aug 04, 2022 at 09:21:37PM +0800, chunxu.li wrote:
> > On Thu, 2022-08-04 at 13:41 +0100, Mark Brown wrote:
> > > On Thu, Aug 04, 2022 at 05:13:59PM +0800, Chunxu Li wrote:
> > > > +		.board = "mediatek,mt8186",
> > > > +		.sof_tplg_filename = "sof-mt8186.tplg",
> > > The mediatek,mt8186 compatible looks like a SoC compatible not a
> > > board
> > > compatible...
> > Our dts config as below:
> > kingler board:
> > compatible = "google,corsola", "google,kingler", "mediatek,mt8186";
> > krabby board:
> > compatible = "google,corsola", "google,krabby", "mediatek,mt8186";
> 
> So the SoC is listed as a fallback for the board and things work out
> fine.
> 
> > Which of the two approaches do you prefer?
> 
> I think it would be clearer to keep what's being matched the same but
> rename the .board field to be .compatible, or possibly
> .system_compatible
> or something if it's unclear what's being matched.  That'd be more
> normal for specifying a compatible string anyway.

Appreciated for you advice, I'll rename the .board to .compatible as
following:

+	.compatible = "mediatek,mt8186",
+	.sof_tplg_filename = "sof-mt8186.tplg",
diff mbox series

Patch

diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c
index e006532caf2f..cb8bed383064 100644
--- a/sound/soc/sof/mediatek/mt8186/mt8186.c
+++ b/sound/soc/sof/mediatek/mt8186/mt8186.c
@@ -497,6 +497,8 @@  static struct snd_sof_dsp_ops sof_mt8186_ops = {
 	/* misc */
 	.get_bar_index	= mt8186_get_bar_index,
 
+	.of_machine_select = sof_of_machine_select,
+
 	/* firmware loading */
 	.load_firmware	= snd_sof_load_firmware_memcpy,
 
@@ -515,7 +517,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[] = {
+	{
+		.board = "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 = {