From patchwork Sat Sep 16 00:10:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 140903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1453271vqi; Fri, 15 Sep 2023 20:16:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjAQ8bTz55E4SLsukGV1fFCiNa7rjmhBma7NPhiHAggHDqz3W15R23efUMMp6Iuq/wgI3z X-Received: by 2002:a05:6a20:4428:b0:134:4f86:7990 with SMTP id ce40-20020a056a20442800b001344f867990mr4911896pzb.3.1694834206015; Fri, 15 Sep 2023 20:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694834205; cv=none; d=google.com; s=arc-20160816; b=ctOCcVsBxj9azR7kxIRau4eD9yco1syMqIfZkv1eQkP9TxnlTL3I7eYe8M6zEV6F29 SBYfDdVEddooluYdnlSycC19RmHih9K5EUefx6zzL6CKZKwMWeLI22tqC0ViM1tUQtiS ZH0VC93Ss8Xhf7QLG4aMbbegd1sOxv8vRfMmeMHy+FaZiw5899Gc4BWPYpGn3xAL5laq CwCXu+/xC1sLFMzBJRgCfLmzWaaV8DGDpm7oI2jpikY1wU6iJnJOsGl8qzZ7xwWcyyWn XHuCYcjKlKtmPgRQdQS+Q1udh+JP5yRcOXzXHVM1L6QlTFgzDHzDeaOp7KSyCO5GTmPP KjVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6ANZFxpwb1E6/2h3bsHO/Ac0s+q1tJrilzF69+2JslE=; fh=MhCCCRx4c0AeUz43uLzZOKA4YzcBN2mk3tAWrRRVvW4=; b=Tu9db+CtFSUwXR/qrP9kPV147JkjeIKSEmXVfePLwMzs4emfwpx9D4FiPCjK4//G6W np31IZy9+4NiRI3PJ4IyxqzRcB3HvnZYvPWbN/K7awyuTQWUk61rnqXbCCwilhZCRjMI 1EOwDMwGCtDOS8JsGhDqflnDGzLfirzy6VYb13Zh+ATN97Ti02MqMKjG6RcxDbuGQ2eF r8DXeoFskVxTAYAUJmjAEOS8MdlM9G4aQJJZTeyymE7VPNIJdApf5CXPXv8T3mZtBXlL vn4NqO4AmS1YLW8Z7W/WWg6thpEMl/yDFk5Q3gK3y7Mjer60pME/ijZV03FH8bgSubCa fx6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nhp+PVuo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id s18-20020a056a00179200b0068fd642fc14si4309211pfg.396.2023.09.15.20.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 20:16:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nhp+PVuo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id CCCCA83ECA3C; Fri, 15 Sep 2023 17:13:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238205AbjIPALQ (ORCPT + 28 others); Fri, 15 Sep 2023 20:11:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238212AbjIPALG (ORCPT ); Fri, 15 Sep 2023 20:11:06 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70EC226B8; Fri, 15 Sep 2023 17:11:00 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38G0AlLj010571; Sat, 16 Sep 2023 00:10:47 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=6ANZFxpwb1E6/2h3bsHO/Ac0s+q1tJrilzF69+2JslE=; b=nhp+PVuo/jfIgAUi5EaF0A2V8PeT/ZvEkQA5ABlMcULayFIPiok8pEza7Y+7zSR/EhgI 1YwEp2PDrKUwa7xYPb9EhIs9jxmeiFx22e0TdFzvhuJWoabYayqNvyD8Ojcinn/HGBBh ftid1m+VKKRmpjccUzJI7LrHamYwbf7EQtZC5jHDLP2hV0xLQ7h3sUxFp5d+1vpGDLTU 0uNx6I9HTxkUvWKR30q2yiz+NiGQZZpYqPQtS52HBLhfFmN5lag3x6td/vuFCH6ltmuw Y4BvH/CLGo34PsL0DLveHT5HsjAHrB8bHBjwtZgTd1x0R2/gHV50Xm7YRi65qNxxa0gX QQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t4g5tjcwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Sep 2023 00:10:47 +0000 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 38G0AgNB011925 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Sep 2023 00:10:42 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.36; Fri, 15 Sep 2023 17:10:42 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , Wesley Cheng Subject: [PATCH v6 20/33] ASoC: usb: Add PCM format check API for USB backend Date: Fri, 15 Sep 2023 17:10:13 -0700 Message-ID: <20230916001026.315-21-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230916001026.315-1-quic_wcheng@quicinc.com> References: <20230916001026.315-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] 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: DTHK5usowK2AGM4sUWUOy2On6hQY8PS7 X-Proofpoint-GUID: DTHK5usowK2AGM4sUWUOy2On6hQY8PS7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_20,2023-09-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 mlxscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309160000 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 17:13:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777162472245009479 X-GMAIL-MSGID: 1777162472245009479 Introduce a check for 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 | 3 +++ sound/soc/soc-usb.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h index 1fa671924018..4785ea165e2a 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -37,6 +37,9 @@ struct snd_soc_usb { void *priv_data; }; +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); void *snd_soc_usb_get_priv_data(struct device *usbdev); diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index b5ab2c1a6dd4..619f9bfd6999 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -74,6 +74,19 @@ void *snd_soc_usb_get_priv_data(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_usb_get_priv_data); +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_add_port() - Add a USB backend port * @dev: USB backend device