From patchwork Thu Jan 26 03:14:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 647139 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 863B6C27C76 for ; Thu, 26 Jan 2023 03:21:29 +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 B272BA4E; Thu, 26 Jan 2023 04:20:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B272BA4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1674703287; bh=lx/gnJcXNZFoFDSGTC39/WuAKp7FXVHyHFqkT0O9rIs=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=LqKXBLdgkGnxkH95Ch0kZZTZcoWfKdCSnP/3AoF9qtH/MkrJns8HZARp7K/MLwLUD Ua8z1Qv1w61IhKi/51BXuzq+P0NEh6Jd/H5VIf+jL1W6uOQH8wSoylhocynp5GUbkp kj3bypvl09hnYOaSTrg45Rp5a31W0TE/IRAsKpn0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 31940F805F0; Thu, 26 Jan 2023 04:15:32 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EDF69F80568; Thu, 26 Jan 2023 04:15:25 +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 D317CF80558 for ; Thu, 26 Jan 2023 04:14:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D317CF80558 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=d1wXSEP4 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30Q3EgC7003775; Thu, 26 Jan 2023 03:14:49 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=9YaFd6y9j4FenaXuzXxC96Owf6Vaq4DV+FD8SKInc2E=; b=d1wXSEP48u2e5+zzWUFAmu/ckZ9QGtC7wPZa507gF+NIOhW0nXfCmNR1NBdIpMRBjkcF mEWkAoiMSlTmLMjbzeEDtctfaKPbt+k04KSEmgxPkLxFrhHSGrWaCnrgHXCxKe8e07bb Cp8X0YYee6L8tc+5oMTFdpXRtVTof3hHhvJ0UXJeSQahR2xQiMxx8FHrrywbL/IP7Imr oK420ht1ENPxCustA4XzCZhfxCpsLsDytftELPZvBLm6iIUiIRW07/z6cgtm9v8EqtHZ ohDzShXPfxhH1fRvjVqjOBTUJIJN+ugdhEQ4cElLpTybEldOsESlki5G0cg8nM+9IavD lQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nbd7arbma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 03:14:49 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30Q3En9T031339 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 03:14:49 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 25 Jan 2023 19:14:48 -0800 From: Wesley Cheng To: , , , , , , , , , , , , Subject: [RFC PATCH v2 18/22] sound: soc: soc-usb: Add PCM format check API for USB backend Date: Wed, 25 Jan 2023 19:14:20 -0800 Message-ID: <20230126031424.14582-19-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230126031424.14582-1-quic_wcheng@quicinc.com> References: <20230126031424.14582-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: t8Rm8HeS8Pc2SnXg9o-kF6dCC6jY6ZmE X-Proofpoint-GUID: t8Rm8HeS8Pc2SnXg9o-kF6dCC6jY6ZmE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-25_14,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 clxscore=1015 priorityscore=1501 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260028 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 ec422a8a834f..d6a0a1bd9c60 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -21,6 +21,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 bfce6c9609e1..130cf12505f3 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -94,6 +94,19 @@ void snd_soc_usb_set_priv_data(struct device *dev, 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); + /** * snd_soc_usb_add_port() - Add a USB backend port * @dev: USB backend device