From f13106b5c5fae60d113afd4f377860919bb029d3 Mon Sep 17 00:00:00 2001 From: Srikanth Shivanand Date: Sat, 26 Mar 2011 17:11:41 +0530 Subject: input: misc: ab8500-accdet: Power optimisation fix. The detection of the accessory is made independent of GPIO35. The GPIO is used only after detection. This saves power. ST-Ericsson ID: ER 330343 Change-Id: Ifbf0028777d242a09067eb560f4476d5522e9074 Signed-off-by: Srikanth Shivanand Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/19312 Reviewed-by: Marcel TUNNISSEN Tested-by: Marcel TUNNISSEN Reviewed-by: Martin PERSSON Tested-by: Martin PERSSON --- drivers/input/misc/ab8500-accdet.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/input/misc/ab8500-accdet.c b/drivers/input/misc/ab8500-accdet.c index 2d5aaf3bce7..28cbc2aed42 100644 --- a/drivers/input/misc/ab8500-accdet.c +++ b/drivers/input/misc/ab8500-accdet.c @@ -150,10 +150,12 @@ enum accessory_irq { * Enumerates the op. modes of the avcontrol switch * @AUDIO_IN Audio input is selected * @VIDEO_OUT Video output is selected + * @NOT_SET The av-switch control signal is disconnected. */ enum accessory_avcontrol_dir { AUDIO_IN, VIDEO_OUT, + NOT_SET, }; /** @@ -690,8 +692,6 @@ static void unplug_irq_handler_work(struct work_struct *work) dd->btn_state = BUTTON_UNK; config_accdetect(dd); - set_av_switch(dd, AUDIO_IN); - accessory_regulator_disable(REGULATOR_ALL); report_jack_status(dd); @@ -749,6 +749,8 @@ static void detect_work(struct work_struct *work) dev_dbg(&dd->pdev->dev, "%s: Enter\n", __func__); + set_av_switch(dd, AUDIO_IN); + new_type = detect(dd, &req_det_count); dd->total_jack_det_count++; @@ -957,8 +959,12 @@ static void set_av_switch(struct ab8500_ad *dd, { int ret; - dev_dbg(&dd->pdev->dev, "%s: Enter\n", __func__); - if (!dd->gpio35_dir_set) { + dev_dbg(&dd->pdev->dev, "%s: Enter (%d)\n", __func__, dir); + if (dir == NOT_SET) { + ret = gpio_direction_input(dd->pdata->video_ctrl_gpio); + dd->gpio35_dir_set = 0; + ret = gpio_direction_output(dd->pdata->video_ctrl_gpio, 0); + } else if (!dd->gpio35_dir_set) { ret = gpio_direction_output(dd->pdata->video_ctrl_gpio, dir == AUDIO_IN ? 1 : 0); if (ret < 0) { @@ -1090,9 +1096,11 @@ static void config_accdetect(struct ab8500_ad *dd) release_irq(dd, UNPLUG_IRQ); release_irq(dd, BUTTON_PRESS_IRQ); release_irq(dd, BUTTON_RELEASE_IRQ); + set_av_switch(dd, NOT_SET); break; case JACK_TYPE_DISCONNECTED: + set_av_switch(dd, NOT_SET); case JACK_TYPE_HEADPHONE: case JACK_TYPE_CVIDEO: config_accdetect1_hw(dd, 1); @@ -1133,7 +1141,6 @@ static void init_work(struct work_struct *work) dev_dbg(&dd->pdev->dev, "%s: Enter\n", __func__); - set_av_switch(dd, AUDIO_IN); dd->jack_type = dd->reported_jack_type = JACK_TYPE_UNSPECIFIED; config_accdetect(dd); queue_delayed_work(dd->irq_work_queue, -- cgit v1.2.3