void bravo_speaker_enable(int en) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("%s %d\n", __func__, en); if (en) { scm.is_right_chan_en = 0; scm.is_left_chan_en = 1; scm.is_stereo_en = 0; scm.is_hpf_en = 1; pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 0); /* unmute */ pmic_spkr_en_mute(LEFT_SPKR, 1); mdelay(40); } else { pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); } }
void htcleo_receiver_enable(int en) { // if (is_cdma_version(system_rev) && // ((system_rev == 0xC1) || (system_rev == 0xC2))) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("%s %d\n", __func__, en); if (en) { scm.is_right_chan_en = 1; scm.is_left_chan_en = 0; scm.is_stereo_en = 0; scm.is_hpf_en = 1; pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(RIGHT_SPKR, 1); /* unmute */ pmic_spkr_en_mute(RIGHT_SPKR, 1); } else { pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); } // } }
void supersonic_receiver_enable(int en) { /* After XB*/ if (system_rev >= 1) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("%s %d\n", __func__, en); if (en) { scm.is_right_chan_en = 1; scm.is_left_chan_en = 0; scm.is_stereo_en = 0; scm.is_hpf_en = 1; pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(RIGHT_SPKR, 1); /* unmute */ pmic_spkr_en_mute(RIGHT_SPKR, 1); } else { pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); } } }
void mahimahi_speaker_enable(int en) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("%s %d\n", __func__, en); if (en) { scm.is_right_chan_en = 0; scm.is_left_chan_en = 1; scm.is_stereo_en = 0; scm.is_hpf_en = 1; pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 0); /* unmute */ pmic_spkr_en_mute(LEFT_SPKR, 1); } else { pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); } if (is_cdma_version(system_rev)) tpa2018d1_set_speaker_amp(en); }
void analog_speaker_enable(int en) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); if (en) { scm.is_right_chan_en = 1; scm.is_left_chan_en = 1; scm.is_stereo_en = 1; scm.is_hpf_en = 1; pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 1); pmic_spkr_en_mute(LEFT_SPKR, 1); pmic_spkr_en_mute(RIGHT_SPKR, 1); } else { pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); } }
void htcleo_speaker_enable(int en) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("%s %d\n", __func__, en); if (en) { scm.is_right_chan_en = 0; scm.is_left_chan_en = 1; scm.is_stereo_en = 0; scm.is_hpf_en = 0; //1; // CotullaTODO: check it pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_set_mux_hpf_corner_freq(SPKR_FREQ_0_76KHZ); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 0); pmic_spkr_en_hpf(ON_CMD); // +LEO /* unmute */ pmic_spkr_en_mute(LEFT_SPKR, 1); mdelay(40); } else { pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_hpf(OFF_CMD); // +LEO pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); } }
void analog_speaker_enable(int en) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("en=%d ", en); if (en) { scm.is_right_chan_en = 1; scm.is_left_chan_en = 1; scm.is_stereo_en = 1; scm.is_hpf_en = 1; pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 1); /* unmute */ pmic_spkr_en_mute(LEFT_SPKR, 1); pmic_spkr_en_mute(RIGHT_SPKR, 1); #if HUAWEI_HWID(S70) #if HUAWEI_HWID_L2(S7, S7201) pmic_secure_mpp_control_digital_output( PM_MPP_12, PM_MPP__DLOGIC__LVL_VDD, PM_MPP__DLOGIC_OUT__CTRL_HIGH); #endif msleep(100); gpio_set_value(GPIO_SPK_PWN, 1); /* 0: MUTE; 1: ON*/ #endif } else { pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en_mute(RIGHT_SPKR, 0); pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); pmic_set_spkr_configuration(&scm); #if HUAWEI_HWID(S70) #if HUAWEI_HWID_L2(S7, S7201) pmic_secure_mpp_control_digital_output( PM_MPP_12, PM_MPP__DLOGIC__LVL_VDD, PM_MPP__DLOGIC_OUT__CTRL_LOW); #endif msleep(100); gpio_set_value(GPIO_SPK_PWN, 0); /* 0: MUTE; 1: ON*/ #endif } }
static int debug_spkr_en_mute(char *buf, int size) { int left_right; int enable; int cnt; cnt = sscanf(buf, "%d %d", &left_right, &enable); if (cnt < 2) { printk(KERN_ERR "%s: sscanf failed cnt=%d" , __func__, cnt); return -EINVAL; } if (pmic_spkr_en_mute(left_right, enable) >= 0) { debug_spkr_left_right = left_right; return size; } return -EFAULT; }
enum adie_state_ret_enum_type adie_state_digital_analog_active(u32 dev_type, u32 dev_id) { s32 dal_rc; enum adie_state_ret_enum_type rc; enum adie_codec_path_type_enum path_type; dal_rc = CAD_RES_SUCCESS; rc = ADIE_STATE_RC_SUCCESS; path_type = get_path_type(dev_type); if (adie_state.adie_path_type[dev_type].enabled == ADIE_TRUE) { /* Stay in this state till teardown or reconfigure */ if ((path_type == ADIE_CODEC_RX) || (path_type == ADIE_CODEC_LB)) { if (is_speaker_mono(dev_id)) { /* make sure its not already on */ if (!adie_spkr_mono_ref2_cnt) { if (pmic_is_stereo) pmic_spkr_en_mute( LEFT_SPKR, 1); else pmic_speaker_cmd( SPKR_MUTE_OFF); } /* increment ref count for LB and RX devices */ adie_spkr_mono_ref2_cnt++; } else if (is_speaker_stereo(dev_id)) { /* make sure its not already on */ if (!adie_spkr_stereo_ref2_cnt) { if (pmic_is_stereo) { pmic_spkr_en_mute( LEFT_SPKR, 1); pmic_spkr_en_mute( RIGHT_SPKR, 1); } else { pmic_speaker_cmd( SPKR_MUTE_OFF); } } /* increment ref count for LB and RX devices */ adie_spkr_stereo_ref2_cnt++; } } else { D("ARD ADIE Loopback Device\n"); } } else { if ((path_type == ADIE_CODEC_RX) || (path_type == ADIE_CODEC_LB)) { if (is_speaker_mono(dev_id)) { /* decrement ref count for LB or RX device */ adie_spkr_mono_ref2_cnt--; if (!adie_spkr_mono_ref2_cnt) { if (pmic_is_stereo) pmic_spkr_en_mute( LEFT_SPKR, 0); else pmic_speaker_cmd(SPKR_MUTE_ON); } } else if (is_speaker_stereo(dev_id)) { /* decrement ref count for LB/RX device */ adie_spkr_stereo_ref2_cnt--; if (!adie_spkr_stereo_ref2_cnt) { if (pmic_is_stereo) { pmic_spkr_en_mute( LEFT_SPKR, 0); pmic_spkr_en_mute( RIGHT_SPKR, 0); } else { pmic_speaker_cmd(SPKR_MUTE_ON); } } } } else { D("ARD ADIE Loopback Device\n"); } /* Proceed to digital off stage */ dal_rc = rpc_adie_codec_proceed_to_stage(adie_state.adie_handle, path_type, ADIE_CODEC_ANALOG_OFF); if (dal_rc != CAD_RES_SUCCESS) { pr_err("ARD ADIE Proceed to Stage failed," " dev_type %d\n", dev_type); rc = ADIE_STATE_RC_FAILURE; goto done; } adie_state.adie_path_type[dev_type].state = ADIE_STATE_DIGITAL_ACTIVE; adie_state.adie_path_type[dev_type].enable_request = ADIE_FALSE; rc = ADIE_STATE_RC_CONTINUE; } done: return rc; }
enum adie_state_ret_enum_type adie_state_digital_active(u32 dev_type, u32 dev_id) { enum adie_state_ret_enum_type rc; enum adie_codec_path_type_enum path_type; s32 dal_rc; rc = ADIE_STATE_RC_SUCCESS; dal_rc = CAD_RES_SUCCESS; path_type = get_path_type(dev_type); if (adie_state.adie_path_type[dev_type].enable_request == ADIE_TRUE) { /* Prepare the PMIC, if necessary. Configure and power on, but mute it until codec output is ready. */ if (path_type == ADIE_CODEC_TX) if ((dev_id == CAD_HW_DEVICE_ID_HANDSET_MIC) || (dev_id == CAD_HW_DEVICE_ID_HEADSET_MIC) || (dev_id == CAD_HW_DEVICE_ID_SPKR_PHONE_MIC) || (dev_id == CAD_HW_DEVICE_ID_HANDSETMIC_HEADSET_MIC) || (dev_id == CAD_HW_DEVICE_ID_LOOPBACK_SPKR_MIC) || (dev_id == CAD_HW_DEVICE_ID_LOOPBACK_HEADSET_MIC) || (dev_id == CAD_HW_DEVICE_ID_LINE_IN_MIC) ) pmic_mic_en(ON_CMD); else /* need to turn off MIC bias for TTY_HEADSET_MIC */ pmic_mic_en(OFF_CMD); else if ((path_type == ADIE_CODEC_RX) || (path_type == ADIE_CODEC_LB)) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(struct spkr_config_mode)); if (is_speaker_mono(dev_id)) { if (!adie_spkr_mono_ref1_cnt) { if (pmic_is_stereo) { scm.is_right_chan_en = 0; scm.is_left_chan_en = 1; scm.is_stereo_en = 0; scm.is_hpf_en = 1; pmic_spkr_en_mute( LEFT_SPKR, 0); pmic_spkr_en_mute( RIGHT_SPKR, 0); pmic_set_spkr_configuration( &scm); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 0); } else { pmic_speaker_cmd(SPKR_MUTE_ON); pmic_speaker_cmd(SPKR_ENABLE); } } /* keep a reference for stereo speaker. case when Rx spkr is disabled when LB speaker is already enabled. */ adie_spkr_mono_ref1_cnt++; } else if (is_speaker_stereo(dev_id)) { if (!adie_spkr_stereo_ref1_cnt) { if (pmic_is_stereo) { scm.is_right_chan_en = 1; scm.is_left_chan_en = 1; scm.is_stereo_en = 1; scm.is_hpf_en = 1; pmic_spkr_en_mute( LEFT_SPKR, 0); pmic_spkr_en_mute( RIGHT_SPKR, 0); pmic_set_spkr_configuration( &scm); pmic_spkr_en(LEFT_SPKR, 1); pmic_spkr_en(RIGHT_SPKR, 1); } else { pmic_speaker_cmd(SPKR_MUTE_ON); pmic_speaker_cmd(SPKR_ENABLE); } } /* keep a reference for stereo speaker. case when Rx spkr is disabled when LB speaker is already enabled. */ adie_spkr_stereo_ref1_cnt++; } } else { pr_err("bad path type\n"); } /* Proceed to next stage */ dal_rc = rpc_adie_codec_proceed_to_stage(adie_state.adie_handle, path_type, ADIE_CODEC_DIGITAL_ANALOG_READY); if (dal_rc != CAD_RES_SUCCESS) { pr_err("ARD ADIE Proceed to Stage failed," " dev_type %d\n", dev_type); rc = ADIE_STATE_RC_FAILURE; goto done; } adie_state.adie_path_type[dev_type].state = ADIE_STATE_DIGITAL_ANALOG_ACTIVE; adie_state.adie_path_type[dev_type].enabled = ADIE_TRUE; adie_state.adie_path_type[dev_type].enable_request = ADIE_FALSE; rc = ADIE_STATE_RC_CONTINUE; } else { if (path_type == ADIE_CODEC_TX) pmic_mic_en(OFF_CMD); else if ((path_type == ADIE_CODEC_RX) || (path_type == ADIE_CODEC_LB)) { if (is_speaker_mono(dev_id)) { /* disable a speaker LB or RX */ adie_spkr_mono_ref1_cnt--; /* if no active speaker ref then disable pmic */ if (!adie_spkr_mono_ref1_cnt) { if (pmic_is_stereo) { pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); } else pmic_speaker_cmd(SPKR_DISABLE); } } else if (is_speaker_stereo(dev_id)) { /* disable a speaker LB or RX */ adie_spkr_stereo_ref1_cnt--; /* if no active speaker ref then disable pmic */ if (!adie_spkr_stereo_ref1_cnt) { if (pmic_is_stereo) { pmic_spkr_en(LEFT_SPKR, 0); pmic_spkr_en(RIGHT_SPKR, 0); } else pmic_speaker_cmd(SPKR_DISABLE); } } } /* Proceed to digital off stage */ dal_rc = rpc_adie_codec_proceed_to_stage(adie_state.adie_handle, path_type, ADIE_CODEC_DIGITAL_OFF); if (dal_rc != CAD_RES_SUCCESS) { pr_err("ARD ADIE Proceed to Stage failed," " dev_type %d\n", dev_type); rc = ADIE_STATE_RC_FAILURE; goto done; } adie_state.adie_path_type[dev_type].state = ADIE_STATE_RESET; rc = ADIE_STATE_RC_CONTINUE; } done: return rc; }