Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1429265rdb; Fri, 16 Feb 2024 16:16:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUtucQigHU7yzBeakQqnzKr4si5O0+YLdhIVr057FtHo1zMZzLK+8eIgsuW2L1pp4SBrDKWKrUvX2X5NqaZXpdbSABIrOYIQAH6J6E9aQ== X-Google-Smtp-Source: AGHT+IF/hsQc6oYAO9dG2PG7MV98unS0X41ZPfiFiA8PWBYc0Wi+VVPs90MjXwEH4658Z/xeOeug X-Received: by 2002:a05:622a:15c4:b0:42c:774e:d63 with SMTP id d4-20020a05622a15c400b0042c774e0d63mr7880094qty.22.1708128996372; Fri, 16 Feb 2024 16:16:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708128996; cv=pass; d=google.com; s=arc-20160816; b=ZROgTWbKQ2jVFa/exgnfizJjLEA0YVQlX2ZZs7WtyynLOI17RC3g+SUcUJIiDdz11K unj1doGPH8f1DOQ9cVvNEGjZdYT6J4BVXJKrGNvWvQmhB6nZvk504GDGHK+NEc8QUg1a K439nX+oYHgZLdw1kJvzgBH/xMzAEbCyXxR9tOE1KRWkn+pgNdhSkvY7iyjWZIbbsT0I XWsSi//dTLnYR8/BdvX1XKUMj16w2W5Jy0j6BRbzDic4ce6smmngRq7wNyBYWPlvDguL DjT+GNOAmkNa4c4txu5zTPXCiZpdZhi99FEPg+lb0GfKhbu6ubydL0mdhxzFLvm7Cdut BHcg== 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=1ti0OFMlpvxuyvNxeli74aYR9ZNdqw1HmgshCcMPrxo=; fh=VKrp0Y7I/+wT36BfKZ6oI/4N9BIwFCn9zerObkOrgGw=; b=EdSBrXAa8LhfFOons2n9dJBQOSPFXP/eWhsWmGSJVwApLvB4Hnhwkd8bjno0xmXRqm eYDmQb8hB0D9ozN3zWlIMD6NhbuYWiAG7I53PnaR5zuBIWGrRmt7ey0v4U/0ktw6J5UC xQTVOO83XzGevm6s0FaZMZv8SK8huPRilrbTn3DXK+H70jWVKMh8of3OHma6ARekihDx eiCEqJzhJjU2bSgyhbo19bFdj9uZLzBgfPjE++dVDOH8iJ/OIGLttcrUWRdiGukYyAk3 PEsHkDfLSjXGWe1X7n8VW3eY62Av3alX5q16zrCJhE8DoFmbm/fi0FsgMEETBPBPaviw ip5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XcRtNr3S; 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-69535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o16-20020ac84290000000b0042dc8c49ff3si980696qtl.360.2024.02.16.16.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:16:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XcRtNr3S; 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-69535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69535-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2FEF31C2356D for ; Sat, 17 Feb 2024 00:15:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 112DA5476B; Sat, 17 Feb 2024 00:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="XcRtNr3S" 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 3D8711172C; Sat, 17 Feb 2024 00:10:52 +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=1708128655; cv=none; b=eyHJfwWc8zErjI+E68H8ljqXd/OlJNvSXU/It5kYE0dBKeLcxJvjCnLlha0PldMRnkJzw7LkMzzxzLi3Bt3fL7aWi8udp5Lx6kf/MST79mlpAX+UjfQwNJ7dEenoUhIjVp6dszbVklgA219S/OZrGC8F28/Nj+U5pY7E//SHWIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708128655; c=relaxed/simple; bh=7iOpsTMbqEwoi14/dcN8UwbNoAatyge1GCbT8mE6mNg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cTfDEcSDcCp5H6UN0JR6evii+0UePgKOUP5Bd5ytucnxHiaaV/df9dIThHUOp11Ox7N+Mxru+qAUu7uW0e1rynDK3EzClWG3iloaSO/dhYEDH1op3o+V/RK7TTeHbOr2kxRsZd3v++DC7UyVp3XnP1Ws3lQ1i3GTeW5+CWP8phE= 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=XcRtNr3S; 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 (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41GNgjQe019252; 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=1ti0OFMlpvxuyvNxeli7 4aYR9ZNdqw1HmgshCcMPrxo=; b=XcRtNr3Sv+u4lYS2guDopN6wfLLNMPdtnJ5J e9TP4JQJgA0/kDpFA1CBJtpuigDAn1AvMF/UsZ+p8ITRrq17nqfIyHY1fpum8cBz myepWPthQmDsBOa9SF+/9pUDsRbeXRBo59TfhN18yU3Pxh5brxjbMLb8HsXuTtLh wMBWi3i02ndz03UZQ40CaxRHcuXcYjI5gaFPFwk0lpO72Sb+vVF333ZMCYTOWdWN B8ghdGLOl1r/Er00gfAPxRKOQtcar4rpTFP0KQw7gzDTJ3wj+O0I7u9/USNUFhtW 79zYM252HBhSIFjAa3nNgPhUA68InoR64BUkYx/YNZNFmn5vUQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wa3bh1ub8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:39 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41H0AcWC011347 (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:38 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v17 31/51] ASoC: usb: Add PCM format check API for USB backend Date: Fri, 16 Feb 2024 16:09:57 -0800 Message-ID: <20240217001017.29969-32-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-GUID: 5cjBY7yNA7yyDL9HrVs2Z39vxOg-Jk6H X-Proofpoint-ORIG-GUID: 5cjBY7yNA7yyDL9HrVs2Z39vxOg-Jk6H 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 spamscore=0 impostorscore=0 mlxscore=0 bulkscore=0 clxscore=1015 adultscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160189 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 5b2fa0877523..8f2d3064b520 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_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_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 d21db2345966..bc77204fd2db 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -80,6 +80,31 @@ void *snd_soc_usb_find_priv_data(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_usb_find_priv_data); +/** + * snd_soc_usb_find_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_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_format); + /** * snd_soc_usb_allocate_port() - allocate a SOC USB device * @component: USB DPCM backend DAI component