diff mbox series

[7/7] ASoC: Intel: common: add quirk for APL RVP boards

Message ID 20181101010718.2878-8-pierre-louis.bossart@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series ASoC: Intel: cleanups | expand

Commit Message

Pierre-Louis Bossart Nov. 1, 2018, 1:07 a.m. UTC
For some reason the RVP/LeafHill SSDT exposes an INT34C3 ID which is
used on other boards to point to the TDF8532 amplifier. Yay BIOS.

Add a DMI-quirk to ignore this ID and check for other valid machine
driver descriptors.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 .../intel/common/soc-acpi-intel-bxt-match.c   | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

Keyon Jie Nov. 1, 2018, 2:35 a.m. UTC | #1
On 2018年11月01日 09:07, Pierre-Louis Bossart wrote:
> For some reason the RVP/LeafHill SSDT exposes an INT34C3 ID which is
> used on other boards to point to the TDF8532 amplifier. Yay BIOS.
> 
> Add a DMI-quirk to ignore this ID and check for other valid machine
> driver descriptors.
> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>   .../intel/common/soc-acpi-intel-bxt-match.c   | 35 +++++++++++++++++++
>   1 file changed, 35 insertions(+)
> 
> diff --git a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
> index 2756fa4ab552..752a1bbff7f7 100644
> --- a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
> +++ b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
> @@ -6,9 +6,43 @@
>    *
>    */
>   
> +#include <linux/dmi.h>
>   #include <sound/soc-acpi.h>
>   #include <sound/soc-acpi-intel-match.h>
>   
> +static unsigned long apl_machine_id;
> +
> +#define APL_RVP  1
> +
> +static int apl_rvp_quirk_cb(const struct dmi_system_id *id)
> +{
> +	apl_machine_id = APL_RVP;
> +	return 1;
> +}
> +
> +static const struct dmi_system_id apl_table[] = {
> +	{
> +		.callback = apl_rvp_quirk_cb,
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
> +			DMI_MATCH(DMI_BOARD_NAME, "Apollolake RVP1A"),
> +		},
> +	},
> +	{},
> +};
> +
> +static struct snd_soc_acpi_mach *apl_quirk(void *arg)
> +{
> +	struct snd_soc_acpi_mach *mach = arg;
> +
> +	dmi_check_system(apl_table);
> +
> +	if (apl_machine_id == APL_RVP)
> +		return NULL;
> +	else
> +		return mach;
> +}
> +
>   static struct snd_soc_acpi_codecs bxt_codecs = {
>   	.num_codecs = 1,
>   	.codecs = {"MX98357A"}
> @@ -50,6 +84,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_bxt_machines[] = {
>   	{
>   		.id = "INT34C3",
>   		.drv_name = "bxt_tdf8532",
> +		.machine_quirk = apl_quirk,
>   		.sof_fw_filename = "intel/sof-apl.ri",
>   		.sof_tplg_filename = "intel/sof-apl-tdf8532.tplg",
>   		.asoc_plat_name = "0000:00:0e.0",
> 

I believe this can work, but when I went through 
snd_soc_acpi_find_machine(), I find a possible bug there, it won't 
continue matching search when the machine_quirk() return NULL.

Let me send a fix for that.

Thanks,
~Keyon
Andy Shevchenko Nov. 1, 2018, 2:11 p.m. UTC | #2
On Wed, Oct 31, 2018 at 08:07:18PM -0500, Pierre-Louis Bossart wrote:
> For some reason the RVP/LeafHill SSDT exposes an INT34C3 ID which is
> used on other boards to point to the TDF8532 amplifier. Yay BIOS.
> 
> Add a DMI-quirk to ignore this ID and check for other valid machine
> driver descriptors.

> +static unsigned long apl_machine_id;
> +
> +#define APL_RVP  1
> +
> +static int apl_rvp_quirk_cb(const struct dmi_system_id *id)
> +{
> +	apl_machine_id = APL_RVP;
> +	return 1;
> +}
> +
> +static const struct dmi_system_id apl_table[] = {
> +	{
> +		.callback = apl_rvp_quirk_cb,
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
> +			DMI_MATCH(DMI_BOARD_NAME, "Apollolake RVP1A"),
> +		},
> +	},

> +	{},

Terminator entry doesn't need a comma. It would prevent from (unlikely)
mistakes when extending the list.

> +};
> +
> +static struct snd_soc_acpi_mach *apl_quirk(void *arg)
> +{
> +	struct snd_soc_acpi_mach *mach = arg;
> +

> +	dmi_check_system(apl_table);

Can't we just use driver_data of the table above and get rid of at least global variable?

> +
> +	if (apl_machine_id == APL_RVP)
> +		return NULL;
> +	else
> +		return mach;
> +}
Pierre-Louis Bossart Nov. 1, 2018, 3:08 p.m. UTC | #3
On 11/1/18 9:11 AM, Andy Shevchenko wrote:
> On Wed, Oct 31, 2018 at 08:07:18PM -0500, Pierre-Louis Bossart wrote:
>> For some reason the RVP/LeafHill SSDT exposes an INT34C3 ID which is
>> used on other boards to point to the TDF8532 amplifier. Yay BIOS.
>>
>> Add a DMI-quirk to ignore this ID and check for other valid machine
>> driver descriptors.
>> +static unsigned long apl_machine_id;
>> +
>> +#define APL_RVP  1
>> +
>> +static int apl_rvp_quirk_cb(const struct dmi_system_id *id)
>> +{
>> +	apl_machine_id = APL_RVP;
>> +	return 1;
>> +}
>> +
>> +static const struct dmi_system_id apl_table[] = {
>> +	{
>> +		.callback = apl_rvp_quirk_cb,
>> +		.matches = {
>> +			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
>> +			DMI_MATCH(DMI_BOARD_NAME, "Apollolake RVP1A"),
>> +		},
>> +	},
>> +	{},
> Terminator entry doesn't need a comma. It would prevent from (unlikely)
> mistakes when extending the list.
Indeed. I don't know how many tables use this though... will update.
>
>> +};
>> +
>> +static struct snd_soc_acpi_mach *apl_quirk(void *arg)
>> +{
>> +	struct snd_soc_acpi_mach *mach = arg;
>> +
>> +	dmi_check_system(apl_table);
> Can't we just use driver_data of the table above and get rid of at least global variable?

Yes. The code is pretty much copy-pasted from other BYT quirks but can 
be written in a better way

Will send a v2 later today, thanks Andy for the suggestion.


>
>> +
>> +	if (apl_machine_id == APL_RVP)
>> +		return NULL;
>> +	else
>> +		return mach;
>> +}
diff mbox series

Patch

diff --git a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
index 2756fa4ab552..752a1bbff7f7 100644
--- a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
@@ -6,9 +6,43 @@ 
  *
  */
 
+#include <linux/dmi.h>
 #include <sound/soc-acpi.h>
 #include <sound/soc-acpi-intel-match.h>
 
+static unsigned long apl_machine_id;
+
+#define APL_RVP  1
+
+static int apl_rvp_quirk_cb(const struct dmi_system_id *id)
+{
+	apl_machine_id = APL_RVP;
+	return 1;
+}
+
+static const struct dmi_system_id apl_table[] = {
+	{
+		.callback = apl_rvp_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
+			DMI_MATCH(DMI_BOARD_NAME, "Apollolake RVP1A"),
+		},
+	},
+	{},
+};
+
+static struct snd_soc_acpi_mach *apl_quirk(void *arg)
+{
+	struct snd_soc_acpi_mach *mach = arg;
+
+	dmi_check_system(apl_table);
+
+	if (apl_machine_id == APL_RVP)
+		return NULL;
+	else
+		return mach;
+}
+
 static struct snd_soc_acpi_codecs bxt_codecs = {
 	.num_codecs = 1,
 	.codecs = {"MX98357A"}
@@ -50,6 +84,7 @@  struct snd_soc_acpi_mach snd_soc_acpi_intel_bxt_machines[] = {
 	{
 		.id = "INT34C3",
 		.drv_name = "bxt_tdf8532",
+		.machine_quirk = apl_quirk,
 		.sof_fw_filename = "intel/sof-apl.ri",
 		.sof_tplg_filename = "intel/sof-apl-tdf8532.tplg",
 		.asoc_plat_name = "0000:00:0e.0",