Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp673697pxb; Tue, 5 Apr 2022 18:13:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH+6dvIVH/iZAbG3ez4iZ0ASu1b1Mi6xc5PYIbpxcVR7+CVgdtBjL6WYWbkzpTDXGLvbPi X-Received: by 2002:a05:6a00:843:b0:4fe:3a5e:b347 with SMTP id q3-20020a056a00084300b004fe3a5eb347mr6306772pfk.64.1649207617672; Tue, 05 Apr 2022 18:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207617; cv=none; d=google.com; s=arc-20160816; b=TyOxJwikcx12SPMWu7kzAc0jymSHEDWXDZFy/Dfccf6zWe4IWHQE4w4oerYmlnqoBd mC+7PzneM7xlUrWsGsKAsrn8wnJe6KVHMgh28nz6+5nxPF2Gm4qdfKVmEir2jqb+ACks Odj1+Sn7qKB4aUgNJkBfwLkWB4upSYIbgz6FttpGH+fabOinwEzDT4WrMwXgWe43Aw8r nq2QCiqeGQI4mg9xNFgqg3KzXDCyc/HX2X5qB7vb9oCru/5ywy9eMGvkeOVOwhuBowHy W2KaTBK6exbNXM58nFUKzBGPrU/of0EFFVDAfYkTtqmQuHpJyea5AFFga9wQqfN+uXnH jEwg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qH+ZhYS9NLjVJ3QiyWHjshIWnrdUs83jxZrKd2CMryc=; b=KCEVuNoDtTWLCLu2HmIUPWjZKjQ5m2+bXLs09/V7gYTyGNE/RCxgWUYdyfJiLO8nLp sGogGjZmPteQlp9XKTBwygZAAchcHEHmY623WySgyVCTg/fFzYALH9/Hv5tQiDir7kKn 6hRwO+WXIumAg5pWgjGmq6UPYZmleRUKT9tRHHELF+MeKISi6rFpRZk4X9W5dUy+jzsn Xe/S8tlCrLNc2CwkkFWO4cgnr4ALGiz4IQZh0f5b1ZKPsShpSg1ONAQMcOeQQrHBpybp CmkRMI/B8Bmq131k1u606phlZT9JTr5hNggbn7bLHixqBAXh49ztNy8kk/YeJG7B0xcR N5Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uficF8lD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pb14-20020a17090b3c0e00b001bf9e717aa2si3226298pjb.76.2022.04.05.18.13.23; Tue, 05 Apr 2022 18:13:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uficF8lD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352516AbiDELL1 (ORCPT + 99 others); Tue, 5 Apr 2022 07:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238478AbiDEIai (ORCPT ); Tue, 5 Apr 2022 04:30:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1B01275D8; Tue, 5 Apr 2022 01:22:19 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 2FF236145F; Tue, 5 Apr 2022 08:22:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D00DC385A1; Tue, 5 Apr 2022 08:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146938; bh=udRcMs7kmOyAA+RyJhsEG9iF/vW5/VUQI/1wSi442CM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uficF8lDyi8UTZQNjXVSO4DhPi6lckMn5rDvDb3rb0mlaqX/sRcB148CSXmq7Y4o1 2EX+Cj2gY+gCOAoZfrsi7LRrGs6l+uCAH1798DIkKD7I0E7L/zd6vjxTZjOIx6l9x/ tCH4P0CC2p92mLeP+Gmgi0h6Pa6ya6zkMggCBuwU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauro Carvalho Chehab , Pierre-Louis Bossart , Bard Liao , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Mark Brown , Sasha Levin Subject: [PATCH 5.17 0943/1126] ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP Date: Tue, 5 Apr 2022 09:28:10 +0200 Message-Id: <20220405070435.188697055@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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