From patchwork Thu Dec 23 05:13:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1572522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=EAKSVysz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JKJJZ56M4z9t5K for ; Thu, 23 Dec 2021 16:14:06 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1n0GQO-0000hl-Fm; Thu, 23 Dec 2021 05:13:56 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1n0GQ7-0000DS-Ry for kernel-team@lists.ubuntu.com; Thu, 23 Dec 2021 05:13:40 +0000 Received: from localhost.localdomain (unknown [103.229.218.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 13B403F124 for ; Thu, 23 Dec 2021 05:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1640236417; bh=kuu0ZSUiPu9IzEEp6hTYmyTyoRGGjeV8vOhWWniaU/o=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EAKSVyszV81ukeY6bH/InuGr064O38C9IRwLOU+Vu9Jz/NDjYCXHY2+uqNcjStkn/ ZOgD85Sm30O7sRu+9IqlNNBQUgvLWXb4zuq1ycI2Xl3nQ950iAXZTvGLp52uPIjiYk 8ZzrnhaPkTe2XumvwVsNJ6qbqU0tQLOGPAP5jw2DEowuQUqoNNUAHa5p/zbHm1f5GL taPuLunQMfX/0RkfVCaNoKYswdtTxv173ZVywkTmQnu3DpYAlvob0TRkwjH9iCEH2r ykOC7qkv4+5js5phug7bHBDjUCw5rypN9Or6iSowMTN17A+8gIOKrNzXq38gR5Lcrv qSKzXvev4fFaA== From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][j][PATCH v2 17/17] ASoC: intel: sof_sdw: add link adr order check Date: Thu, 23 Dec 2021 13:13:07 +0800 Message-Id: <20211223051307.8485-18-hui.wang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223051307.8485-1-hui.wang@canonical.com> References: <20211223051307.8485-1-hui.wang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Bard Liao BugLink: https://bugs.launchpad.net/bugs/1951563 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 Link: https://lore.kernel.org/r/20211027021824.24776-11-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown (cherry picked from commit 296c789ce1e501be8b46ebb24da4ba53063cc10a) Signed-off-by: Hui Wang --- 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 c1550e789513..b478f940a1db 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -589,10 +589,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; @@ -618,6 +619,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 */ @@ -1126,7 +1133,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);