From nobody Sun Feb 8 10:31:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 819DBEE01F1 for ; Wed, 13 Sep 2023 17:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbjIMRQn (ORCPT ); Wed, 13 Sep 2023 13:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231637AbjIMRQS (ORCPT ); Wed, 13 Sep 2023 13:16:18 -0400 Received: from out-229.mta0.migadu.com (out-229.mta0.migadu.com [IPv6:2001:41d0:1004:224b::e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D25E1BD6 for ; Wed, 13 Sep 2023 10:16:14 -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=1694625372; 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=+ARN8kgft71oXLI4365VA9XtD4zR8PCN1d80Gtbr/rE=; b=ek6NOC2JyHHW+0JBOgYvmhndtYiDCTJQ79WE2eZ3MCZOuw7eBKvPjunD1ZbhjzL7kUgSr2 3XEAjdQfr7/0tqcbXuImSQDDTYgoX00119gc+b7lZNx861vj9J+xVK97xdtYcUjVcnwF+d TZbyel9IJp3+vZkkNSM7aijnynxD/D49rYeyF0KsDvWjIFGoCFAfMjG+SOmutpfKTo2Siq vIrWVGE3Jcs21zfIplTgwTVmqgGq47nuMqaSc6/lpTTUG15f4ZwxNIfEQoJBVCrTfknN58 mvmQ7wd9DsFaYRybsUNNGPo5Z+TqyEqDdrQxwxfZuYC5+25AFm5RkCBE0XH8pw== 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 v2 1/3] ASoC: wm8782: Handle maximum audio rate at runtime Date: Thu, 14 Sep 2023 03:15:50 +1000 Message-ID: <20230913171552.92252-2-contact@jookia.org> In-Reply-To: <20230913171552.92252-1-contact@jookia.org> References: <20230913171552.92252-1-contact@jookia.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 +/* regulator power supply names */ +static const char *supply_names[] =3D { + "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 =3D + 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[] =3D { SND_SOC_DAPM_INPUT("AINL"), SND_SOC_DAPM_INPUT("AINR"), @@ -33,28 +57,22 @@ static const struct snd_soc_dapm_route wm8782_dapm_rout= es[] =3D { { "Capture", NULL, "AINR" }, }; =20 +static const struct snd_soc_dai_ops wm8782_dai_ops =3D { + .hw_params =3D &wm8782_dai_hw_params, +}; + static struct snd_soc_dai_driver wm8782_dai =3D { .name =3D "wm8782", .capture =3D { .stream_name =3D "Capture", .channels_min =3D 2, .channels_max =3D 2, - /* For configurations with FSAMPEN=3D0 */ - .rates =3D SNDRV_PCM_RATE_8000_48000, + .rates =3D SNDRV_PCM_RATE_8000_192000, .formats =3D SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, }, -}; - -/* regulator power supply names */ -static const char *supply_names[] =3D { - "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 =3D &wm8782_dai_ops, }; =20 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; =20 + /* For configurations with FSAMPEN=3D0 */ + priv->max_rate =3D 48000; + return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8782, &wm8782_dai, 1); } --=20 2.42.0 From nobody Sun Feb 8 10:31:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F8AEE01F0 for ; Wed, 13 Sep 2023 17:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231534AbjIMRQr (ORCPT ); Wed, 13 Sep 2023 13:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231849AbjIMRQ1 (ORCPT ); Wed, 13 Sep 2023 13:16:27 -0400 Received: from out-211.mta0.migadu.com (out-211.mta0.migadu.com [IPv6:2001:41d0:1004:224b::d3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A0D1DC for ; Wed, 13 Sep 2023 10:16:22 -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=1694625381; 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=3FeZkXz+JQqXeiU3HazldI8mgv0sJ787/pyCTmTegd4=; b=ZFkMudF4vLRf2wwyLkRMjGNESmuzTssdLkRAglApAJ8yPv6gK4CSmiVmSozhR/msO9T1X0 cwe809Oob+FAKFsjPNz50zFhGBQ6/MCMc1ZqLlbRyDxgja44nq1wiNyMteDtGAob8nGyaR 5ImsryHJjxA4FjkZpt6MY9Hi3jc7QgOLDHRYjP0oZj9ntRl9OdCRjCGGJTBvNDI7CnYOZx FOb9TDIIXM03aX7F+vEO2AP+PNTKhYSIlmGy1TYSmYKNeUMbI0/XCxvfLNV13unO0eurm3 X5O334si6FTqxRHh0IBJoZ9i+yGS3mhJ6pvlWEJo5n/we4vWKmDit3H4xCe/Rg== 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 v2 2/3] ASoC: wm8782: Use wlf,fsampen device tree property Date: Thu, 14 Sep 2023 03:15:51 +1000 Message-ID: <20230913171552.92252-3-contact@jookia.org> In-Reply-To: <20230913171552.92252-1-contact@jookia.org> References: <20230913171552.92252-1-contact@jookia.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The wm8782 supports rates 96kHz and 192kHz as long as the hardware is configured properly. Allow this to be specified in the device tree. Signed-off-by: John Watts --- sound/soc/codecs/wm8782.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm8782.c b/sound/soc/codecs/wm8782.c index 63ab63f3189a..249b58b093d6 100644 --- a/sound/soc/codecs/wm8782.c +++ b/sound/soc/codecs/wm8782.c @@ -122,8 +122,9 @@ static const struct snd_soc_component_driver soc_compon= ent_dev_wm8782 =3D { static int wm8782_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; struct wm8782_priv *priv; - int ret, i; + int ret, i, fsampen; =20 priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -139,8 +140,26 @@ static int wm8782_probe(struct platform_device *pdev) if (ret < 0) return ret; =20 - /* For configurations with FSAMPEN=3D0 */ - priv->max_rate =3D 48000; + // Assume lowest value by default to avoid inadvertent overclocking + fsampen =3D 0; + + if (np) + of_property_read_u32(np, "wlf,fsampen", &fsampen); + + switch (fsampen) { + case 0: + priv->max_rate =3D 48000; + break; + case 1: + priv->max_rate =3D 96000; + break; + case 2: + priv->max_rate =3D 192000; + break; + default: + dev_err(dev, "Invalid wlf,fsampen value"); + return -EINVAL; + } =20 return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8782, &wm8782_dai, 1); --=20 2.42.0 From nobody Sun Feb 8 10:31:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3992EE01F0 for ; Wed, 13 Sep 2023 17:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbjIMRQv (ORCPT ); Wed, 13 Sep 2023 13:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbjIMRQf (ORCPT ); Wed, 13 Sep 2023 13:16:35 -0400 Received: from out-212.mta0.migadu.com (out-212.mta0.migadu.com [IPv6:2001:41d0:1004:224b::d4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB409B; Wed, 13 Sep 2023 10:16:31 -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=1694625390; 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=M7MW2tmPsMPWsEPrNQ/SepXgoJLxl3hENl0P4TjZeAI=; b=Eo7GK7lq/gTTAwl8Iy1o6l/u1wMdmmidG3pp1PYNMzKEUtD+WJr9xocXAp9ZMJZSwY5uhA qKi1EQ+yRFZou1//6N1q5p+JacFDiV0LjBsntUl1g2ZhyNYir1b+IPuyokqE4z1qsQETOz Lb/6JJomyGI2HGW0AmFvoixKxa6o5eUMZNMIvrxr7N/NezCHvHYu3lMCBJdc9VHTxWrt3w ysEMyzsFcwILr8JB/zSDpBbwyoR1kKQJhVp7AbMNuJo3POkswmSpkrNjgOFU8oXJIu09lz E5KlceLKLs4DYHNycBjvgf8ntchf6F8h5bO+z2PhTGej7RrrdIY4B0Je+jJW1g== 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 v2 3/3] ASoC: dt-bindings: wlf,wm8782: Add wlf,fsampen property Date: Thu, 14 Sep 2023 03:15:52 +1000 Message-ID: <20230913171552.92252-4-contact@jookia.org> In-Reply-To: <20230913171552.92252-1-contact@jookia.org> References: <20230913171552.92252-1-contact@jookia.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The WM8782 can safely support rates higher than 48kHz by changing the value of the FSAMPEN pin. Allow specifying the FSAMPEN pin value in the device tree. Signed-off-by: John Watts --- Documentation/devicetree/bindings/sound/wm8782.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/wm8782.txt b/Documenta= tion/devicetree/bindings/sound/wm8782.txt index 256cdec6ec4d..d217a616e103 100644 --- a/Documentation/devicetree/bindings/sound/wm8782.txt +++ b/Documentation/devicetree/bindings/sound/wm8782.txt @@ -8,10 +8,15 @@ Required properties: - Vdda-supply : phandle to a regulator for the analog power supply (2.7V = - 5.5V) - Vdd-supply : phandle to a regulator for the digital power supply (2.7V= - 3.6V) =20 +Optional properties: + + - wlf,fsampen : FSAMPEN pin value, 0 for low, 1 for high, 2 for disconnec= ted + Example: =20 wm8782: stereo-adc { compatible =3D "wlf,wm8782"; Vdda-supply =3D <&vdda_supply>; Vdd-supply =3D <&vdd_supply>; + wlf,fsampen =3D <2>; /* 192KHz */ }; --=20 2.42.0