コード例 #1
0
void tegra_pcm_control(int enable, struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_dapm_context *dapm = &codec->dapm;
	struct snd_soc_card *card = codec->card;
	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
	static int open_status = 0;
	static int aec_st = AEC_DISABLE;
	int func = substream->stream;

	mutex_lock(&machine->fm34_lock);
	if(enable) {
		open_status |= (0x01<<func);
		if(open_status == 0x03 && AEC_DISABLE == aec_st && snd_soc_dapm_get_pin_status(dapm, "Int Mic")
				&& machine->input_source != AUDIO_SOURCE_VOICE_RECOGNITION) {
			//printk(KERN_INFO "##### input:%d voice:%d mode:%d\n",
			//		machine->input_source, machine->voice_call, machine->audio_mode);
			if(machine->input_source == AUDIO_SOURCE_VOICE_COMMUNICATION
					|| machine->voice_call
					|| machine->audio_mode == MODE_IN_COMMUNICATION) {
				if(set_fM34_echo()) {
					aec_st = AEC_ENABLE;
					tegra_wm8903_digital_voip_gain(codec, 0);
				}
			}
		}
	} else {
		if(AEC_ENABLE == aec_st) {
			set_fM34_bypass(0);
			aec_st = AEC_DISABLE;
			tegra_wm8903_digital_voip_gain(codec, 255);
		}
		open_status &= ~(0x01<<func);
	}
	mutex_unlock(&machine->fm34_lock);
}
コード例 #2
0
void tegra_pcm_control(int enable, int func)
{
	struct snd_soc_device *pdata = platform_get_drvdata(tegra_snd_device);
	//struct tegra_audio_data* audio_data = pdata->card->codec->socdev->codec_data;
	static int open_status = 0;
	#ifdef CONFIG_SND_SOC_FM34
	static int aec_st = AEC_N;
	int val;
	#endif

	if(enable) {
		open_status |= (0x01<<func);

		if(func == SNDRV_PCM_STREAM_PLAYBACK) {
			#ifdef CONFIG_SND_SOC_FM34
			if(open_status & (0x01<<SNDRV_PCM_STREAM_CAPTURE)) {
				if(AEC_N == aec_st && snd_soc_read(pdata->card->codec, WM8903_CLOCK_RATE_TEST_4)) {
					if(set_fM34_echo()) {
						aec_st = AEC_C;
						if(0 == mic_mute_state) {
							val = ((0xC0<<WM8903_ADCL_VOL_SHIFT) | WM8903_ADCVU);
							snd_soc_write(pdata->card->codec, WM8903_ADC_DIGITAL_VOLUME_LEFT, val);
							//snd_soc_write(pdata->card->codec, WM8903_ADC_DIGITAL_VOLUME_RIGHT, val);
						}
					}
				}
			}
			#endif
		} else if(func == SNDRV_PCM_STREAM_CAPTURE) {
			val = ((0xEF<<WM8903_ADCL_VOL_SHIFT) | WM8903_ADCVU);
			#ifdef CONFIG_SND_SOC_FM34
			if(snd_soc_read(pdata->card->codec, WM8903_CLOCK_RATE_TEST_4)) {
				if(open_status & (0x01<<SNDRV_PCM_STREAM_PLAYBACK) && AEC_N == aec_st) {
					if(set_fM34_echo()) {
						aec_st = AEC_C;
						val = ((0xC0<<WM8903_ADCL_VOL_SHIFT) | WM8903_ADCVU);
					}
				}
			}
			#endif
			if(0 == mic_mute_state) {
				snd_soc_write(pdata->card->codec, WM8903_ADC_DIGITAL_VOLUME_LEFT, val);
				//snd_soc_write(pdata->card->codec, WM8903_ADC_DIGITAL_VOLUME_RIGHT, val);
			}
		}
	} else {
		#ifdef CONFIG_SND_SOC_FM34
		if(AEC_C == aec_st) {
			set_fM34_bypass();
			aec_st = AEC_N;
		}
		#endif
		if(func == SNDRV_PCM_STREAM_CAPTURE) {
			val = ((0x00<<WM8903_ADCL_VOL_SHIFT) | WM8903_ADCVU);
		} else {
			val = ((0xEF<<WM8903_ADCL_VOL_SHIFT) | WM8903_ADCVU);
		}
		if(0 == mic_mute_state) {
			snd_soc_write(pdata->card->codec, WM8903_ADC_DIGITAL_VOLUME_LEFT, val);
			//snd_soc_write(pdata->card->codec, WM8903_ADC_DIGITAL_VOLUME_RIGHT, val);
		}

		open_status &= ~(0x01<<func);
	}
}