Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3958111rdb; Thu, 14 Sep 2023 07:49:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWKuJvyShX/etqDdtVCMxqkDc+yzqBJ5WuxNWWEUYOy/qYlHFAwUjWkXSwik9yZEXW2yjU X-Received: by 2002:a17:902:654e:b0:1bc:4f04:17f4 with SMTP id d14-20020a170902654e00b001bc4f0417f4mr2619525pln.30.1694702968059; Thu, 14 Sep 2023 07:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694702968; cv=none; d=google.com; s=arc-20160816; b=DaOzu6Bw8bmahhEz7dPZ9X6sMmO6yTmE2vRCGBRmNrK6iqevAzz/XB0JUwP8iz4bOh dE0mnZiWdbsy1jIz+AMeivClg+ygTcouf3/5AyCJQ0X+qNNpQaVlltfOEz0Yj0bLm/SI fG2obAOhtYUrR4A1vLm38MMlZX3hOeOmyhB1ds3GVePnn3QrTW0glvpGKASY+kmMYk6+ NY0DZqaxLFK3qvQKvcuaVqYqzmr28JLjPpAwuChaEAFZbyTkU+i+uuVFYC94jyxY18nN 0pqYUbrm/NoHnhZG2f/7RWP/fa5nN81eeKaRd5y0qLXh4gz9XgAD1GOk/e6WrUBkU/fo Fsbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2IPcvMJ6I8FbRO8Q4YQtRfi9KDKzY1NIt+8SrW/Lmko=; fh=+/DzR/shtn859kA9twsgbLwV1z5MglYuHp6J65I2G0k=; b=LQtXQiSYKjfzTQV3I+hEYhO0bI2/FH1yhgJg8O8AytHClVBxcqwgmZxiS0ZzYW3QmE +Eiw/icZxjyIRlH8FMcIXxTDgTJRr54jqm7/d8//fhKDGmaTiLuirznWSvPNw6hPx/pN wE3eqx68pLgd0yz+cV+d5p9R36mzpxqyzGTA/YPcn8XTfEpiOCAYhpISRO1QX//VANyA huuXkEt/DZ4jV3NYX8OxfWSDnA0B/hOPlSZf0gGiLIgu2RkGtB40hO5ZuB+yx5ZbLCN8 csnzrY+Q7Rxcm0Pj3U0lEJ4vh/waXvZfG+NuW1/EjtvvdxfEBCpxrXuOhO+Tp4rGZ3l9 f3Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=k4vrvgwH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o66-20020a634145000000b00577796b5206si1671220pga.898.2023.09.14.07.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 07:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=k4vrvgwH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 798FA807D0EE; Thu, 14 Sep 2023 02:45:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237303AbjINJpB (ORCPT + 99 others); Thu, 14 Sep 2023 05:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237276AbjINJow (ORCPT ); Thu, 14 Sep 2023 05:44:52 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D30210B; Thu, 14 Sep 2023 02:44:47 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 38E74Pac017688; Thu, 14 Sep 2023 04:44:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=PODMain02222019; bh=2IPcvMJ6I8FbRO8 Q4YQtRfi9KDKzY1NIt+8SrW/Lmko=; b=k4vrvgwH+PHcuZOxITvoDXV/MGy6LsJ fxq6A0NwXRHusvyS1L86igNQhbdOmNzfoRFa1/9NuGaJ0lozThBcwAKQiasypKRm XsLE0ciCDMaULGybZ2EwdK351FUFRGQ7GiCIMJSUVIlMhSpaoOtJF0yUjXmU4kKM jy2JFOZ+gz9GPm/l5tYgwTtYXGb0H4efbLnx0ogm0y0U7K5Kz5VXblh9ER0jI9PT WblW1Q8aI9DUHCcM0638xOFCJwCbr8K0YyriSLSptdhNHM7PlLlCFoN8XagE2Z0s mk8OS9vcL+mpE9mo26rUA6cu2RiLX71uooAlY86JbEcrIFGDQSfxqRA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3t2y7shwme-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 04:44:26 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Thu, 14 Sep 2023 10:44:24 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Thu, 14 Sep 2023 10:44:24 +0100 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id AC7A93563; Thu, 14 Sep 2023 09:44:24 +0000 (UTC) Date: Thu, 14 Sep 2023 09:44:24 +0000 From: Charles Keepax To: John Watts CC: , Liam Girdwood , "Mark Brown" , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , Jaroslav Kysela , Takashi Iwai , , , Subject: Re: [PATCH v2 1/3] ASoC: wm8782: Handle maximum audio rate at runtime Message-ID: <20230914094424.GT103419@ediswmail.ad.cirrus.com> References: <20230913171552.92252-1-contact@jookia.org> <20230913171552.92252-2-contact@jookia.org> <20230914092107.GR103419@ediswmail.ad.cirrus.com> <20230914093731.GS103419@ediswmail.ad.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230914093731.GS103419@ediswmail.ad.cirrus.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-GUID: UHigTcmN-D1fbaxpxvzaZ8DMT4-fWt-r X-Proofpoint-ORIG-GUID: UHigTcmN-D1fbaxpxvzaZ8DMT4-fWt-r X-Proofpoint-Spam-Reason: safe 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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:45:11 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 lipwig.vger.email On Thu, Sep 14, 2023 at 09:37:31AM +0000, Charles Keepax wrote: > On Thu, Sep 14, 2023 at 07:27:03PM +1000, John Watts wrote: > > On Thu, Sep 14, 2023 at 09:21:07AM +0000, Charles Keepax wrote: > > > On Thu, Sep 14, 2023 at 03:15:50AM +1000, John Watts wrote: > > > > 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 > > > > --- > > > > +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; > > > > +} > > > > > > We should be setting this as a constraint in startup, rather > > > than returning an error in hw_params. That will let user-space > > > know the supported rates and allow it to resample if necessary. > > > > How do you do this? The struct with the rate is statically defined. > > > > You can programmatically add additional constraints, commonly > this will be done from the startup callback on the DAI. See > something like arizona_startup in sound/soc/codecs/arizona.c for > an example, that enables 44.1/48k rates based on clocks but the > principle should be similar. > Although I would also imagine snd_pcm_hw_constraint_minmax is going to be more appropriate in your case. Thanks, Charles