Re: [PATCH 2/3] ASoC: samsung: midas_wm1811: Add GPIO-based headset jack detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux