[9609][EVB] audio: The SPK ID is moved to the machine level
authorShinHyung <s47.kang@samsung.com>
Tue, 16 Oct 2018 02:04:17 +0000 (11:04 +0900)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:29:48 +0000 (17:29 +0800)
Change-Id: I6638e06b1fb2628468dba676a49369fe76065108
Signed-off-by: ShinHyung <s47.kang@samsung.com>
arch/arm64/boot/dts/exynos/exynos9609-robusta2_evb.dts
sound/soc/samsung/exynos9610_madera.c

index bc5d627e8a6d2479683950a813190b294f255005..4f4f8b2db37cecd37cc12b1840dc0b795bd1f87e 100755 (executable)
 
                                cirrus,opclk = <3 0 12288000>;
 
+                               gpios = <&gpm25 0 0>;
+
                                samsung,routing =
                                        "HEADSETMIC", "MICBIAS1B",
                                        "IN1BR", "HEADSETMIC",
index 6585fc5387fa3c36ccd0bd43e3c3a7e73fb1a81e..e3740a6ee91f0e58b9b32f7acee43439b4b92ab6 100755 (executable)
@@ -21,6 +21,7 @@
 #include <linux/of.h>
 #include <linux/clk.h>
 #include <linux/slab.h>
+#include <linux/of_gpio.h>
 
 #include <soc/samsung/exynos-pmu.h>
 #include <sound/samsung/abox.h>
@@ -92,9 +93,12 @@ struct madera_drvdata {
        int left_amp_dai;
        int right_amp_dai;
        struct clk *clk[MADERA_MAX_CLOCKS];
+       unsigned int spk_id;
+       int spk_id_value;
 };
 
 static struct madera_drvdata exynos9610_drvdata;
+static struct snd_soc_card exynos9610_madera;
 
 static int map_fllid_with_name(const char *name)
 {
@@ -1099,10 +1103,24 @@ static const char * const vts_output_texts[] = {
         "DMIC1",
 };
 
+static int madera_spk_id_get(struct snd_kcontrol *kcontrol,
+               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_card *card = &exynos9610_madera;
+       struct madera_drvdata *drvdata = card->drvdata;
+
+       dev_info(drvdata->dev, "%s(%d)\n", __func__, drvdata->spk_id_value);
+       ucontrol->value.integer.value[0] = drvdata->spk_id_value;
+
+       return 0;
+}
+
 static const struct snd_kcontrol_new exynos9610_controls[] = {
        SOC_DAPM_PIN_SWITCH("DMIC1"),
        SOC_DAPM_PIN_SWITCH("DMIC2"),
        SOC_DAPM_PIN_SWITCH("DMIC3"),
+       SOC_SINGLE_EXT("SPK ID", SND_SOC_NOPM, 0, 1, 0,
+                       madera_spk_id_get, NULL),
 };
 
 static struct snd_soc_dapm_widget exynos9610_widgets[] = {
@@ -1318,6 +1336,16 @@ static int exynos9610_audio_probe(struct platform_device *pdev)
        if (ret)
                dev_info(card->dev, "Failed to parse outclk: %d\n", ret);
 
+       if (of_get_property(np, "gpios", NULL) != NULL)  {
+               drvdata->spk_id = of_get_gpio(np, 0);
+               if (drvdata->spk_id < 0) {
+                       dev_err(&pdev->dev, "failed to get SPK ID GPIO");
+               } else {
+                       drvdata->spk_id_value = gpio_get_value(drvdata->spk_id);
+                       dev_info(&pdev->dev, "SPK_ID gpio value = %d\n", drvdata->spk_id_value);
+               }
+       }
+
        for_each_child_of_node(np, dai) {
                if (!exynos9610_dai[nlink].name)
                        exynos9610_dai[nlink].name = dai->name;