Exemple #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;
#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;
}
int tegra_controls_init(struct snd_soc_codec *codec)
{
	int err;

	if (!audio_data) {
		audio_data = kzalloc(sizeof(*audio_data), GFP_KERNEL);
		if (!audio_data) {
			pr_err("failed to allocate tegra_audio_data \n");
			return -ENOMEM;
		}

		/* Add tegra specific controls */
		err = snd_soc_add_controls(codec, tegra_controls,
						ARRAY_SIZE(tegra_controls));
		if (err < 0)
			goto fail;

		/* 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));

		audio_data->codec = codec;
		/* Add play route control */
		err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_play_route_control, NULL));
		if (err < 0)
			goto fail;

		/* Add capture route control */
		err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_capture_route_control, NULL));
		if (err < 0)
			goto fail;

		/* Add call mode switch control */
		err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_call_mode_control, NULL));
		if (err < 0)
			goto fail;

#ifndef CONFIG_MACH_SAMSUNG_VARIATION_TEGRA
		/* Add jack detection */
		err = tegra_jack_init(codec);
		if (err < 0)
			goto fail;
#endif

		/* Default to HP output */
		tegra_jack_func = TEGRA_HP;
		tegra_spk_func = TEGRA_SPK_ON;
		tegra_ext_control(codec);

		snd_soc_dapm_sync(codec);
	}

	return 0;

fail:
	if (audio_data) {
		kfree(audio_data);
		audio_data = 0;
	}
	return err;
}