From patchwork Fri Feb 16 03:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 201916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp288879dyb; Thu, 15 Feb 2024 20:17:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbKdNL0NhJJhsvsg5pPmVkEc3v0UeDaSvENVgQkV06ZmvKg4GSqCrhwsdfZgwxnG/ZMT77Z8FK4gUGxV/oyCvFM5Bkrw== X-Google-Smtp-Source: AGHT+IEqzBx02Fn54eb/1R+kdzcxRmnRHdFYiRCV6o1Q1Q+vOw53UoY3UDSRzR6w6v44YdSUHdzD X-Received: by 2002:a17:90b:400a:b0:299:275d:b677 with SMTP id ie10-20020a17090b400a00b00299275db677mr3060733pjb.5.1708057075469; Thu, 15 Feb 2024 20:17:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708057075; cv=pass; d=google.com; s=arc-20160816; b=Ji0D0sr1xdnvEcTds/t+DG7uTUwRTANmPD0JE1gt+xvAZI52zbA5rELKQ1P4sFIN5y 8vvxpBj2X5o2LbtC0Lc8LxsF00u4rmW9sEqoKpxz+9asfvr5KaAI8dNVAGbfUtwsuOPN hgS083vJdMH+7a78k8m7AAEz1GtcDkzI05SGKKIDVzpENuoV4w2hoQHcSkEsXNXsyaiN mQAOg2bVNfqR0g+wL0o+BJqsFBT0kpWB2QxE9+lhDO+5a9UakD5eYWvcXlhVpk9OwPNk rbWIygOExrqszC2prpccdXwj0vjT+qmhMW9rJEVefqDgI/xwOxf9AZQH29gs+zqwmsqu AsvQ== 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=RV0ybdn36Osf0McJvntYQHCyRAQTNn1d6AgGKDEdTLg=; fh=VKrp0Y7I/+wT36BfKZ6oI/4N9BIwFCn9zerObkOrgGw=; b=abUT7PhmxPmeYIAIV44CA2rl4tOOvLB0pn1p18qiF15RFTeV9TWDRtpsalumBXYQV5 4DjNUKanpnAUYPGJtn0RXrd+GNzRVciWIrqOuc7zwUyXvk8PJ+Z/q6OgJsDpbG9/da8l VGy6lQ8dlHpL/S52jVtQEU+59rmnsuosNALEMpOmUPpGhC46iqzQYG5eU6EO5UKUJSkY WwypET4z1CNV/l41c0mr00rtwaCe/AQX7qv7TByxtRgdQWN0BNfHyspwKAPwv6bkLosN 21RGrmyjFpiS2RGoODgyAyVW3yX0TV+S5ZZ2RtKhCcZKSytn+TrWTWQWMa3uXNB/eXVU VYOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iUkp2LYx; 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-68023-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68023-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jb20-20020a17090b409400b00296890c7545si4189373pjb.161.2024.02.15.20.17.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:17:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68023-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iUkp2LYx; 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-68023-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68023-ouuuleilei=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 81672B23E5F for ; Fri, 16 Feb 2024 04:12:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 219BB4C3AA; Fri, 16 Feb 2024 04:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="iUkp2LYx" 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 3D22A1B962; Fri, 16 Feb 2024 04:00:02 +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=1708056004; cv=none; b=R56hlHXSHPVYx9lOZdY/GwvyzC5ZbtsqbUkz0VVgkm59rwC1LoVNTgbU+X152fes6uayKetPu2KQ5cpCi2qTpSD8s/IlCUaNLal/y2oz+xpKYlpVKlg2WpU8P9iPjFHAkCg3/BmGvm29HT+TvQU5kCFeD+NWe3Bj2I1ejqVO2BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708056004; c=relaxed/simple; bh=9mxf3hDU42S3/KBOnWpwuNDTh+qkgMU/2v2wDqgDwRg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QWIr1qp/zSu8KI8p903Dz2BpRmvRtGALuE8IMA433LzvcXKnsbTtPFn5wb7xddK6UzH+4xzpcpp9KRvOJMnuSJp68YscRujOk/QuC5xLTv5HiadJ24B5yuWIyWaCzxTPg1h7fopipchYEDe5vqlMJpUoBhMKfAjiesD9oz8d1o4= 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=iUkp2LYx; 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 (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41G3eQc8005286; Fri, 16 Feb 2024 03:59:42 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=RV0ybdn36Osf0McJvntY QHCyRAQTNn1d6AgGKDEdTLg=; b=iUkp2LYxCOXSohBqT4dtwgmrwsv4LpYtuQWP O00JxqkpJ3NfgNoNp2l0Nsdi30xgU8clSmfXTvh0zhOlbI1gjeHq1tX1SSFnQDKM BIGqcfsY+oByW7h3QO2C4zJIwlM00Jvr/JEWa3PqL4mWMXZ5CrsNU00WMi4FKn7q GfvhrTubm+4mGWHkzERS8BhaGkiIVuI9b0ifiRkWNhdYrOniP0JDeAixub/URHQe 85sRY6gf25bCaZMF04G/2mbuk6ZT5NMuRKMY1maHJrCkvKR/oSMEO9+zLoTXHBRx GfDysKJannPe/qg4IbGDgc8uG35I2u7YeciHnXKrRAIdW6pzTg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9cd4ayge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59:42 +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 41G3xfm6032321 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59:41 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; Thu, 15 Feb 2024 19:59:41 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v16 31/50] ASoC: usb: Add PCM format check API for USB backend Date: Thu, 15 Feb 2024 19:59:04 -0800 Message-ID: <20240216035923.23392-32-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240216035923.23392-1-quic_wcheng@quicinc.com> References: <20240216035923.23392-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 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: aQxjnJ_qJkf0fcWbOisCSG9RmLlbg9je X-Proofpoint-ORIG-GUID: aQxjnJ_qJkf0fcWbOisCSG9RmLlbg9je 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_02,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 adultscore=0 priorityscore=1501 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160030 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791027655837387351 X-GMAIL-MSGID: 1791027655837387351 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. Change-Id: I36a49574d0cf6a66c9fec79ff461bcaaefeaf73f 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