All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: broonie@kernel.org, tiwai@suse.de
Cc: alsa-devel@alsa-project.org,
	pierre-louis.bossart@linux.intel.com, bard.liao@intel.com
Subject: [PATCH 10/10] ASoC: intel: sof_sdw: add link adr order check
Date: Wed, 27 Oct 2021 10:18:24 +0800	[thread overview]
Message-ID: <20211027021824.24776-11-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20211027021824.24776-1-yung-chuan.liao@linux.intel.com>

We assume the adr order described in a snd_soc_acpi_link_adr array is
jack -> amp -> mic. We follow the same order to implement the topology.
We will need a special topology if we configure a snd_soc_acpi_link_adr
array with different order. Adding a check and a warning message can
remind people to keep the order when adding a new snd_soc_acpi_link_adr
array.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 sound/soc/intel/boards/sof_sdw.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index d9321fff4284..999ed6e80175 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -530,10 +530,11 @@ static inline int find_codec_info_acpi(const u8 *acpi_id)
  * Since some sdw slaves may be aggregated, the CPU DAI number
  * may be larger than the number of BE dailinks.
  */
-static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links,
+static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_link_adr *links,
 				int *sdw_be_num, int *sdw_cpu_dai_num)
 {
 	const struct snd_soc_acpi_link_adr *link;
+	int _codec_type = SOF_SDW_CODEC_TYPE_JACK;
 	bool group_visited[SDW_MAX_GROUPS];
 	bool no_aggregation;
 	int i;
@@ -559,6 +560,12 @@ static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links,
 		if (codec_index < 0)
 			return codec_index;
 
+		if (codec_info_list[codec_index].codec_type < _codec_type)
+			dev_warn(dev,
+				 "Unexpected address table ordering. Expected order: jack -> amp -> mic\n");
+
+		_codec_type = codec_info_list[codec_index].codec_type;
+
 		endpoint = link->adr_d->endpoints;
 
 		/* count DAI number for playback and capture */
@@ -1067,7 +1074,7 @@ static int sof_card_dai_links_create(struct device *dev,
 	ssp_num = ssp_codec_index >= 0 ? hweight_long(ssp_mask) : 0;
 	comp_num = hdmi_num + ssp_num;
 
-	ret = get_sdw_dailink_info(mach_params->links,
+	ret = get_sdw_dailink_info(dev, mach_params->links,
 				   &sdw_be_num, &sdw_cpu_dai_num);
 	if (ret < 0) {
 		dev_err(dev, "failed to get sdw link info %d", ret);
-- 
2.17.1


  parent reply	other threads:[~2021-10-27  2:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  2:18 [PATCH 00/10] ASoC: Intel: sof_sdw: Use fixed DAI link id Bard Liao
2021-10-27  2:18 ` [PATCH 01/10] ASoC: intel: sof_sdw: return the original error number Bard Liao
2021-10-27  2:18 ` [PATCH 02/10] ASoC: Intel: sof_sdw: fix jack detection on HP Spectre x360 convertible Bard Liao
2021-10-27  2:18 ` [PATCH 03/10] ASoC: Intel: sof_sdw: add SKU for Dell Latitude 9520 Bard Liao
2021-10-27  2:18 ` [PATCH 04/10] ASoC: intel: sof_sdw: rename be_index/link_id to link_index Bard Liao
2021-10-27  2:18 ` [PATCH 05/10] ASoC: intel: sof_sdw: Use a fixed DAI link id for AMP Bard Liao
2021-10-27  2:18 ` [PATCH 06/10] ASoC: intel: sof_sdw: move DMIC link id overwrite to create_sdw_dailink Bard Liao
2021-10-27  2:18 ` [PATCH 07/10] ASoC: intel: sof_sdw: remove SOF_RT715_DAI_ID_FIX quirk Bard Liao
2021-10-27  2:18 ` [PATCH 08/10] ASoC: intel: sof_sdw: remove sof_sdw_mic_codec_mockup_init Bard Liao
2021-10-27  2:18 ` [PATCH 09/10] ASoC: intel: sof_sdw: remove get_next_be_id Bard Liao
2021-10-27  2:18 ` Bard Liao [this message]
2021-11-15 20:18 ` [PATCH 00/10] ASoC: Intel: sof_sdw: Use fixed DAI link id 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=20211027021824.24776-11-yung-chuan.liao@linux.intel.com \
    --to=yung-chuan.liao@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /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.