From patchwork Tue Feb 13 00:54:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 200184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp278410dyb; Mon, 12 Feb 2024 17:59:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCULizyD2/O9cEz06MPaptbWj0d8lGyNUZiqyPM3J5fU7DYE0QH8M1y6ub8vTmM4EaLiMEJ5BAM0mySuuAHVEVs2/GVyDQ== X-Google-Smtp-Source: AGHT+IHbTRSa3IHNTgF34RTUFIxPgnp1nVemRF9S0Cn5EAMxLobtMEHeRU7dMQdFbcLc8K/0tyy2 X-Received: by 2002:a05:6a21:920d:b0:19e:3a94:6309 with SMTP id tl13-20020a056a21920d00b0019e3a946309mr12965242pzb.5.1707789549443; Mon, 12 Feb 2024 17:59:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707789549; cv=pass; d=google.com; s=arc-20160816; b=Y9GHzoWVa+aC+c9sHjSICi4tf9GcMVhirgZpZVfXIxQIysYR2FrfesFOHwIls0GKCt tkg0xDB2jGvgzfKYXycVO9LuDZE+FaOszdwAo64nIl63Hex0ZksvJEmsEWymZaudnQnD CRnzHJntzoWRHREWMV3jtL6yB8hacEFw/tRNn/C9EFImBkziKLu5cM96b4zvNDf0fbWZ a6NTlQshPH0sHxwJew9zjfUMMp+Tg1zHdkNBBJqNn9HxG3JSghIREr8XFYyteJb8yQaE 6OzNPYf9vIaLt/0uvRlRXe3cbJLlmFaJfEfen03Q50dTMJw2VM2nl//JAi6/wpIJ6XPH ZfgA== 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=5MPghwqMnmfMlYR/X2xQeWKKOu6Pyk4OEgkIZw/sPpA=; fh=Zk+ohc59Qnx/Xn2XyNSX+an/TboGs6xDWC8KYdUvjdI=; b=Gfhf7231tCvZkQUXds0AKI9xkDOoOUl8a5lN0Lofy7LgTERCNSLZM0CSv95uqLevOJ qqoB1yMeRTBErp701yewKsSkS24FJJMDvquPvN2R2QGgjHDEu2xyxRYZ/WqNdDIjilUa +2P4u0GZLsAa7SKEXk+rbn2qV9BNO1oSk4pHwi5QkM5J+xQ5B+HfsXd4zZQ9yUrGStST 638JVw57BrZVIeEkTIzP85+PpsdFWGoOKzlu3YXj53xJWKUfjwMSSXYRaiQhGYqpet+P tn5qh6CvniPCxGXvUU/7rjVatMaURFPgPJ/paovhdtpZxock40/tQvwuAP729yn3of3r co/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mqms3qzN; 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-62824-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62824-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCXq209CEP3UrdFN/wYNFOyyWP5V+x8KBdl7tIv7lZYPhXRIoJ70nc0S0BZjtxKpM5Kk7rAk0jqKJMMbCH+cBMz7oy3TDQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b8-20020a633408000000b005dc0fe6b511si1165594pga.147.2024.02.12.17.59.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:59:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62824-ouuuleilei=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=mqms3qzN; 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-62824-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62824-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5A491B253B8 for ; Tue, 13 Feb 2024 01:36:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A669F6341C; Tue, 13 Feb 2024 00:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mqms3qzN" 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id F1CB25820C; Tue, 13 Feb 2024 00:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785712; cv=none; b=X8iV+QVuKNHW0oh6Ro3jV2rvp2rFhq5983rHwalthFOv5LKW9+T5jugQK4Yp9aTrb5QhCJFM1VpvhP0/KwULztIovF/U9ELPSOmEA/iCXBsU1GMekTL5u6sUE6X8T4jY/CFrkGp25/4CCc/bYLre5bmQ/iWzyz3lo+Ft4yDndl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785712; c=relaxed/simple; bh=YEBC0eKEC3+ceGGPNrb1zBdbPqDsis3CQ0o2eThqCSE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qzFA9jXbgZ3Xvf2o6Rbnv0bkEuhp6A9TcRRfiRlqTkGzaafJ49mDR6gmiTc949/BMc1fJNgET1HcQqUil/iXLGq5Xn8MvPA9d9NCEba8j4di/H+cWqORFhTKkB3iGkG1ROU4FXAb6Fbjl3jzpBnprnVQo+mP8mP3+KWbSmWoWBQ= 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=mqms3qzN; arc=none smtp.client-ip=205.220.168.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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41CNgpcZ032474; Tue, 13 Feb 2024 00:54:45 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=5MPghwqMnmfMlYR/X2xQ eWKKOu6Pyk4OEgkIZw/sPpA=; b=mqms3qzNPISCtBo6NMB/89bUDDa4fyJvGbb2 SsjjHwFxou8PXHTvdCJbzyIKnnbkZD0HtYc7cLODNEZy9yOTm/UhgCDa8vy3Yu3E HipgMefK6o701cKBCFn6UzlUpXIH63s/JELTaV4LWSdULftWQGTCqK/PC24xVq9U VvtUISeDP8NA9Wwwzhk2bcQxY7qgyumdNmBaR3K4qw68+uKsqCrKX+rSG1SJzAcK gK68WM4pEsLu1y3Qr2kbyu5ZdvUE2ZEYIpAlPPNQelC1HtqXmIw40Aod+4t5skQb zsAkAqYpcme+Vxtv3zL46YtDnWWGDgOhf9zc7b1rAZtZhY456Q== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w7ju79jxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:45 +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 41D0simT030076 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:44 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:44 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v15 43/50] ASoC: usb: Create SOC USB SND jack kcontrol Date: Mon, 12 Feb 2024 16:54:15 -0800 Message-ID: <20240213005422.3121-44-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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-ORIG-GUID: n_aLO-D4USnVh2ptlN7k1ubcq2AuJtKy X-Proofpoint-GUID: n_aLO-D4USnVh2ptlN7k1ubcq2AuJtKy 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 impostorscore=0 mlxlogscore=682 lowpriorityscore=0 spamscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=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: 1790747134217691346 X-GMAIL-MSGID: 1790747134217691346 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 | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h index 41e59892c360..b75a48986b6e 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_dai_state { SND_SOC_USB_IDLE, SND_SOC_USB_PREPARED, @@ -77,6 +79,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_supported_streams, void *data); @@ -132,6 +136,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_supported_streams, void *data) diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index d3183c0d3844..f2e83c2d68fd 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,40 @@ 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_status(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {