Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp875871rwi; Wed, 19 Oct 2022 04:11:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6f6NLL97dJsgNaaHJmngEwXzipNQB1lBjKxk/WAMLP7xayna+EPEdLVDz+EAgvTOhWIxyv X-Received: by 2002:a17:902:7c11:b0:178:a6ca:4850 with SMTP id x17-20020a1709027c1100b00178a6ca4850mr8133885pll.111.1666177901423; Wed, 19 Oct 2022 04:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177901; cv=none; d=google.com; s=arc-20160816; b=iZU0D8vjsWC2s9jqJVsV15KCRENISoSKZI6e2khOSXULTGiV8n+rfRdaGgOsRA6WRV vijeij8GFaRF9xe+5mGPDYJoIzKzV7W5LQ4x7+1mEjCskz+dE2VjdHryqfqTj/uuwPIB 1dUk75Cbbc8/L7cSkciNuWHWddLkkoUtnKhhJ8F+SUfs9g1fY85LIIEdb6Ut9qZt5dDv 3YfogdTazE9NYiqoiGGmKkOaGsvre/L+ChfCOOYG/i5+IMwzrL97xALjj1QQcPNYhLkJ 1g0pMyrFs/9bBItYQG1YpEL6IPt2af2MSGYxvbx/KFSuNtq0SvM0doSP0Tn/Ry6FJjMT cLqg== 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=Qm5wmh6PxQ3/Tn1y5d7HHNsRB2z0MlMUorXHGntJ3nU=; b=pCLmAJfwTVIDMlXFOeYTQGlrz5nRYR6aUIOFT6Hyf10p1wfjrpGJ6tutB8BxFmpR4W Y7wkNscWGmWPJF63LBDV2jMhToyMS9c+f2870ep7k8UmLHyFjgSOrTFfRG45doyKS1H+ mHTtK6O+uKW03Rbe+ATNqJE++Mu6CV76gyY6JbVISrve+95fA8k4Ut/GBq205fU/s5zu bRoxYvI4wFOjjIq6xzsEo6Pwndbl+QAtDaaf2PdXWDCyjPaz/UvKZxc0CLyX4ONX+g6R PnO2vMz+3WbMb+StdjH2BOwMrqrhdc8mWeSQoQ/pepm309ayHJ05quhI7Q0Ecv4WYQ2F ND4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bzXAUqCc; 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 v190-20020a6389c7000000b0046b30704f89si14811191pgd.675.2022.10.19.04.11.28; Wed, 19 Oct 2022 04:11:41 -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=bzXAUqCc; 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 S234585AbiJSKvg (ORCPT + 99 others); Wed, 19 Oct 2022 06:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234564AbiJSKt3 (ORCPT ); Wed, 19 Oct 2022 06:49:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08DBE14BB71; Wed, 19 Oct 2022 03: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 ams.source.kernel.org (Postfix) with ESMTPS id 3B04CB824C2; Wed, 19 Oct 2022 09:11:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF157C433C1; Wed, 19 Oct 2022 09:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170696; bh=8vlZOH+1gnjwy2xjkBABceLfZcQrgsu6aRHtvXp0IEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bzXAUqCc8BDenCN6P9al8XIwEpprm9kxdSK/CJQhV3RJBl0kHCZXq6YRE/2Pk5CDo mwBON4DcKGXc26lp7fbQoQEQc50Wm+VaQu2PryETFPin5P1Jfb9r+3m8pjgelN8P/t j2sav56cpCWxXFABNOFC0663Y+gLbjDVrCHuOUn0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Kai Vehmanen , Bard Liao , Mark Brown , Sasha Levin Subject: [PATCH 6.0 753/862] ASoC: SOF: add quirk to override topology mclk_id Date: Wed, 19 Oct 2022 10:34:00 +0200 Message-Id: <20221019083323.177619438@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 d136949dd8e2e309dc2f186507486b71cbe9acdb ] Some Intel-based platforms rely on a topology file that hard-codes the use of MCLK0. This is incorrect in 10% of the cases. Rather than generating yet another set of topology files, this patch adds a kernel module parameter to override the topology value. In hindsight, we should never have allowed mclks to be specified in topology, this is a hardware-level information that should not have been visible in the topology. Future patches will try to set this value automagically, e.g. by parsing the NHLT content. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen Reviewed-by: Bard Liao Link: https://lore.kernel.org/r/20220919115350.43104-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda.c | 11 +++++++++++ sound/soc/sof/ipc3-topology.c | 7 +++++++ sound/soc/sof/sof-priv.h | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 6d4ecbe14adf..ada2e6775749 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -376,6 +376,10 @@ static int dmic_num_override = -1; module_param_named(dmic_num, dmic_num_override, int, 0444); MODULE_PARM_DESC(dmic_num, "SOF HDA DMIC number"); +static int mclk_id_override = -1; +module_param_named(mclk_id, mclk_id_override, int, 0444); +MODULE_PARM_DESC(mclk_id, "SOF SSP mclk_id"); + #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) static bool hda_codec_use_common_hdmi = IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI); module_param_named(use_common_hdmi, hda_codec_use_common_hdmi, bool, 0444); @@ -1565,6 +1569,13 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) sof_pdata->tplg_filename = tplg_filename; } + + /* check if mclk_id should be modified from topology defaults */ + if (mclk_id_override >= 0) { + dev_info(sdev->dev, "Overriding topology with MCLK %d from kernel_parameter\n", mclk_id_override); + sdev->mclk_id_override = true; + sdev->mclk_id_quirk = mclk_id_override; + } } /* diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c index 65923e7a5976..a39b43850f0e 100644 --- a/sound/soc/sof/ipc3-topology.c +++ b/sound/soc/sof/ipc3-topology.c @@ -1249,6 +1249,7 @@ static int sof_link_afe_load(struct snd_soc_component *scomp, struct snd_sof_dai static int sof_link_ssp_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) { + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; struct sof_dai_private_data *private = dai->private; u32 size = sizeof(*config); @@ -1273,6 +1274,12 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, struct snd_sof_dai config[i].hdr.size = size; + if (sdev->mclk_id_override) { + dev_dbg(scomp->dev, "tplg: overriding topology mclk_id %d by quirk %d\n", + config[i].ssp.mclk_id, sdev->mclk_id_quirk); + config[i].ssp.mclk_id = sdev->mclk_id_quirk; + } + /* copy differentiating hw configs to ipc structs */ config[i].ssp.mclk_rate = le32_to_cpu(hw_config[i].mclk_rate); config[i].ssp.bclk_rate = le32_to_cpu(hw_config[i].bclk_rate); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 823583086279..828c74bb75f8 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -594,6 +594,10 @@ struct snd_sof_dev { /* to protect the ipc_rx_handler_list and dsp_state_handler_list list */ struct mutex client_event_handler_mutex; + /* quirks to override topology values */ + bool mclk_id_override; + u16 mclk_id_quirk; /* same size as in IPC3 definitions */ + void *private; /* core does not touch this */ }; -- 2.35.1