Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3897161rdb; Thu, 14 Sep 2023 06:13:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/wiHrd4JRaJzQ++aA8YpzaeRh7qIFj4Pw5myZN0/UMV/bKtxahgmOAp9+nXMbBeKp41qg X-Received: by 2002:a17:902:8345:b0:1c3:a2f2:b327 with SMTP id z5-20020a170902834500b001c3a2f2b327mr5273125pln.2.1694697222228; Thu, 14 Sep 2023 06:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694697222; cv=none; d=google.com; s=arc-20160816; b=haefkaYagSp9l8cvAp1EhzZGwfuaz8MIHj5fSIb5ZFe063HovdVag2pmKB776d9gj0 YxIll9YijyVig9dsUy6daDY7RJ63WrtbFGhuzPa5xhYlJXUhYtpNMD2Mb4iXl3YzTUE+ 6d4WDWqfkOLNUj8zO79Wd5v4s336oPyRaup5CAdR11U8sTH/hO9YVUtich48lFcFAYdx 7gPfWUNdXdzD5hoX5C0Cy6xAbHChEkHOFmKpOid24QcD0zOellW9rnOkvGZGIwZH9S2c kIulu6phisLq/muTZhby8U+k8+HbngqXzWMPmxcKZ8x1aoxxQ/Ez5zMmwX724oMUkqFF QhHQ== 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=+ARN8kgft71oXLI4365VA9XtD4zR8PCN1d80Gtbr/rE=; fh=K2LUYf+eeIUUOAFkE7bz3JhUBLdTtfJsbrtjFyoTvGs=; b=XjJO/8qemO3TkXvRwBC+7h4onJBHyrA+29skVTfgdQV8fZMuVaE0QdBK6u33HhUDPY fFYuHSllpOBKquDMZOwQxZ0hXC9yNEvZmmfxjnALM9RuV47FDt7GraTMAA279GW6IqdU zrVVuHE+fVH8/s2C5nwTSP0sKhgrlcOTG4ZCWdDYNKdDcY8wdE2KDN3g9prb2MYlupVL 8xBokxyAaKCBHhov32mjNk9R0BJi34T6mmyXLg7ucOdJ7D3OCSFMrgBipSUV+CPD8Ond 7Ku+SYBsWTUkV9d7qkLxfaAeNu3ZMuZ6zrzneM0qImgdwSmcwoO0THVePqM4ZdPorUlz Zrjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=ek6NOC2J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d15-20020a170902654f00b001bc67506b38si1581777pln.367.2023.09.14.06.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:13:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=ek6NOC2J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id A036381A1EB9; Wed, 13 Sep 2023 10:16:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbjIMRQl (ORCPT + 99 others); Wed, 13 Sep 2023 13:16:41 -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: 8bit X-Migadu-Flow: FLOW_OUT 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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:16:49 -0700 (PDT) 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.42.0