All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>,
	tiwai@suse.de,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	broonie@kernel.org, Bard Liao <yung-chuan.liao@linux.intel.com>,
	Bard Liao <bard.liao@intel.com>
Subject: [PATCH v2 08/11] ASoC: SOF: Intel: SoundWire: refine ACPI match
Date: Mon,  8 Feb 2021 17:33:33 -0600	[thread overview]
Message-ID: <20210208233336.59449-9-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20210208233336.59449-1-pierre-louis.bossart@linux.intel.com>

We have existing platforms where the wrong machine is selected. We
need to make sure the number of devices reported on a link matches
what we expect for a link descriptor. This helps avoid using the
TGL-RVP configuration for an HP platform or vice-versa, depending on
the order in which they are inserted in the table.

Co-developed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
---
 sound/soc/sof/intel/hda.c | 59 +++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 57853ef89cd1..2279e30c9245 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -1021,32 +1021,63 @@ static bool link_slaves_found(struct snd_sof_dev *sdev,
 	struct sdw_intel_slave_id *ids = sdw->ids;
 	int num_slaves = sdw->num_slaves;
 	unsigned int part_id, link_id, unique_id, mfg_id;
-	int i, j;
+	int i, j, k;
 
 	for (i = 0; i < link->num_adr; i++) {
 		u64 adr = link->adr_d[i].adr;
+		int reported_part_count = 0;
 
 		mfg_id = SDW_MFG_ID(adr);
 		part_id = SDW_PART_ID(adr);
 		link_id = SDW_DISCO_LINK_ID(adr);
+
+		for (j = 0; j < num_slaves; j++) {
+			/* find out how many identical parts were reported on that link */
+			if (ids[j].link_id == link_id &&
+			    ids[j].id.part_id == part_id &&
+			    ids[j].id.mfg_id == mfg_id)
+				reported_part_count++;
+		}
+
 		for (j = 0; j < num_slaves; j++) {
+			int expected_part_count = 0;
+
 			if (ids[j].link_id != link_id ||
 			    ids[j].id.part_id != part_id ||
 			    ids[j].id.mfg_id != mfg_id)
 				continue;
-			/*
-			 * we have to check unique id
-			 * if there is more than one
-			 * Slave on the link
-			 */
-			unique_id = SDW_UNIQUE_ID(adr);
-			if (link->num_adr == 1 ||
-			    ids[j].id.unique_id == SDW_IGNORED_UNIQUE_ID ||
-			    ids[j].id.unique_id == unique_id) {
-				dev_dbg(bus->dev,
-					"found %x at link %d\n",
-					part_id, link_id);
-				break;
+
+			/* find out how many identical parts are expected */
+			for (k = 0; k < link->num_adr; k++) {
+				u64 adr2 = link->adr_d[i].adr;
+				unsigned int part_id2, link_id2, mfg_id2;
+
+				mfg_id2 = SDW_MFG_ID(adr2);
+				part_id2 = SDW_PART_ID(adr2);
+				link_id2 = SDW_DISCO_LINK_ID(adr2);
+
+				if (link_id2 == link_id &&
+				    part_id2 == part_id &&
+				    mfg_id2 == mfg_id)
+					expected_part_count++;
+			}
+
+			if (reported_part_count == expected_part_count) {
+				/*
+				 * we have to check unique id
+				 * if there is more than one
+				 * Slave on the link
+				 */
+				unique_id = SDW_UNIQUE_ID(adr);
+				if (reported_part_count == 1 ||
+				    ids[j].id.unique_id == unique_id) {
+					dev_dbg(bus->dev, "found %x at link %d\n",
+						part_id, link_id);
+					break;
+				}
+			} else {
+				dev_dbg(bus->dev, "part %x reported %d expected %d on link %d, skipping\n",
+					part_id, reported_part_count, expected_part_count, link_id);
 			}
 		}
 		if (j == num_slaves) {
-- 
2.25.1


  parent reply	other threads:[~2021-02-08 23:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 23:33 [PATCH v2 00/11] ASoC: SOF/Intel/SoundWire: add missing quirks and DMIC support Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 01/11] ASoC: Intel: sof_sdw: reorganize quirks by generation Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 02/11] ASoC: Intel: sof-sdw: indent and add quirks consistently Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 03/11] ASoC: Intel: sof_sdw: add quirk for HP Spectre x360 convertible Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 04/11] ASoC: Intel: sof_sdw: add mic:dmic and cfg-mics component strings Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 05/11] ASoC: Intel: sof_sdw: detect DMIC number based on mach params Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 06/11] ASoC: intel: sof_sdw: add trace for dai links Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 07/11] ASoC: Intel: soc-acpi: add ACPI matching table for HP Spectre x360 Pierre-Louis Bossart
2021-02-08 23:33 ` Pierre-Louis Bossart [this message]
2021-02-08 23:33 ` [PATCH v2 09/11] ASoC: SOF: Intel: detect DMIC number in SoundWire mixed config Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 10/11] ASoC: SOF: Intel: HDA: don't keep a temporary variable Pierre-Louis Bossart
2021-02-08 23:33 ` [PATCH v2 11/11] ASoC: SOF: Intel: hda: add dev_dbg() when DMIC number is overridden Pierre-Louis Bossart
2021-02-10 20:11 ` [PATCH v2 00/11] ASoC: SOF/Intel/SoundWire: add missing quirks and DMIC support Mark Brown

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=20210208233336.59449-9-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=guennadi.liakhovetski@intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=yung-chuan.liao@linux.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.