]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
ASoC: rt5640: add option for jack detection source
authorDavid Yu <davyu@nvidia.com>
Mon, 27 Feb 2017 07:34:20 +0000 (16:34 +0900)
committermobile promotions <svcmobile_promotions@nvidia.com>
Tue, 7 Mar 2017 08:10:44 +0000 (00:10 -0800)
by default, only JD2 as jack detection source is available.
for other platforms using the different source, adding dt property,
sel_jd_source.

0 = OFF
1 = GPIO1
2 = JD1
3 = JD2
4 = GPIO2

Bug 200283058
Bug 200265232

Change-Id: Ic5ce3b1d6ddf8e238786072f140c4756d3c7640a
Signed-off-by: Harry Hong <hhong@nvidia.com>
Reviewed-on: http://git-master/r/776070
Signed-off-by: David Yu <davyu@nvidia.com>
Reviewed-on: http://git-master/r/1311714
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
sound/soc/codecs/rt5640.c
sound/soc/codecs/rt5640.h
sound/soc/tegra-alt/tegra_t210ref_mobile_alt.c

index 9585d95f25e263d52249c2d40c430f2b93848742..dbc6a89e775a87f7ff7cbf8bc25702d03c3ec2d7 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2011 Realtek Semiconductor Corp.
  * Author: Johnny Hsu <johnnyhsu@realtek.com>
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2017, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -2048,9 +2048,14 @@ static int rt5640_probe(struct snd_soc_codec *codec)
                break;
        case RT5640_ID_5639:
                /* Enable JD2 Function for Extra JD Status */
+               snd_soc_update_bits(codec, RT5640_DUMMY1, 0x3b01, 0x3b01);
                snd_soc_write(codec, RT5640_DUMMY2, 0x4140);
-               snd_soc_write(codec, RT5640_JD_CTRL, 0x6000);
-               snd_soc_write(codec, 0xbb, 0x6000);
+               if (rt5640->sel_jd_source >= 0)
+                       snd_soc_update_bits(codec, RT5640_JD_CTRL,
+                               RT5640_JD_MASK,
+                               rt5640->sel_jd_source << RT5640_JD_SFT);
+               else
+                       snd_soc_write(codec, RT5640_JD_CTRL, 0x6000);
 
                snd_soc_dapm_new_controls(dapm,
                        rt5639_specific_dapm_widgets,
@@ -2158,7 +2163,7 @@ int rt5640_headset_detect(struct snd_soc_codec *codec,
                        snd_soc_write(codec, RT5640_PWR_ANLG1, 0xa814);
                        snd_soc_write(codec, RT5640_MICBIAS, 0x3810);
                        snd_soc_write(codec, RT5640_DUMMY1, 0x3b01);
-                   snd_soc_update_bits(codec, RT5640_GLB_CLK,
+                       snd_soc_update_bits(codec, RT5640_GLB_CLK,
                                RT5640_SCLK_SRC_MASK,
                                0x3 << RT5640_SCLK_SRC_SFT);
                }
@@ -2397,6 +2402,10 @@ static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np)
 
        rt5640->pdata.ldo1_en = of_get_named_gpio(np,
                                        "realtek,ldo1-en-gpios", 0);
+
+       if (of_property_read_s32(np, "sel_jd_source", &rt5640->sel_jd_source))
+               rt5640->sel_jd_source = -1;
+
        /*
         * LDO1_EN is optional (it may be statically tied on the board).
         * -ENOENT means that the property doesn't exist, i.e. there is no
index ee87cfb74727d32856652c4c25f3aa1127e3d2e6..881230d9901b39df965f0a5cde6e54049e83059d 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright 2011 Realtek Microelectronics
  * Author: Johnny Hsu <johnnyhsu@realtek.com>
+ * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -2094,6 +2095,8 @@ struct rt5640_priv {
        int pll_in;
        int pll_out;
 
+       int sel_jd_source;
+
        bool hp_mute;
 };
 
index e8cfb674865d63a415837414cb3d43f8b7736ed5..98eefa7a73d5a72fe7b6d81bddd021abcc4564eb 100644 (file)
@@ -159,8 +159,7 @@ static int tegra_t210ref_jack_notifier(struct notifier_block *self,
                                jack->status |= SND_JACK_HEADPHONE;
                                jack->status |= SND_JACK_MICROPHONE;
                        }
-               }
-       } else {
+               } else {
                        /* Disable ext mic; enable signal is active-low*/
                        if (gpio_is_valid(pdata->gpio_ext_mic_en))
                                gpio_direction_output(
@@ -170,6 +169,7 @@ static int tegra_t210ref_jack_notifier(struct notifier_block *self,
 
                        jack->status &= ~SND_JACK_HEADPHONE;
                        jack->status &= ~SND_JACK_MICROPHONE;
+               }
        }
 
        switch (jack->status) {