Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1412753lqd; Thu, 25 Apr 2024 15:07:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC0w5UWs0QooArWY+7oM0ANG8AkeQJAFb8UGfRqlCc4dP2N6ExVaHLrajv0ITpZJNPWfHQRnMtZuK13E1tJgu9PL1nFdHdLTQfNb4ydQ== X-Google-Smtp-Source: AGHT+IFlLlg4DVyrF1z+f5e6wY4ewwihMuKJg+uCRRX9l9LZFe4r9vxiClmr9oAQmtE5vnBS/smQ X-Received: by 2002:a05:6214:dc3:b0:6a0:9388:885f with SMTP id 3-20020a0562140dc300b006a09388885fmr1720114qvt.5.1714082825455; Thu, 25 Apr 2024 15:07:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714082825; cv=pass; d=google.com; s=arc-20160816; b=V36YYvAa/ivbL1tLgtzgJYB6W5PcRXrf5Mg1GDMv/smi9NCibdf0sxjISHCt8idxo1 kTcqrekLvhqgB1+1GNq9jiqud4NJKshVwHrNNbdb36Il89LnQ6FJORaBqXYsDrTe3CY9 Nn80vfsAXSJZnmFuy60e1xqRsnUv471QT38D/8LD3YnccVGy4TPpP73MFs2GfUfbZs1G jB8Ij5R0ur7CMjVxJHzKW7D702bu12P+lGQEQR/R3kpLPAmLxU2dal+JIfXxQ/L18S0Z PYu7gk2H8aPsyofkFVdkflyFlW1NiRPUK95kgrhD0oawzhjic9X0oQUmCZhJANC7B74g xeew== 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=eYqTxR4oahFBxiAY8wO2h810DsVvVFBwbpackgBgnJk=; fh=usWEz1eJjYCle08WABmDyuqCrJGq9m48/LVlmybnzRs=; b=dmN5qbsTuVX5au5tAqU8FH+KU6aC3qnJTx17bPNTFqs8iN+0z/iTfMHDUScbM7EAsp PK9zNNmXPyScOKK740I+9plNGpp9UbregiQ+iAc/bnxMRAMJV9638AqrdSCECaEsgX0W 7pYPl9V6D7qrHYoVJiwYn+OAWj11vgnPEr1zkL1WhvNc7QMSLC+3JAVYs1efeSaqNWm5 5TzK2b6c9C4aEkRoCeBDebn414nLz+I0FYQ/wggGBRO1iR6Z6eJ378Zs/uL+GX6g/x5o YWQGv3qHDJZhXcycmtRr52lXcu6yKZwc8Ubu5sOP6oepWMjYIbPh/vbgQBZtwYDb8e7T S4vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XrYwrGJy; 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-159283-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id eh23-20020a05622a579700b004369224c9dfsi16705773qtb.528.2024.04.25.15.07.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:07:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159283-linux.lists.archive=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=XrYwrGJy; 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-159283-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159283-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 977D61C248CF for ; Thu, 25 Apr 2024 22:05:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35ADE1C8FC9; Thu, 25 Apr 2024 21:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="XrYwrGJy" 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 1FB7D181CF0; Thu, 25 Apr 2024 21:52:21 +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=1714081944; cv=none; b=Dcmsp5vOZ32H1TnOG6gGDik5uVJPxLe/xnFTHijE6NppOeNQyqxiG9j/Kmc46FVmxprv/lztXSu8m1NoeH/OVEMTKkpy7jxdy4RD5kda7fFsRXM2rNJDSM8T6P61s/J3H6EoPDO1aKIGkchDhIIqW6+khSeZl3cSUAbz7ultVzI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081944; c=relaxed/simple; bh=HatCXrKbB2dW03v6FFj4WAg4Ef2LAgC0P7KuQ+/6pw4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X1jEA5+wbn2kz124W40W74VlPvfVfmSW3TG8Sjqk5E987wlB5waAYu5cTBmrFqoW4UohD5ZEa/y1kOq1r2OH/L2HDz+gzNuRtmjcIiW9MbG/mYYi4K7aLBv/ymX9H2k8KDxvkq+eTivJyw7QwVTYE6lEvIEqeTgAIv0T/fbEZmM= 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=XrYwrGJy; 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 (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43PLS2on030011; Thu, 25 Apr 2024 21:51:47 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=eYqTxR4oahFBxiAY8wO2 h810DsVvVFBwbpackgBgnJk=; b=XrYwrGJyKzY0+pmBL3VHh/kabw3x8yGR1wtk 3bi6Y20fswy941ju81EJrj1EAv5fIH9w9mmGjYd29MbTq6MFo/UWggi93iSRVOZp O1Dd353fUhWOYWkTINAvybMobpvlk09wfydBm1R107vhnrvBx86vsF59BFHK7hni 7S0S4gPY0WyxJXiDjq/gBj9jhSFQxPKY7lgeqNMQCQvfL/MsQsK6kvUAv5EWrmjv J65qTXLga10+oCullZ7idyVYdLrGVn+vIcSZuPW6F7CToI8oYsNigyoRJTBY3TFz W440fgFFBFQmxdKmaAM/KgGni9k3mM6Gkh0d0OI+ykxefvKMiw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xqenkks43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:47 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43PLpkZm015489 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:46 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:45 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v20 33/41] ASoC: usb: Create SOC USB SND jack kcontrol Date: Thu, 25 Apr 2024 14:51:17 -0700 Message-ID: <20240425215125.29761-34-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-ORIG-GUID: -jkTvdWAaae0itUboYrRKLHyZmSHYuEx X-Proofpoint-GUID: -jkTvdWAaae0itUboYrRKLHyZmSHYuEx 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 phishscore=0 mlxlogscore=852 priorityscore=1501 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404250159 Expose API for creation of a jack control for notifying of available devices that are plugged in/discovered, and that support offloading. This allows for control names to be standardized across implementations of USB audio offloading. Signed-off-by: Wesley Cheng --- include/sound/soc-usb.h | 10 ++++++++++ sound/soc/soc-usb.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h index 5e6076f65a41..3137f538270f 100644 --- a/include/sound/soc-usb.h +++ b/include/sound/soc-usb.h @@ -6,6 +6,8 @@ #ifndef __LINUX_SND_SOC_USB_H #define __LINUX_SND_SOC_USB_H +#include + enum snd_soc_usb_kctl { SND_SOC_USB_KCTL_CARD_ROUTE, SND_SOC_USB_KCTL_PCM_ROUTE, @@ -88,6 +90,8 @@ int snd_soc_usb_prepare_session(struct snd_soc_usb *usb, int card_idx, int pcm_i int snd_soc_usb_shutdown_session(struct snd_soc_usb *usb, int session_id); int snd_soc_usb_set_session_state(struct snd_soc_usb *usb, int session_id, enum snd_soc_usb_dai_state state); +int snd_soc_usb_setup_offload_jack(struct snd_soc_component *component, + struct snd_soc_jack *jack); struct snd_soc_usb *snd_soc_usb_allocate_port(struct snd_soc_component *component, int num_streams, void *data); @@ -143,6 +147,12 @@ static inline int snd_soc_usb_set_session_state(struct snd_soc_usb *usb, return -EINVAL; } +static inline int snd_soc_usb_setup_offload_jack(struct snd_soc_component *component, + struct snd_soc_jack *jack) +{ + return -ENODEV; +} + static inline struct snd_soc_usb *snd_soc_usb_allocate_port( struct snd_soc_component *component, int num_streams, void *data) diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index e291f146a79d..27c76a33da32 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -4,8 +4,10 @@ */ #include #include -#include + +#include #include + #include "../usb/card.h" static DEFINE_MUTEX(ctx_mutex); @@ -42,6 +44,39 @@ static struct snd_soc_usb *snd_soc_find_usb_ctx(struct device_node *node) } /* SOC USB sound kcontrols */ +/** + * snd_soc_usb_setup_offload_jack() - Create USB offloading jack + * @component: USB DPCM backend DAI component + * @jack: jack structure to create + * + * Creates a jack device for notifying userspace of the availability + * of an offload capable device. + * + * Returns 0 on success, negative on error. + * + */ +int snd_soc_usb_setup_offload_jack(struct snd_soc_component *component, + struct snd_soc_jack *jack) +{ + int ret; + + ret = snd_soc_card_jack_new(component->card, "USB Offload Playback Jack", + SND_JACK_HEADPHONE, jack); + if (ret < 0) { + dev_err(component->card->dev, "Unable to add USB offload jack\n"); + return ret; + } + + ret = snd_soc_component_set_jack(component, jack, NULL); + if (ret) { + dev_warn(component->card->dev, "Failed to set jack: %d\n", ret); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_usb_setup_offload_jack); + static int snd_soc_usb_get_offload_card_status(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {