From nobody Sun Sep 14 20:25:46 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 2E8D8C38147 for ; Wed, 18 Jan 2023 13:26:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbjARN0T (ORCPT ); Wed, 18 Jan 2023 08:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231672AbjARNZe (ORCPT ); Wed, 18 Jan 2023 08:25:34 -0500 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F80A9B11A for ; Wed, 18 Jan 2023 04:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674046360; x=1705582360; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/x6a0kRqZFzfACVy+tFZa/D9buCWMk7aPEZ6L3MonEA=; b=kEwuorQ0DMhcfZFTIhFT5F/jom3ZIXO2OGSjrpg+vM+iF/G4FQQrF2IN O2yQ/LHkHn46R2fk+Qv0ofE+lppaox1QR8jv7ksH2WpPvlLzjGoCeITOT rKSN3A1qJiZb2yQMHMBl1TVN4nQtS6W1hgwp8QN5IeWPM8RwN5IPV6z2G U+xdLWxeBUCcAsyOBsClt0O1vKLnbrNbWRkGNTwKAxWrohcv32AUhd7v7 MLdqvmW485U2xdd6Q8zq0y92WsAO4E3GS7l7NOlmyy4xwF8Uy8QscGYrd 1TLHaLthuiApM/xdTUIGdyHA42e6CnwHPItEQ+9owezkyEYpjiWq3Tm1e g==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai CC: , , , Astrid Rost Subject: [PATCH v1 1/4] ASoC: soc-component: add get_jack_supported_type Date: Wed, 18 Jan 2023 13:52:23 +0100 Message-ID: <20230118125226.333214-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230118125226.333214-1-astrid.rost@axis.com> References: <20230118125226.333214-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 supported jack type of snd_jack_types. This allows a generic card driver to check whether the jack type is valid or add all supported ones. Signed-off-by: Astrid Rost --- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index c26ffb033777..5aa43c323028 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_supported_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_supported_type(struct snd_soc_component *co= mponent); =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..112da1647f10 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -256,6 +256,24 @@ 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_supported_type + * @component: COMPONENTs + * + * Returns the supported jack type of the component + */ +int snd_soc_component_get_jack_supported_type( + struct snd_soc_component *component) +{ + int ret =3D -ENOTSUPP; + + if (component->driver->get_jack_supported_type) + ret =3D component->driver->get_jack_supported_type(component); + + return soc_component_ret(component, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_component_get_jack_supported_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 20:25:46 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 972C5C32793 for ; Wed, 18 Jan 2023 13:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231149AbjARNZ4 (ORCPT ); Wed, 18 Jan 2023 08:25:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbjARNZU (ORCPT ); Wed, 18 Jan 2023 08:25:20 -0500 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BBE77CCC0 for ; Wed, 18 Jan 2023 04:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674046352; x=1705582352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SDuZPaHsxgFdJEIP3i2Sn6P/NroSujvTJa3yqm7oHHI=; b=n9p3JwfPY9TxVbx5u8UMOxd/dhSZYoBqCDll3/aGS1AGvE91ctIJTrGY regvK3W4qqElNLkcoqxnLunTwROGRnQUoZ2biGkquJcUbytnGE6imQIW8 d8tAYWGLaQRJIfJBeq6VyM8zkqDTz+oQVjdC8IQ/sxjj0sXbQDX9l4sfN WvXNZxtnbRmRZQVSmWAA+T++kL+MD1ObJ75z1SZ2gzR0HV7B4TLQLVhTY poGaezo1CVjmT3cQfBZrsS3ihJf/HG9oK+z2NmqC3Lb3xm1/Z/mZsoeHz QG2CUAktvCZ6LAF27fDUz7wif9LNDg5Y6GBvlPBEYKdZpcIbhto656Gv8 Q==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai CC: , , , Astrid Rost Subject: [PATCH v1 2/4] ASoC: simple-card-utils: create jack inputs for aux_devs Date: Wed, 18 Jan 2023 13:52:24 +0100 Message-ID: <20230118125226.333214-3-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230118125226.333214-1-astrid.rost@axis.com> References: <20230118125226.333214-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 has the functions set_jack and get_jack_supported_type counts as jack device. Add a devicetree entry, in case not all input types are required. simple-card,aux-jack-types: Array of snd_jack_type to create jack-input-event for jack devices in aux-devs. If the setting is 0, the supported type of the device is used. Signed-off-by: Astrid Rost --- include/sound/simple_card_utils.h | 3 ++ sound/soc/generic/simple-card-utils.c | 63 +++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 4 ++ 3 files changed, 70 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..668123549fbf 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -786,6 +786,69 @@ 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 device *dev =3D card->dev; + struct snd_soc_component *component; + char prop[128]; + int found_jack_index =3D 0; + int num =3D 0; + int ret; + + if (priv->aux_jacks) + return 0; + + snprintf(prop, sizeof(prop), "%saux-jack-types", prefix); + num =3D of_property_count_u32_elems(dev->of_node, prop); + 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) { + if (found_jack_index >=3D num) + break; + + if (component->driver->set_jack && + component->driver->get_jack_supported_type) { + char id[128]; + int type =3D 0; + struct snd_soc_jack *jack =3D + &(priv->aux_jacks[found_jack_index]); + int type_supp_mask =3D + snd_soc_component_get_jack_supported_type( + component); + + ret =3D of_property_read_u32_index( + dev->of_node, prop, found_jack_index++, &type); + if (ret) + continue; + + if (type) + type &=3D type_supp_mask; /* use only supported types */ + else + type =3D type_supp_mask; /* use all supported types */ + + if (!type) + continue; + + /* create jack */ + 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 20:25:46 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 3C91EC32793 for ; Wed, 18 Jan 2023 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjARN00 (ORCPT ); Wed, 18 Jan 2023 08:26:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbjARNZg (ORCPT ); Wed, 18 Jan 2023 08:25:36 -0500 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88F979AAB1 for ; Wed, 18 Jan 2023 04:52:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674046362; x=1705582362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c9tQ6467axGUUkqK8Hn/WxBs1AovQDwhp7i0J3ZaltU=; b=oUTJko1HiCs47ScSwNDFuyBfNE3/2E0xF+mmifvzaRtcShJ/MXnqcHDa 29gKUadym3+U7+WVCNHoP9uvyS4348E3/lpNlI1nwRC6mNj0QDzvgTEg/ DPSu18dUf4VREGNeM9BDgNV3hwz73rG/IcU/BVJN+0qflq01JqhAcC/uf K1eu20Wa9h8CJN7GJiubj2tcQCAJl/bbNExAZOn1qYV1rU6FND0ikxNfu QUg/MHcgYuO2t+PFvzrFFyRHsz/sSrAmGNLWbv+Eoxyk60OelSrx4H6/F NOI/Jn5IkJTAf3jTbC/QzcloJxQdtv137/5qNNgBYNzsNSaCGhvt7ppvX A==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai CC: , , , Astrid Rost Subject: [PATCH v1 3/4] ASoC: ts3a227e: add set_jack and get_jack_supported_type Date: Wed, 18 Jan 2023 13:52:25 +0100 Message-ID: <20230118125226.333214-4-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230118125226.333214-1-astrid.rost@axis.com> References: <20230118125226.333214-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_supported_type to allow simple-card-utils to add a jack for it. Signed-off-by: Astrid Rost --- sound/soc/codecs/ts3a227e.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 2305a472d132..212dfd2b60ed 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -258,7 +258,22 @@ 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) +{ + return ts3a227e_enable_jack_detect(component, jack); +} + +static int ts3a227e_get_supported_jack_type(struct snd_soc_component *comp= onent) +{ + return TS3A227E_JACK_MASK; +} + +static const struct snd_soc_component_driver ts3a227e_soc_driver =3D { + .name =3D "ti,ts3a227e", + .set_jack =3D ts3a227e_set_jack, + .get_jack_supported_type =3D ts3a227e_get_supported_jack_type, +}; =20 static const struct regmap_config ts3a227e_regmap_config =3D { .val_bits =3D 8, --=20 2.30.2 From nobody Sun Sep 14 20:25:46 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 3953EC32793 for ; Wed, 18 Jan 2023 13:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbjARN03 (ORCPT ); Wed, 18 Jan 2023 08:26:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbjARNZj (ORCPT ); Wed, 18 Jan 2023 08:25:39 -0500 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBFA59EE09; Wed, 18 Jan 2023 04:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1674046363; x=1705582363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9tpzvI7fdZDoAPrHN+US7UGk+e/yxtX1rAxxB7G8nrs=; b=Iy+5CP26+TNYmwUfX0m5NAr/r09Z11LCCPN4aobXxgHRcPSxR7vic8KZ tYWuvLK71Du6z7TegR/4dE/T3fikMYoTgr0uKmyrpjesCts4H8JC2uBL7 Li8Ba1JrWooLLUsJ+KMcel0TPlWgB5g0N+fn/AujQihFdHfsrVHeTYUUs /NLiUoFH915l91i0X/+nNCY3taUVndjIOH3UBqWcafbJ/tjv79YM+D/cE phw96VsabNtBz08UTAkVPTZJ8hpPWIvu7uZANxGeBoIkodtPzFgTutOFK 8AGsq6XYngTSiCrKruMrprpkZ3xyaUFtX9l0KKeiAamf6iYsu/uJZg2S9 Q==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Rob Herring , Kuninori Morimoto CC: , , , Astrid Rost , Subject: [PATCH v1 4/4] ASoC: dt-bindings: simple-card: create jack for aux_devs Date: Wed, 18 Jan 2023 13:52:26 +0100 Message-ID: <20230118125226.333214-5-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230118125226.333214-1-astrid.rost@axis.com> References: <20230118125226.333214-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 simple-card,aux-jack-types: Array of snd_jack_type to create jack-input-event for jack devices in aux-devs. If the setting is 0, the supported type of the device is used. A device which has the functions set_jack and get_jack_supported_type counts as jack device. Signed-off-by: Astrid Rost --- .../bindings/sound/simple-card.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Doc= umentation/devicetree/bindings/sound/simple-card.yaml index ed19899bc94b..2635b1c04fc9 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.yaml +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml @@ -199,6 +199,13 @@ properties: maxItems: 1 simple-audio-card,mic-det-gpio: maxItems: 1 + simple-audio-card,aux-jack-types: + $ref: "/schemas/types.yaml#/definitions/uint32-array" + description: | + Array of snd_jack_type to create jack-input-event for jack + devices in aux-devs. If the setting is 0, the supported + type of the device is used. A device which has the functions + set_jack and get_jack_supported_type counts as jack device. =20 patternProperties: "^simple-audio-card,cpu(@[0-9a-f]+)?$": @@ -498,3 +505,31 @@ examples: }; }; }; +#-------------------- +# Add a headphone and a headset mic jack, +# which use an auxiliary jack detector e.g. via i2c. +# The events, which should be enabled are: +# SND_JACK_HEADPHONE =3D 1 +# SND_JACK_MICROPHONE =3D 2 +#-------------------- + - | + sound { + compatible =3D "simple-audio-card"; + simple-audio-card,widgets =3D + "Headphone", "Headphone Jack", + "Headset Mic", "Headset Mic Jack"; + simple-audio-card,routing =3D + "Headphone Jack", "HPLEFT", + "Headphone Jack", "HPRIGHT", + "LEFTIN", "Headset Mic", + "RIGHTIN", "Headset Mic"; + simple-audio-card,aux-devs =3D <&hp_jack>, <&hs_mic_jack>; + simple-audio-card,aux-jack-types =3D <1 2>; + simple-audio-card,cpu { + sound-dai =3D <&ssi2>; + }; + simple-audio-card,codec { + sound-dai =3D <&codec>; + clocks =3D <&clocks>; + }; + }; --=20 2.30.2