From patchwork Wed Oct 11 00:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 151083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp222044vqb; Tue, 10 Oct 2023 17:26:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDWVF8S3RxZSWGSgEGPOs9fcWeufEaKvk7sco0PleTywtyF5Ux59zWSIVG+M+4uBKBkhtj X-Received: by 2002:a17:90a:17c5:b0:27d:3b8:a08a with SMTP id q63-20020a17090a17c500b0027d03b8a08amr335849pja.1.1696983991789; Tue, 10 Oct 2023 17:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696983991; cv=none; d=google.com; s=arc-20160816; b=TRf0kwinppgjmAlA+UuczPZ4EjB+t6hC/f2g7dqfPIygyknlR0jmH7J27CiUpU8lBr lmocDOOLXxnxfounE4a1bUyrewmNZMAQ8o4nOqB5QSidhYW2o6TCrVQBBMn/5nZ6otow ysFmxxUEipLb/OAqCBUVdb8aU0s8VQ7pA3OypQ/fM94N8ihrcPnDOKTptSJHHvLtEzZE mtJxNXkT/COraKU4mlw0SOrDNZ+hEYmdd9NZYYFGUqIC2XsYZJm76lAWogr47oTE8McT R9UjUsKtvdKcGv5XECMTZ3VMTiT1z/+1PdMGB+TL41mgx+52+ZSEUuB90uuXJVBKhqQf RiBQ== 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=Shqo9s0lYRwfd+WgaNXsqGc7coVeRQUHUyu7Rj3csx0=; fh=ASZxE/GudOQkGCAz0d02NHHSpg4iNHYOcDWl1imlof0=; b=CTQnmJnguskH1vROMgr1NmLVGzqQWEfTPj1cq5WQUL8gn9aaPEeAPmd9f1WFc08rO3 +sH5W4afPCn/QQo7TGaJ0qkz0LdBUcCanOLlHVo7UGjS/XMutlwfP5VXm8gTeEWa3ji5 AKyzAoMhAdvvK/g0aemoWRh8MaiFcU7EmPQe208PsypRvIAfwoCEd3rfZoQ0Pm3xXh9S ewlW2LWmo+9I8+325jginhW/9Vh5STLn1nTdEJ2RbZVaKi/8c4zUy03AR3jBAg2Ji7wG ax4usKVQjqgFDcKx9YkjMxQOuFpcY1AmadJU0hnctHnN5X1HZHQu7eAtdURJoSgyrz24 wdRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LCNv9NYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id d20-20020a17090ac25400b0027740943ec2si8408712pjx.158.2023.10.10.17.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 17:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LCNv9NYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 516B58081CD6; Tue, 10 Oct 2023 17:25:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344606AbjJKAYE (ORCPT + 19 others); Tue, 10 Oct 2023 20:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344395AbjJKAXQ (ORCPT ); Tue, 10 Oct 2023 20:23:16 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED2CDD; Tue, 10 Oct 2023 17:23:12 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39B0L2K8005089; Wed, 11 Oct 2023 00:22:36 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=Shqo9s0lYRwfd+WgaNXsqGc7coVeRQUHUyu7Rj3csx0=; b=LCNv9NYCibLOqj+AWQ1SQH+YtC4MMKBexo6tC7eHWS8z5iAnzb2S86KU5lujNN7De1iT qNZO5QUQz7+iuwOFtRBnTnSSVP7NVCDkDo/alXEhJYU2/sBeK8VpmcY2CjcVDelk4iMT oCos3dv7/swFRAyFMWGTShi45yba8IGiTRDOJpFYOwwHSnKSNWFuDGmRWihBHbqLOeYz fIR2At5zozlc2kGIj9x+jO5qjJcZIaUVxLannINKOMH1uHqP2AVDFHsezYtBstQ2gSVn g9VAMXFCURWTJ8Tue4Dywy+ae3zJggQXms5AFJxwmTd0g41JGxd9ImgpHbvHKr0XvLko /Q== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tmxjpjf4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 00:22:36 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39B0MZSe002191 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 00:22:35 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; Tue, 10 Oct 2023 17:22:35 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , Wesley Cheng Subject: [PATCH v8 21/34] ASoC: usb: Add PCM format check API for USB backend Date: Tue, 10 Oct 2023 17:21:33 -0700 Message-ID: <20231011002146.1821-22-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231011002146.1821-1-quic_wcheng@quicinc.com> References: <20231011002146.1821-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) 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: -znV2yii-4jLsWrzjJqvRy1axGuU28BN X-Proofpoint-ORIG-GUID: -znV2yii-4jLsWrzjJqvRy1axGuU28BN 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-10-10_19,2023-10-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 impostorscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310110001 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 17:25:20 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779416685863514617 X-GMAIL-MSGID: 1779416685863514617 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 58c686f4f7ba..c6ddc055c4cd 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_find_priv_data(struct device *usbdev); diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index 73b1bcc3b506..7407678a993e 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -63,6 +63,19 @@ void *snd_soc_usb_find_priv_data(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_usb_find_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