From patchwork Fri Dec 23 23:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 636981 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38C4AC3DA7A for ; Sun, 25 Dec 2022 18:52:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 70E764B46; Sun, 25 Dec 2022 19:52:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 70E764B46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1671994370; bh=/vM3c6B09g2fOzchvCQhce6AWJDoup4BSs7h45MCGH4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=uSBwH6k15sKBMiJCHdQ5em4b17VTxmrJ0i9YDVCKwm47XAGUp7vSQV1bt7oGM5EXj GUCu88xGGCZkoHUVEagoTMOPPeFZtbq9sXeLe170L4tJCFrS8t5pdb28NPAa1Mopxp +PkMHhGn3QdhgzUhLTSsnGT7k2OxR2DOpDc87N7U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 12846F8056F; Sun, 25 Dec 2022 19:49:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9CB91F8047B; Sat, 24 Dec 2022 00:33:00 +0100 (CET) Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0E3C0F8052F for ; Sat, 24 Dec 2022 00:32:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0E3C0F8052F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=NhpykZ1S 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 2BNNT2pb013829; Fri, 23 Dec 2022 23:32:48 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=MbzKRBWZtSM2mW1OG2asvJd3zGd4KYoy90tUAmpa/ks=; b=NhpykZ1SCgZYP+fhRTc+331q9uM04f0Bwr9W1wGVojyVz5EBiOgbl2xJwu84lwXbrrKG 1LzAJa9Y0WfNlsD4SezU5aCeJGcej6L/obItuYvXbo4ldmrdbGm8eXU0GswNnlrYVGtt Ljg0xbeqDsTsKps4vy/61jhQPIuG9Oo2mo9MLeTBVMe6oMBYE6JRk3D3nBODGNPnGblT cHepr4veDs+MUWKdfyita8p62La+xYRK3lmhewrw0qs3o1uyecgqasS0fnao3C8O2vvV N3ANREgA9F5DBPCc99TCIGcwxRHlcq6+2sJf/aWReDmmdxpcUO7s0Em7A6k5TflEGXlD nQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mncd0gy4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Dec 2022 23:32:47 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BNNWlqN016918 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Dec 2022 23:32:47 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.986.36; Fri, 23 Dec 2022 15:32:46 -0800 From: Wesley Cheng To: , , , , , , , , , , , , Subject: [RFC PATCH 11/14] sound: soc: soc-usb: Add PCM format check API for USB backend Date: Fri, 23 Dec 2022 15:31:57 -0800 Message-ID: <20221223233200.26089-12-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221223233200.26089-1-quic_wcheng@quicinc.com> References: <20221223233200.26089-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-GUID: 25O5TuV6qVUDlTonNbfXm45G_5ar5RkL X-Proofpoint-ORIG-GUID: 25O5TuV6qVUDlTonNbfXm45G_5ar5RkL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-23_08,2022-12-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 suspectscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212230197 X-Mailman-Approved-At: Sun, 25 Dec 2022 19:49:45 +0100 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Wesley Cheng , quic_jackp@quicinc.com, quic_plai@quicinc.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 7d52e5d2371c..36df6f4fe093 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -19,6 +19,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(int card_idx); int snd_soc_usb_disconnect(void); void snd_soc_usb_set_priv_data(void *priv); diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index c6c376960e4d..021380a022bc 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -25,6 +25,19 @@ void snd_soc_usb_set_priv_data(void *priv) } EXPORT_SYMBOL_GPL(snd_soc_usb_set_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); + struct snd_soc_usb *snd_soc_usb_add_port(struct device *dev, int (*connection_cb)(struct snd_soc_usb *usb, int card_idx, int connected))