Ejemplo n.º 1
0
static int tegra_codec_init(struct snd_soc_codec *codec)
{
	struct tegra_audio_data* audio_data = codec->socdev->codec_data;
	int err = 0;

	if (!audio_data->init_done) {
		audio_data->dap_mclk = tegra_das_get_dap_mclk();
		if (!audio_data->dap_mclk) {
			pr_err("Failed to get dap mclk \n");
			err = -ENODEV;
			return err;
		}

		/* Add tegra specific widgets */
		snd_soc_dapm_new_controls(codec, tegra_dapm_widgets,
					ARRAY_SIZE(tegra_dapm_widgets));

		/* Set up tegra specific audio path audio_map */
		snd_soc_dapm_add_routes(codec, audio_map,
					ARRAY_SIZE(audio_map));

		err = tegra_controls_init(codec);
		if (err < 0) {
			pr_err("Failed in controls init \n");
			return err;
		}

		audio_data->codec = codec;
		audio_data->init_done = 1;
	}

	return err;
}
Ejemplo n.º 2
0
static int tegra_codec_init(struct snd_soc_codec *codec)
{
	struct tegra_audio_data* audio_data = codec->socdev->codec_data;
	int err = 0;
#ifdef CONFIG_MACH_ACER_VANGOGH
	int ret = 0;
#endif

	if (!audio_data->init_done) {
		audio_data->dap_mclk = tegra_das_get_dap_mclk();
		if (!audio_data->dap_mclk) {
			pr_err("Failed to get dap mclk \n");
			err = -ENODEV;
			return err;
		}

		/* Add tegra specific widgets */
		snd_soc_dapm_new_controls(codec, tegra_dapm_widgets,
					ARRAY_SIZE(tegra_dapm_widgets));

		/* Set up tegra specific audio path audio_map */
		snd_soc_dapm_add_routes(codec, audio_map,
					ARRAY_SIZE(audio_map));

		/* Add jack detection */
		err = tegra_jack_init(codec);
		if (err < 0) {
			pr_err("Failed in jack init \n");
			return err;
		}

		/* Default to OFF */
		tegra_ext_control(codec, TEGRA_AUDIO_OFF);

		err = tegra_controls_init(codec);
		if (err < 0) {
			pr_err("Failed in controls init \n");
			return err;
		}

#ifdef CONFIG_MACH_ACER_VANGOGH
		ret = wm8903_cdc_irq_init(codec);
		if (ret < 0) {
			pr_err("Failed in cdc irq init \n");
		}
#endif

		audio_data->codec = codec;
		audio_data->init_done = 1;
	}

	return err;
}
Ejemplo n.º 3
0
static int tegra_codec_init(struct snd_soc_codec *codec)
{
	struct adam_audio_priv* ctx = codec->socdev->codec_data;
	int ret = 0;

	if (!ctx->init_done) {
		
		/* Get and enable the DAP clock */
		ctx->dap_mclk = tegra_das_get_dap_mclk();
		if (!ctx->dap_mclk) {
			pr_err("Failed to get dap mclk \n");
			return -ENODEV;
		}
		clk_enable(ctx->dap_mclk);

		/* Add the controls used to route audio to bluetooth/voice */
		tegra_das_controls_init(codec);
		
		/* Store the GPIO used to detect headphone */
		tegra_jack_gpios[0].gpio = ctx->gpio_hp_det;

		/* Add tegra specific widgets */
		snd_soc_dapm_new_controls(codec, tegra_dapm_widgets,
					ARRAY_SIZE(tegra_dapm_widgets));

#ifdef ADAM_MANUAL_CONTROL_OF_OUTPUTDEVICE
		/* Add specific adam controls */
		ret = snd_soc_add_controls(codec, tegra_controls,
					ARRAY_SIZE(tegra_controls));
		if (ret < 0) {
			pr_err("Failed to register controls\n");
			return ret;
		}
#endif
					
		/* Set up tegra specific audio path audio_map */
		snd_soc_dapm_add_routes(codec, audio_map,
					ARRAY_SIZE(audio_map));

		/* make sure to register the dapm widgets */
		snd_soc_dapm_new_widgets(codec);
					
		/* Set endpoints to not connected */
		snd_soc_dapm_nc_pin(codec, "LINEL");
		snd_soc_dapm_nc_pin(codec, "LINER");
		snd_soc_dapm_nc_pin(codec, "PHONEIN");
		snd_soc_dapm_nc_pin(codec, "MIC2");
		snd_soc_dapm_nc_pin(codec, "MONO");

		/* Set endpoints to default off mode */
		snd_soc_dapm_enable_pin(codec, "Internal Speaker");
		snd_soc_dapm_enable_pin(codec, "Internal Mic");
		snd_soc_dapm_disable_pin(codec, "Headphone Jack");
	
		ret = snd_soc_dapm_sync(codec);
		if (ret) {
			pr_err("Failed to sync\n");
			return ret;
		}

#ifndef ADAM_MANUAL_CONTROL_OF_OUTPUTDEVICE
		/* Headphone jack detection */		
		ret = snd_soc_jack_new(codec->socdev->card, "Headphone Jack", SND_JACK_HEADPHONE,
				 &ctx->tegra_jack);
		if (ret)
			return ret;
			 
		ret = snd_soc_jack_add_pins(&ctx->tegra_jack,
			      ARRAY_SIZE(tegra_jack_pins),
			      tegra_jack_pins);
		if (ret)
			return ret;
				  
		ret = snd_soc_jack_add_gpios(&ctx->tegra_jack,
			       ARRAY_SIZE(tegra_jack_gpios),
			       tegra_jack_gpios);
		if (ret)
			return ret;
#endif

		ctx->init_done = 1;
	}

	return ret;
}