From 1bf8a7b830bac38b02686c514c7e2a73c03078c7 Mon Sep 17 00:00:00 2001 From: zwp Date: Mon, 22 Aug 2011 20:02:01 -0700 Subject: [PATCH] phone-pad:according to TCL circuit ,we change some channel configs of wm8994 codec. --- arch/arm/mach-rk29/board-rk29phonepadsdk.c | 7 ++- drivers/headset_observe/rk_headset.c | 2 +- include/linux/mfd/wm8994/pdata.h | 6 ++ sound/soc/codecs/wm8994.c | 65 +++++++++++++++++++--- 4 files changed, 68 insertions(+), 12 deletions(-) mode change 100755 => 100644 arch/arm/mach-rk29/board-rk29phonepadsdk.c mode change 100755 => 100644 include/linux/mfd/wm8994/pdata.h mode change 100755 => 100644 sound/soc/codecs/wm8994.c diff --git a/arch/arm/mach-rk29/board-rk29phonepadsdk.c b/arch/arm/mach-rk29/board-rk29phonepadsdk.c old mode 100755 new mode 100644 index e9a79bc90ce0..bd2b09d482e9 --- a/arch/arm/mach-rk29/board-rk29phonepadsdk.c +++ b/arch/arm/mach-rk29/board-rk29phonepadsdk.c @@ -822,8 +822,11 @@ struct wm8994_pdata wm8994_platdata = { .jd_scthr = 0, .jd_thr = 0, - - .PA_control_pin = 0, + + .BB_input_diff = 1, + .phone_pad = 1, + + .PA_control_pin = RK29_PIN6_PB6, .Power_EN_Pin = RK29_PIN5_PA1, .speaker_incall_vol = 0, diff --git a/drivers/headset_observe/rk_headset.c b/drivers/headset_observe/rk_headset.c index 0264230c4e3f..f71aac53ff44 100755 --- a/drivers/headset_observe/rk_headset.c +++ b/drivers/headset_observe/rk_headset.c @@ -316,7 +316,7 @@ static void headset_timer_callback(unsigned long arg) struct rk_headset_pdata *pdata = headset->pdata; int i,level = 0; -// DBG("headset_timer_callback\n"); + DBG("headset_timer_callback,headset->headset_status=%d\n",headset->headset_status); if(headset->headset_status == HEADSET_OUT) { diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h old mode 100755 new mode 100644 index 9d420171eefe..11412bed2583 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -93,6 +93,12 @@ struct wm8994_pdata { unsigned int jd_scthr:2; unsigned int jd_thr:2; + //for phonepad + unsigned int phone_pad:1; // =0 is not phone_pad, =1 is phone_pad + + //BB input can be differential or single ended + unsigned int BB_input_diff:1; // =0 single ended =1 differential + //If an external amplifier speakers wm8994 enable>0 disable=0 unsigned int PA_control_pin; diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c old mode 100755 new mode 100644 index 6db87b57c80e..afa63c857142 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -985,6 +985,9 @@ void AP_to_speakers(void) #ifndef PCM_BB void handsetMIC_to_baseband_to_headset(void) {// + struct wm8994_priv *wm8994 = wm8994_codec->private_data; + struct wm8994_pdata *pdata = wm8994->pdata; + DBG("%s::%d\n",__FUNCTION__,__LINE__); if(wm8994_current_mode == wm8994_handsetMIC_to_baseband_to_headset)return; @@ -1001,8 +1004,17 @@ void handsetMIC_to_baseband_to_headset(void) //path wm8994_write(0x28, 0x0030); //IN1LN_TO_IN1L IN1LP_TO_IN1L wm8994_write(0x34, 0x0002); //IN1L_TO_LINEOUT1P - wm8994_write(0x2D, 0x0003); //bit 1 IN2LP_TO_MIXOUTL bit 0 DAC1L_TO_MIXOUTL - wm8994_write(0x2E, 0x0003); //bit 1 IN2RP_TO_MIXOUTR bit 0 DAC1R_TO_MIXOUTL + if(pdata->BB_input_diff == 1) + { + wm8994_write(0x2B, 0x0005); + wm8994_write(0x2D, 0x0041); + wm8994_write(0x2E, 0x0081); + } + else + { + wm8994_write(0x2D, 0x0003); //bit 1 IN2LP_TO_MIXOUTL bit 0 DAC1L_TO_MIXOUTL + wm8994_write(0x2E, 0x0003); //bit 1 IN2RP_TO_MIXOUTR bit 0 DAC1R_TO_MIXOUTL + } wm8994_write(0x60, 0x0022); wm8994_write(0x60, 0x00EE); wm8994_write(0x420, 0x0000); @@ -1027,6 +1039,9 @@ void handsetMIC_to_baseband_to_headset(void) void mainMIC_to_baseband_to_headset(void) {// + struct wm8994_priv *wm8994 = wm8994_codec->private_data; + struct wm8994_pdata *pdata = wm8994->pdata; + DBG("%s::%d\n",__FUNCTION__,__LINE__); if(wm8994_current_mode == wm8994_mainMIC_to_baseband_to_headset)return; @@ -1043,8 +1058,17 @@ void mainMIC_to_baseband_to_headset(void) //path wm8994_write(0x28, 0x0003); //IN1RN_TO_IN1R IN1RP_TO_IN1R wm8994_write(0x34, 0x0004); //IN1R_TO_LINEOUT1P - wm8994_write(0x2D, 0x0003); //bit 1 IN2LP_TO_MIXOUTL bit 0 DAC1L_TO_MIXOUTL - wm8994_write(0x2E, 0x0003); //bit 1 IN2RP_TO_MIXOUTR bit 0 DAC1R_TO_MIXOUTL + if(pdata->BB_input_diff == 1) + { + wm8994_write(0x2B, 0x0005); + wm8994_write(0x2D, 0x0041); + wm8994_write(0x2E, 0x0081); + } + else + { + wm8994_write(0x2D, 0x0003); //bit 1 IN2LP_TO_MIXOUTL bit 0 DAC1L_TO_MIXOUTL + wm8994_write(0x2E, 0x0003); //bit 1 IN2RP_TO_MIXOUTR bit 0 DAC1R_TO_MIXOUTL + } wm8994_write(0x36, 0x0003); wm8994_write(0x60, 0x0022); wm8994_write(0x60, 0x00EE); @@ -1060,7 +1084,7 @@ void mainMIC_to_baseband_to_headset(void) //power wm8994_write(0x03, 0x3030); wm8994_write(0x05, 0x0303); - wm8994_write(0x02, 0x6210); + wm8994_write(0x02, 0x6250); wm8994_write(0x01, 0x0303); msleep(50); wm8994_write(0x01, 0x0333); @@ -1657,6 +1681,7 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct wm8994_priv *wm8994 = wm8994_codec->private_data; + struct wm8994_pdata *pdata = wm8994->pdata; char route = kcontrol->private_value & 0xff; char last_route = wm8994->kcontrol.private_value & 0xff; wake_lock(&wm8994->wm8994_on_wake); @@ -1672,28 +1697,40 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, PA_ctrl(GPIO_LOW); break; } + printk("%s,route=%d\n",__FUNCTION__,route); //set rount switch(route) { case SPEAKER_NORMAL: //AP-> 8994Codec -> Speaker case SPEAKER_RINGTONE: case EARPIECE_RINGTONE: - AP_to_speakers(); + if(pdata->phone_pad == 1) + AP_to_headset(); + else + AP_to_speakers(); break; case SPEAKER_INCALL: //BB-> 8994Codec -> Speaker - mainMIC_to_baseband_to_speakers(); + if(pdata->phone_pad == 1) + mainMIC_to_baseband_to_headset(); + else + mainMIC_to_baseband_to_speakers(); break; case HEADSET_NORMAL: //AP-> 8994Codec -> Headset AP_to_headset(); break; case HEADSET_INCALL: //AP-> 8994Codec -> Headset +#ifdef CONFIG_RK_HEADSET_DET if(Headset_isMic()) handsetMIC_to_baseband_to_headset(); else +#endif mainMIC_to_baseband_to_headset(); break; case EARPIECE_INCALL: //BB-> 8994Codec -> EARPIECE - mainMIC_to_baseband_to_earpiece(); + if(pdata->phone_pad == 1) + mainMIC_to_baseband_to_headset(); + else + mainMIC_to_baseband_to_earpiece(); break; case EARPIECE_NORMAL: //BB-> 8994Codec -> EARPIECE switch(wm8994_current_mode) @@ -1703,7 +1740,10 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, AP_to_headset(); break; default: - AP_to_speakers(); + if(pdata->phone_pad == 1) + AP_to_headset(); + else + AP_to_speakers(); break; } break; @@ -1757,6 +1797,13 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, msleep(50); PA_ctrl(GPIO_HIGH); break; + case EARPIECE_INCALL: + if(pdata->phone_pad == 1) + { + msleep(50); + PA_ctrl(GPIO_HIGH); + } + break; default: break; } -- 2.34.1