Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3949980rwo; Mon, 24 Jul 2023 20:49:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGPRfUqkIfkJ1Y67z0pzTKPjAYWzWl/It35fimHJR4HBq3FYhgKBGgmj+GYbTBQzuz4MmuY X-Received: by 2002:a05:6a20:117:b0:12d:5b6:7b32 with SMTP id 23-20020a056a20011700b0012d05b67b32mr7254697pzr.3.1690256947928; Mon, 24 Jul 2023 20:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690256947; cv=none; d=google.com; s=arc-20160816; b=rMOk4omAddN9jBUz9Aa+8b84mEkcL+8IlhDK8SvrvDP8l8mbNvFRhRRhx1ooYHKxOB WaaL2dCGM0X2pe8t30+tg+KkXxYRPCsdEu5pIUvvQMFtZjjdLTbKtLxB2pVDiLFr+ZYg 8RHLugf1lboBRS5QCUU/bUSb7GDpxU5J0C+UFHsTwNjj8+/dGa6lz404j8RDUOa5h4Zu 2DZtDVffUAB63wEHFroZ1yrk/hHgyfHWInjSRAEygdnXIbVDjfQJDdN72VoMQkJD3WQX ohk2K3Fa9k8TU0Cqwz30GAlsLNmebnZLHmmrqhyJc3KW6AgJCV9/zq5YJPWt0Ewe6HoJ R1bA== 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=z68fCq2ZuHitXC9DmrURIaybjzyPCYfC3/izUUA0QtY=; fh=Zah5MX43vfshi7s92Ld+vn5YZO52CQtO4oeiq16jPIc=; b=H4HpNR0yYQSRIcewOWk8CY88zkI90dAChi2z2XMLU1qqXjrt1ofQ3qmvFFoKBaThlg h+AGx72xGAHUdYJQWnN76jf1jc5Cb6Z3Wdvp+3VzqoLZy1X/DClmSBrOhE+f7z+lTaS9 XvgwETd1tyw005nryTqQUfAe+8VGf2VNTx+Trx6GuZDFKx7fgiYYDIuvtmFrHK2acpM4 AsRUEDKHgmbUjipiwZG5soHaElAvBpdoOvzQjNsYqZsOFGw/0e2qBrT1pUE+UtqLBUuQ gGnS97T/4qBPzgPjJ9hdkjqpskUFJi+SZolwUUWPnfgZ5x/hVyql2ZiGjKpqUeGQu+VL ApCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jVsuxGE+; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li11-20020a170903294b00b001b86c526fd8si9800289plb.448.2023.07.24.20.48.48; Mon, 24 Jul 2023 20:49:07 -0700 (PDT) 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=jVsuxGE+; 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 S231185AbjGYChw (ORCPT + 99 others); Mon, 24 Jul 2023 22:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbjGYCgJ (ORCPT ); Mon, 24 Jul 2023 22:36:09 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB973173B; Mon, 24 Jul 2023 19:35:27 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36P2T8Xv004690; Tue, 25 Jul 2023 02:34:44 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=z68fCq2ZuHitXC9DmrURIaybjzyPCYfC3/izUUA0QtY=; b=jVsuxGE+jSQCtJW9CTE+HMbCxZmZxBkBcbhJ8Bc2zgl0bs33sio+d/kBG6iZv0CWEiMf cn8NC+YJLTPSzNr7gMs6FnTjjaTtBApn+0SCdZyRjt2Ih22BTJ6ZvuTiZYaPSdvGh0wp 3e6l3k+Mbxp+4+OcESrXZyjp2ctSNJRAuzojwvgNA0oPSGxqJQ7vO0jkydOL7utTg3O3 E67rg2k6EnnUEW09eif0oWEDyf+0Fmt2KvfxARH21uAPBC2AyJvViblXWQA3EO7QlLvO iHWZCBoIJCekONGdDHbrNGEc4QGuuqzTPmB3AxyN90fwJuJsDYlZO3WX87eYAangf0AI gw== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s1s1jsn6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 02:34:43 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36P2Yheh015135 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 02:34:43 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 19:34:41 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , , CC: , , , , , , , , , , , Wesley Cheng Subject: [PATCH v4 19/32] sound: usb: card: Check for support for requested audio format Date: Mon, 24 Jul 2023 19:34:03 -0700 Message-ID: <20230725023416.11205-20-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230725023416.11205-1-quic_wcheng@quicinc.com> References: <20230725023416.11205-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 1R-QArTOF-M_YbbnYKbt_CoeiCY3Buee X-Proofpoint-ORIG-GUID: 1R-QArTOF-M_YbbnYKbt_CoeiCY3Buee X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_18,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307250021 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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 | 28 ++++++++++++++++++++++++++++ sound/usb/card.h | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index a3fad66a3337..365f6d978608 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -142,6 +142,34 @@ int snd_usb_unregister_platform_ops(void) } EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); +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 = usb_chip[card_idx]; + struct snd_usb_substream *subs = NULL; + struct snd_usb_stream *as; + const struct audioformat *fmt; + + if (!chip) + return NULL; + + mutex_lock(&chip->mutex); + if (enable[card_idx]) { + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + fmt = find_substream_format(subs, params); + if (fmt) { + mutex_unlock(&chip->mutex); + return as; + } + } + } + mutex_unlock(&chip->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 c48744724f7d..6d0f76ffec9d 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -216,6 +216,8 @@ struct snd_usb_platform_ops { #if IS_ENABLED(CONFIG_SND_USB_AUDIO) int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); int snd_usb_unregister_platform_ops(void); +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction); #else static int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops) { @@ -226,5 +228,11 @@ static int snd_usb_unregister_platform_ops(void) { return -EOPNOTSUPP; } + +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 */