Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp34512lqp; Mon, 10 Jun 2024 17:15:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3neL5mQ96LqL2hB8CsVv7PE/PMXeVHkYxRTYZk3gHEp1NrbcWrFOBzd+m/H/Br1Or5pFmVjepM6/WQY7r8U4zoc1S32iW7IrKquCC1w== X-Google-Smtp-Source: AGHT+IFKrmnD3TMzMe8uJjP7rdBENUrvVlIlcOfmMp6EFOIrUssjD6jvHrxR5v+OrWFtz7vAmwDJ X-Received: by 2002:a05:6a20:9184:b0:1b6:a7c5:4fb4 with SMTP id adf61e73a8af0-1b6a7c55844mr4604976637.16.1718064919326; Mon, 10 Jun 2024 17:15:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718064919; cv=pass; d=google.com; s=arc-20160816; b=BldTEIRhzpnwIu97CmF3Fj8g+4RY/YsC2ZUFQxT8MbK8ZvtcacakZp/Mc9xNjHrsLV bmK2pGDhh2M2PN9bcZTi38ksQA++LLdbt+8bxV+KmjoPCHRa7naN5Qg//FiHi+6CglqU gnVetjv8WNAO5iTdb5/UjHTTderkUOQ7Zs6atxSJlnwQ/PkREQADv69EeZo2G4exZp0/ eMo0CLCSNbSd4FSnkABzSjhMkQa36fXPpNCSOC3TKoKMOaeE8IU8vo4i3TuUUjHpnTNv uDVFLlanAExSKcjFmLD6NUbaMVTKBntmTiO44c4UUdOfwvZsvKiIVO2bwZnGtJ88tU/G 4GmQ== 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=gkgwHI3kwei94J8pWmry7o76uKy5cIhhnmC7ddLvP80=; fh=wtHMo7F9o0E380HmQ3oEdtbLMOdVnxgjuxg3Tsny7VY=; b=YmlDNurSyxvhezdbjIK1LuuocpoptW13y3YXEeO9PVe9eLijO/hJLXPborW+/eR5Oa 2eGqIz+fzGgT4vJR5SQDmjwyfLXb0DwK4j5dyAjEt0xKlmXIgBT+4YAQPJOtHl6lA38J jPnTSgiCZrJIDAwx6LIo6RztAMs9YgH2/EqimPP3sRNDnDhwyBlvXvrLudUqsyWcHRjP 2jCB/xpbHqcxqBeyi3RM6TkvluQPzsGHM/PhWRXkV8/0AburGnnEkHLfuA5QYtSHR8kg ONiOouWhQMU1d3mRT0dMum0Ht4gk+ztbzn56W731ZBerEte6yleB5GxYW4QYu5p8x6UE Pw5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T4yPgJHr; 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-209100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209100-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 41be03b00d2f7-6e443b31ee3si4724805a12.30.2024.06.10.17.15.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 17:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209100-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=T4yPgJHr; 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-209100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209100-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 EABDFB225ED for ; Tue, 11 Jun 2024 00:08:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C61A1667C2; Mon, 10 Jun 2024 23:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="T4yPgJHr" 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 59C3D15885E; Mon, 10 Jun 2024 23:58:49 +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=1718063931; cv=none; b=GQj9wSbvu24VIEtCKpzf6UyTi292LHjbo9yQslnqyE0gibEtroMIYQY5kDF/IOzVZg4yKc4+KlgokQouc+OvLZXEEHkuhywNoTAOfN4hDcADqoPgeH67w6CEYkZELsHYfGs14ROLtmDGD3mwhranVTGhXou6KJ301kBGgQist4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718063931; c=relaxed/simple; bh=gFU1ePwlYhlzYWUxRjQ4ycd26Pc8/+kgoUs3ozS2g5M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fKsq/c76NHhT0djWYplsFUIXXoQM2P9BGdO7tgCAQCAsgUlI4fU28ZsmEHDdUfhd9UY6a4H3XiQ4AKWPUYb7sKwLx3QIKkGQCtnSf5YUThISwgqpnTyZFkdmJ/K/4feamPJ1rJ0OGIr2+KCR8KUgWEfTCNEirndiUPFOh5b3T9k= 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=T4yPgJHr; 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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45AE192L012940; Mon, 10 Jun 2024 23:58:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=gkgwHI3kwei94J8pWmry7o76 uKy5cIhhnmC7ddLvP80=; b=T4yPgJHr7Ogw6D8Z4KI2DUD8ZHfN4Y1V7frBNodt 3oaOAlIwAxO6elalLvApLt5jwldF99C+9/A241rzbVaU+ouxCn8/h95jPIEfPPfi d5KxL2lAnjc0uD96nYe2hSdKmjmCO9c9WQeP0OuZduVVvkFW1wV44iwm9gz+KUUn R7dFSKdNsMoRBLqFaBdDDbw7eXkBMOfkA6LdIeS0CMqMtg3sd7e4UKvnNXKzOFEb S56m+zo2zkE7Y0k9Ww4Rvb5CpAktRL9PxQ4SrRwpUKiF3Q+b1ujdiPIAafq899jK Y41XuB/UrIKTv5uh3zaa4U5KbVcMHTOI8WerSbPL4YoIhQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ymd0edf5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Jun 2024 23:58:24 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 45ANwN6p001499 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Jun 2024 23:58:23 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; Mon, 10 Jun 2024 16:58:22 -0700 From: Wesley Cheng To: , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v23 14/32] ASoC: usb: Add PCM format check API for USB backend Date: Mon, 10 Jun 2024 16:57:50 -0700 Message-ID: <20240610235808.22173-15-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240610235808.22173-1-quic_wcheng@quicinc.com> References: <20240610235808.22173-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: qHhRMsVIskDGmY-oCEMXazkTDMBeN23X X-Proofpoint-ORIG-GUID: qHhRMsVIskDGmY-oCEMXazkTDMBeN23X X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-10_07,2024-06-10_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406100177 Introduce a helper to check if a particular PCM format is supported by the USB audio device connected. If the USB audio device does not have an audio profile which can support the requested format, then notify the USB backend. Signed-off-by: Wesley Cheng --- include/sound/soc-usb.h | 9 +++++++++ sound/soc/soc-usb.c | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h index e8fe4439c234..4b1b992c8b27 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -39,6 +39,8 @@ struct snd_soc_usb { #if IS_ENABLED(CONFIG_SND_SOC_USB) const char *snd_soc_usb_get_components_tag(bool playback); +int snd_soc_usb_find_supported_format(int card_idx, + struct snd_pcm_hw_params *params, int direction); int snd_soc_usb_connect(struct device *usbdev, struct snd_soc_usb_device *sdev); int snd_soc_usb_disconnect(struct device *usbdev, struct snd_soc_usb_device *sdev); @@ -55,6 +57,13 @@ static inline const char *snd_soc_usb_get_components_tag(bool playback) return ""; } +static inline int snd_soc_usb_find_supported_format(int card_idx, + struct snd_pcm_hw_params *params, + int direction) +{ + return -EINVAL; +} + static inline int snd_soc_usb_connect(struct device *usbdev, struct snd_soc_usb_device *sdev) { diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index 8490715791a5..3bb66808f196 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -74,6 +74,31 @@ void *snd_soc_usb_find_priv_data(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_usb_find_priv_data); +/** + * snd_soc_usb_find_supported_format() - Check if audio format is supported + * @card_idx: USB sound chip array index + * @params: PCM parameters + * @direction: capture or playback + * + * Ensure that a requested audio profile from the ASoC side is able to be + * supported by the USB device. + * + * Return 0 on success, negative on error. + * + */ +int snd_soc_usb_find_supported_format(int card_idx, + struct snd_pcm_hw_params *params, int direction) +{ + struct snd_usb_stream *as; + + as = snd_usb_find_suppported_substream(card_idx, params, direction); + if (!as) + return -EOPNOTSUPP; + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_usb_find_supported_format); + /** * snd_soc_usb_allocate_port() - allocate a SOC USB device * @component: USB DPCM backend DAI component