Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp310431rdb; Mon, 18 Sep 2023 16:22:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGligBIf6uOq3oEG+Gu+OoGaWQMdg7xQ3x50ikNQ8MdJqB8oZ0+Okji75B15QkyQxryqWhi X-Received: by 2002:a17:903:191:b0:1b8:a19e:a3d3 with SMTP id z17-20020a170903019100b001b8a19ea3d3mr11604309plg.52.1695079320260; Mon, 18 Sep 2023 16:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695079320; cv=none; d=google.com; s=arc-20160816; b=Y7gKuAzDGy2RZFM5Fsy1yKv/o7NWY9KFXMPn+kI6tsone9RwCjnmgZDb3PSFWZmn+h Iy2VXiCI8FGD+zyDn9dzxnn6jnhPhKYO5oLLdV6x94ny1uJWzLInhMWoiyrCkMC9oMON cOsTBEmng02B3kGz/8V3JXhS7tfAnrUzQdlWwVpuhno2B/KgzUk5s5G/Ez7z1L6BfRxi W/dVwu1t+eI0caGfAe9EBa54pYjgxqoCAP7tePORv2szH+obBQuN/Ta3LsjREiXeLFsb q8HUUvz7DGXPGH9mw7YURsikL6kcQ6ssF9Dnk0oNb9kNIx9wNU0lxQo/4/lR7xj0AM+T 8Cug== 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=xSNguzTtIikVl+RQdSUYwmi0RN1Huyk35tspr09PREQ=; fh=o2U44G9A4LTpJ59K7pAEIGHu4kjGtR8t+y7j7b/fsto=; b=n17jLQDOCWtl0G2aC/k+AGd6Q5lwiRM4SBUwsXiTa7XIZ+WEJ89D4cJgLso6pJW/UO 2kwi/jCCl/MdeAbZvva+JCPCfxOhooqE/1sTksW4X3/8ElVYhXt3eFll3bej9XhrWcRT 7zx3Y0YvshpxM5joqPv4JQzF0G9jgIf+y/6XSFNSRYUuFbLG1WxZGH4lgmmZt76dOGHU MAVUCgIf231OayNMtpm2PfdMGfMqxQ2ujbcnqkGH1Sub6gTHMvpSubnCsDkfFaYRvReg Nhhk7suyHRhRkyPNIxetNn8epS9w7kpF9/2DQYH7rcaSRPrMUbQE1AKm3NGDF93jBAMz BY8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=isHIvKmX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id lg8-20020a170902fb8800b001c2027fa3f5si8553936plb.114.2023.09.18.16.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 16:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=isHIvKmX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BD8C48116B0C; Mon, 18 Sep 2023 08:25:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240042AbjIRPXs (ORCPT + 99 others); Mon, 18 Sep 2023 11:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236784AbjIRPXi (ORCPT ); Mon, 18 Sep 2023 11:23:38 -0400 Received: from out-228.mta1.migadu.com (out-228.mta1.migadu.com [IPv6:2001:41d0:203:375::e4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0F810C4 for ; Mon, 18 Sep 2023 08:19:40 -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=1695042950; 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=xSNguzTtIikVl+RQdSUYwmi0RN1Huyk35tspr09PREQ=; b=isHIvKmXlXetcHeWf7DjvK3hd0YtioC94nvej32bNq/CvGmTve1YeRzk+rYdpbOh0eQmpk 3aiceae+rP8+l/Bty+m+0HhdJ1aPNr9wTOaaXq8QcJU/1D3y62W4pOmNmmFobZ3fW+9BI5 IteLeq+6kc4S8MCQ1xLRVOVJdBKUGOEqHm/qlXmvM085CmOb7lyFmN67ZPTrwlR5rA92kH BLmKr17w/zrQraxWAHXbs6ZAPSqI1ztNaVsn6me2MSKb/5xeUJ8BB9L9M/UquqEbTNmhzf Y3xECSLmLS/OImXDAGxVOfMUi014+rkxkLAHyEw90TlaljKsCYCp6MqrfVh0fw== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Charles Keepax , John Watts , patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/3] ASoC: wm8782: Constrain maximum audio rate at runtime Date: Mon, 18 Sep 2023 23:15:30 +1000 Message-ID: <20230918131532.2257615-2-contact@jookia.org> In-Reply-To: <20230918131532.2257615-1-contact@jookia.org> References: <20230918131532.2257615-1-contact@jookia.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:25:00 -0700 (PDT) The wm8782 supports up to 192kHz audio when pins are set correctly. Instead of hardcoding which rates are supported constrain them at runtime based on a max_rate variable. Signed-off-by: John Watts Acked-by: Charles Keepax --- sound/soc/codecs/wm8782.c | 42 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/wm8782.c b/sound/soc/codecs/wm8782.c index 95ff4339d103..f3dc87b92b1e 100644 --- a/sound/soc/codecs/wm8782.c +++ b/sound/soc/codecs/wm8782.c @@ -23,6 +23,27 @@ #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_startup(struct snd_pcm_substream *sub, struct snd_soc_dai *dai) +{ + struct snd_pcm_runtime *runtime = sub->runtime; + struct wm8782_priv *priv = + snd_soc_component_get_drvdata(dai->component); + + return snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, + 8000, priv->max_rate); +} + static const struct snd_soc_dapm_widget wm8782_dapm_widgets[] = { SND_SOC_DAPM_INPUT("AINL"), SND_SOC_DAPM_INPUT("AINR"), @@ -33,28 +54,22 @@ static const struct snd_soc_dapm_route wm8782_dapm_routes[] = { { "Capture", NULL, "AINR" }, }; +static const struct snd_soc_dai_ops wm8782_dai_ops = { + .startup = &wm8782_dai_startup, +}; + 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 +136,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.42.0