Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp687339rdg; Thu, 10 Aug 2023 16:45:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBb/479jm64k6b66kdYnhesKlWBPUuzuRdW6Qu91dDNX0fCbhcPOCoF+fNiJuERcMeM/uZ X-Received: by 2002:a05:6808:341:b0:3a1:dfa0:7e18 with SMTP id j1-20020a056808034100b003a1dfa07e18mr357963oie.25.1691711152010; Thu, 10 Aug 2023 16:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691711151; cv=none; d=google.com; s=arc-20160816; b=DarDDcR37/SJqwhwW90o0AHGa8K0aub8SPG294uwoh8IBaK3mIcY4L1k2ogexyTW5w iQ26BZbuiGPcBkGtILm2tjTY2ET6KFrgZ2pbSjtD68aEw151ixDJ9Bq/+1RLluYcbFDE 5wNMvt8ry538SB4yjaKkZBN3dxW5oxmnCHGR39qhEXJ21XtSCffTf1rH2//4HvFaBwIt qyUfi/npvlKrK3cXR1UbhTKSEnpDpCRDxBovxJ433EkbKEJaTAuMK/Ir6Fou9sfKZCoX Xy6HVgLSY84qLFCXgp4YJAKNp4iy+5KLFw2t3MTHj82e+A+BHLDotTgNcIR6OiMGwqxD 7j3w== 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=NOt1sdSQzarb5tnZ/esvuAWXN80C1rxnQDdSGkr2tUk=; fh=CC0w0QMZihF8rAnnrP2QVOFueFnFAy+Qst7Su0+Cc2o=; b=UdTIFSFOHGXK5aMbkCpaH0NupBC5JYh+SBPQ+oZlbQS7S5oJ7W4Y/qM1qFunkSPWOm o37m1Br52psKw58RaGcN7CrRqqHRQeHj+9YqmTA7ZN1lN/HWBflxzY8RSa40wrxFrlmf FgTNGXlr3huNKhAOiGP6rzYRVtrJ0D3IQraBtLFVi7aw4MZo2sakWRxPpoTFYG8wq793 08i8PDECXlMIEv16OYKcgUg8s59zYD1YhRe18e6H3luM2wvgOERspFeCNbulpe9PQj6U VRlaxsdjwaWpJKbxsr3IpSRkTzVVWvIWwzwWtb+DW0UPLN7wReJ8FIpSaM73mcJRGK4O I4zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=01K1Clo5; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j192-20020a638bc9000000b00565568761a4si2232552pge.736.2023.08.10.16.45.38; Thu, 10 Aug 2023 16:45:50 -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=@jookia.org header.s=key1 header.b=01K1Clo5; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjHJWtt (ORCPT + 99 others); Thu, 10 Aug 2023 18:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbjHJWts (ORCPT ); Thu, 10 Aug 2023 18:49:48 -0400 Received: from out-95.mta1.migadu.com (out-95.mta1.migadu.com [IPv6:2001:41d0:203:375::5f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63D622710 for ; Thu, 10 Aug 2023 15:49:48 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691707785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NOt1sdSQzarb5tnZ/esvuAWXN80C1rxnQDdSGkr2tUk=; b=01K1Clo5tUXVhOGMDlAbBOlOOwcHAo5RT/lrxTGiIK/AC5POgCHYrmpcisnJD5PzcFj5hv dQIbBEM9GPPWfgeIxJRjm27c8VCCcFSczjMcfY9b0Zm2z7X12KN9UgeiBg/nSND71ShynG 4sb0q/7HBZsQcJx+6xLSgO3E84ngsDkYts7ulTYd9AIQ36TeWnNY0uGD8kx0SOPMbQ7iFz cg0QHmOaIJKuaL9LP/LK0gUUC392rni1LmiG8RsIXf7pJPS+X+FehGTc8YFZ2FTvglYg2+ OHXnDHBO/AvUebXLeGTQxOcPqOS6MOw4ycXcK1gyAzI1I9oY0orH/JbcIXxJZg== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , John Watts , patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] ASoC: wm8782: Handle maximum audio rate at runtime Date: Fri, 11 Aug 2023 08:49:28 +1000 Message-ID: <20230810224930.3216717-2-contact@jookia.org> In-Reply-To: <20230810224930.3216717-1-contact@jookia.org> References: <20230810224930.3216717-1-contact@jookia.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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 The wm8782 supports up to 192kHz audio when pins are set correctly. Instead of hardcoding which rates are supported enable them all then refer to a max_rate variable at runtime. Signed-off-by: John Watts --- sound/soc/codecs/wm8782.c | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/wm8782.c b/sound/soc/codecs/wm8782.c index 95ff4339d103..63ab63f3189a 100644 --- a/sound/soc/codecs/wm8782.c +++ b/sound/soc/codecs/wm8782.c @@ -23,6 +23,30 @@ #include #include +/* regulator power supply names */ +static const char *supply_names[] = { + "Vdda", /* analog supply, 2.7V - 3.6V */ + "Vdd", /* digital supply, 2.7V - 5.5V */ +}; + +struct wm8782_priv { + struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; + int max_rate; +}; + +static int wm8782_dai_hw_params(struct snd_pcm_substream *component, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct wm8782_priv *priv = + snd_soc_component_get_drvdata(dai->component); + + if (params_rate(params) > priv->max_rate) + return -EINVAL; + + return 0; +} + static const struct snd_soc_dapm_widget wm8782_dapm_widgets[] = { SND_SOC_DAPM_INPUT("AINL"), SND_SOC_DAPM_INPUT("AINR"), @@ -33,28 +57,22 @@ static const struct snd_soc_dapm_route wm8782_dapm_routes[] = { { "Capture", NULL, "AINR" }, }; +static const struct snd_soc_dai_ops wm8782_dai_ops = { + .hw_params = &wm8782_dai_hw_params, +}; + static struct snd_soc_dai_driver wm8782_dai = { .name = "wm8782", .capture = { .stream_name = "Capture", .channels_min = 2, .channels_max = 2, - /* For configurations with FSAMPEN=0 */ - .rates = SNDRV_PCM_RATE_8000_48000, + .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, }, -}; - -/* regulator power supply names */ -static const char *supply_names[] = { - "Vdda", /* analog supply, 2.7V - 3.6V */ - "Vdd", /* digital supply, 2.7V - 5.5V */ -}; - -struct wm8782_priv { - struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; + .ops = &wm8782_dai_ops, }; static int wm8782_soc_probe(struct snd_soc_component *component) @@ -121,6 +139,9 @@ static int wm8782_probe(struct platform_device *pdev) if (ret < 0) return ret; + /* For configurations with FSAMPEN=0 */ + priv->max_rate = 48000; + return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8782, &wm8782_dai, 1); } -- 2.41.0