diff mbox

AsoC: tegra_max98090: honor headphone detect GPIO polarity

Message ID 1456940623-1496-1-git-send-email-sctincman@gmail.com
State Deferred
Headers show

Commit Message

Jonathan Tinkham March 2, 2016, 5:43 p.m. UTC
Set the invert property for the headphone jack depending on the GPIO polarity
in the device-tree.

Signed-off-by: Jonathan Tinkham <sctincman@gmail.com>
---
 sound/soc/tegra/tegra_max98090.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stephen Warren March 3, 2016, 6:37 p.m. UTC | #1
On 03/02/2016 10:43 AM, Jonathan Tinkham wrote:
> Set the invert property for the headphone jack depending on the GPIO polarity
> in the device-tree.
>
> Signed-off-by: Jonathan Tinkham <sctincman@gmail.com>
> ---

I think this is an updatd version of a previous patch, so it should say 
"[PATCH V2]" in the subject, and have a description of the changes you 
made between the versions here, below the --- line.

> diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
> index 902da36..da4e8d1 100644
> --- a/sound/soc/tegra/tegra_max98090.c
> +++ b/sound/soc/tegra/tegra_max98090.c
> @@ -42,6 +42,7 @@
>   struct tegra_max98090 {
>   	struct tegra_asoc_utils_data util_data;
>   	int gpio_hp_det;
> +	enum of_gpio_flags gpio_hp_det_flags;
>   	int gpio_mic_det;
>   };
>
> @@ -155,6 +156,8 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
>   				      ARRAY_SIZE(tegra_max98090_hp_jack_pins));
>
>   		tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det;
> +		tegra_max98090_hp_jack_gpio.invert =
> +			machine->gpio_hp_det_flags & OF_GPIO_ACTIVE_LOW;

So now, this .invert flag is always set directly based on the GPIO 
flags. That's good.

I believe this means you should remove the .invert assignment from 
static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio too, since 
it's always over-written, so doesn't need a default value.

Question: Should we make the same change for DT property 
nvidia,mic-det-gpios and value tegra_max98090_mic_jack_gpio.invert? 
tegra124-nyan.dts currently says GPIO_ACTIVE_HIGH for both hp-det-gpios 
and mic-det-gpios. I don't know if the DT is correct for both of those 
(and hence making the same change for the mic-det-gpios would break 
Nyan) or not.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Tinkham March 4, 2016, 5:42 p.m. UTC | #2
On 03/03/2016 11:37 AM, Stephen Warren wrote:
> On 03/02/2016 10:43 AM, Jonathan Tinkham wrote:
>> Set the invert property for the headphone jack depending on the GPIO 
>> polarity
>> in the device-tree.
>>
>> Signed-off-by: Jonathan Tinkham <sctincman@gmail.com>
>> ---
>
> I think this is an updatd version of a previous patch, so it should 
> say "[PATCH V2]" in the subject, and have a description of the changes 
> you made between the versions here, below the --- line.

Ah yes, my apologies. For the next version should I increment that to v3 
or v2 then?
>
>> diff --git a/sound/soc/tegra/tegra_max98090.c 
>> b/sound/soc/tegra/tegra_max98090.c
>> index 902da36..da4e8d1 100644
>> --- a/sound/soc/tegra/tegra_max98090.c
>> +++ b/sound/soc/tegra/tegra_max98090.c
>> @@ -42,6 +42,7 @@
>>   struct tegra_max98090 {
>>       struct tegra_asoc_utils_data util_data;
>>       int gpio_hp_det;
>> +    enum of_gpio_flags gpio_hp_det_flags;
>>       int gpio_mic_det;
>>   };
>>
>> @@ -155,6 +156,8 @@ static int tegra_max98090_asoc_init(struct 
>> snd_soc_pcm_runtime *rtd)
>> ARRAY_SIZE(tegra_max98090_hp_jack_pins));
>>
>>           tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det;
>> +        tegra_max98090_hp_jack_gpio.invert =
>> +            machine->gpio_hp_det_flags & OF_GPIO_ACTIVE_LOW;
>
> So now, this .invert flag is always set directly based on the GPIO 
> flags. That's good.
>
> I believe this means you should remove the .invert assignment from 
> static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio too, since 
> it's always over-written, so doesn't need a default value.
>
> Question: Should we make the same change for DT property 
> nvidia,mic-det-gpios and value tegra_max98090_mic_jack_gpio.invert? 
> tegra124-nyan.dts currently says GPIO_ACTIVE_HIGH for both 
> hp-det-gpios and mic-det-gpios. I don't know if the DT is correct for 
> both of those (and hence making the same change for the mic-det-gpios 
> would break Nyan) or not.
Hmmm, it is indeed the same logic. I will implement and test on nyan.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Warren March 4, 2016, 5:47 p.m. UTC | #3
On 03/04/2016 10:42 AM, Jonathan Tinkham wrote:
>
>
> On 03/03/2016 11:37 AM, Stephen Warren wrote:
>> On 03/02/2016 10:43 AM, Jonathan Tinkham wrote:
>>> Set the invert property for the headphone jack depending on the GPIO
>>> polarity
>>> in the device-tree.
>>>
>>> Signed-off-by: Jonathan Tinkham <sctincman@gmail.com>
>>> ---
>>
>> I think this is an updatd version of a previous patch, so it should
>> say "[PATCH V2]" in the subject, and have a description of the changes
>> you made between the versions here, below the --- line.
>
> Ah yes, my apologies. For the next version should I increment that to v3
> or v2 then?

May as well make it V3 since that's what it is:-)
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
index 902da36..da4e8d1 100644
--- a/sound/soc/tegra/tegra_max98090.c
+++ b/sound/soc/tegra/tegra_max98090.c
@@ -42,6 +42,7 @@ 
 struct tegra_max98090 {
 	struct tegra_asoc_utils_data util_data;
 	int gpio_hp_det;
+	enum of_gpio_flags gpio_hp_det_flags;
 	int gpio_mic_det;
 };
 
@@ -155,6 +156,8 @@  static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
 				      ARRAY_SIZE(tegra_max98090_hp_jack_pins));
 
 		tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det;
+		tegra_max98090_hp_jack_gpio.invert =
+			machine->gpio_hp_det_flags & OF_GPIO_ACTIVE_LOW;
 		snd_soc_jack_add_gpios(&tegra_max98090_hp_jack,
 					1,
 					&tegra_max98090_hp_jack_gpio);
@@ -234,7 +237,8 @@  static int tegra_max98090_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, card);
 	snd_soc_card_set_drvdata(card, machine);
 
-	machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0);
+	machine->gpio_hp_det = of_get_named_gpio_flags(
+		np, "nvidia,hp-det-gpios", 0, &machine->gpio_hp_det_flags);
 	if (machine->gpio_hp_det == -EPROBE_DEFER)
 		return -EPROBE_DEFER;