Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2595132lqt; Mon, 22 Apr 2024 16:00:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXGeBvnJnhY7kOowMr0zpemQg+w2IVUxg3Z+a3kZiA1xYgM2wPpnqUIcZdzuK5ksJw/zQbHD6bJlQLJV5+XfLex6InH9fdpk+7rYZ53A== X-Google-Smtp-Source: AGHT+IHzfhCYsjsHlgEEAQmXofUgvyWMkAfUxMJZd56J5OHUn9bGmFuSTblj5ekiIEBhYsCX0fF2 X-Received: by 2002:a17:906:2bd4:b0:a51:c311:8199 with SMTP id n20-20020a1709062bd400b00a51c3118199mr1014932ejg.31.1713826837458; Mon, 22 Apr 2024 16:00:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713826837; cv=pass; d=google.com; s=arc-20160816; b=df7OsX+XrpZ6jelMTnPsb67/jss281dVTGJyLQZKeaOFu/d8JjuLyzLn8cmuA0EYO4 LHFTR3ptp0j5xmSH80myWt0dAlprJBRitrnNVquBGXRTAR+6eONLM0q9LFLT919GeIRm ambrL5pk5Y9iiXRikfFd947qUuGQE3ijVS5aiIi6PBcjMA/LAa3/n3mcpRCrtfobObv1 ez9QpwlmcO+RYLtS/JcRV8hwXYAn/4WbzRpF028d3sGf0bqpGEHaSD7AUu1rOGCA0QSO U2mdWzpDyWrOA6x6AP4gHkuSR7dvNryFC17MpXiZQdrh4hKU9R3Fx2Q97mTCh10jZgoy kQmQ== 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=QxJ9EKof3fFYrqQXOUyxiC6w8nimUgnvL4JJX26W1REvTnPHyoaltjQvxUoIQjllHj u3R9oRHlGIPhHqjJ0wZVs74uYqdS8p4rUkZC92y6mhhMrcfrv9MoufwIQfZ5eZo9ZLzd rynHushJPV7rtdO3RMaxuWEaSE3eQZteKcjbPjIhX/LjAjSTvuYeOwaRuAU69Hky5PtF YcrXhoCrTBYyXWXFqBh/IijoAWY7/RXJM7S5CogbPfLiC1LU8eXcbuPwO6eJsmewB1Eh QqCAQvgzyaVtjHqLtQkdHe0l6MkeUVX5YAiDzuIbeCIs18jPbw/r+snyDSkPKkKTv2Gi mP9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FIpOsOa8; 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-154154-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154154-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bl15-20020a170906c24f00b00a55617c9f1bsi6364582ejb.992.2024.04.22.16.00.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 16:00:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154154-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FIpOsOa8; 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-154154-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154154-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0B7B01F20CC4 for ; Mon, 22 Apr 2024 23:00:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E69C116C686; Mon, 22 Apr 2024 22:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="FIpOsOa8" 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 F000F15381B; Mon, 22 Apr 2024 22:50:05 +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=1713826211; cv=none; b=rNzGvS81CSc11kakWB+hyFNjSiVzDgum50NilgRHCKvh8t6p4g3ubN4F+k3RX1O+/bMYrWnyZvCQnbAhRdsbYx4w0CQVVwcwNKgLHEOEeuhpCIXVAsIwzARjKQzvccEXNRvwtHAjTxBls9JuS2Uj8AUmLT+bmDPvfTEgxpAgQy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713826211; c=relaxed/simple; bh=HatCXrKbB2dW03v6FFj4WAg4Ef2LAgC0P7KuQ+/6pw4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JpnaMjm2fCNCXD8pafSdLZLpqwEPXi96KEtLLkiorEKHdXFq616LOEQ63vdH4d0sR1jkW7HeAyZQw1efnz4gzVciHz3DPI5+BYrZy80EWSljyUPxMSOXlKmkCZLXMbg3F+90mu66z7g05yEQPwaH5hHPTcI1MN4RFxGmO7GDr8Q= 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=FIpOsOa8; 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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43MKQ7XE022182; Mon, 22 Apr 2024 22:49:41 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=FIpOsOa8JGjXPOhG35wdx3f+O1N/tU0+Vvl8 P4228g2dY+PzCjHG57Irw7FEPQtVz9Dwo4NBznKzt2QyWh3PNp/2YqVNjFG2IJiz m8evmPVn3Yx2FjRPsx22id+8FbYopSSPBWbUSVo/fusxPDEjYraiAjBmYHV34RQM AoFJ3ElCIddtfPipC+QN0m578VWsHh1CHGkMzMxC4IytceH4dL7pdbLrddZpBCGP gMEBqD8S+mE9K4uN7MDg3cVZMHcubLpYfnbA5f+PZu8EgN2sjaH/VrVYZIE/9VhJ SM5RHV6l+2krXs2kI16hFqVfxVayJSMzt8qUrf+Iwyw8itl3mQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xnn82hskn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Apr 2024 22:49:40 +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 43MMnPGF027784 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Apr 2024 22:49:25 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; Mon, 22 Apr 2024 15:49:25 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v19 33/41] ASoC: usb: Create SOC USB SND jack kcontrol Date: Mon, 22 Apr 2024 15:48:58 -0700 Message-ID: <20240422224906.15868-34-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240422224906.15868-1-quic_wcheng@quicinc.com> References: <20240422224906.15868-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: 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: zKrlTiDEBuXlAEWjHUS82JwFGanM5TkN X-Proofpoint-ORIG-GUID: zKrlTiDEBuXlAEWjHUS82JwFGanM5TkN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-22_16,2024-04-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=849 priorityscore=1501 clxscore=1015 suspectscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404220096 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) {