From patchwork Fri Dec 23 23:31:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 36347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6000:1b02:0:0:0:0 with SMTP id f2csp32359wrz; Fri, 23 Dec 2022 15:34:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXt8O86IZeHpa0GP5rhkR7rA6TdyhnOfi56EoOoL51EpWVTZ05tPKKVRVc9i+Qve4opfGNMU X-Received: by 2002:a17:907:6f18:b0:837:3ed3:9c2b with SMTP id sy24-20020a1709076f1800b008373ed39c2bmr10003887ejc.5.1671838490692; Fri, 23 Dec 2022 15:34:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671838490; cv=none; d=google.com; s=arc-20160816; b=dl+rNi+53ea95unAr0rEn8s9f5SiDbb9/M//kf7qVLD6M69bjAqyER6sxLW93APJAW o90FP+YZvsVzzjt1P2Grr866q6NfsfNZl3CZRYr9tNO+akwqyo8LV28SVKSrbuXy92ct ai94v0TP+zIoB7PsiqYJa5zrKAhe2AR9HZKV6UzrZR3t2WwDiDx+TpUBVXsS5SFy1nU4 4aEHJLEa6cwooWNhqUt0/k5Fg6jEp3XIEToKw3m+9C/WBiB8i+Jkl8LU1Gd+3bCBfVAU NDt5HtCpeQUDmk+2Dwn4AL1+C2dT5NWzbKhrLaU6e5qqdj2/WCATlbGRhB6WUMx6hkuF umsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hTI5FHC1YAemhozMegfqvLXGLlmKwd7KUrOXylR/oc4=; b=wutgJ+JfBmK03cAvQI2W0o2iUmrkiFVSXqKDLdIHhmUlkeCAG9lPHmXG85uY3/4UE0 y8/aiHNcijwlsk4pZ4O3r03JoMic/iba+OS/iUJ4BWmi4lvggogkCEOxPkv3m5HZGpA2 u0fN0p4fsZmdDJ9HLe1PIQDqtheju2Wbom5Ld+H5musTG7INw4hHr2KGgQbEHzUt4p4/ 67JLUvjcsQQ9BwD4r2FSsrnEX1Bh+R7r2zqSq8Iqi0JHV55Hpv/dOIQaI06aOn55BgH9 xjyKv2haSQ4/SaulB8dMW5GqfSGLOvho3trhjNcc2BxOFdF1CtJjcQE9PJeZdd3BkDxv q36A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Tv9gXXHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a056402281000b0047920cdf1ccsi4434708ede.73.2022.12.23.15.34.17; Fri, 23 Dec 2022 15:34:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Tv9gXXHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233543AbiLWXdk (ORCPT + 99 others); Fri, 23 Dec 2022 18:33:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231757AbiLWXdN (ORCPT ); Fri, 23 Dec 2022 18:33:13 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD98C10FE1; Fri, 23 Dec 2022 15:33:12 -0800 (PST) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BNNRW5f026949; Fri, 23 Dec 2022 23:32:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=hTI5FHC1YAemhozMegfqvLXGLlmKwd7KUrOXylR/oc4=; b=Tv9gXXHzolqDQ+A3DaaETNrc301xcPACjVAHXzaGyvzkTbXvqDVw/jShEUQuMdJK371N +JJ3m4xA9tYnrEyF1UkuZxUtLdgHul9irhsasJkuuBnCFDorcKI+FzzfjMYYOfWgUQd1 2NDunGRYBdHgV6gTmBjtJ3nEgHQedwrMcct+LN3thBSvfpzD1EUy6aB8YJH3zRqRO45w gUGO12CF/NXsLxh7xbuBqWHfsV/iAhOHJDw5TtNiK+RmdVlATpGaY49z7z8dc0GnrPNU SjdLgoXjOAnrNdg30eGvXb+FLUuMXjNTU3rv4mNHokVVh000eLVuyt5WOXFHtq5FNUIe +w== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mm2brx5g8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Dec 2022 23:32:47 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BNNWkmd001854 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Dec 2022 23:32:46 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 23 Dec 2022 15:32:46 -0800 From: Wesley Cheng To: , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [RFC PATCH 10/14] sound: usb: card: Check for support for requested audio format Date: Fri, 23 Dec 2022 15:31:56 -0800 Message-ID: <20221223233200.26089-11-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221223233200.26089-1-quic_wcheng@quicinc.com> References: <20221223233200.26089-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: hEsPdu6rderHJlTTpN2IAY96ibDhSSSt X-Proofpoint-GUID: hEsPdu6rderHJlTTpN2IAY96ibDhSSSt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-23_08,2022-12-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212230197 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753049717157796715?= X-GMAIL-MSGID: =?utf-8?q?1753049717157796715?= 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 initiated by the ASoC USB backend path. Signed-off-by: Wesley Cheng --- sound/usb/card.c | 19 +++++++++++++++++++ sound/usb/card.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index 396e5a34e23b..9b8d2ed308c8 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -133,6 +133,25 @@ int snd_usb_unregister_vendor_ops(void) } EXPORT_SYMBOL_GPL(snd_usb_unregister_vendor_ops); +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction) +{ + struct snd_usb_stream *as; + struct snd_usb_substream *subs = NULL; + const struct audioformat *fmt; + + if (usb_chip[card_idx] && enable[card_idx]) { + list_for_each_entry(as, &usb_chip[card_idx]->pcm_list, list) { + subs = &as->substream[direction]; + fmt = find_substream_format(subs, params); + if (fmt) + return as; + } + } + + return 0; +} + /* * disconnect streams * called from usb_audio_disconnect() diff --git a/sound/usb/card.h b/sound/usb/card.h index a785bb256b0d..d4936b6054fc 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -213,4 +213,7 @@ struct snd_usb_vendor_ops { int snd_usb_register_vendor_ops(struct snd_usb_vendor_ops *ops); int snd_usb_unregister_vendor_ops(void); + +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction); #endif /* __USBAUDIO_CARD_H */