From patchwork Tue Jul 25 02:34:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 13325539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24381C00528 for ; Tue, 25 Jul 2023 02:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbjGYCfM (ORCPT ); Mon, 24 Jul 2023 22:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbjGYCfL (ORCPT ); Mon, 24 Jul 2023 22:35:11 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E9D719A1; Mon, 24 Jul 2023 19:35:05 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36P2EmnC003501; Tue, 25 Jul 2023 02:34:45 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=3+NthnHMYb0aBxkwQRLsMo8vtaEUG/221TLwVqmJMEU=; b=I8vWh4wPKSYeijGDJ1upyaylIV+i0z4N+cxt2L/gt9F1RmBosmmBry8AOPPnS2X7J48y TsdMofzRn8SnnqRu2SLDA6cD93rULqlBuuDbIz7jFkoFTlGGolTiQ3fm3EjjSbJnTcSW GI4gYkHM5olG4TV+iR2i3CmdpCC4OzrTw9C+SuyQky/BMbfyB1XYV68L/DeyGQwCG58N 2bsogYL1jzk5dAjR1YLFeUegLMUGvuh1R6IrL16WL644QEnUilqL3c8oiUNpGrdzvxaB HXW5w2ovjkxQg6BtJkvFLBoj21X7+79eCirnshnUz9nSv36o7U4cX5Xse7oOyhy9bGoA zQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s1vh8h4c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 02:34:44 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36P2YhjW015218 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 02:34:43 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 19:34:42 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , , CC: , , , , , , , , , , , Wesley Cheng Subject: [PATCH v4 20/32] sound: soc: soc-usb: Add PCM format check API for USB backend Date: Mon, 24 Jul 2023 19:34:04 -0700 Message-ID: <20230725023416.11205-21-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230725023416.11205-1-quic_wcheng@quicinc.com> References: <20230725023416.11205-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 nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 3JKeuQ05a1I3dbzzhtDwm3Qy-8MgHshD X-Proofpoint-GUID: 3JKeuQ05a1I3dbzzhtDwm3Qy-8MgHshD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_18,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 impostorscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307250020 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 378992ea07bd..71e6e75e600a 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -23,6 +23,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, int card_idx); int snd_soc_usb_disconnect(struct device *usbdev); void snd_soc_usb_set_priv_data(struct device *dev, void *priv); diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index 4293451cdd49..cdce1bb42df5 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -70,6 +70,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