diff options
author | Xing Zheng <zhengxing@rock-chips.com> | 2019-06-17 19:14:39 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2019-06-20 14:17:41 +0800 |
commit | e8949686cbfe60048567e11884c5b2ba9a433959 (patch) | |
tree | f35c2dbb21e78ff8729ec61b7189f03b92c4c6c5 /drivers | |
parent | 48a7471142d1d8f009e6ae505f00070ceb146957 (diff) |
rk_headset: add support jack report
This patch supports Jack's event report switching Audio
paths on public platforms.
Change-Id: I83e395f81fb60a2b446a309fae820d26d7df4661
Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/headset_observe/rk_headset_irq_hook_adc.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/headset_observe/rk_headset_irq_hook_adc.c b/drivers/headset_observe/rk_headset_irq_hook_adc.c index 53a0525f7bd0..e75880ebfa77 100644 --- a/drivers/headset_observe/rk_headset_irq_hook_adc.c +++ b/drivers/headset_observe/rk_headset_irq_hook_adc.c @@ -35,6 +35,8 @@ #include <linux/wakelock.h> #include <linux/gpio.h> +#include <sound/jack.h> +#include <sound/soc.h> #include <asm/atomic.h> #include "rk_headset.h" @@ -109,6 +111,17 @@ struct headset_priv { }; static struct headset_priv *headset_info; +static struct snd_soc_jack *hpdet_jack; + +void rk_headset_set_jack_detect(struct snd_soc_jack *jack) +{ + hpdet_jack = jack; + + /* Send an initial empty report */ + snd_soc_jack_report(jack, 0, SND_JACK_HEADSET); +} +EXPORT_SYMBOL_GPL(rk_headset_set_jack_detect); + //1 static irqreturn_t headset_interrupt(int irq, void *dev_id) { @@ -224,6 +237,27 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id) switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); DBG("headset notice android headset status = %d\n",headset_info->cur_headset_status); + + if (hpdet_jack) { + int report_type = 0; + + switch (headset_info->cur_headset_status) { + case BIT_HEADSET: + report_type = SND_JACK_HEADSET; + break; + case BIT_HEADSET_NO_MIC: + report_type = SND_JACK_HEADPHONE; + break; + default: + break; + } + + DBG("%s: report type: 0x%x\n", __func__, report_type); + + snd_soc_jack_report(hpdet_jack, + report_type, + SND_JACK_HEADPHONE); + } } // rk_send_wakeup_key(); out: @@ -308,6 +342,27 @@ static void hook_once_work(struct work_struct *work) switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); DBG("%s notice android headset status = %d\n",__func__,headset_info->cur_headset_status); + + if (hpdet_jack) { + int report_type = 0; + + switch (headset_info->cur_headset_status) { + case BIT_HEADSET: + report_type = SND_JACK_HEADSET; + break; + case BIT_HEADSET_NO_MIC: + report_type = SND_JACK_HEADPHONE; + break; + default: + break; + } + + DBG("%s: report type: 0x%x\n", __func__, report_type); + + snd_soc_jack_report(hpdet_jack, + report_type, + SND_JACK_HEADPHONE); + } } //2 |