]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
Jetson-CV: Dummy codec override from DT file
authorViswanath L <viswanathl@nvidia.com>
Mon, 14 Nov 2016 08:50:15 +0000 (14:20 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Tue, 15 Nov 2016 06:48:26 +0000 (22:48 -0800)
Dummy codec is kept as default codec-dai and overridden with
rt565x codec-dai for super-module; this achieves dummy codec
functionality with minimal changes in machine driver

Bug 1714809
Bug 1810165

Change-Id: I480a81cf7427c7e7e2773a5c434faa9f17c5c733
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: http://git-master/r/928327
Reviewed-on: http://git-master/r/1229931
Reviewed-on: http://git-master/r/1252611
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
sound/soc/tegra-alt/tegra_t210ref_mobile_rt565x_alt.c

index 0507e6652736cf987c3b8ad8aa12f4a70089fce3..4b36df9383e050013a92d5b14ad22ea20b483246 100644 (file)
@@ -188,9 +188,6 @@ static int tegra_t210ref_dai_init(struct snd_soc_pcm_runtime *rtd,
        unsigned int idx, mclk, clk_out_rate;
        int err, codec_rate, clk_rate;
 
-       if (machine->is_codec_dummy)
-               return 0;
-
        codec_rate = tegra_t210ref_srate_values[machine->rate_via_kcontrol];
        clk_rate = (machine->rate_via_kcontrol) ? codec_rate : rate;
 
@@ -254,11 +251,14 @@ static int tegra_t210ref_dai_init(struct snd_soc_pcm_runtime *rtd,
        if (idx != -EINVAL) {
                dai_params =
                (struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;
-               err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
-               RT5659_SCLK_S_MCLK, clk_out_rate, SND_SOC_CLOCK_IN);
-               if (err < 0) {
-                       dev_err(card->dev, "codec_dai clock not set\n");
-                       return err;
+
+               if (!machine->is_codec_dummy) {
+                       err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
+                       RT5659_SCLK_S_MCLK, clk_out_rate, SND_SOC_CLOCK_IN);
+                       if (err < 0) {
+                               dev_err(card->dev, "codec_dai clock not set\n");
+                               return err;
+                       }
                }
 
                dai_params->formats = 1ULL <<
@@ -423,8 +423,6 @@ static int tegra_t210ref_init(struct snd_soc_pcm_runtime *rtd)
                SND_JACK_BTN_1, KEY_MEDIA);
        /* FIXME: map other button events too */
 
-       rt5659_set_jack_detect(codec, &tegra_t210ref_hp_jack);
-
        snd_soc_dapm_sync(dapm);
 
        return 0;
@@ -544,11 +542,13 @@ static struct snd_soc_compr_ops tegra_t210ref_compr_ops = {
 static const struct snd_soc_dapm_widget tegra_t210ref_dapm_widgets[] = {
        SND_SOC_DAPM_HP("x Headphone Jack", tegra_rt565x_event_hp),
        SND_SOC_DAPM_SPK("x Int Spk", tegra_rt565x_event_int_spk),
+       SND_SOC_DAPM_HP("x Headphone", NULL),
        SND_SOC_DAPM_HP("y Headphone", NULL),
        SND_SOC_DAPM_HP("z Headphone", NULL),
        SND_SOC_DAPM_HP("s Headphone", NULL),
        SND_SOC_DAPM_MIC("x Int Mic", tegra_rt565x_event_int_mic),
        SND_SOC_DAPM_MIC("x Mic Jack", tegra_rt565x_event_ext_mic),
+       SND_SOC_DAPM_MIC("x Mic", NULL),
        SND_SOC_DAPM_MIC("y Mic", NULL),
        SND_SOC_DAPM_MIC("z Mic", NULL),
        SND_SOC_DAPM_MIC("s Mic", NULL),
@@ -718,38 +718,7 @@ static struct snd_soc_card snd_soc_tegra_t210ref = {
        .fully_routed = true,
 };
 
-static void replace_codec_link(struct platform_device *pdev,
-       struct snd_soc_dai_link *links)
-{
-       int i;
-       struct snd_soc_card *card = platform_get_drvdata(pdev);
-       struct tegra_t210ref *machine = snd_soc_card_get_drvdata(card);
-       struct device_node *np = pdev->dev.of_node;
-
-       for (i = 0; i < machine->num_codec_links; i++) {
-               if (links[i].name &&
-                       (strstr(links[i].name, "rt565x-playback"))) {
-                       links[i].init = NULL;
-
-                       links[i].codec_of_node =
-                               of_parse_phandle(np, "nvidia,dummy-codec-dai",
-                                       0);
-
-                       machine->is_codec_dummy = 1;
-
-                       if (of_property_read_string(np,
-                               "nvidia,dummy-codec-dai-name",
-                               &links[i].codec_dai_name)) {
-                               dev_err(&pdev->dev, "Property 'dummy-codec-dai\
-                                       -name' missing or invalid\n");
-                       }
-               }
-       }
-
-       return;
-}
-
-static void dai_link_setup(struct platform_device *pdev, int dummy)
+static void dai_link_setup(struct platform_device *pdev)
 {
        struct snd_soc_card *card = platform_get_drvdata(pdev);
        struct tegra_t210ref *machine = snd_soc_card_get_drvdata(card);
@@ -757,15 +726,8 @@ static void dai_link_setup(struct platform_device *pdev, int dummy)
        struct snd_soc_codec_conf *tegra_t210ref_codec_conf = NULL;
        struct snd_soc_dai_link *tegra_machine_dai_links = NULL;
        struct snd_soc_dai_link *tegra_t210ref_codec_links = NULL;
-       struct tegra_asoc_platform_data *pdata = machine->pdata;
        int i;
 
-       if (dummy) {
-               tegra_machine_remove_dai_link();
-               tegra_machine_remove_codec_conf();
-               pdata->gpio_hp_det = -1;
-       }
-
        /* set new codec links and conf */
        tegra_t210ref_codec_links = tegra_machine_new_codec_links(pdev,
                tegra_t210ref_codec_links,
@@ -783,10 +745,6 @@ static void dai_link_setup(struct platform_device *pdev, int dummy)
                }
        }
 
-       /* overwrite codec link */
-       if (dummy)
-               replace_codec_link(pdev, tegra_t210ref_codec_links);
-
        tegra_t210ref_codec_conf = tegra_machine_new_codec_conf(pdev,
                tegra_t210ref_codec_conf,
                &machine->num_codec_links);
@@ -852,6 +810,7 @@ static int tegra_t210ref_driver_probe(struct platform_device *pdev)
        struct tegra_asoc_platform_data *pdata = NULL;
        struct snd_soc_codec *codec = NULL;
        int ret = 0, idx;
+       const char *codec_dai_name;
 
        if (!np) {
                dev_err(&pdev->dev, "No device tree node for t210ref driver");
@@ -881,7 +840,7 @@ static int tegra_t210ref_driver_probe(struct platform_device *pdev)
                goto err;
 
 
-       dai_link_setup(pdev, 0);
+       dai_link_setup(pdev);
 
 #ifdef CONFIG_SWITCH
        /* Addd h2w swith class support */
@@ -921,24 +880,31 @@ static int tegra_t210ref_driver_probe(struct platform_device *pdev)
 
        ret = snd_soc_register_card(card);
        if (ret) {
-#ifdef CONFIG_SND_SOC_TEGRA_ALT_FORCE_CARD_REG
-               dai_link_setup(pdev, 1);
-               ret = snd_soc_register_card(card);
-#endif
-
-               if (ret) {
-                       dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
-                               ret);
-                       goto err_alloc_dai_link;
-               }
+               dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
+                       ret);
+               goto err_alloc_dai_link;
        }
 
        idx = tegra_machine_get_codec_dai_link_idx("rt565x-playback");
        /* check if idx has valid number */
        if (idx == -EINVAL)
                dev_warn(&pdev->dev, "codec link not defined - codec not part of sound card");
-       else
+       else {
                codec = card->rtd[idx].codec;
+               codec_dai_name = card->rtd[idx].dai_link->codec_dai_name;
+
+               dev_info(&pdev->dev,
+                       "codec-dai \"%s\" registered\n", codec_dai_name);
+               if (!strcmp("dit-hifi", codec_dai_name)) {
+                       dev_info(&pdev->dev, "This is a dummy codec\n");
+                       machine->is_codec_dummy = 1;
+               }
+       }
+
+       if (!machine->is_codec_dummy) {
+               /* setup for jack detection only in non-dummy case */
+               rt5659_set_jack_detect(codec, &tegra_t210ref_hp_jack);
+       }
 
        return 0;