static void set_bias (struct snd_soc_codec *codec, int mode) { /* Set MIC BIAS */ /* VOICECALL, VOICEMEMO, PLAYBACK_HP */ if ((mode & 0xf0) == MM_AUDIO_VOICECALL || (mode & 0xf0) == MM_AUDIO_VOICEMEMO ) { if ((mode & 0x0f) == MM_AUDIO_OUT_RCV || (mode & 0x0f) == MM_AUDIO_OUT_SPK || (mode & 0x0f) == MM_AUDIO_OUT_HP ) mic_enable(1); } else { if(!get_headset_status()) mic_enable(0); } /* Set AMP BIAS */ /* SPK, EARJACK, VOICEMEMO */ if ((mode & 0x0f) == MM_AUDIO_OUT_SPK || (mode & 0x0f) == MM_AUDIO_OUT_HP || (mode & 0x0f) == MM_AUDIO_OUT_SPK_HP || (mode & 0xf0) == MM_AUDIO_VOICEMEMO ) { if (mode != MM_AUDIO_VOICECALL_BT) amp_enable(1); } else { amp_enable(0); } }
static void set_bias (struct snd_soc_codec *codec, int mode) { P("BIAS Control (%x)", mode); /* Set MIC BIAS */ /* VOICECALL, VOICEMEMO */ if ((mode & 0xf0) == MM_AUDIO_VOICECALL || (mode & 0xf0) == MM_AUDIO_VOICEMEMO) { if( mode == MM_AUDIO_VOICECALL_RCV || mode == MM_AUDIO_VOICEMEMO_MAIN || mode == MM_AUDIO_VOICEMEMO_SUB) { P("Main Mic"); mic_set_path(AK4671_MIC_PATH_MAIN); } else if ( mode== MM_AUDIO_VOICECALL_SPK ) { P("Sub Mic"); mic_set_path(AK4671_MIC_PATH_SUB); } P("Mic En : 1"); mic_enable(1); } else { P("Mic En : 0"); mic_enable(0); } /* Disable Mics for all BT operations */ if ((mode & 0x0f) == MM_AUDIO_OUT_BT) { P("Mic En : 0"); mic_enable(0); } /* Set AMP BIAS */ /* SPK, EARJACK, VOICEMEMO */ if ((mode & 0x0f) == MM_AUDIO_OUT_SPK || (mode & 0x0f) == MM_AUDIO_OUT_HP || (mode & 0x0f) == MM_AUDIO_OUT_SPK_HP || (mode & 0x0f) == MM_AUDIO_OUT_RING_SPK_HP || (mode & 0xf0) == MM_AUDIO_VOICEMEMO ) { if (mode != MM_AUDIO_VOICECALL_BT) amp_enable(1); } else amp_enable(0); }
static int set_external_amp_power(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { P("amp power : %d", (int)ucontrol->value.integer.value[0]); if (ucontrol->value.integer.value[0] == 0) { // Off amp_enable(0); } else if (ucontrol->value.integer.value[0] == 1) { // On amp_enable(1); } else { P("invalid value"); return -1; } return 1; }
/* power down chip */ static int ak4671_shutdown(struct platform_device *pdev) { P(" "); amp_enable(0); return 0; }
static void set_amp_gain(int amp_state) { int fail = 0; EAMP_PRINTK("amp_state=%d",amp_state); switch (amp_state) { case SPK_ON: msleep(5); fail = amp_enable(1); /*need 10 msec for chip ready*/ msleep(100); fail = tpa2028d_poweron(); break; case SPK_OFF: amp_enable(2); fail = tpa2028d_powerdown(); fail = amp_enable(0); break; default: printk("Amp_state [%d] does not support \n", amp_state); } }
int idle_mode_disable(struct snd_soc_codec *codec, int mode) { P("Diasble PATH : %d\n", mode); /* PLAYBACK_HP */ if ( (mode & 0x0f) != MM_AUDIO_PLAYBACK_HP && /* for earjack send/end key interrupt */ (mode & 0x0f) == MM_AUDIO_PLAYBACK_SPK_HP) { mic_enable(0); } amp_enable(0); switch(mode) { case 0: P("Path : Off"); break; case MM_AUDIO_PLAYBACK_RCV : P("MM_AUDIO_PLAYBACK_RCV Off"); codec->write(codec, 0x0F, 0x04); // RCP/RCN power-down mdelay(2); // wait more than 1ms codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_SPK : case MM_AUDIO_PLAYBACK_HP : case MM_AUDIO_PLAYBACK_SPK_HP : case MM_AUDIO_PLAYBACK_RING_SPK_HP : P("MM_AUDIO_PLAYBACK_SPK Off"); codec->write(codec, 0x10, 0x73); // MUTEN='0' mdelay(30); // wait more than 500ms codec->write(codec, 0x10, 0x00); // LOUT2/ROUT2 power-down codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_BT : codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; default: printk("[SOUND MODE] invalid IDLE mode!!! \n"); } return 0; }
int idle_mode_disable(struct snd_soc_codec *codec, int mode) { P("Diasble PATH : 0x%x\n", mode); if(!get_headset_status()) mic_enable(0); amp_enable(0); switch(mode) { case 0: P("Path : Off"); break; case MM_AUDIO_PLAYBACK_RCV : //P("MM_AUDIO_PLAYBACK_RCV Off"); codec->write(codec, 0x0F, 0x04); // RCP/RCN power-down mdelay(2); // wait more than 1ms codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_SPK : case MM_AUDIO_PLAYBACK_HP : case MM_AUDIO_PLAYBACK_SPK_HP : case MM_AUDIO_PLAYBACK_RING_SPK_HP : //P("MM_AUDIO_PLAYBACK_SPK, HP, SPK_HP Off"); codec->write(codec, 0x10, 0x73); // MUTEN='0' mdelay(30); // wait more than 30ms codec->write(codec, 0x10, 0x00); // LOUT2/ROUT2 power-down codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_BT : codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; default: printk("[SOUND MODE] invalid IDLE mode!!! \n"); } return 0; }
static int ak4671_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->codec; P(""); ak4671_set_bias_level(codec, SND_SOC_BIAS_OFF); if ( (ak4671_path & 0xf0) != MM_AUDIO_VOICECALL && (ak4671_path & 0xf0) != MM_AUDIO_VOICEMEMO ) { path_disable(codec, ak4671_path); /* AUDIO_EN & MAX8906_AMP_EN Disable */ amp_enable(0); /* Board Specific function */ audio_power(0); /* Board Specific function */ mic_enable(0); /* MICBIAS Disable (SPH-M900 Only) */ ak4671_power = 0; ak4671_idle_mode = IDLE_POWER_DOWN_MODE_ON; } return 0; }
int path_disable(struct snd_soc_codec *codec, int mode) { P("Diasble PATH : 0x%x\n", mode); amp_enable(0);//for noise reduce switch(mode) { case 0: P("Path : Off"); break; case MM_AUDIO_PLAYBACK_RCV : //P("MM_AUDIO_PLAYBACK_RCV Off"); codec->write(codec, 0x0F, 0x27); // LOPS='1' mdelay(2); // wait more than 1ms codec->write(codec, 0x0F, 0x04); // RCP/RCN power-donw mdelay(2); // wait more than 1ms codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_SPK : case MM_AUDIO_PLAYBACK_HP : case MM_AUDIO_PLAYBACK_SPK_HP : case MM_AUDIO_PLAYBACK_RING_SPK_HP : //P("MM_AUDIO_PLAYBACK_SPK, HP, SPK_HP Off"); codec->write(codec, 0x10, 0x73); // MUTEN='0' mdelay(30); // wait more than 30ms codec->write(codec, 0x10, 0x00); // LOUT2/ROUT2 power-down codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_BT : codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_VOICECALL_RCV : //P("set MM_AUDIO_VOICECALL_RCV Off"); /* MIC-AMP Rch + A/P Rch => RCP/RCN Off */ codec->write(codec, 0x19, 0x04); // use soft mute to cut signal mdelay(24); codec->write(codec, 0x0A, 0x20); // only MIC-AMP-Rch to RCP/RCN codec->write(codec, 0x00, 0x0D); // DAC-Rch power-up codec->write(codec, 0x04, 0x00); // Mic Amp input select default codec->write(codec, 0x0A, 0x00); //Mic Amp Rch -> RcP/Rcn select default codec->write(codec, 0x0D, 0x00); //Mic Amp Lch -> Lop/Lon select default codec->write(codec, 0x06, 0x00); //pmloopl, pmloopr power down /* Normal Off */ codec->write(codec, 0x11, 0xA7); // LOPS3=1 codec->write(codec, 0x0F, 0x27); // LOPS1=1 codec->write(codec, 0x0F, 0x24); // RCP/RCN power-down codec->write(codec, 0x11, 0xA4); // LOP/LON power-down mdelay(30); codec->write(codec, 0x11, 0x10); // default codec->write(codec, 0x0F, 0x00); // default //codec->write(codec, 0x01, 0x00); // codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_VOICECALL_SPK : case MM_AUDIO_VOICECALL_HP : case MM_AUDIO_VOICECALL_SPK_LOOP: //P("set MM_AUDIO_VOICECALL_SPK,HP Off"); /* MIC-AMP Rch + A/P Rch => Lout2/Rout2 Off */ #if 0 codec->write(codec, 0x19, 0x04); // use soft mute to shut-down signal mdelay(24); codec->write(codec, 0x0B, 0x00); // Swith-off DAC-Lch codec->write(codec, 0x0C, 0x20); // Swith-off DAC-Rch codec->write(codec, 0x00, 0x0D); // DAC power-up codec->write(codec, 0x02, 0x00); // PLL power-down #endif /* Normal Off */ codec->write(codec, 0x11, 0xA7); // LOPS3=1 codec->write(codec, 0x11, 0xA4); // LOP/LON power-down codec->write(codec, 0x10, 0x6B); // MUTEN=0 mdelay(30); codec->write(codec, 0x11, 0x10); // default codec->write(codec, 0x10, 0x00); // default //codec->write(codec, 0x01, 0x00); // codec->write(codec, 0x00, 0x00); // break; case MM_AUDIO_VOICECALL_BT : //P("set MM_AUDIO_VOICECALL_BT Off"); /* Mixing ADC Rch and A/P Rch Off */ //codec->write(codec, 0x15, 0x14); // 5-band-EQ-Lch: from SRC-B; codec->write(codec, 0x15, 0x00); // 5-band-EQ-Lch: from SRC-B; // Rch: from SVOLA Rch /* Normal Off */ codec->write(codec, 0x11, 0xA7); // LOPS3=1 codec->write(codec, 0x11, 0xA4); // LOP/LON power-down mdelay(30); // Wait more than 30ms codec->write(codec, 0x11, 0x10); // default codec->write(codec, 0x53, 0x00); // PMSRA/B, PMPCM power-down //codec->write(codec, 0x02, 0x00); // PLL power-down //codec->write(codec, 0x01, 0x00); codec->write(codec, 0x00, 0x00); // VCOM and others power-down break; case MM_AUDIO_VOICEMEMO_MAIN : //P("set MM_AUDIO_VOICEMEMO_MAIN Off"); codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_VOICEMEMO_SUB : //P("set MM_AUDIO_VOICEMEMO_SUB Off"); codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_VOICEMEMO_EAR : //P("set MM_AUDIO_VOICEMEMO_EAR Off"); codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_VOICEMEMO_BT : //P("set MM_AUDIO_VOICEMEMO_BT Off"); codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; default: printk("[SOUND MODE] invalid mode!!! \n"); } return 0; }
static void s3c_audio_off(void) { pr_info("%s: Turn off audio power, amp\n", __func__); amp_enable(0); audio_power(0); }
int path_disable(struct snd_soc_codec *codec, int mode) { P("Diasble PATH : %x\n", mode); /* for Noise */ amp_enable(0); /* use soft mute to shut-down signal */ codec->write(codec, 0x19, 0x05); /* Set path disable sequence */ switch(mode) { case 0: P("Path : Off"); break; case MM_AUDIO_PLAYBACK_RCV : P("MM_AUDIO_PLAYBACK_RCV Off"); codec->write(codec, 0x0F, 0x27); // LOPS='1' mdelay(2); // wait more than 1ms codec->write(codec, 0x0F, 0x04); // RCP/RCN power-donw mdelay(2); // wait more than 1ms codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_SPK : case MM_AUDIO_PLAYBACK_HP : case MM_AUDIO_PLAYBACK_SPK_HP : case MM_AUDIO_PLAYBACK_RING_SPK_HP : P("MM_AUDIO_PLAYBACK_SPK Off"); codec->write(codec, 0x10, 0x73); // MUTEN='0' mdelay(30); // wait more than 500ms codec->write(codec, 0x10, 0x00); // LOUT2/ROUT2 power-down codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_PLAYBACK_BT : codec->write(codec, 0x00, 0x01); // VCOM power up codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_VOICECALL_RCV : P("set MM_AUDIO_VOICECALL_RCV Off"); /* MIC-AMP Rch + A/P Rch => RCP/RCN Off */ codec->write(codec, 0x19, 0x05); // use soft mute to cut signal mdelay(24); codec->write(codec, 0x0A, 0x20); // only MIC-AMP-Rch to RCP/RCN codec->write(codec, 0x00, 0x0D); // DAC-Rch power-up codec->write(codec, 0x02, 0x00); // PLL power-down /* Normal Off */ codec->write(codec, 0x11, 0xA7); // LOPS3=1 codec->write(codec, 0x0F, 0x27); // LOPS1=1 codec->write(codec, 0x0F, 0x24); // RCP/RCN power-down codec->write(codec, 0x11, 0xA4); // LOP/LON power-down mdelay(30); codec->write(codec, 0x11, 0x10); // default codec->write(codec, 0x0F, 0x00); // default codec->write(codec, 0x01, 0x00); // codec->write(codec, 0x00, 0x00); // VCOM power down break; case MM_AUDIO_VOICECALL_SPK : case MM_AUDIO_VOICECALL_HP : { P("set MM_AUDIO_VOICECALL_SPK,HP Off"); /* MIC-AMP Rch + A/P Rch => Lout2/Rout2 Off */ codec->write(codec, 0x19, 0x05); // use soft mute to shut-down signal mdelay(24); if(tty_mode == 2) { codec->write(codec, 0x0A, 0x20); // only MIC-AMP-Rch to RCP/RCN } else { codec->write(codec, 0x0B, 0x00); // Swith-off DAC-Lch codec->write(codec, 0x0C, 0x20); // Swith-off DAC-Rch } codec->write(codec, 0x00, 0x0D); // DAC power-up codec->write(codec, 0x02, 0x00); // PLL power-down /* Normal Off */ codec->write(codec, 0x11, 0xA7); // LOPS3=1 if(tty_mode == 2) { codec->write(codec, 0x0F, 0x27); // LOPS1=1 codec->write(codec, 0x0F, 0x24); // RCP/RCN power-down } else { codec->write(codec, 0x10, 0x6B); // MUTEN=0 } codec->write(codec, 0x11, 0xA4); // LOP/LON power-down mdelay(30); codec->write(codec, 0x11, 0x10); // default codec->write(codec, 0x10, 0x00); // default codec->write(codec, 0x01, 0x00); // codec->write(codec, 0x00, 0x00); // VCOM power down break; } case MM_AUDIO_VOICECALL_BT : P("set MM_AUDIO_VOICECALL_BT Off"); /* Mixing ADC Rch and A/P Rch Off */ codec->write(codec, 0x15, 0x14); // 5-band-EQ-Lch: from SRC-B; // Rch: from SVOLA Rch codec->write(codec, 0x15, 0x00); // Default value /* Normal Off */ codec->write(codec, 0x11, 0xA7); // LOPS3=1 codec->write(codec, 0x11, 0xA4); // LOP/LON power-down mdelay(30); // Wait more than 300ms codec->write(codec, 0x11, 0x10); // default codec->write(codec, 0x53, 0x00); // PMSRA/B, PMPCM power-down codec->write(codec, 0x02, 0x00); // PLL power-down codec->write(codec, 0x01, 0x00); codec->write(codec, 0x00, 0x00); // VCOM and others power-down break; case MM_AUDIO_VOICEMEMO_MAIN : P("set MM_AUDIO_VOICEMEMO_MAIN Off"); codec->write(codec, 0x05, 0x55); // => MIC-AMP Gain=0dB (default) codec->write(codec, 0x12, 0x91); // Lch Input Volume : +0dB codec->write(codec, 0x13, 0x91); // Rch Input Volume : +0dB codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_VOICEMEMO_SUB : P("set MM_AUDIO_VOICEMEMO_SUB Off"); codec->write(codec, 0x05, 0x55); // => MIC-AMP Gain=0dB (default) codec->write(codec, 0x12, 0x91); // Lch Input Volume : +0dB (default) codec->write(codec, 0x13, 0x91); // Rch Input Volume : +0dB (default) codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_VOICEMEMO_EAR : P("set MM_AUDIO_VOICEMEMO_EAR Off"); codec->write(codec, 0x05, 0x55); // => MIC-AMP Gain=0dB (default) codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_VOICEMEMO_BT : P("set MM_AUDIO_VOICEMEMO_BT Off"); codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_FMRADIO_RCV : P("set MM_AUDIO_FMRADIO_RCV Off"); codec->write(codec, 0x0F, 0x27); // => LOPS1=1 mdelay(1); // Wait more than 1ms codec->write(codec, 0x0F, 0x04); // => LOUT1/ROUT1 power-down mdelay(1); // Wait more than 1ms codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_FMRADIO_SPK : case MM_AUDIO_FMRADIO_HP : P("set MM_AUDIO_FMRADIO_HP/SPK Off"); codec->write(codec, 0x10, 0x73); // => MUTEN=0 mdelay(500); // Wait more than 500ms codec->write(codec, 0x10, 0x00); // => LOUT2/ROUT2 power-down codec->write(codec, 0x00, 0x01); /* Recording ALC Disable */ codec->write(codec, 0x18, 0x02); // ALC Disable codec->write(codec, 0x00, 0x00); break; case MM_AUDIO_FMRADIO_BT : P("set MM_AUDIO_FMRADIO_BT Off"); codec->write(codec, 0x00, 0x01); codec->write(codec, 0x00, 0x00); break; default: printk("[SOUND MODE] invalid mode: %x !!! \n", mode); } return 0; }