Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1412806lqd; Thu, 25 Apr 2024 15:07:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjVCKzuI1RLZlS5Qw9uxeA4mPD3DUB7dTZGqYgsWzjxs3J6vDVCc2cMHuHLMmYQ5L/uzF1IsrOwayHyWpwJDCD/U1vM7olLPEC2BEPiw== X-Google-Smtp-Source: AGHT+IHPQ3CaYv7xriZaaAhjDF0CcpVa0soGKP2rTF9vhNyFquB0JM0jt5+l22svj6KN2Ot1giyw X-Received: by 2002:a17:90a:840c:b0:2a2:71c7:7e26 with SMTP id j12-20020a17090a840c00b002a271c77e26mr853629pjn.28.1714082832580; Thu, 25 Apr 2024 15:07:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714082832; cv=pass; d=google.com; s=arc-20160816; b=z/tiODC6cefJfcJllJnDms7Dn9K/g/cJw0nBmdA564dmFI5baAErvoz7iJcPVQoNCV JdjaKzcBggoNlxg85M/KGg9OPWbyZ01incaJOlfalbTaFB3+uIMfaMs8GC8/b+o8dT6P S8QkT0e/x3v2JRZD93FNygpSqXzo6hxPMXij04VpAJGS5+PkekWPSwZPocGgSEJ0SgHj AxlYIrvdsZab1ddWXUAAUscakKfEG0HIC/fp3IFIq5/Vn+yzPu2koAP1aNtle+HNDFYT JeZKRcBLK4Hg38MrgwIKKP4gTUFeR4938+F2XdGW8ONNuOadp6OAbITaYtq0RiEnHKTx QOFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uxQbOrCLKFSBlEbrW7J90CdIysG93sYR5VFMrTIX9B0=; fh=usWEz1eJjYCle08WABmDyuqCrJGq9m48/LVlmybnzRs=; b=hjuMkPdSWN26wQFVEv60pdbvioHXPZnATh8ouw3528vS6jjopLP+O8nUjgITZ9RlZW FmWsXpxDntOFRVuCGJ4Efu+sYrLnKGBQ8xqBaPDTQGFU/Sy7OjYP6gBEnBM5kt3qnoHm Y7zNILr9EyIKnefvcq6xidoTlSsZ2qbL9VYYA2f+LkqxPf2FInsMnwUU+a6kwgdey8+2 STptSwHmkbknUzjPKpC4TBm7qGDC9NRwazB5fQz1NAM+CGKzh8Zza16tsqI/IaLf03TT Wc8pL9Z6RGQQx9pkWPcno0eDDXv0JlL5PzNFtXcMNOMoh3wS6cniUJX7X3b0h24VTJKp +Yag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=O3xVm0gb; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-159248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9-20020a17090a114900b002a5566ccf28si15276268pje.50.2024.04.25.15.07.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=O3xVm0gb; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-159248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 81D4CB27408 for ; Thu, 25 Apr 2024 21:53:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DFDA15ECF6; Thu, 25 Apr 2024 21:52:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="O3xVm0gb" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC03B155A27; Thu, 25 Apr 2024 21:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081927; cv=none; b=uM8JJHhM6broK9BhC1+TyiuDv8dN2Hx+cglmVR63hK//jHJRH9ti70GqivRxTSrdNpkQ9zHfjYCzPiCUqfP2VZLIqFRUcydP1MeFQy9B7ltR4VEZVufCLtR4EGp6MqFpw37UyDBX4VBVY/4a3f+lFqPAb5MKeBFlKutnDGF6IO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081927; c=relaxed/simple; bh=IQZWERZG+85eUZHZ4qNMhcg3Lt1vXI3rCcAPxn3UFc0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CxwA2QAY1YsJ2IqS+8APIBmsqMo1380TnZC9S+YvsH3N6h3B9o/0rhK/Bms0mG8kV/PaktcOer5dmGerhSJonP+3/TzbsiPF4mZG+qAmGvmV04nEknKDXaTShTTkLfeJ0x0kmzS89NRpwUKE+IuR3GZ3QDhbpCblHvS6gZ/DcRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=O3xVm0gb; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43PKIYQx002674; Thu, 25 Apr 2024 21:51: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=uxQbOrCLKFSBlEbrW7J9 0CdIysG93sYR5VFMrTIX9B0=; b=O3xVm0gbOgeQnVnnGEMB1TyDf7OSlm0oWnUx AzByLl9ou2Gc7CbYqub9IJ6zdxlUCAFruKAelWCxMHjY3i+FzNODiZObxYALuiuc GW5H4m0hCUg+H6AEnlwS10s0g8JJPnq3T/9lVyyovqA6kZZZD+/AdwT1qRfjbxgp bPKeepfhOZ39i35J1tR4KhXTz60v5gpWE4Ws/XkGmmuS13mSi7e5EoFFtdlSWmKX qRRMc6xJXjHo7yMWtIlTnyOq4IJttc/0K8ANQ5P5g8vilDHGLt/Lm53Y1IP8Rhqd G1E7RQHwgI55xMZ3ZwUD8hSKr9vA3hwPcGCOQgH/xznX6k8QDw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xqqtf15jw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:44 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43PLpgNx011208 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:43 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.1544.9; Thu, 25 Apr 2024 14:51:42 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v20 21/41] ALSA: usb-audio: Check for support for requested audio format Date: Thu, 25 Apr 2024 14:51:05 -0700 Message-ID: <20240425215125.29761-22-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240425215125.29761-1-quic_wcheng@quicinc.com> References: <20240425215125.29761-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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-GUID: v_66yMph8dPqL47PWKrzVz-hb8f3VCzQ X-Proofpoint-ORIG-GUID: v_66yMph8dPqL47PWKrzVz-hb8f3VCzQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-25_21,2024-04-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404250159 Allow for checks on a specific USB audio device to see if a requested PCM format is supported. This is needed for support when playback is initiated by the ASoC USB backend path. Signed-off-by: Wesley Cheng --- sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ sound/usb/card.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index 7dc8007ba839..1ad99a462038 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -155,6 +155,37 @@ 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; + struct snd_usb_stream *as; + + /* + * Register mutex is held when populating and clearing usb_chip + * array. + */ + guard(mutex)(®ister_mutex); + chip = usb_chip[card_idx]; + + if (chip && enable[card_idx]) { + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + if (snd_usb_find_substream_format(subs, params)) + return as; + } + } + + 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 02e4ea898db5..d66cc0b139af 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -217,4 +217,7 @@ struct snd_usb_platform_ops { 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); #endif /* __USBAUDIO_CARD_H */