From nobody Sun Sep 14 11:02:37 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85C97C38142 for ; Mon, 23 Jan 2023 13:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbjAWN7p (ORCPT ); Mon, 23 Jan 2023 08:59:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231858AbjAWN7m (ORCPT ); Mon, 23 Jan 2023 08:59:42 -0500 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC1324114 for ; Mon, 23 Jan 2023 05:59:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674482373; x=1706018373; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/WXW21EG+pqy+W42CXni76Bfh0YGb++llEepThhlRRc=; b=Vvvpde2+d0eTl1hPh4Jpy8cfbBUg2HVP0Mmt+6Ek4W/VdFk43GUEUIWX rqMfgB6GHNnXe50/f4lUg6oQrkavbhLopNyO6FVBt4BD026W/vpDp35ZF bD3jgLOvpbpsUO2lYBi1X3/kwFtjpwQylv6pIamNkt0XfRXyA39KGUiAD 4eO+wCvOEoFkdjRChnjOilUZOvDbNCHqeGYAkFnN9btfDukZgk6eWMTy5 gksXuxOa/OzWaFvXOHQRNsfKBJdlArcZY/jwCzfg7Uii5T+TXJobtrjVx yqKe0HwXcl5tqqG2EOqNXM0c7MWedwjNsVFh1frU2cv1EZ4Z98gt8zuiW w==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai CC: , , , Astrid Rost Subject: [PATCH v3 1/3] ASoC: soc-component: add get_jack_type Date: Mon, 23 Jan 2023 14:59:11 +0100 Message-ID: <20230123135913.2720991-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230123135913.2720991-1-astrid.rost@axis.com> References: <20230123135913.2720991-1-astrid.rost@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add function to return the jack type of snd_jack_types. This allows a generic card driver to add a jack with the specified type. Signed-off-by: Astrid Rost --- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index c26ffb033777..3203d35bc8c1 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -98,6 +98,7 @@ struct snd_soc_component_driver { int source, unsigned int freq_in, unsigned int freq_out); int (*set_jack)(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data); + int (*get_jack_type)(struct snd_soc_component *component); =20 /* DT */ int (*of_xlate_dai_name)(struct snd_soc_component *component, @@ -384,6 +385,7 @@ int snd_soc_component_set_pll(struct snd_soc_component = *component, int pll_id, unsigned int freq_out); int snd_soc_component_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data); +int snd_soc_component_get_jack_type(struct snd_soc_component *component); =20 void snd_soc_component_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type type, int subseq); diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index e12f8244242b..3cd6952212e1 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -256,6 +256,26 @@ int snd_soc_component_set_jack(struct snd_soc_componen= t *component, } EXPORT_SYMBOL_GPL(snd_soc_component_set_jack); =20 +/** + * snd_soc_component_get_jack_type + * @component: COMPONENTs + * + * Returns the jack type of the component + * This can either be the supported type or one read from + * devicetree with the property: jack-type. + */ +int snd_soc_component_get_jack_type( + struct snd_soc_component *component) +{ + int ret =3D -ENOTSUPP; + + if (component->driver->get_jack_type) + ret =3D component->driver->get_jack_type(component); + + return soc_component_ret(component, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_component_get_jack_type); + int snd_soc_component_module_get(struct snd_soc_component *component, void *mark, int upon_open) { --=20 2.30.2 From nobody Sun Sep 14 11:02:37 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CEAEC38142 for ; Mon, 23 Jan 2023 13:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231989AbjAWN7r (ORCPT ); Mon, 23 Jan 2023 08:59:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbjAWN7n (ORCPT ); Mon, 23 Jan 2023 08:59:43 -0500 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E96025E2A for ; Mon, 23 Jan 2023 05:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674482374; x=1706018374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vpu9tETurwEUff35qr7E5xH/0FKUrT9IUn9FLfI3fJw=; b=V+BKYXJfed4nsSklcpI7qcIaERQKjmp4TyAFIN8C+XD2kSU+LVFy6wzJ dmPxAsFSKZD/0FqfO9G/Bais7SV7cWyDJDZ0vMeLuI8ZBdCXwXT/nLtff vzkNXC+fxm/sRTjk3h9H7F612bmglVVJpAxTXbwThd8Ys56mEejChxJ9I 0ipa+Kvp+mWh1CUvRFcx+EyVLyNhfG2sxDO/7UmKGm6lDj/qNj7vn0XcB DbTDDFi5+4ZqbUkYl2DWrCFxx0A6BOPIDqXgWrsU1pUezDdMdMxgyQSLT 0F+3kZkG8HPLOaWINHMA9IbaJy9m4EbRFbINdZLTN+yc7hHI619Ok2U5Y g==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai CC: , , , Astrid Rost Subject: [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs Date: Mon, 23 Jan 2023 14:59:12 +0100 Message-ID: <20230123135913.2720991-3-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230123135913.2720991-1-astrid.rost@axis.com> References: <20230123135913.2720991-1-astrid.rost@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a generic way to create jack inputs for auxiliary jack detection drivers (e.g. via i2c, spi), which are not part of any real codec. The simple-card can be used as combining card driver to add the jacks, no new one is required. Create a jack (for input-events) for jack devices in the auxiliary device list (aux_devs). A device which returns a valid value on get_jack_type counts as jack device; set_jack is required to add the jack to the device. Signed-off-by: Astrid Rost --- include/sound/simple_card_utils.h | 3 ++ sound/soc/generic/simple-card-utils.c | 49 +++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 4 +++ 3 files changed, 56 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_= utils.h index 38590f1ae9ee..a3f3f3aa9e6e 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -69,6 +69,7 @@ struct asoc_simple_priv { } *dai_props; struct asoc_simple_jack hp_jack; struct asoc_simple_jack mic_jack; + struct snd_soc_jack *aux_jacks; struct snd_soc_dai_link *dai_link; struct asoc_simple_dai *dais; struct snd_soc_dai_link_component *dlcs; @@ -187,6 +188,8 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card = *card, int asoc_simple_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, int is_hp, char *prefix, char *pin); +int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv, + char *prefix); int asoc_simple_init_priv(struct asoc_simple_priv *priv, struct link_info *li); int asoc_simple_remove(struct platform_device *pdev); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simp= le-card-utils.c index e35becce9635..56552a616f21 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -786,6 +786,55 @@ int asoc_simple_init_jack(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(asoc_simple_init_jack); =20 +int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv, char *prefix) +{ + struct snd_soc_card *card =3D simple_priv_to_card(priv); + struct snd_soc_component *component; + int found_jack_index =3D 0; + int type =3D 0; + int num =3D 0; + int ret; + + if (priv->aux_jacks) + return 0; + + for_each_card_auxs(card, component) { + type =3D snd_soc_component_get_jack_type(component); + if (type > 0) + num++; + } + if (num < 1) + return 0; + + priv->aux_jacks =3D devm_kcalloc(card->dev, num, + sizeof(struct snd_soc_jack), GFP_KERNEL); + if (!priv->aux_jacks) + return -ENOMEM; + + for_each_card_auxs(card, component) { + char id[128]; + struct snd_soc_jack *jack; + + if (found_jack_index >=3D num) + break; + + type =3D snd_soc_component_get_jack_type(component); + if (type <=3D 0) + continue; + + /* create jack */ + jack =3D &(priv->aux_jacks[found_jack_index++]); + snprintf(id, sizeof(id), "%s-jack", component->name); + ret =3D snd_soc_card_jack_new(card, id, type, jack); + if (ret) + continue; + + (void)snd_soc_component_set_jack(component, jack, NULL); + } + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_init_aux_jacks); + int asoc_simple_init_priv(struct asoc_simple_priv *priv, struct link_info *li) { diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-car= d.c index feb55b66239b..e98932c16754 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -623,6 +623,10 @@ static int simple_soc_probe(struct snd_soc_card *card) if (ret < 0) return ret; =20 + ret =3D asoc_simple_init_aux_jacks(priv, PREFIX); + if (ret < 0) + return ret; + return 0; } =20 --=20 2.30.2 From nobody Sun Sep 14 11:02:37 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01EDCC05027 for ; Mon, 23 Jan 2023 13:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232022AbjAWN7z (ORCPT ); Mon, 23 Jan 2023 08:59:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232042AbjAWN7t (ORCPT ); Mon, 23 Jan 2023 08:59:49 -0500 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4AA23DB7 for ; Mon, 23 Jan 2023 05:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674482383; x=1706018383; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GFfgTb34a//0h/wk1qs7LHk+iVK4qzPfVOmAPGqO2dk=; b=IlW/XCh4wi3QdBU/iv9N0/iOD5OlNlKkIKdd9P6vX1omT7PYm8jtlQYt hp53/cxam38jzCdrTlUl+Cp734dTqaguiN5xYd5OithsfJNp6LZPXKd4z AtN4RGK1Bnr0zPaDv+ArXGtNPRa8Y7oLJp0uZy2wAXMi73a4Awn42WtMb LKMf2q8BLBcjZ6yBPQzFt8JGEKaLb4/v2OjIFunC7DeGZRuTxwErvzF3b x9T8oDqoeaJisWEdm5FwXQIzUH/sYaePu4B+YcdJbGtzkaFUTVsIxNLFz 3ix4DwIoeplLNAkyOcaCkFyKBBxd1c/qta8SN2W+HG+MORZJyuaGkFaz3 A==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai CC: , , , Astrid Rost Subject: [PATCH v3 3/3] ASoC: ts3a227e: add set_jack and get_jack_type Date: Mon, 23 Jan 2023 14:59:13 +0100 Message-ID: <20230123135913.2720991-4-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230123135913.2720991-1-astrid.rost@axis.com> References: <20230123135913.2720991-1-astrid.rost@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add set_jack and get_jack_type to allow simple-card-utils to add a jack for it. Signed-off-by: Astrid Rost --- sound/soc/codecs/ts3a227e.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 2305a472d132..5282112c7d8d 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -258,7 +258,25 @@ int ts3a227e_enable_jack_detect(struct snd_soc_compone= nt *component, } EXPORT_SYMBOL_GPL(ts3a227e_enable_jack_detect); =20 -static struct snd_soc_component_driver ts3a227e_soc_driver; +static int ts3a227e_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *jack, void *data) +{ + if (jack =3D=3D NULL) + return -EINVAL; + + return ts3a227e_enable_jack_detect(component, jack); +} + +static int ts3a227e_get_jack_type(struct snd_soc_component *component) +{ + return SND_JACK_HEADSET; +} + +static const struct snd_soc_component_driver ts3a227e_soc_driver =3D { + .name =3D "ti,ts3a227e", + .set_jack =3D ts3a227e_set_jack, + .get_jack_type =3D ts3a227e_get_jack_type, +}; =20 static const struct regmap_config ts3a227e_regmap_config =3D { .val_bits =3D 8, --=20 2.30.2