From: Krzysztof Kozlowski <krzk@kernel.org>
To: Artur Weber <aweber.kernel@gmail.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH 2/3] ASoC: samsung: midas_wm1811: Add GPIO-based headset jack detection
Date: Mon, 6 May 2024 08:30:29 +0200 [thread overview]
Message-ID: <1038ca45-b9e9-4625-9c43-5ef4abf4a86d@kernel.org> (raw)
In-Reply-To: <20240503-midas-wm1811-gpio-jack-v1-2-e8cddbd67cbf@gmail.com>
On 03/05/2024 20:55, Artur Weber wrote:
> Some Samsung devices that use the midas_wm1811 driver use a GPIO-based
> method for detecting whether the headset jack is plugged in, as well as
> detecting which headset buttons are pressed. There are two GPIOs:
> a "headset detect" GPIO responsible for detecting jack insertion, and
> a "headset key" GPIO which triggers when a button on the headset is
> pressed. The plug type and the button pressed are determined based
> on information from an ADC channel.
...
>
> @@ -433,6 +590,9 @@ static int midas_probe(struct platform_device *pdev)
> struct snd_soc_card *card = &midas_card;
> struct device *dev = &pdev->dev;
> static struct snd_soc_dai_link *dai_link;
> + enum iio_chan_type channel_type;
> + u32 fourpole_threshold[2];
> + u32 button_threshold[3];
> struct midas_priv *priv;
> int ret, i;
>
> @@ -468,6 +628,91 @@ static int midas_probe(struct platform_device *pdev)
> return PTR_ERR(priv->gpio_lineout_sel);
> }
>
> + priv->gpio_headset_detect = devm_gpiod_get_optional(dev,
> + "headset-detect", GPIOD_IN);
> + if (IS_ERR(priv->gpio_headset_detect)) {
> + dev_err(dev, "Failed to get headset jack detect GPIO\n");
syntax is:
return dev_err_probe()
> + return PTR_ERR(priv->gpio_headset_detect);
> + }
> +
> + if (priv->gpio_headset_detect) {
> + priv->adc_headset_detect = devm_iio_channel_get(dev,
> + "headset-detect");
> + if (IS_ERR(priv->adc_headset_detect)) {
> + dev_err(dev, "Failed to get ADC channel\n");
return dev_err_probe()
> + return PTR_ERR(priv->adc_headset_detect);
> + }
> +
> + ret = iio_get_channel_type(priv->adc_headset_detect,
> + &channel_type);
> + if (ret) {
> + dev_err(dev, "Failed to get ADC channel type\n");
> + return ret;
> + }
> +
> + if (channel_type != IIO_VOLTAGE) {
> + dev_err(dev, "ADC channel is not voltage\n");
> + return ret;
> + }
> +
> + priv->gpio_headset_key = devm_gpiod_get(dev, "headset-key",
> + GPIOD_IN);
> + if (IS_ERR(priv->gpio_headset_key)) {
> + dev_err(dev, "Failed to get headset key gpio\n");
return dev_err_probe()
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-05-06 6:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 18:55 [PATCH 0/3] ASoC: samsung: midas-audio: Add GPIO-based headset jack detection Artur Weber
2024-05-03 18:55 ` [PATCH 1/3] ASoC: dt-bindings: samsung,midas-audio: " Artur Weber
2024-05-06 6:28 ` Krzysztof Kozlowski
2024-05-03 18:55 ` [PATCH 2/3] ASoC: samsung: midas_wm1811: " Artur Weber
2024-05-06 6:30 ` Krzysztof Kozlowski [this message]
2024-05-03 18:55 ` [PATCH 3/3] ARM: dts: samsung: exynos4212-tab3: Fix headset mic, add " Artur Weber
2024-05-06 6:31 ` Krzysztof Kozlowski
2024-05-07 12:44 ` Artur Weber
2024-05-07 14:53 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1038ca45-b9e9-4625-9c43-5ef4abf4a86d@kernel.org \
--to=krzk@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=alsa-devel@alsa-project.org \
--cc=aweber.kernel@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=tiwai@suse.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox