From nobody Mon Apr 6 06:33:15 2026 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 231EFECAAA1 for ; Fri, 9 Sep 2022 09:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbiIIJcw (ORCPT ); Fri, 9 Sep 2022 05:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbiIIJcU (ORCPT ); Fri, 9 Sep 2022 05:32:20 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87410D51DC for ; Fri, 9 Sep 2022 02:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1662715810; x=1694251810; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5kDWDLM4dvskJrZT61dQQhMEV6z9clf/KDjy1daE//E=; b=ZBVMNSVRckIYBdIBpFJIJG2LzwctJylgvHmyLc+IxR0LjKdug3P0Y20f fgXmqHTX7dtIrz4c/7hPzWbPyMtDnUwrVnlJJNAaWbztc0nWr09Y4Y0LW jKTgmfT/uL3ukAyTR9GEjOa+Lo7PLOVp80Gyka3BaHtBTO6vpjOTk2q/w HdmSonO/HEsVTU1DeAyHJtcL54YZik/6w5BC93Fc1bW1vwvaFCbnytNYR rvhxddNhFobVHBt1eWpy2+C8Wz5X3QlWGEgTWSuusNJkwXoNayqfbxV37 Ze6lCm0/w7+1RN93tyI/i7P2gQuVAnlz0xyXFNGgr6tDB1/2mnAtaaYX8 A==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai CC: , alsa-devel-mejlinglistan , Astrid Rost , Subject: [PATCH] ASoC: ts3a227e: allow enabling the jack detect in driver Date: Fri, 9 Sep 2022 11:30:01 +0200 Message-ID: <20220909093001.13110-1-astrid.rost@axis.com> X-Mailer: git-send-email 2.20.1 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" ti,jack-detect enables the jack detection input device Signed-off-by: Astrid Rost Reported-by: kernel test robot --- sound/soc/codecs/Kconfig | 2 ++ sound/soc/codecs/ts3a227e.c | 62 ++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index d16b4efb88a7..cb86e52cd02f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -1671,6 +1671,8 @@ config SND_SOC_TLV320ADCX140 config SND_SOC_TS3A227E tristate "TI Headset/Mic detect and keypress chip" depends on I2C + select SND_JACK + select SND_JACK_INPUT_DEV =20 config SND_SOC_TSCS42XX tristate "Tempo Semiconductor TSCS42xx CODEC" diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index d8ab0810fceb..b5d0d32cafdb 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -38,6 +38,32 @@ static const int ts3a227e_buttons[] =3D { SND_JACK_BTN_3, }; =20 +/* Headphones jack detection DAPM pin */ +static struct snd_soc_jack_pin ts3a227e_jack_pins[] =3D { + + { + .pin =3D "Headphone Jack", + .mask =3D SND_JACK_HEADPHONE, + }, + { + .pin =3D "Internal Speaker", + /* disable speaker when hp jack is inserted */ + .mask =3D SND_JACK_HEADPHONE, + .invert =3D 1, + }, + { + .pin =3D "Headset Mic", + .mask =3D SND_JACK_MICROPHONE, + }, + { + .pin =3D "Internal Mic", + /* disable microphone when microphone jack is inserted */ + .mask =3D SND_JACK_MICROPHONE, + .invert =3D 1, + }, + +}; + #define TS3A227E_NUM_BUTTONS 4 #define TS3A227E_JACK_MASK (SND_JACK_HEADPHONE | \ SND_JACK_MICROPHONE | \ @@ -250,7 +276,12 @@ 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_probe(struct snd_soc_component *component); + +static const struct snd_soc_component_driver ts3a227e_soc_driver =3D { + .name =3D "Audio Accessory Detection ts3a227e", + .probe =3D ts3a227e_probe, +}; =20 static const struct regmap_config ts3a227e_regmap_config =3D { .val_bits =3D 8, @@ -355,6 +386,35 @@ static int ts3a227e_resume(struct device *dev) } #endif =20 +static int ts3a227e_probe(struct snd_soc_component *component) +{ + int ret =3D 0; + bool enable =3D 0; + struct snd_soc_card *card =3D component->card; + struct ts3a227e *ts3a227e =3D snd_soc_component_get_drvdata(component); + + enable =3D device_property_read_bool(component->dev, "ti,jack-detect"); + if (enable) { + /* Enable Headset and 4 Buttons Jack detection */ + ts3a227e->jack =3D devm_kzalloc(component->dev, + sizeof(struct snd_soc_jack), GFP_KERNEL); + + ret =3D snd_soc_card_jack_new_pins(card, "Headset Jack", + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3, + ts3a227e->jack, + ts3a227e_jack_pins, + ARRAY_SIZE(ts3a227e_jack_pins)); + if (ret) + return ret; + + ret =3D ts3a227e_enable_jack_detect(component, ts3a227e->jack); + } + + return ret; +} + static const struct dev_pm_ops ts3a227e_pm =3D { SET_SYSTEM_SLEEP_PM_OPS(ts3a227e_suspend, ts3a227e_resume) }; --=20 2.20.1