Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1433578rdb; Fri, 16 Feb 2024 16:29:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgxrUlIoTJdGKaLDoOV5oeZLNDSIBOEzWCcoNTyRJO0qYUZrwqssuYvUU7e9UTbKK4toNZD7NcY3Z43rktEpzES6/FTTIu/8VAb0oFwg== X-Google-Smtp-Source: AGHT+IEbIs4V1fHcAjGFBz9VpkJPcVOD9mzHDaDuvQpILv2RRG+u+hPOZ85aXJy3DPbJ6SLLpjPT X-Received: by 2002:a17:90b:1990:b0:299:48de:9c7a with SMTP id mv16-20020a17090b199000b0029948de9c7amr1780910pjb.0.1708129751360; Fri, 16 Feb 2024 16:29:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708129751; cv=pass; d=google.com; s=arc-20160816; b=cXHO24CY90+BuZGs8Bo0xWXH5zLa2IggQJL0KrtO/EGL8xswzeZ3F58WCsOW/o/UjQ DZIt3maGxaWhqSDrUEhmPSPuG9urI9Ay4go8m09Q/Sz5rtwN5nOxbzttg6VlQAjR1V+S c/GR0NqmUthO634WBhuQDVnZUIT4lYDygFcl3qXeo41U7nxvcCAjVvYV9/buCaBiCbdk guoFlsbw58yaeTUZTnlmNqPP/rlZEsgY3MzHcl96XCN+L2Uoh5Hwimn7yWNO8ky4daSg f8QfRwXnYZe51o9nT6j6kP/BlbAsQI0qetV+4HvVPoXjRJIIXs9NxfZoNu4in/v8OLOk QH0g== 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=VKrp0Y7I/+wT36BfKZ6oI/4N9BIwFCn9zerObkOrgGw=; b=n1phlLmZCCsdo1dbP/3UGAfo0nkgBBbnUQ+wo9xqjVAn7O0CnRznKCOF2espXeDY4b b7eijekx39qTNGZrSEj9SNVOdera/EoFRke1b/QCUe6ovNSP3luTnC841XZ4Q03DNKCx YLd86wsiXFs9ekBkAvWG55lV2kne1VRYYFFYXC/nSRQ3co/D5lrnaLM6xu4SYmW6MB8E PFepRU/Brjm2C0N0IFDvYAVniEkXNwDI8zyFaM4hSIZuSoNMOegqlV96LgOANNEbCUJe PcK8KXW1axXr+iQTpj09Q3VwP+Sl2rx5vzBuaOXgdyIII4NxkkhuszjWiOiG4p7yBT9D K0tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UOYtzKGQ; 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-69570-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id pt2-20020a17090b3d0200b00296fcd007d2si739373pjb.29.2024.02.16.16.29.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:29:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69570-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UOYtzKGQ; 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-69570-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69570-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CAE222859AB for ; Sat, 17 Feb 2024 00:25:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 171E1149012; Sat, 17 Feb 2024 00:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UOYtzKGQ" 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 C2531D266; Sat, 17 Feb 2024 00:11:04 +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=1708128667; cv=none; b=AJI19ZsjoB/wY+/NrElqXEC5O7UG0IIE3YJoQXVDIsj030ZBC7GaHg1+frTfqwS+Cx3YfkOpj0tnpN7qE7VXbmarsAD5kBsTWvtNQTnPrDSB5hhC4favbDJVFGnALLqkO+Qs8BM5OEWnkDcGRbi1igsCiUABxapH4xTwdbZJluY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708128667; c=relaxed/simple; bh=HatCXrKbB2dW03v6FFj4WAg4Ef2LAgC0P7KuQ+/6pw4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KJssFGwp2VfRVg38KRmre7unM8QOHBAQ85zY2DfTFlk88UGXb3AXp/Tl34I3I43kTxMf4qE+su7gKIHzim1jhbrvECMZz2niTLh+LYoR8AZwDa2AlovHgNkv/E6S4AnboNEggLjU4zHj/MctZR9DKcWy5nbg3JoTnC4CbIu52e0= 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=UOYtzKGQ; 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 (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41GNRuLk016162; Sat, 17 Feb 2024 00:10:43 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=UOYtzKGQyQigd5RiIVX5SxG+/zwLeGkSIwNJ Iabl85yAtDneqsLj866LRRjOfDJ8Ibtc32GfbD3lqt7CHJUg7NfL4Mgj1b0pmbRA cxmAIRfIaOzkWCo3xcl60S3PNWfi2MVU2UN14Jus0bQU0a64IGBT3bbRyFyeihHE +r6TEOrgNTFD7aZnQo/dN57RAGhbXzipagHYzNyf8d78kobKUEPrTlm01CseSH+U vHpGQ9sDQORlVLL2hQ1X9y57uHDCe9Nd2WdqLaNUS4jHuHBr9uxGByRUr0ifZfm6 jbXblDlya5nh6AlqDF/d/Umt81FZS2jlRBMoF1mwS5Q+PRHvKg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wabeers4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:43 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41H0AfrI011379 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10: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; Fri, 16 Feb 2024 16:10:41 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v17 43/51] ASoC: usb: Create SOC USB SND jack kcontrol Date: Fri, 16 Feb 2024 16:10:09 -0800 Message-ID: <20240217001017.29969-44-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240217001017.29969-1-quic_wcheng@quicinc.com> References: <20240217001017.29969-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: 5qpoNHmkow2lZ0ld5g4M62O86L0iyB46 X-Proofpoint-GUID: 5qpoNHmkow2lZ0ld5g4M62O86L0iyB46 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-16_23,2024-02-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 phishscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 mlxlogscore=850 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160189 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) {