Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3467103rdg; Tue, 17 Oct 2023 16:23:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQcPZwrql1JD0Lp5Lmci0PzlpCQRL1t4LNKPLEkRSBiQ1w6oCbcjI9QX4HryYY9/didhTb X-Received: by 2002:a17:90a:474e:b0:27d:20f5:3629 with SMTP id y14-20020a17090a474e00b0027d20f53629mr3520423pjg.46.1697585030308; Tue, 17 Oct 2023 16:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697585030; cv=none; d=google.com; s=arc-20160816; b=ehDVkcqLw403W2U5IroxVnrvMOQ8G/DetkQf8LyzCQ/HnbCokuOljWMnWhmWCmQ0kl 0YuQ26e7SyeCMKUtKu7JNwlBOTYIHYVc0YgArruvIIt/EsNPofKDdHBDr9MTXiB9S0S9 E/hOi099YzeiUFWPrIFVxo5Ogz0lZdANWkasnNIKmbed7kRM0y/5faB+ISqOWEN+2N2W 20yNJWz2w/MB/6bYzrvvs7OB6wNBwmqXD+6h7RpzPymVNqvJixGQWPUV6RWUoxuukU6I oRwTBWve4lzBq6Te7TKmTStYoaQBxdjrSPkjP+cvXMq7bLz+64XtndSxwuCkx1NWwRM/ 75XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OI9CGbLP8YWr395p4M4BUgSAoDLpxHteGXY5voEOfog=; fh=T2kIl/luTXifFXsTyrv3SMMIMK/cqEF9ESJJzecA3Cs=; b=DbxCzRvYRiMZVlF/clCOjvdgqN1Q7hT0ChaUXE8JCC1dnllUdXa0hFj+aihOaQjVIg sfJMmBr+wmRUekkeA/YEFGPkM0U3guex9TQUYuN3SpENHsXSgMJgwjm24SeVRkokIadv r7sE6LJeRpeskFqoHomqwclqJTaYFlqYpqEEwKi4WnsREDuMGLwn8F2h4lPgPxYevPWC 4qcbmPpL1FbNc1Dv0TZ/t5JBDttup9HF+XajtcsCc0KBglrnoi7LW9uMoruGTXTZXM5R XLK5khrvx+i/lTI2yEjdY+MdPzHoyJxutJwPPkDP8Uidcc/3osd5QbEyZ2mfRnSl2RBN KAyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TavW5mbz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y191-20020a638ac8000000b00578b4082453si834093pgd.712.2023.10.17.16.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 16:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TavW5mbz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5A07D802843F; Tue, 17 Oct 2023 16:23:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235032AbjJQXXd (ORCPT + 99 others); Tue, 17 Oct 2023 19:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344327AbjJQXXY (ORCPT ); Tue, 17 Oct 2023 19:23:24 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51BB1FE; Tue, 17 Oct 2023 16:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697585000; x=1729121000; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=2UKUUSI67P7VTV+D5P7W1dLNBm5HCyoV51RKoH6boYk=; b=TavW5mbzx3lO9rKW69sqvxqM4dzMACsepUdqBnL3OVnk5KBuZOcxeI4B eS6guP+5eOYcAmg3r0m8R+VgICIuNUjltV2d0FDPg/Ka3eZ7MqWjsWYzO DFenq8G0jxHufCd4vp0gllAjzr6u35mL7oBqlZJ68pwXfKEj+BD+M1Xow ctV4/Pim70y7v/G3dauag9aD/I6vVudXeTHFSNELdEH00FUoJGXz1PhfQ byHWbqeE5vR+5Hi/HiYXljPW1gsBtdUxAxpDkz7QR/FKtFPYz6iNq9/mC xNG+YXBAObnoEQxReDh9u/FgNqGkIoaLrGhMYLtqCetOBkuJgqNpWS/wG g==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="384778101" X-IronPort-AV: E=Sophos;i="6.03,233,1694761200"; d="scan'208";a="384778101" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 16:23:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="826637465" X-IronPort-AV: E=Sophos;i="6.03,233,1694761200"; d="scan'208";a="826637465" Received: from asprado-mobl2.amr.corp.intel.com (HELO [10.212.55.179]) ([10.212.55.179]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 16:23:17 -0700 Message-ID: Date: Tue, 17 Oct 2023 17:29:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 20/34] ALSA: usb-audio: Check for support for requested audio format Content-Language: en-US To: Wesley Cheng , mathias.nyman@intel.com, gregkh@linuxfoundation.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, srinivas.kandagatla@linaro.org, bgoswami@quicinc.com, Thinh.Nguyen@synopsys.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org References: <20231017200109.11407-1-quic_wcheng@quicinc.com> <20231017200109.11407-21-quic_wcheng@quicinc.com> From: Pierre-Louis Bossart In-Reply-To: <20231017200109.11407-21-quic_wcheng@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 17 Oct 2023 16:23:47 -0700 (PDT) On 10/17/23 15:00, Wesley Cheng wrote: > Allow for checks on a specific USB audio device to see if a requested PCM > format is supported. This is needed for support for when playback is This is needed for support when playback is > initiated by the ASoC USB backend path. > > Signed-off-by: Wesley Cheng > --- > sound/usb/card.c | 40 ++++++++++++++++++++++++++++++++++++++++ > sound/usb/card.h | 11 +++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/sound/usb/card.c b/sound/usb/card.c > index c0b312e264bf..88f431917c15 100644 > --- a/sound/usb/card.c > +++ b/sound/usb/card.c > @@ -162,6 +162,46 @@ int snd_usb_unregister_platform_ops(void) > } > EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); > > +/* > + * Checks to see if requested audio profile, i.e sample rate, # of > + * channels, etc... is supported by the substream associated to the > + * USB audio device. > + */ > +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > + struct snd_pcm_hw_params *params, int direction) > +{ > + struct snd_usb_audio *chip; > + struct snd_usb_substream *subs = NULL; useless init? > + struct snd_usb_stream *as; > + const struct audioformat *fmt; > + > + /* > + * Register mutex is held when populating and clearing usb_chip > + * array. > + */ > + mutex_lock(®ister_mutex); > + chip = usb_chip[card_idx]; > + if (!chip) { > + mutex_unlock(®ister_mutex); > + return NULL; > + } > + > + if (enable[card_idx]) { > + list_for_each_entry(as, &chip->pcm_list, list) { > + subs = &as->substream[direction]; > + fmt = snd_usb_find_substream_format(subs, params); > + if (fmt) { > + mutex_unlock(®ister_mutex); > + return as; > + } > + } > + } > + mutex_unlock(®ister_mutex); > + > + return NULL; > +} > +EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); > + > /* > * disconnect streams > * called from usb_audio_disconnect() > diff --git a/sound/usb/card.h b/sound/usb/card.h > index 2884912adc96..e26292363cf0 100644 > --- a/sound/usb/card.h > +++ b/sound/usb/card.h > @@ -216,4 +216,15 @@ struct snd_usb_platform_ops { > > int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); > int snd_usb_unregister_platform_ops(void); > + > +#if IS_ENABLED(CONFIG_SND_USB_AUDIO) > +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > + struct snd_pcm_hw_params *params, int direction); > +#else > +static struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > + struct snd_pcm_hw_params *params, int direction) > +{ > + return NULL; > +} > +#endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */ > #endif /* __USBAUDIO_CARD_H */