ASoC: Improve machine driver selection based on quirk data
authorNaveen M <naveen.m@intel.com>
Mon, 15 May 2017 08:12:15 +0000 (13:42 +0530)
committerMark Brown <broonie@kernel.org>
Wed, 24 May 2017 17:27:47 +0000 (18:27 +0100)
Use quirk function to select the correct machine driver
by checking all codecs instead of only one based on quirk data.

Signed-off-by: Naveen M <naveen.m@intel.com>
Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/common/sst-acpi.h
sound/soc/intel/common/sst-match-acpi.c
sound/soc/intel/skylake/skl.c

index 3649d3b08c9e27b1b78d8a35d60ea62a18d9f399..afe9b87b8bd558065153da3a5c7ac4e7a7b536e7 100644 (file)
@@ -58,5 +58,25 @@ struct sst_acpi_mach {
        /* board name */
        const char *board;
        struct sst_acpi_mach * (*machine_quirk)(void *arg);
+       const void *quirk_data;
        void *pdata;
 };
+
+#define SST_ACPI_MAX_CODECS 3
+
+/**
+ * struct sst_codecs: Structure to hold secondary codec information apart from
+ * the matched one, this data will be passed to the quirk function to match
+ * with the ACPI detected devices
+ *
+ * @num_codecs: number of secondary codecs used in the platform
+ * @codecs: holds the codec IDs
+ *
+ */
+struct sst_codecs {
+       int num_codecs;
+       u8 codecs[SST_ACPI_MAX_CODECS][ACPI_ID_LEN];
+};
+
+/* check all codecs */
+struct sst_acpi_mach *sst_acpi_codec_list(void *arg);
index 88e4977578b53a05dd62001c392c3aaae27a768a..56d26f36a3cba16f25217b465cfe4704c674e3c9 100644 (file)
@@ -151,5 +151,23 @@ bool sst_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 }
 EXPORT_SYMBOL_GPL(sst_acpi_find_package_from_hid);
 
+struct sst_acpi_mach *sst_acpi_codec_list(void *arg)
+{
+       struct sst_acpi_mach *mach = arg;
+       struct sst_codecs *codec_list = (struct sst_codecs *) mach->quirk_data;
+       int i;
+
+       if (mach->quirk_data == NULL)
+               return mach;
+
+       for (i = 0; i < codec_list->num_codecs; i++) {
+               if (sst_acpi_check_hid(codec_list->codecs[i]) != true)
+                       return NULL;
+       }
+
+       return mach;
+}
+EXPORT_SYMBOL_GPL(sst_acpi_codec_list);
+
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Intel Common ACPI Match module");
index a4d1121595b61161a22fb1f4d08afd653aa5cc3d..ceb7734d74ed7b9a04755cb2fce8a38ca5c3952e 100644 (file)
@@ -876,6 +876,10 @@ static void skl_remove(struct pci_dev *pci)
        dev_set_drvdata(&pci->dev, NULL);
 }
 
+static struct sst_codecs skl_codecs = { 1, {"NAU88L25"} };
+static struct sst_codecs kbl_codecs = { 1, {"NAU88L25"} };
+static struct sst_codecs bxt_codecs = { 1, {"MX98357A"} };
+
 static struct sst_acpi_mach sst_skl_devdata[] = {
        {
                .id = "INT343A",
@@ -886,12 +890,16 @@ static struct sst_acpi_mach sst_skl_devdata[] = {
                .id = "INT343B",
                .drv_name = "skl_n88l25_s4567",
                .fw_filename = "intel/dsp_fw_release.bin",
+               .machine_quirk = sst_acpi_codec_list,
+               .quirk_data = &skl_codecs,
                .pdata = &skl_dmic_data
        },
        {
                .id = "MX98357A",
                .drv_name = "skl_n88l25_m98357a",
                .fw_filename = "intel/dsp_fw_release.bin",
+               .machine_quirk = sst_acpi_codec_list,
+               .quirk_data = &skl_codecs,
                .pdata = &skl_dmic_data
        },
        {}
@@ -907,6 +915,8 @@ static struct sst_acpi_mach sst_bxtp_devdata[] = {
                .id = "DLGS7219",
                .drv_name = "bxt_da7219_max98357a_i2s",
                .fw_filename = "intel/dsp_fw_bxtn.bin",
+               .machine_quirk = sst_acpi_codec_list,
+               .quirk_data = &bxt_codecs,
        },
 };
 
@@ -920,12 +930,16 @@ static struct sst_acpi_mach sst_kbl_devdata[] = {
                .id = "INT343B",
                .drv_name = "kbl_n88l25_s4567",
                .fw_filename = "intel/dsp_fw_kbl.bin",
+               .machine_quirk = sst_acpi_codec_list,
+               .quirk_data = &kbl_codecs,
                .pdata = &skl_dmic_data
        },
        {
                .id = "MX98357A",
                .drv_name = "kbl_n88l25_m98357a",
                .fw_filename = "intel/dsp_fw_kbl.bin",
+               .machine_quirk = sst_acpi_codec_list,
+               .quirk_data = &kbl_codecs,
                .pdata = &skl_dmic_data
        },
        {}