From patchwork Wed Jan 5 08:13:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1575528 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=pvGCdRy3; 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 4JTMhS4PK1z9sRR for ; Wed, 5 Jan 2022 19:14:16 +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 1n51Qv-0003dp-Ml; Wed, 05 Jan 2022 08:14:09 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1n51Qg-0002pG-UG for kernel-team@lists.ubuntu.com; Wed, 05 Jan 2022 08:13:55 +0000 Received: from localhost.localdomain (unknown [123.112.64.101]) (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-0.canonical.com (Postfix) with ESMTPSA id AC86040004 for ; Wed, 5 Jan 2022 08:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1641370432; bh=+DLKChc47/k2HH66V/XJpkks4vA+SKN8CRAlFEfRYCs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pvGCdRy3MarZxJVI/c0zibROkm8zUpDxzimWKGFVYD17DMOtVj/6AvowzteNzBN3Z kzEwonBH9vFl92NCBjh3nLj2ShcbqtEI3r0gPCd8X41+HrEvHy2bdnJ4nXqBAgXgN0 hJYYMhqbjkCro9pC3xJ+sYK0tIGhZvcHkGZHZJAF/2rgVMzbw7IndNolH9iuv//aci Zt5WmxycMlPGpYBUsSbwvZUxAxiw5lS2QXhnv+20cpwuz3/xu+sHRiYV7p9QHkxxvq atvMq5e0mARLNN/pJKY6iL74PnjZ43zc4uUAryGIFB89GTsFaS75na8e0wLrpurNAy jtpx2pGf70ELQ== From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][j][PATCH v3 17/17] ASoC: intel: sof_sdw: add link adr order check Date: Wed, 5 Jan 2022 16:13:13 +0800 Message-Id: <20220105081313.17903-18-hui.wang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220105081313.17903-1-hui.wang@canonical.com> References: <20220105081313.17903-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 linux-next) 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);