From 1436e245490eae548375bca3265e11a99052550f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=82=B1=E5=BB=BA=E6=96=8C?= Date: Fri, 8 Jul 2011 14:43:07 +0800 Subject: [PATCH] rk29_phone: 1.fix bug Because headphones can not sleep 2.wm8994 add a wake_lock 3.turn up the speaker sound --- arch/arm/mach-rk29/board-rk29-a22.c | 2 +- drivers/headset_observe/rk_headset.c | 29 +++++++++++++++++++++++++--- sound/soc/codecs/wm8994.c | 15 +++++++++++--- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-rk29/board-rk29-a22.c b/arch/arm/mach-rk29/board-rk29-a22.c index c5eb8a7dbb54..7dbe471677a0 100755 --- a/arch/arm/mach-rk29/board-rk29-a22.c +++ b/arch/arm/mach-rk29/board-rk29-a22.c @@ -1537,7 +1537,7 @@ struct wm8994_pdata wm8994_platdata = { .speaker_incall_vol = 0, .speaker_incall_mic_vol = -9, - .speaker_normal_vol = -26, + .speaker_normal_vol = -10, .earpiece_incall_vol = 0, .headset_incall_vol = 6, .headset_incall_mic_vol = -6, diff --git a/drivers/headset_observe/rk_headset.c b/drivers/headset_observe/rk_headset.c index 3cad1a203dbe..1b4469ebbc68 100755 --- a/drivers/headset_observe/rk_headset.c +++ b/drivers/headset_observe/rk_headset.c @@ -37,6 +37,8 @@ #include #include "rk_headset.h" #include +#include +#include /* Debug */ #if 1 @@ -229,7 +231,7 @@ static void headsetobserve_work(struct work_struct *work) DBG("---- ERROR: on headset headset_in_type error -----\n"); break; } - + rk28_send_wakeup_key(); switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status); RE_ERROR: @@ -240,7 +242,7 @@ static void Hook_work(struct work_struct *work) { int i,level = 0; struct rk_headset_pdata *pdata = headset_info->pdata; - static unsigned int old_status = 0; + static unsigned int old_status = HOOK_UP; // DBG("---Hook_work---\n"); mutex_lock(&headset_info->mutex_lock[HOOK]); @@ -252,7 +254,7 @@ static void Hook_work(struct work_struct *work) #ifdef CONFIG_SND_SOC_WM8994 if(wm8994_set_status() < 0) { - DBG("wm8994 is not set on heatset channel\n"); + DBG("wm8994 is not set on heatset channel or suspend\n"); goto RE_ERROR; } #endif @@ -438,6 +440,7 @@ static int rockchip_headsetobserve_probe(struct platform_device *pdev) ret = request_irq(headset->irq[HEADSET], headset_interrupt, headset->irq_type[HEADSET], NULL, NULL); if (ret) goto failed_free; + enable_irq_wake(headset->irq[HEADSET]); //------------------------------------------------------------------ ret = gpio_request(pdata->Hook_gpio , NULL); if (ret) @@ -508,8 +511,28 @@ failed_free: return ret; } +static int rockchip_headsetobserve_suspend(struct platform_device *pdev, pm_message_t state) +{ + DBG("%s----%d\n",__FUNCTION__,__LINE__); + disable_irq(headset_info->irq[HEADSET]); + disable_irq(headset_info->irq[HOOK]); + + return 0; +} + +static int rockchip_headsetobserve_resume(struct platform_device *pdev) +{ + DBG("%s----%d\n",__FUNCTION__,__LINE__); + enable_irq(headset_info->irq[HEADSET]); + enable_irq(headset_info->irq[HOOK]); + + return 0; +} + static struct platform_driver rockchip_headsetobserve_driver = { .probe = rockchip_headsetobserve_probe, +// .resume = rockchip_headsetobserve_resume, +// .suspend = rockchip_headsetobserve_suspend, .driver = { .name = "rk_headsetdet", .owner = THIS_MODULE, diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index ea2a29015084..9d9339064bb7 100755 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include @@ -154,6 +156,8 @@ struct wm8994_priv { /* call_vol: save all kinds of system volume value. */ unsigned char call_vol; unsigned char BT_call_vol; + + struct wake_lock wm8994_on_wake; }; int reg_send_data(struct i2c_client *client, unsigned short *reg, unsigned short *data, u32 scl_rate) @@ -213,13 +217,15 @@ int wm8994_set_status(void) case wm8994_recorder_and_AP_to_headset: case wm8994_handsetMIC_to_baseband_to_headset: case wm8994_handsetMIC_to_baseband_to_headset_and_record: + case null: ret = 1; break; default: ret = -1; break; } - + if(wm8994->work_type == SNDRV_PCM_TRIGGER_SUSPEND) + ret = -2; mutex_unlock(&wm8994->route_lock); return ret; } @@ -2692,6 +2698,7 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, { struct wm8994_priv *wm8994 = wm8994_codec->private_data; char route = kcontrol->private_value & 0xff; + wake_lock(&wm8994->wm8994_on_wake); mutex_lock(&wm8994->route_lock); wm8994->kcontrol = kcontrol;//save rount @@ -2795,6 +2802,7 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, } out: mutex_unlock(&wm8994->route_lock); + wake_unlock(&wm8994->wm8994_on_wake); return 0; } @@ -3067,7 +3075,6 @@ static void wm8994_work_fun(struct work_struct *work) default: break; } - } #define WM8994_RATES SNDRV_PCM_RATE_8000_48000 @@ -3118,7 +3125,8 @@ static int wm8994_suspend(struct platform_device *pdev, pm_message_t state) wm8994_current_mode< null )//incall status,wm8994 not suspend return 0; DBG("%s----%d\n",__FUNCTION__,__LINE__); - + + wm8994->work_type = SNDRV_PCM_TRIGGER_SUSPEND; PA_ctrl(GPIO_LOW); wm8994_write(0x00, 0x00); @@ -3528,6 +3536,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c, INIT_DELAYED_WORK(&wm8994->wm8994_delayed_work, wm8994_work_fun); mutex_init(&wm8994->io_lock); mutex_init(&wm8994->route_lock); + wake_lock_init(&wm8994->wm8994_on_wake, WAKE_LOCK_SUSPEND, "wm8994_on_wake"); return wm8994_register(wm8994, SND_SOC_I2C); } -- 2.34.1