From patchwork Thu Jan 26 03:14:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 647142 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 711E9C27C76 for ; Thu, 26 Jan 2023 03:19: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 44B5286E; Thu, 26 Jan 2023 04:19:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 44B5286E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1674703192; bh=lDk48THoq7qXpo++ZpBGtY0le9DtVm37/UmMOnAgD0Q=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=e+iH/yfAKQfZAblOv2oZv64KjUiqH1PVjnN+diwLypKjsCM6JiAuS7Tsv7GGWZzm/ oqfZZxuNByQursuXj1tR1qU42J1gY8rCFDL+lA6MMtAHXFVo1NC05dJIJkJNzaKxER T+VGTVPTO56bUSXGZVJg0O1Dl+72dGZxhs2TrE4Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 38E83F805D5; Thu, 26 Jan 2023 04:15:22 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6B2BCF805C4; Thu, 26 Jan 2023 04:15:17 +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 01866F8055B for ; Thu, 26 Jan 2023 04:14:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 01866F8055B 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=ELmmCvDZ 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 30Q2va2S018786; 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=/Ys3+vP/SR8aiAN4HzahjXM1RRlJ/QH4E8Ntv69ejEQ=; b=ELmmCvDZ9+WCF14SiSiDuH5RQ1Z7hn8gSHVnFvAT5JbLuVtHFSJ48UZLWZ2MvP0HHRxd 2SXmOPQWAEVVRtX9bBs9rNkIfI7ieiRMvy7ovuuYQ+sUlFG0NRC3NYEbaxAqzh2XEtgf 7/4dILqIlWMQ3VmgJnHt5RVFuAmJP1V64A0/hFldVGgCctpaEiD+B+tGmdc5YNAVA4UH 0LX80m++RpHzb8QyzLhOXaKv0Xigt8CriJb44ku+56Ik8A6Ew2ID/ZV9eQ5UGtgbXeJ9 8VjrNc+cc9UddSguQZHCt3EwpXHwxmd0gJv/5A1jHYqHywsAAiMATByPbC+/wqRGYEk7 HQ== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nbd7arbm9-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 NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30Q3EmJM031672 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 03:14:48 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:47 -0800 From: Wesley Cheng To: , , , , , , , , , , , , Subject: [RFC PATCH v2 17/22] sound: usb: card: Check for support for requested audio format Date: Wed, 25 Jan 2023 19:14:19 -0800 Message-ID: <20230126031424.14582-18-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: w3DrZv4JekBRL12Ama70yMbCy-AyGu0X X-Proofpoint-GUID: w3DrZv4JekBRL12Ama70yMbCy-AyGu0X 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" Allow for checks on a specific USB audio device to see if a requested PCM format is supported. This is needed for support for when playback is initiated by the ASoC USB backend path. Signed-off-by: Wesley Cheng --- sound/usb/card.c | 28 ++++++++++++++++++++++++++++ sound/usb/card.h | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index 59be5f543315..be06d19ee935 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -136,6 +136,34 @@ int snd_usb_unregister_platform_ops(void) } EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction) +{ + struct snd_usb_audio *chip = usb_chip[card_idx]; + struct snd_usb_substream *subs = NULL; + struct snd_usb_stream *as; + const struct audioformat *fmt; + + if (!chip) + return NULL; + + mutex_lock(&chip->mutex); + if (enable[card_idx]) { + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + fmt = find_substream_format(subs, params); + if (fmt) { + mutex_unlock(&chip->mutex); + return as; + } + } + } + mutex_unlock(&chip->mutex); + + return NULL; +} +EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); + /* * disconnect streams * called from usb_audio_disconnect() diff --git a/sound/usb/card.h b/sound/usb/card.h index 2249c411c3a1..410a4ffad98e 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -215,6 +215,8 @@ struct snd_usb_platform_ops { #if IS_ENABLED(CONFIG_SND_USB_AUDIO) int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); int snd_usb_unregister_platform_ops(void); +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction); #else int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops) { @@ -225,5 +227,11 @@ int snd_usb_unregister_platform_ops(void) { return -EOPNOTSUPP; } + +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction) +{ + return NULL; +} #endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */ #endif /* __USBAUDIO_CARD_H */