From patchwork Fri Feb 16 03:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 201898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp288021dyb; Thu, 15 Feb 2024 20:15:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW25qQ+VYIlZGEtxGfwFmB9jNgtGKJSiVTZUyJgyhDH9dx3j/JWAIrxQApYp4JtwTIvND8X33TABzLA1N0kF6Z/VX6q+g== X-Google-Smtp-Source: AGHT+IHTZ3x3G89HDlB/tXAOG5phVwkrQvcMBHQXMam4JAJ7U1xfpLGNhI2PLDSHy0/gro+hT2YN X-Received: by 2002:a17:906:a8c:b0:a3d:14d0:f253 with SMTP id y12-20020a1709060a8c00b00a3d14d0f253mr2556582ejf.9.1708056932209; Thu, 15 Feb 2024 20:15:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708056932; cv=pass; d=google.com; s=arc-20160816; b=ipZ7iseHx5ZESIH5K6XdKSLrMYu50E9EEupUGtV7DVgNUbF3VSVXpUw9vglt4YV5z9 UVDE61LX4tzO4eyQanruyokT2c+KErFxtdlXWePNc+Lwf4dwaPJNeWe9p1WcYSDsiymR FiijGzwjgm6tRieku+WTGMmkSWqDqsO7iAJIxSMpdMRPULBNxdIRtVcD9QogmgL5LIfv 46rjYCKkhR2YNCqH9EMhk+JyBou/YohYfY4WRrcwkysVtMr1pzf2RuVvGa3j259nqPUp wdSWC3qyuZZvvW/HOBqY03DgXJaDBy3H5HBFVFbSL0StRAqf/O3w92cHp2+BLCPWxuBn Jdzg== 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=Kqfk46HOPQ+19/hZvw7A39g+GudQNHlbfAP9rSygOlA=; fh=VKrp0Y7I/+wT36BfKZ6oI/4N9BIwFCn9zerObkOrgGw=; b=BJp+6v6I1DaEUrPIugswiHt2DokrWJ2JTEQaHFgmGWwzT/x0B3LtdG9oUfX7PE6PQI juTW1Pz8Kd/KuWw4BjxoTrXujlhH4K36sl7cJfxA6/u5lFcSwpDQyaKVuvz/i9doiley 0yYj1H9bGR51s01Z5QkoKCgLZpySwC12vx7UB7H8hF1b5OZojd9bOhnU1vn08c1WDL4G zsiq1IOqQcoAQZxOo+DaJWeYzvFha+EaArYfa3ofCo4NAEvAoSt92ncR0oX7CuLcD+Q2 UwTE0gpYOx+8AX1DlEyqfbjw8nQ1Gy0OgPJFqG3uBREj+aNFFk5cX9h0k7lNbp9u+Jh3 MjVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=S3rDWvYZ; 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-68029-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68029-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. [147.75.80.249]) by mx.google.com with ESMTPS id k16-20020a170906055000b00a3d13fa4a58si1249303eja.137.2024.02.15.20.15.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:15:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68029-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=S3rDWvYZ; 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-68029-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68029-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 020931F29DA3 for ; Fri, 16 Feb 2024 04:15:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3861E59160; Fri, 16 Feb 2024 04:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="S3rDWvYZ" 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 3E50D1DDF4; Fri, 16 Feb 2024 04:00:04 +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=1708056007; cv=none; b=dqMAmg8Tmle03/g0XJZVHezvfykQfLgdGRig8z0zBgxEIM9WnrxdXdkbLEHxdo6GDAJxsxdxAbai12X4X+6FTyE58Mkq3+yn/KTMvXK8MatBGfmp/ZsYLPFLtco28RZ8tgm64L10Vu+V0JKjSpRWvOXs4AIYcCBUUFuAxZyNReA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708056007; c=relaxed/simple; bh=YvXiQvwxdEUc8TXsqkCD0uJsEZco2x8/DRbjNpw03Hw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hvmzpMmM2cZz9txlBZr20Yf1yus6Iq03RTv4R+ZgXWt883sMDxm8VzbbOJuaoVM03nomLCAFwpxE3RLelVUgvKsU+36SL+qUvjeXtteyO473Cgrj8sa2l3fse/HrqH2OMwsn6Tu4HEj81ot6lkINLrxFM1z3SY0ZErZcSRWpozg= 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=S3rDWvYZ; 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 (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41G3lvlR021071; Fri, 16 Feb 2024 03:59:46 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=Kqfk46HOPQ+19/hZvw7A 39g+GudQNHlbfAP9rSygOlA=; b=S3rDWvYZiOA+o+6HE7bALHlZ3xTcQ34kuEcX hpMKAaUmEOpBUm3npV/CO+d6HOPfsCFeXN7HlWwkLXT/uf4J9o3FkZL5n7zbzrLs SJ7JqUr5VvhHUl3pgbzTWq4AZdZR3J+ABhyraxvR72NYjtusCly9aL6xfzOVOd8k 3fFf2NWnL+TeZ1RRCbV33ydYKrI7pq8elw5TWJD8rmvGjrzUXErGb2dC+NPGWavF Pow343/hJL332EI7F7n3gLIFdOA5tQ/wOljisqBIBmBXPbBVakqXxEtAX4uunDas 0FhcOlSARUGsAQuJIPE2+6y3IHy+t8uZEXrcWrE2g7CSbbf+Cg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wa03r80gk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59:45 +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 41G3xj8v032355 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59:45 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; Thu, 15 Feb 2024 19:59:44 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v16 43/50] ASoC: usb: Create SOC USB SND jack kcontrol Date: Thu, 15 Feb 2024 19:59:16 -0800 Message-ID: <20240216035923.23392-44-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240216035923.23392-1-quic_wcheng@quicinc.com> References: <20240216035923.23392-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-ORIG-GUID: 9f6feTpDblJS3amwTfXMgHfCTNr7hP1Y X-Proofpoint-GUID: 9f6feTpDblJS3amwTfXMgHfCTNr7hP1Y 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_03,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=823 lowpriorityscore=0 mlxscore=0 adultscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160031 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791027505613676461 X-GMAIL-MSGID: 1791027505613676461 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. Change-Id: Iee46f330bbea8c2c1a6d06977a3c7b8bb63adfa5 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) {