Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1431721rdb; Fri, 16 Feb 2024 16:23:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWQPto2eodq+Cyskwp6xikL9GKhee74Ae5tNdk0e3fABWvsXYZLlp8MVknvjK+nV8jW151zeLYxm/tsByK4aIp9FNOPLHQ2cWyZMiyeVQ== X-Google-Smtp-Source: AGHT+IH3qHFBy8Xp7whmSv674/2nNd0VeJz/yvUArRC+ooS8yfn+cvfnBqIFQImBAqvEvc/Hmo1a X-Received: by 2002:a17:906:c2d7:b0:a3c:9bc7:7a0e with SMTP id ch23-20020a170906c2d700b00a3c9bc77a0emr4390724ejb.9.1708129420881; Fri, 16 Feb 2024 16:23:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708129420; cv=pass; d=google.com; s=arc-20160816; b=I8MdwqLYhX5wD1xzlMGCZJWsLWdYg8sCsg6raJlRa0XaH5aAArQRJ7ZNUqZnHNYaOE 76Z0MOcwaI2ctHx0CLmuxA5e2q3CzVfhcP12QPtgkGla8zKbdJkq5hDeNeXZA6Fb7/ej HFNhd8SiNA+bEZ0h0iw7j5hJZwq0X5VUGIvsrA5sFLnrPb3oz1mqLDJjYJvumVw/DOOu 15omEwhIsfIC5gDdTdccFfhklIj6sqwKxlwqaNNyCKad6t3SsmksDtZD8iR1rSe0PQRn svm4V1/TT+qek7WIZf8+y/Fbzo1Bcm4+QW/RrCUK2vAzuil/f9kKYH2Hsdzf+ZPsLPo3 B2mw== 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=3bwLuYCMG73fmLRYggLzUSc2Pw8XejmjpquTCB1HSg4=; fh=VKrp0Y7I/+wT36BfKZ6oI/4N9BIwFCn9zerObkOrgGw=; b=qC2sHxVz2LqeogIfywR6fhtw/6vBVdgEtjk8VvCZ4LbV+yUCExlL389Xs3NPez01WT vovpzQYWoejGpKSZ8CKayNkd3sNhShvU7soVUXpYaOrsdM8srZ8tjqlIrys5MmGpZCdD 0xJkEJiVlKTEdD8ofVi+xqZO44HBeC0ScENI/+ekA9JuMERrXfJPHV9Zw3vzOjGJ0QqC /m0LedcS/ydHp0moIW2FkVmPMr33Qb5sr08jaPQzyiqUOBv0edud4fOOJzT3EzLt5xag nEHa1+KlK2kOINMffwE6mzVY5yl3VLXTWwSeHXFK7idKDB+oqok2rclk9GOYN1ztekHD b8Pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="g5/SemVR"; 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-69563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gz2-20020a170906f2c200b00a3d5f9f8e7csi358422ejb.1013.2024.02.16.16.23.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="g5/SemVR"; 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-69563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69563-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 78DE61F2147E for ; Sat, 17 Feb 2024 00:23:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96AF77F481; Sat, 17 Feb 2024 00:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="g5/SemVR" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 A7C2350A6E; Sat, 17 Feb 2024 00:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708128665; cv=none; b=oeGfBhTnXJ7M9KbhP4a/1sWNyyo3QP+1n25zqGUc8XjnNUxTFXOYiFIdMNRBV/EPbpjUqoqIx2IkQ+Ie5Lcbw3cfRzC/0HesMIqL7jYPYO1yqArOXtZuFAlZArdYRkKS2cWvLSr65I/WK6bAHfiZPozqocueJyoxOVBjCyRTbXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708128665; c=relaxed/simple; bh=4lnx2mrepTwqsAVALf/CpfYu3ABkH0WHKcZbALGTiRA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=om8ScMcXKDGYK0dSSCW5ddvod63m29YuIhNPJjLJjmefDiAfeLT5885ukBnr8/IisZH15xoBl8O7tDLcH6AG05XlMeJoaaPNg1tuOkJdnygwagJxGy21FwUuJ0M2PrSgr33922aHS4v/Y/qPLi1Bqz5xSeQp3oOEHMGTuowb9ok= 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=g5/SemVR; arc=none smtp.client-ip=205.220.168.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 (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41GNrwXI002078; Sat, 17 Feb 2024 00:10:39 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=3bwLuYCMG73fmLRYggLz USc2Pw8XejmjpquTCB1HSg4=; b=g5/SemVRBqBRnch7kMzThbX9mKdNXa82dsww 3LQtD7fBpVq3GnA5NryCyLIWDOw7zihNcTfDSbmr6UuILwSsxKUI9+Qin9Q7vk+1 Xm+U8XqClTLn3dNtu0sowYBKooohsx1wzvypGUbLSe7XPB45Sd6pp1RLLxdfivyv W4CJ2I3Nh8usf/YagrxNxBRqZcngVI32E2ylcRFCZnZGVolsuTdMTnxVjX9SCukN K6qbsMCMM6xTCtflnVRx+vY6oS5JYUo+w8zNcoSXnzWX+4DJE+D6k8Qek5CGtJkq FJiBkvOxRwheS22CJITJbGn6d4yIcb8xejhIPGmv0NW0C2u7qg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9xv9j898-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:38 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41H0AcNP012916 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:38 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.1118.40; Fri, 16 Feb 2024 16:10:37 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v17 30/51] ALSA: usb-audio: Check for support for requested audio format Date: Fri, 16 Feb 2024 16:09:56 -0800 Message-ID: <20240217001017.29969-31-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240217001017.29969-1-quic_wcheng@quicinc.com> References: <20240217001017.29969-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-ORIG-GUID: BJKS9E6do4_EsoM1hFpxXBQphzuXes6O X-Proofpoint-GUID: BJKS9E6do4_EsoM1hFpxXBQphzuXes6O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-16_23,2024-02-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160189 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 | 11 +++++++++++ 2 files changed, 42 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..a03d0b5e242b 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -217,4 +217,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 */