From patchwork Thu Sep 21 21:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 143237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5391411vqi; Fri, 22 Sep 2023 00:52:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1OEjYFSPcUw96XNmLaqBMiYbMBFunEAHbz/QtuAlYkU2mUoJMF2zKHGiBWf5fdLzJ8hSS X-Received: by 2002:a05:620a:2443:b0:773:b795:c9e9 with SMTP id h3-20020a05620a244300b00773b795c9e9mr9341628qkn.17.1695369144037; Fri, 22 Sep 2023 00:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695369143; cv=none; d=google.com; s=arc-20160816; b=V49KiAami+VoxpI3Kihasv8mA9ynady3U7P0QDzE/KaEb30uiL31hsdUgLVE8mTvnh 8KsnHbyfUb00iHChNzkUvmks/sjuqHubjwndkU2Yzs0JWXSDVbWIEWsETjQQrS0B6pZJ iw0zht/ZbwRW6IpR27S4ytUkYUCtK/bHSDFxSGsOlSsFC3vyNrkmD26NJzWw+1fYvqGV q7fvuL88cjbPPHB2iS+9Pfhy8x4q7gI4jKpouNv9waEhlQk5hpBdbO4SMSDzYyVG8vNj XRDnW4deYOvAcJTI5Lx389FksHIBpAZ/XTfH827Cq9ubOBcCiI1SdXqrYM0Z1RHeJttO U8GQ== 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=RAn+Row8ZNiGWgBhNK4kTXF3KLbfKQxbMLwolNrWAymr5fYbH3Or72x4Sd8R8qredT 3G+Kx9wgM2YhCVVyz2hxFOPhzU3mm77zuHZWKYl7ROGmO7r9VRJ/w2RWepo686BbFzSB DYyFGS3DIK2kj9172dUbFKAdi8mFLoa3RqTuAh3I+xD16R5ZsbUpC1XRs7Vm3h334SbU U8yYNT9/SH9+DA/2Ypm0H9j4hT73LCWx1A8/1eCY56qYd4cmqmbmhsuSqReaz+SKQ2ku lMUa4y7UlyzBvjwHFgM44FfrhhPZQMMgfdCNDWZlBvffqrcuDctL4fHhFNEipt86ecrk os2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EIzUEDGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j9-20020a056a00234900b00690d7d99e2fsi3482112pfj.212.2023.09.22.00.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 00:52:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EIzUEDGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id DB2BC823CE8B; Thu, 21 Sep 2023 15:03:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbjIUWDW (ORCPT + 29 others); Thu, 21 Sep 2023 18:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjIUWDE (ORCPT ); Thu, 21 Sep 2023 18:03:04 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70461FCF; Thu, 21 Sep 2023 14:49:48 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38LLOinV000623; Thu, 21 Sep 2023 21:49:25 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=EIzUEDGENg1Oc+G8iiWkzbtXpIf8ktcy6AcQfv86hyES9DCrrCTJXc0eHiPh7HWbYjVQ el90VI53ooJp5N+ErGjBb1VxtWMacL8FPBz8ed5eoHkd+xVZ9kBa41ItDyVuC2iJEYKU NG7CPC1UB89+87fqUMCpR//DMQn6Dze9mlqrRAGMkdcihLal92PY2/Ba1cTSis8puyxG 76Ke8XHxnajjPcftdm5DTcxEjQ1PFq5bMj5sbpB/TYViqjTO7JDIDsxlQoQKm0YLEQYH j68FQD8LJYUUxVQn1has/AOM3JPMz80jH+pyEC4qkLH+REth3JC0Chf3N0RvEJsnI6rf /w== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t8um1r96u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 21:49:25 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38LLmxL6009020 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 21:48:59 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; Thu, 21 Sep 2023 14:48:58 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , Wesley Cheng Subject: [PATCH v7 20/33] ASoC: usb: Add PCM format check API for USB backend Date: Thu, 21 Sep 2023 14:48:30 -0700 Message-ID: <20230921214843.18450-21-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230921214843.18450-1-quic_wcheng@quicinc.com> References: <20230921214843.18450-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: xOdLAOsJpTEHwNh7z1cwwbf7UNDvypQo X-Proofpoint-GUID: xOdLAOsJpTEHwNh7z1cwwbf7UNDvypQo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-21_19,2023-09-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 bulkscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309210189 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 15:03:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777723395339924763 X-GMAIL-MSGID: 1777723395339924763 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