All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naveen M <naveen.m@intel.com>
To: alsa-devel@alsa-project.org
Cc: vinod.koul@intel.com, liam.r.girdwood@linux.intel.com,
	tiwai@suse.de, broonie@kernel.org, naveen.m@intel.com,
	Harsha Priya <harshapriya.n@intel.com>,
	pierre-louis.bossart@intel.com
Subject: [PATCH v3 5/7] ASoC: Improve machine driver selection based on quirk data
Date: Mon, 15 May 2017 13:42:15 +0530	[thread overview]
Message-ID: <1494835937-22068-6-git-send-email-naveen.m@intel.com> (raw)
In-Reply-To: <1494835937-22068-1-git-send-email-naveen.m@intel.com>

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>
---
 sound/soc/intel/common/sst-acpi.h       | 20 ++++++++++++++++++++
 sound/soc/intel/common/sst-match-acpi.c | 18 ++++++++++++++++++
 sound/soc/intel/skylake/skl.c           | 14 ++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/sound/soc/intel/common/sst-acpi.h b/sound/soc/intel/common/sst-acpi.h
index 3649d3b..afe9b87 100644
--- a/sound/soc/intel/common/sst-acpi.h
+++ b/sound/soc/intel/common/sst-acpi.h
@@ -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);
diff --git a/sound/soc/intel/common/sst-match-acpi.c b/sound/soc/intel/common/sst-match-acpi.c
index 88e4977..56d26f3 100644
--- a/sound/soc/intel/common/sst-match-acpi.c
+++ b/sound/soc/intel/common/sst-match-acpi.c
@@ -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");
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 22a7e39..fd1dae1 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -862,6 +862,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",
@@ -872,12 +876,16 @@ static void skl_remove(struct pci_dev *pci)
 		.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
 	},
 	{}
@@ -893,6 +901,8 @@ static void skl_remove(struct pci_dev *pci)
 		.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,
 	},
 };
 
@@ -906,12 +916,16 @@ static void skl_remove(struct pci_dev *pci)
 		.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
 	},
 	{}
-- 
1.9.1

  parent reply	other threads:[~2017-05-15  8:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15  8:12 [PATCH v3 0/7] ASoC: Intel: kabylake: Adds rt5663+max98927 machine driver Naveen M
2017-05-15  8:12 ` [PATCH v3 1/7] ASoC: Intel: Convert atom machine data to C99 style Naveen M
2017-05-24 17:41   ` Applied "ASoC: Intel: Convert atom machine data to C99 style" to the asoc tree Mark Brown
2017-05-15  8:12 ` [PATCH v3 2/7] ASoC: Intel: Convert skl machine data to C99 style Naveen M
2017-05-24 17:41   ` Applied "ASoC: Intel: Convert skl machine data to C99 style" to the asoc tree Mark Brown
2017-05-15  8:12 ` [PATCH v3 3/7] ASoC: Intel: Create a helper to search for matching machine Naveen M
2017-05-15  8:12 ` [PATCH v3 4/7] ASoC: Move quirk to identify correct machine driver Naveen M
2017-05-15  8:12 ` Naveen M [this message]
2017-05-15  8:12 ` [PATCH v3 6/7] ASoC: Intel: Add Kabylake Realtek Maxim " Naveen M
2017-05-15  8:12 ` [PATCH v3 7/7] ASoC: Intel: Add Kabylake RT5663+MAX98927 machine driver entry Naveen M
2017-05-15 10:54 ` [PATCH v3 0/7] ASoC: Intel: kabylake: Adds rt5663+max98927 machine driver Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494835937-22068-6-git-send-email-naveen.m@intel.com \
    --to=naveen.m@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=harshapriya.n@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=pierre-louis.bossart@intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.