Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1422406lqd; Thu, 25 Apr 2024 15:29:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/EETsb9YygePdQZU2DJDS3ux2MO7e/M2+34R6yjb8D5AAcG35hxGcHpTGwiCh4jB9N7fFif+rG0TDNkMDqAjSxAi6yD07+JffbiA0mA== X-Google-Smtp-Source: AGHT+IGoq3KnlIeCrIzGAopcIXDu4PiylS3doqR4RAwEwq/YCRPK6cxfWB9HFjN0m9OZYBu/j99i X-Received: by 2002:a05:6870:9347:b0:233:a2c:470e with SMTP id j7-20020a056870934700b002330a2c470emr872635oak.57.1714084160888; Thu, 25 Apr 2024 15:29:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714084160; cv=pass; d=google.com; s=arc-20160816; b=xRJVl6hxim5M8gnfWy6E72D92xIGMNtbIU1uu2SWEeso2t/zOsDvohTOGRWxZUkEaL tX+Ymu6fSUeODZUOG2rMMBB0SWnTHmV41Epi/TBMF/+kadQ6iqvFVxI3IRDKk0n/mMr8 lJc93aFUakZiU4QXWNCOQah4OStxpEL8tbmPayfmKiKmqpnU9Mlcn1IKZYTnkbb4F91r So0vWrkE1jIO2Zm75HgJnwjkG48091ei0rWuqj4/LWugaYm1LrvTHEId2a/pcf3cm6Pp me2/gK5Mqt9ZmV/LVntfoeNuv2TERDyMixvMZs2m+LQ2y3dw0JgB7bw/ZrhjNOCtbRPx RKmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1ti0OFMlpvxuyvNxeli74aYR9ZNdqw1HmgshCcMPrxo=; fh=usWEz1eJjYCle08WABmDyuqCrJGq9m48/LVlmybnzRs=; b=nydcUJYiLTz9xAizUbbsp1FSRYjwBIVRIXwE1tKKAVPk7HbrsQtPrYtJtoQ3rQ9kA3 M59FbvGhsljXBCMlpMKYIjRixHzoQzDrdlzzkQ/72f2CuLGFNTdXPuBUth3TYNN6W2Bq sszllFsFWwFWnuWC10nPH2lm1TZcwRpXxzXGWXdDFVUvzVi9k1CxqEVGV3tszt+M2klN +3phL4lFC7VCdrb/P+XOYP908d7xyoa1RXvArvpfKjAGz2JDEtR3K6lxMJ/eToeAoLun kqppsT+ha8favCBWzfh2W9tYXROiNpAaetCtRcXs7WkcqBk+IHPyL2oj9ga9Ji1g+twN ocvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FPCaZ5+f; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-159271-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z16-20020a656650000000b005f7c90de2aasi12607529pgv.575.2024.04.25.15.29.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159271-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FPCaZ5+f; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-159271-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B9E3EB29602 for ; Thu, 25 Apr 2024 22:03:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1219F1BF6ED; Thu, 25 Apr 2024 21:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="FPCaZ5+f" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8EF9180A8E; Thu, 25 Apr 2024 21:52:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081942; cv=none; b=IER2wgnbukr6EI7VTR0W8DONT5oZl3lykD8c49C6LaWcd7CqBC2LGBqloz81gz/5XGQ52FZcilhWbewmyiyst3Fu7mOTepWw2zJjcOT1lmsKZR294MrNblxORPPLR46EkQpb2C41XIM/V+TwfRShOmVHG6ZHheFUW7HmH9TuD8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081942; c=relaxed/simple; bh=7iOpsTMbqEwoi14/dcN8UwbNoAatyge1GCbT8mE6mNg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QUGZo9/xuTo+OtFDhJAblrcfY03swSJh6LSsBOJWX679mlFz5L/G5J2ErSfqoUkCtzptPBuxdo3Cg9xEpyyzwWouo84YgNXZv7dyAh159INR2WNCBEbeHUmaBVXOmmPWbzs2IYpyDll+LQawJA7YwG0RYUjXvuHsL7FhRaVdeAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=FPCaZ5+f; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43PKd6H4011591; Thu, 25 Apr 2024 21:51:44 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=1ti0OFMlpvxuyvNxeli7 4aYR9ZNdqw1HmgshCcMPrxo=; b=FPCaZ5+fZL0NFbNCsoHOwbmYS8GndQZtJgd1 kFg+U7chlMhFb7ODpDjQioMCr7dwyeIdBLPvPgZx5QIEbNC/ri0jZZwbAtgs8sHi 895MtJ41pO3qGDQztkLX7o/vxwfUafcud1LJALd3ilrxNgo+KnqPPUtr7R7hKd/0 eYaShe3ZqHCusU20Uc2xMnHCqIovfm8Df46X10KmB1gLNpvQNWFL0LWPu1MYeeun 0s8CSyuAV42LIqqVCWF3/tiKB1qvnKzUXpVQummBMRHk4i3Z/qV7TP52n2KyEV+Q lhaT5w6pRK+TVvMW6E6EXy6QGtaZvH32ddBTJX+TAX4QBr4d1Q== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xqtph8nds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:44 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43PLphBe008028 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:43 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.1544.9; Thu, 25 Apr 2024 14:51:42 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v20 22/41] ASoC: usb: Add PCM format check API for USB backend Date: Thu, 25 Apr 2024 14:51:06 -0700 Message-ID: <20240425215125.29761-23-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240425215125.29761-1-quic_wcheng@quicinc.com> References: <20240425215125.29761-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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: V9XkieLCoguprWH0OpSC0uES_0QW6VhQ X-Proofpoint-ORIG-GUID: V9XkieLCoguprWH0OpSC0uES_0QW6VhQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-25_21,2024-04-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 suspectscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404250159 Introduce a helper to check 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 | 9 +++++++++ sound/soc/soc-usb.c | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h index 5b2fa0877523..8f2d3064b520 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -39,6 +39,8 @@ struct snd_soc_usb { #if IS_ENABLED(CONFIG_SND_SOC_USB) const char *snd_soc_usb_get_components_tag(bool playback); +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); @@ -55,6 +57,13 @@ static inline const char *snd_soc_usb_get_components_tag(bool playback) return ""; } +static inline int snd_soc_usb_find_format(int card_idx, + struct snd_pcm_hw_params *params, + int direction) +{ + return -EINVAL; +} + static inline int snd_soc_usb_connect(struct device *usbdev, struct snd_soc_usb_device *sdev) { diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index d21db2345966..bc77204fd2db 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -80,6 +80,31 @@ void *snd_soc_usb_find_priv_data(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_usb_find_priv_data); +/** + * snd_soc_usb_find_format() - Check if audio format is supported + * @card_idx: USB sound chip array index + * @params: PCM parameters + * @direction: capture or playback + * + * Ensure that a requested audio profile from the ASoC side is able to be + * supported by the USB device. + * + * Return 0 on success, negative on error. + * + */ +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_allocate_port() - allocate a SOC USB device * @component: USB DPCM backend DAI component