From patchwork Sat Oct 22 07:28:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1107719wrr; Sat, 22 Oct 2022 01:41:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mEqVJX2kSHXcWzCy+oz4mreZPPE1I9fi8/3ZnmIT1pR89dbJV6Gi7F2e7fOsDkA2cthQX X-Received: by 2002:a05:6402:1941:b0:457:13a:cce9 with SMTP id f1-20020a056402194100b00457013acce9mr21531469edz.265.1666428112101; Sat, 22 Oct 2022 01:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428112; cv=none; d=google.com; s=arc-20160816; b=Y7fzszS/JUXTqk+by/4pEVvlQwOCSpp9SWzlSP50doD13UKLdudNGTNzyyDAZpC1rk 6oLRHJucw0pgTxwdMyGGQm7eeIBIccQAfjNDv1Bqaoqw87jMG8wjSimAxhHlwshm+t/s KwTGgCuI35BOoxo4TTl1McGP5vlASNe1t+XMmtIt4z6fEDN8fl+Xj/m8LtyUl5cC76hr Qd6g/i09eEzpiUN3S35m3uwINq7STrNag3isy6FCf148es7EQstCmWAGBTqTxWPLoWX9 qS8TeBN0xgfs0KOzBZyKfl6bkeqDQGjFZ5GHxRpTvkJJCa+k04TRFlR3mxk1VMZFzxgs ixBg== 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=JLI3j3WO5NV75LYwkgTjwJt/bew8AJj9F7Ur2rNZhrg=; b=NmMRyBLD0gYnnv2hRU09bDgucouxtDocMEGTGAPTlrPSfkxwa4Ov8dIlmsiJljn1Gm J+X8lZ9Vq4dVWNrt8cgN+P0mbzT9k7/wJA9vsElqjJX1NdIvIzJQ4jkXaIXMCQtHinux dfDVpbIvIJt31SNjACYLxPCZHK32YoVnfRMuczUXsL0vRuEuDZwUIBIr0BIu1pEWWn3o mZRGDKxnKo8tFUgLMGIL7DXFIWTUmbDA/SSl31nF99aVyBxMjXH6AqC1e5aVnf1VPRD5 dqDF/qy+QCoPX6Jre97OMzap4q8yzM5pYBusSPFPaWIZgRhgFK17xYkkD6NX/yr4y9LZ b4eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MlrJHRm5; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a056402084b00b0045b265a1712si27371732edz.595.2022.10.22.01.41.25; Sat, 22 Oct 2022 01:41:52 -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=MlrJHRm5; 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 S234601AbiJVIjR (ORCPT + 99 others); Sat, 22 Oct 2022 04:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234449AbiJVIfb (ORCPT ); Sat, 22 Oct 2022 04:35:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E391DDCD; Sat, 22 Oct 2022 01:04:25 -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 8978D60B81; Sat, 22 Oct 2022 08:03:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C03BC433C1; Sat, 22 Oct 2022 08:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425798; bh=iRWAp7mT/u5ZsntRpuy7Qz6GdmF0Etd7XBAveRikPHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlrJHRm5pnas+PVRJjzU5xzxQzREXur+3HD4Ve7kXagmam+fwtRT35nY2whMHLBRK 0PoFRWfBfBfcZCIl+dJRGNl22GZpjvW0O/aBx4MMV347yE1Piywu6LpoVPRsLTKSKX aA102eee8ljdzc4lQnfS5hzAgRPpLC7sJVniDyH0= 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 5.19 618/717] ASoC: SOF: add quirk to override topology mclk_id Date: Sat, 22 Oct 2022 09:28:17 +0200 Message-Id: <20221022072525.787620162@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376524314652843?= X-GMAIL-MSGID: =?utf-8?q?1747376524314652843?= 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 17f2f3a982c3..7d9e62ab9d0e 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); @@ -1433,6 +1437,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 e97f50d5bcba..b8ec302bc887 100644 --- a/sound/soc/sof/ipc3-topology.c +++ b/sound/soc/sof/ipc3-topology.c @@ -1233,6 +1233,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); @@ -1257,6 +1258,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 f11f575fd1da..544e5be9d10e 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -585,6 +585,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 */ };