From patchwork Wed Dec 20 22:45:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 181836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp58531dyi; Wed, 20 Dec 2023 15:00:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNpYZyFyW2XkAAnLryPMKsyUUT4qBrBa9iEykgO69aCEzTLJViGSRnc0Isj5/qgDBS+RZ5 X-Received: by 2002:adf:f807:0:b0:336:710f:9a6c with SMTP id s7-20020adff807000000b00336710f9a6cmr222020wrp.47.1703113203511; Wed, 20 Dec 2023 15:00:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703113203; cv=none; d=google.com; s=arc-20160816; b=F/nxqWoj6WHyCrSWGhfewiYReKR7RdITGqi9jlkUbF8VizZOt2kqq3qsyba7PyY+ae h+l0y/olkCyuD5R/tO9v5EYJNkPZ5O0jxqG3qhCjLxXMa0zCV4/Gfr/ehv4shvnsinkl 3iaeZyB09+8PehQ6jyWP9l1VZGMhyeNG4hmTjajZRXNPWP56cBT58lkhpWcY5IrguDYg juBAmfun39CzU0X2d8w+paogxyXOcvOI9spKIwtLKEOoB1qQKwtnxC7RXbnhVO68k+Go vuqpbrONC/gKy7wmg7Kp4JmHYeY3aVPil8oB34MhgSgVWk6pgB0WsbJYF9jNTyRkF9MB RqWg== ARC-Message-Signature: i=1; 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=eUt//nWbm09sEQ6QXS2Y8csJazCMoz2j6WQ8KxnNB4w=; fh=0KzismZj+xI0Z//ZGdqKIH/FO9LtSZM7Yj4P0VtrCz0=; b=duMegMQVdhG8olNdh5i8hKbIIM6p3IpHxCTdqww68LzEfC3eBDNOAG3HyCmlX1uwz4 bQ+pVTqo7ojPDuJDnMZFjlBXdCjxSjaYyRntpFTKE8CSCyWu9ENjBeOqlVz8rZaB43BJ C3T4yaBuBsQSPwufER/4V0vUfk8bG8IZfgZl9cESUvZhA4RWsvgeBSWate2bGa7VyZZ6 aIrR/7kakt0+N/S0/3qGmlaPS7IPyvWFeoF/hwQYmnYaQQuK6AfXoIUnUhnxBmFjYMV3 mfswKBCoXwfzkhoBZKTEPNZ6/WuiEv/3rA/FyMh2ZZfzvj64sgSBUOLxj5rIAVKAV8+Y aQuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ddstcRVF; spf=pass (google.com: domain of linux-kernel+bounces-7563-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7563-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q5-20020a170906144500b00a23645fc93asi243090ejc.886.2023.12.20.15.00.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 15:00:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7563-ouuuleilei=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=ddstcRVF; spf=pass (google.com: domain of linux-kernel+bounces-7563-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7563-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 26BBE1F2453D for ; Wed, 20 Dec 2023 23:00:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31BEA68E9B; Wed, 20 Dec 2023 22:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ddstcRVF" X-Original-To: linux-kernel@vger.kernel.org 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 BE9A44F88F; Wed, 20 Dec 2023 22:46:18 +0000 (UTC) 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 (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BKMcB6X013016; Wed, 20 Dec 2023 22:46:05 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=eUt//nWbm09sEQ6QXS2Y 8csJazCMoz2j6WQ8KxnNB4w=; b=ddstcRVFNJYcKfFtjvP3+yVXHjjgAxk/zP1m EKsRfYT6mjls2HzC4oIloeSb0+qwAuTBEUHNKXdHmPk5QXalAFIjsmEMfochDQFN uCq+jWk1ztV2jJrfG2PyeJvjHZBvPiuT8tx+C8X0nNVXDdb9hGxK+0A3vOp5SLmm gvYqQvSwb/5u+8Ob8QI7+sh7sTopHv8+s4Ezxgdu3ldWS06LLwBgglo1RMCWqCiy D8Xffo4f45J3TzrEVNvL0yAlf/AIuoM8DUPzlDz1AtIOTTi7ySsv1vj9ddcC5IDp YdQD6PHYAUKieH9CoPbCiF7vNxbFHS/mSRp1jyoayb6xSakwvg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v3th6tf2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 22:46:04 +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 3BKMk4r7008437 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 22:46:04 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; Wed, 20 Dec 2023 14:46:03 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v11 33/41] ASoC: usb: Create SOC USB SND jack kcontrol Date: Wed, 20 Dec 2023 14:45:36 -0800 Message-ID: <20231220224544.18031-34-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231220224544.18031-1-quic_wcheng@quicinc.com> References: <20231220224544.18031-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: 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-GUID: 7lfszVWaVwqpT7E0bMef8LxVo50Y5fGj X-Proofpoint-ORIG-GUID: 7lfszVWaVwqpT7E0bMef8LxVo50Y5fGj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 bulkscore=0 mlxlogscore=693 lowpriorityscore=0 phishscore=0 priorityscore=1501 clxscore=1015 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312200163 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785843630204894167 X-GMAIL-MSGID: 1785843630204894167 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 | 4 ++++ sound/soc/soc-usb.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h index b0dbb89316fe..6bbd4339e8c5 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, @@ -76,6 +78,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); diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index 50cd53db365f..7d202b0a2680 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -4,8 +4,11 @@ */ #include #include + +#include #include #include + #include "../usb/card.h" static DEFINE_MUTEX(ctx_mutex); @@ -42,6 +45,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, "SNDUSB OFFLD 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) {