Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp208495lfu; Wed, 30 Mar 2022 21:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvlJMOnjYoas7oJTlxcYsCoand5BdKE78hv66Um0eajZc3IYLoXP98Hxx33pnDbW26w4qS X-Received: by 2002:a17:902:7c8c:b0:156:5651:1d51 with SMTP id y12-20020a1709027c8c00b0015656511d51mr1050848pll.107.1648699340076; Wed, 30 Mar 2022 21:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648699340; cv=none; d=google.com; s=arc-20160816; b=kUKLFkQ3bMIra+qmALc+FtHw1tUlYVikRINQj+0wqx7mGko73B3cnssdX32BoadvEc LXK0e5k657lt8Md375hDBUotZYNDUQQz0sbso+Tr7ZGP9kfdnS7txB07aEMO7Z4/XtyR SEbChhAUH7lD5T2C2kJ9otpSALRFItEYNVYqOnWs8ENfsuXj7G+3gPSksJPYe6KQpkYj r4GP2OrubFgfOxUq8MyjWLhOBHDsvk2fjLqf/fwjq6rb/w7DN+0xaCy5Bcas97NfQjUf WK901xrnL/ITi0Vuae1szNJnI9CeWhyIB050VYXZ4LxU8LLxvh2ZdYq2OT5Q7tQtVYhy fihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qH+ZhYS9NLjVJ3QiyWHjshIWnrdUs83jxZrKd2CMryc=; b=bZuhanQqSyaR7pw8dDYG240HTSP5xy3aeQlogF5+Hvm5uZk3YC+9jZ6eXxmvPXXT4U mB02tQ+u3QPADK7hgUysfaF0T3VS2wIyKKhfWDZr4JVSaClHf1uJ01SLF4I1ey0sXtfL jBSpYj9ixKEW9+sw1OTCOAK5WAUIGXfLEg9wIEqGsgRoAQ/goNuRVbQ4vGLR6wxGuzUi h7ynD91GyKgdxamffD5VFAI2zKHcXEDPngl/xlaiKyn8/Wiy4IetDAE/vw206ekdkuiy wRUU3ONLMSano/r5OAG0SOF4tPxq41jkb1wBLY26Ib/ksKhgLg2syRN8s2gn5FviWbAE rTHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iKWmJVDv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 21-20020a630e55000000b00381f044e11fsi20103729pgo.550.2022.03.30.21.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:02:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iKWmJVDv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CFBD178681; Wed, 30 Mar 2022 20:09:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344701AbiC3MCX (ORCPT + 99 others); Wed, 30 Mar 2022 08:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344896AbiC3Lxp (ORCPT ); Wed, 30 Mar 2022 07:53:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF73270842; Wed, 30 Mar 2022 04:49:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 800ECB81C36; Wed, 30 Mar 2022 11:49:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 051C5C36AE9; Wed, 30 Mar 2022 11:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640995; bh=udRcMs7kmOyAA+RyJhsEG9iF/vW5/VUQI/1wSi442CM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iKWmJVDv9Zy3cJ8d9MSrVdPgRNpKZ8LX15+AHxo3ESuEQ19a/BsHLZQNQZlID59b0 TbBc6HpIjo94lF5LEm7016wSDizFcTuZe1LfQgPSo/SAjgVgLWnPabYtrsJbrx4bt5 7CyYRuBtIm8BPyLzPwle/Jn/9jshXu4SBo9dz57/Fs8YP6jFjjHeP+vfs+eI5SneN0 F1Xv7HCNMh3uO9ZTBlTMYXlCijhoxjiXAttI0HXxqrhyawGrK8S0h0vggnMTQ3t6r9 yNx3ZWYZhE1/rQYsmp61Pg44TwaZmXAiJ6QnS7vh9bHjmu6cza9LhJzqwjmi/4Wa7g tQSuu735GFLwQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Mauro Carvalho Chehab , Bard Liao , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Mark Brown , Sasha Levin , lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.16 53/59] ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP Date: Wed, 30 Mar 2022 07:48:25 -0400 Message-Id: <20220330114831.1670235-53-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114831.1670235-1-sashal@kernel.org> References: <20220330114831.1670235-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart [ Upstream commit 651c304df7f6e3fbb4779527efa3eb128ef91329 ] Since we see a proliferation of devices with various configurations, we want to automatically set the DMIC and SSP information. This patch relies on the information extracted from NHLT and partially reverts existing DMI quirks added by commit a164137ce91a ("ASoC: Intel: add machine driver for SOF+ES8336") Note that NHLT can report multiple SSPs, choosing from the ssp_link_mask in an MSB-first manner was found experimentally to work fine. The only thing that cannot be detected is the GPIO type, and users may want to use the quirk override parameter if the 'wrong' solution is provided. Tested-by: Mauro Carvalho Chehab Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Péter Ujfalusi Link: https://lore.kernel.org/r/20220308192610.392950-15-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/intel/boards/sof_es8336.c | 56 +++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c index 20d577eaab6d..46e453915f82 100644 --- a/sound/soc/intel/boards/sof_es8336.c +++ b/sound/soc/intel/boards/sof_es8336.c @@ -228,24 +228,25 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id) return 1; } +/* + * this table should only be used to add GPIO or jack-detection quirks + * that cannot be detected from ACPI tables. The SSP and DMIC + * information are providing by the platform driver and are aligned + * with the topology used. + * + * If the GPIO support is missing, the quirk parameter can be used to + * enable speakers. In that case it's recommended to keep the SSP and DMIC + * information consistent, overriding the SSP and DMIC can only be done + * if the topology file is modified as well. + */ static const struct dmi_system_id sof_es8336_quirk_table[] = { - { - .callback = sof_es8336_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "CHUWI Innovation And Technology"), - DMI_MATCH(DMI_BOARD_NAME, "Hi10 X"), - }, - .driver_data = (void *)SOF_ES8336_SSP_CODEC(2) - }, { .callback = sof_es8336_quirk_cb, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"), DMI_MATCH(DMI_BOARD_NAME, "WN1"), }, - .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | - SOF_ES8336_TGL_GPIO_QUIRK | - SOF_ES8336_ENABLE_DMIC) + .driver_data = (void *)(SOF_ES8336_TGL_GPIO_QUIRK) }, {} }; @@ -470,11 +471,33 @@ static int sof_es8336_probe(struct platform_device *pdev) card = &sof_es8336_card; card->dev = dev; - if (!dmi_check_system(sof_es8336_quirk_table)) - quirk = SOF_ES8336_SSP_CODEC(2); + /* check GPIO DMI quirks */ + dmi_check_system(sof_es8336_quirk_table); - if (quirk & SOF_ES8336_ENABLE_DMIC) - dmic_be_num = 2; + if (!mach->mach_params.i2s_link_mask) { + dev_warn(dev, "No I2S link information provided, using SSP0. This may need to be modified with the quirk module parameter\n"); + } else { + /* + * Set configuration based on platform NHLT. + * In this machine driver, we can only support one SSP for the + * ES8336 link, the else-if below are intentional. + * In some cases multiple SSPs can be reported by NHLT, starting MSB-first + * seems to pick the right connection. + */ + unsigned long ssp = 0; + + if (mach->mach_params.i2s_link_mask & BIT(2)) + ssp = SOF_ES8336_SSP_CODEC(2); + else if (mach->mach_params.i2s_link_mask & BIT(1)) + ssp = SOF_ES8336_SSP_CODEC(1); + else if (mach->mach_params.i2s_link_mask & BIT(0)) + ssp = SOF_ES8336_SSP_CODEC(0); + + quirk |= ssp; + } + + if (mach->mach_params.dmic_num) + quirk |= SOF_ES8336_ENABLE_DMIC; if (quirk_override != -1) { dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n", @@ -483,6 +506,9 @@ static int sof_es8336_probe(struct platform_device *pdev) } log_quirks(dev); + if (quirk & SOF_ES8336_ENABLE_DMIC) + dmic_be_num = 2; + sof_es8336_card.num_links += dmic_be_num + hdmi_num; dai_links = sof_card_dai_links_create(dev, SOF_ES8336_SSP_CODEC(quirk), -- 2.34.1