Message ID | 20240213005422.3121-32-quic_wcheng@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-62783-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp268592dyb; Mon, 12 Feb 2024 17:27:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5T+H+jvh+c5aNGN/YzpqBsg74IcdEPemTAhB8QFPNFWkD5Gn0b9a849343PyMfF6e+5UD X-Received: by 2002:a05:620a:22b:b0:787:188e:f15d with SMTP id u11-20020a05620a022b00b00787188ef15dmr2019168qkm.28.1707787669405; Mon, 12 Feb 2024 17:27:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707787669; cv=pass; d=google.com; s=arc-20160816; b=pgJ225xIME2mFic9H/9pmC2ofDTSWw89JzmoqFjG/d3JEZx3DATW7c7g29KUqU7DNz rwpdUpep4/GdW5BNABRbCyIPWSZljcWFmAW970D2RYVmCJEo62CDwxDq4v6+OLiH9r2u 1sV+Skn4ZZBvitE3LiXBQZbkARVuTkJ+/H1V5TRCWqFJg30C8JmRj3/Mepjx+TMJ5iLX EzhPY2FKI5GV+Of+CW7R5unFg3AxzTa1w+Wb6t9R3ECEdENLsfRgsn2TvYT66vUVr8iG NxyX92Ai12NDff5B4HwhGWxdw7h9pBTLYe4Z2gnNuJQwhq2gEULaoMhMDtV08VgM/3U/ pofg== 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=hhIHa3SWBsZkrlvmJNicRycOcIZIFBMhAQCmyl30frw=; fh=4FqLgk3WSfjbzSQ2ti+HKgWVHJO93sWebPuiQMlU1+4=; b=rEUmL1R6d86wRbEWZnuboY9ZH8xK4XQScYHd0kog4NP45irEGVWYuuAID8bYEl2cyl pMPsk5XkzB3O3EGi9N1e193m/dKCvF9CLs8e500Cdblq9QtMet7zOxe+3whgvIU5jhBZ RnpjgfbJ2AfAwMUJ6v8kvWys+mnqJf5/l3wWYxsdJMoZDxEjrRpPe1Zt13CySLYbJPNC 6MxnKyxDM1uQ14C7snRQI6fhY3SDcohlxgCzt+G4zwlzQ2EjK6pagG8UvXBNz3x0Gi/l Vwi8dm70WECP2JcqA/sKPxEZsiIFZYErB61rqJIB6YTeerNq37K/z2am8+kwt2IpGpiv E2AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TUerxrEw; 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-62783-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62783-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCWS0VpfBa2YzzCQWVXOQNgeE/3X1idGEEHnjhLu1woZ7y68pn0PL44Eyq4YAVUzMRXhaVT7begqGqwqTeNsnsfvehCRsQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m10-20020a05620a214a00b00783f2040be5si7295546qkm.535.2024.02.12.17.27.49 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:27:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62783-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TUerxrEw; 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-62783-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62783-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 334001C2475D for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 01:27:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71CEB5EE80; Tue, 13 Feb 2024 00:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="TUerxrEw" 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 EE90C2232A; Tue, 13 Feb 2024 00:54:55 +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=1707785698; cv=none; b=ulRtpKi2qlFIGpvjGOfrD0GZa9ymrnVIVgy1/GbJrRGkjL4D8XypodyEgXmQ5uAuUfLAMJKJQMXmOj/OMD1NYjxcZE7YLRrDmkGOUUO2fHLg7vvb/KlsPI/xAY4K/Bbg7DxJ8DaJONhXsX0bTmKuWl+CcXSAvtL1227Dr8QYo6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785698; c=relaxed/simple; bh=avZQi57FuGJuxh3XlCVKmJg47Qvdp7d8VoFrgvxtZi4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NI0Zq7JD+Ich1+4rqcFIYsknQAF02F5C/Tte334gGhRExOD2p/+YIeSxERJp9jG3sHSgKmt1PDz4/sVh213C/aAUwwYVu3UcU52gZ0VP8LVLYahiupqMzWV0dd5txvTq5ZLPt3kLca41RUus0AorVXGHqqGtzIfSL+eq5quFRcQ= 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=TUerxrEw; 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.17.1.24/8.17.1.24) with ESMTP id 41D0SKZp003900; Tue, 13 Feb 2024 00:54:42 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=hhIHa3SWBsZkrlvmJNic RycOcIZIFBMhAQCmyl30frw=; b=TUerxrEw2ctMBi7w/rrOo5vGfI1ewvT3z9S0 Ny+JTTSCnjxb6gxUfAC0Dv55TMd+VJHVHfhE034Ez/GUY975RlP4ayoY8Go2Rifr bb0CzzP0RCHwYjBiVeeMerWuhxrXv5rLO4a5tu7S7plMdkMfKUX4y1HMpvcZSoyj rr+GapSzFwO5JSb4hjFmamSsq6JDq00Z1KLRNlcf/l2hA5/+jSOaNrhRlT6x3GMA bQ9Cvzu/Nr3FC71Din5V2iLONmeMB1S9DY612wKqpcS5YTZkxofNOcrYrPnGgrNd SmLeHvmES58aRO4ndV2Hi3HpmQANcrPAmPpt4YleRO4w05clJw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w7ww5r1ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:42 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41D0sf8T016277 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:41 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.1118.40; Mon, 12 Feb 2024 16:54:41 -0800 From: Wesley Cheng <quic_wcheng@quicinc.com> To: <srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>, <perex@perex.cz>, <conor+dt@kernel.org>, <corbet@lwn.net>, <lgirdwood@gmail.com>, <andersson@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>, <gregkh@linuxfoundation.org>, <Thinh.Nguyen@synopsys.com>, <broonie@kernel.org>, <bgoswami@quicinc.com>, <tiwai@suse.com>, <robh+dt@kernel.org>, <konrad.dybcio@linaro.org> CC: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-sound@vger.kernel.org>, <linux-usb@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>, <linux-doc@vger.kernel.org>, <alsa-devel@alsa-project.org>, Wesley Cheng <quic_wcheng@quicinc.com> Subject: [PATCH v15 31/50] ASoC: usb: Add PCM format check API for USB backend Date: Mon, 12 Feb 2024 16:54:03 -0800 Message-ID: <20240213005422.3121-32-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240213005422.3121-1-quic_wcheng@quicinc.com> References: <20240213005422.3121-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) 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: WtlFOqttDo-UPYpPMtJZ0ee6DW8Bzevo X-Proofpoint-ORIG-GUID: WtlFOqttDo-UPYpPMtJZ0ee6DW8Bzevo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-12_20,2024-02-12_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402130005 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790745163229328884 X-GMAIL-MSGID: 1790745163229328884 |
Series |
Introduce QC USB SND audio offloading support
|
|
Commit Message
Wesley Cheng
Feb. 13, 2024, 12:54 a.m. UTC
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 <quic_wcheng@quicinc.com>
---
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 c0cf5d1e9024..2790b51d979e 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 a1e0363bd760..e3556c397b39 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