mirror of
https://github.com/revyos/thead-kernel.git
synced 2026-09-18 13:22:15 +02:00
sync: huiwei: e94a4cf98b93de7f711637033a43f0e2f5f3ac7a
merge into c2a6429c9b9d3fe12738317f410fb1b5cb96cb3b
This commit is contained in:
@@ -85,5 +85,7 @@ source "sound/soc/codecs/Kconfig"
|
||||
# generic frame-work
|
||||
source "sound/soc/generic/Kconfig"
|
||||
|
||||
source "sound/soc/headset_observe/Kconfig"
|
||||
|
||||
endif # SND_SOC
|
||||
|
||||
|
||||
@@ -61,3 +61,4 @@ obj-$(CONFIG_SND_SOC) += xilinx/
|
||||
obj-$(CONFIG_SND_SOC) += xtensa/
|
||||
obj-$(CONFIG_SND_SOC) += zte/
|
||||
obj-$(CONFIG_SND_SOC) += thead/
|
||||
obj-$(CONFIG_RK_HEADSET) += headset_observe/
|
||||
|
||||
@@ -91,6 +91,7 @@ config SND_SOC_ALL_CODECS
|
||||
imply SND_SOC_DMIC
|
||||
imply SND_SOC_ES8156
|
||||
imply SND_SOC_ES8316
|
||||
imply SND_SOC_ES8323
|
||||
imply SND_SOC_ES8328_SPI
|
||||
imply SND_SOC_ES8328_I2C
|
||||
imply SND_SOC_ES7134
|
||||
@@ -791,6 +792,10 @@ config SND_SOC_ES8316
|
||||
tristate "Everest Semi ES8316 CODEC"
|
||||
depends on I2C
|
||||
|
||||
config SND_SOC_ES8323
|
||||
tristate "Everest Semi ES8323 CODEC"
|
||||
depends on I2C
|
||||
|
||||
config SND_SOC_ES8328
|
||||
tristate
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ snd-soc-es7210-objs := es7210.o
|
||||
snd-soc-es7241-objs := es7241.o
|
||||
snd-soc-es8156-objs := es8156.o
|
||||
snd-soc-es8316-objs := es8316.o
|
||||
snd-soc-es8323-objs := es8323.o
|
||||
snd-soc-es8328-objs := es8328.o
|
||||
snd-soc-es8328-i2c-objs := es8328-i2c.o
|
||||
snd-soc-es8328-spi-objs := es8328-spi.o
|
||||
@@ -400,6 +401,7 @@ obj-$(CONFIG_SND_SOC_ES7210) += snd-soc-es7210.o
|
||||
obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o
|
||||
obj-$(CONFIG_SND_SOC_ES8156) += snd-soc-es8156.o
|
||||
obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o
|
||||
obj-$(CONFIG_SND_SOC_ES8323) += snd-soc-es8323.o
|
||||
obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
|
||||
obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
|
||||
obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
|
||||
|
||||
1232
sound/soc/codecs/es8323.c
Normal file
1232
sound/soc/codecs/es8323.c
Normal file
File diff suppressed because it is too large
Load Diff
151
sound/soc/codecs/es8323.h
Normal file
151
sound/soc/codecs/es8323.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright 2005 Openedhand Ltd.
|
||||
*
|
||||
* Author: Richard Purdie <richard@openedhand.com>
|
||||
*/
|
||||
|
||||
#ifndef _ES8323_H
|
||||
#define _ES8323_H
|
||||
|
||||
#define CONFIG_HHTECH_MINIPMP 1
|
||||
|
||||
/* ES8323 register space */
|
||||
|
||||
#define ES8323_CONTROL1 0x00
|
||||
#define ES8323_CONTROL2 0x01
|
||||
#define ES8323_CHIPPOWER 0x02
|
||||
#define ES8323_ADCPOWER 0x03
|
||||
#define ES8323_DACPOWER 0x04
|
||||
#define ES8323_CHIPLOPOW1 0x05
|
||||
#define ES8323_CHIPLOPOW2 0x06
|
||||
#define ES8323_ANAVOLMANAG 0x07
|
||||
#define ES8323_MASTERMODE 0x08
|
||||
#define ES8323_ADCCONTROL1 0x09
|
||||
#define ES8323_ADCCONTROL2 0x0a
|
||||
#define ES8323_ADCCONTROL3 0x0b
|
||||
#define ES8323_ADCCONTROL4 0x0c
|
||||
#define ES8323_ADCCONTROL5 0x0d
|
||||
#define ES8323_ADCCONTROL6 0x0e
|
||||
#define ES8323_ADCCONTROL7 0x0f
|
||||
#define ES8323_ADCCONTROL8 0x10
|
||||
#define ES8323_ADCCONTROL9 0x11
|
||||
#define ES8323_ADCCONTROL10 0x12
|
||||
#define ES8323_ADCCONTROL11 0x13
|
||||
#define ES8323_ADCCONTROL12 0x14
|
||||
#define ES8323_ADCCONTROL13 0x15
|
||||
#define ES8323_ADCCONTROL14 0x16
|
||||
|
||||
#define ES8323_DACCONTROL1 0x17
|
||||
#define ES8323_DACCONTROL2 0x18
|
||||
#define ES8323_DACCONTROL3 0x19
|
||||
#define ES8323_DACCONTROL4 0x1a
|
||||
#define ES8323_DACCONTROL5 0x1b
|
||||
#define ES8323_DACCONTROL6 0x1c
|
||||
#define ES8323_DACCONTROL7 0x1d
|
||||
#define ES8323_DACCONTROL8 0x1e
|
||||
#define ES8323_DACCONTROL9 0x1f
|
||||
#define ES8323_DACCONTROL10 0x20
|
||||
#define ES8323_DACCONTROL11 0x21
|
||||
#define ES8323_DACCONTROL12 0x22
|
||||
#define ES8323_DACCONTROL13 0x23
|
||||
#define ES8323_DACCONTROL14 0x24
|
||||
#define ES8323_DACCONTROL15 0x25
|
||||
#define ES8323_DACCONTROL16 0x26
|
||||
#define ES8323_DACCONTROL17 0x27
|
||||
#define ES8323_DACCONTROL18 0x28
|
||||
#define ES8323_DACCONTROL19 0x29
|
||||
#define ES8323_DACCONTROL20 0x2a
|
||||
#define ES8323_DACCONTROL21 0x2b
|
||||
#define ES8323_DACCONTROL22 0x2c
|
||||
#define ES8323_DACCONTROL23 0x2d
|
||||
#define ES8323_DACCONTROL24 0x2e
|
||||
#define ES8323_DACCONTROL25 0x2f
|
||||
#define ES8323_DACCONTROL26 0x30
|
||||
#define ES8323_DACCONTROL27 0x31
|
||||
#define ES8323_DACCONTROL28 0x32
|
||||
#define ES8323_DACCONTROL29 0x33
|
||||
#define ES8323_DACCONTROL30 0x34
|
||||
|
||||
#define ES8323_LADC_VOL ES8323_ADCCONTROL8
|
||||
#define ES8323_RADC_VOL ES8323_ADCCONTROL9
|
||||
|
||||
#define ES8323_LDAC_VOL ES8323_DACCONTROL4
|
||||
#define ES8323_RDAC_VOL ES8323_DACCONTROL5
|
||||
|
||||
#define ES8323_LOUT1_VOL ES8323_DACCONTROL24
|
||||
#define ES8323_ROUT1_VOL ES8323_DACCONTROL25
|
||||
#define ES8323_LOUT2_VOL ES8323_DACCONTROL26
|
||||
#define ES8323_ROUT2_VOL ES8323_DACCONTROL27
|
||||
|
||||
#define ES8323_ADC_MUTE ES8323_ADCCONTROL7
|
||||
#define ES8323_DAC_MUTE ES8323_DACCONTROL3
|
||||
|
||||
|
||||
|
||||
#define ES8323_IFACE ES8323_MASTERMODE
|
||||
|
||||
#define ES8323_ADC_IFACE ES8323_ADCCONTROL4
|
||||
#define ES8323_ADC_SRATE ES8323_ADCCONTROL5
|
||||
|
||||
#define ES8323_DAC_IFACE ES8323_DACCONTROL1
|
||||
#define ES8323_DAC_SRATE ES8323_DACCONTROL2
|
||||
|
||||
|
||||
|
||||
#define ES8323_CACHEREGNUM 53
|
||||
#define ES8323_SYSCLK 0
|
||||
|
||||
struct es8323_setup_data {
|
||||
int i2c_bus;
|
||||
unsigned short i2c_address;
|
||||
};
|
||||
|
||||
#if 1 //lzcx
|
||||
#define ES8323_PLL1 0
|
||||
#define ES8323_PLL2 1
|
||||
|
||||
/* clock inputs */
|
||||
#define ES8323_MCLK 0
|
||||
#define ES8323_PCMCLK 1
|
||||
|
||||
/* clock divider id's */
|
||||
#define ES8323_PCMDIV 0
|
||||
#define ES8323_BCLKDIV 1
|
||||
#define ES8323_VXCLKDIV 2
|
||||
|
||||
/* PCM clock dividers */
|
||||
#define ES8323_PCM_DIV_1 (0 << 6)
|
||||
#define ES8323_PCM_DIV_3 (2 << 6)
|
||||
#define ES8323_PCM_DIV_5_5 (3 << 6)
|
||||
#define ES8323_PCM_DIV_2 (4 << 6)
|
||||
#define ES8323_PCM_DIV_4 (5 << 6)
|
||||
#define ES8323_PCM_DIV_6 (6 << 6)
|
||||
#define ES8323_PCM_DIV_8 (7 << 6)
|
||||
|
||||
/* BCLK clock dividers */
|
||||
#define ES8323_BCLK_DIV_1 (0 << 7)
|
||||
#define ES8323_BCLK_DIV_2 (1 << 7)
|
||||
#define ES8323_BCLK_DIV_4 (2 << 7)
|
||||
#define ES8323_BCLK_DIV_8 (3 << 7)
|
||||
|
||||
/* VXCLK clock dividers */
|
||||
#define ES8323_VXCLK_DIV_1 (0 << 6)
|
||||
#define ES8323_VXCLK_DIV_2 (1 << 6)
|
||||
#define ES8323_VXCLK_DIV_4 (2 << 6)
|
||||
#define ES8323_VXCLK_DIV_8 (3 << 6)
|
||||
#define ES8323_VXCLK_DIV_16 (4 << 6)
|
||||
|
||||
#define ES8323_DAI_HIFI 0
|
||||
#define ES8323_DAI_VOICE 1
|
||||
|
||||
#define ES8323_1536FS 1536
|
||||
#define ES8323_1024FS 1024
|
||||
#define ES8323_768FS 768
|
||||
#define ES8323_512FS 512
|
||||
#define ES8323_384FS 384
|
||||
#define ES8323_256FS 256
|
||||
#define ES8323_128FS 128
|
||||
#endif
|
||||
|
||||
#endif
|
||||
16
sound/soc/headset_observe/Kconfig
Executable file
16
sound/soc/headset_observe/Kconfig
Executable file
@@ -0,0 +1,16 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Headset device configuration
|
||||
#
|
||||
|
||||
menu "Headset device support"
|
||||
|
||||
config RK_HEADSET
|
||||
tristate "Rockchips HeadSet support"
|
||||
help
|
||||
Rockchips HeadSet support:
|
||||
support hook interrupt mode.
|
||||
support hook adc mode.
|
||||
|
||||
endmenu
|
||||
|
||||
2
sound/soc/headset_observe/Makefile
Executable file
2
sound/soc/headset_observe/Makefile
Executable file
@@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
obj-$(CONFIG_RK_HEADSET) += rockchip_headset_core.o rk_headset.o rk_headset_irq_hook_adc.o
|
||||
643
sound/soc/headset_observe/rk_headset.c
Executable file
643
sound/soc/headset_observe/rk_headset.c
Executable file
@@ -0,0 +1,643 @@
|
||||
/* arch/arm/mach-rockchip/rk28_headset.c
|
||||
*
|
||||
* Copyright (C) 2009 Rockchip Corporation.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/hrtimer.h>
|
||||
#include <linux/extcon-provider.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/rk_headset.h>
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
#include <linux/earlysuspend.h>
|
||||
#endif
|
||||
|
||||
/* Debug */
|
||||
#if 1
|
||||
#define DBG(x...) printk(x)
|
||||
#else
|
||||
#define DBG(x...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define BIT_HEADSET BIT(0)
|
||||
#define BIT_HEADSET_NO_MIC BIT(1)
|
||||
|
||||
#define HEADSET 0
|
||||
#define HOOK 1
|
||||
#define LINEIN 2
|
||||
#define IPLIN 3
|
||||
|
||||
#define HEADSET_IN 1
|
||||
#define HEADSET_OUT 0
|
||||
#define LINEIN_IN 1
|
||||
#define LINEIN_OUT 0
|
||||
#define HOOK_DOWN 1
|
||||
#define HOOK_UP 0
|
||||
#define enable 1
|
||||
#define disable 0
|
||||
|
||||
#if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610)
|
||||
extern void rk2928_codec_set_spk(bool on);
|
||||
#endif
|
||||
#ifdef CONFIG_SND_SOC_WM8994
|
||||
extern int wm8994_set_status(void);
|
||||
#endif
|
||||
|
||||
/* headset private data */
|
||||
struct headset_priv {
|
||||
struct input_dev *input_dev;
|
||||
struct rk_headset_pdata *pdata;
|
||||
unsigned int headset_status : 1;
|
||||
unsigned int linein_status : 1;
|
||||
unsigned int iplin_status : 1;
|
||||
unsigned int hook_status : 1;
|
||||
unsigned int isMic : 1;
|
||||
unsigned int isHook_irq : 1;
|
||||
int cur_headset_status;
|
||||
unsigned int irq[4];
|
||||
unsigned int irq_type[4];
|
||||
struct delayed_work h_delayed_work[4];
|
||||
struct extcon_dev *edev;
|
||||
struct mutex mutex_lock[4];
|
||||
struct timer_list headset_timer;
|
||||
unsigned char *keycodes;
|
||||
};
|
||||
|
||||
static struct headset_priv *headset_info;
|
||||
|
||||
int rk_headset_get_headset(void)
|
||||
{
|
||||
if(NULL == headset_info)
|
||||
return -1;
|
||||
printk("Enter %d into %s(%d)\n", headset_info->cur_headset_status,__func__, __LINE__);
|
||||
return headset_info->cur_headset_status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rk_headset_get_headset);
|
||||
|
||||
#ifdef CONFIG_MODEM_MIC_SWITCH
|
||||
#define HP_MIC 0
|
||||
#define MAIN_MIC 1
|
||||
|
||||
|
||||
void Modem_Mic_switch(int value)
|
||||
{
|
||||
if (value == HP_MIC)
|
||||
gpio_set_value(headset_info->pdata->mic_switch_gpio,
|
||||
headset_info->pdata->hp_mic_io_value);
|
||||
else if (value == MAIN_MIC)
|
||||
gpio_set_value(headset_info->pdata->mic_switch_gpio,
|
||||
headset_info->pdata->main_mic_io_value);
|
||||
}
|
||||
|
||||
void Modem_Mic_release(void)
|
||||
{
|
||||
if (headset_info->cur_headset_status == 1)
|
||||
gpio_set_value(headset_info->pdata->mic_switch_gpio,
|
||||
headset_info->pdata->hp_mic_io_value);
|
||||
else
|
||||
gpio_set_value(headset_info->pdata->mic_switch_gpio,
|
||||
headset_info->pdata->main_mic_io_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int read_gpio(int gpio)
|
||||
{
|
||||
int i, level;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
level = gpio_get_value(gpio);
|
||||
if (level < 0) {
|
||||
pr_warn("%s:get pin level again,pin=%d,i=%d\n",
|
||||
__func__, gpio, i);
|
||||
msleep(1);
|
||||
continue;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (level < 0)
|
||||
pr_err("%s:get pin level err!\n", __func__);
|
||||
return level;
|
||||
}
|
||||
|
||||
static irqreturn_t headset_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
DBG("---headset_interrupt---\n");
|
||||
schedule_delayed_work(&headset_info->h_delayed_work[HEADSET],
|
||||
msecs_to_jiffies(50));
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t linein_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
DBG("---linein_interrupt---\n");
|
||||
schedule_delayed_work(&headset_info->h_delayed_work[LINEIN],
|
||||
msecs_to_jiffies(50));
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t iplin_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
DBG("---iplin_interrupt---\n");
|
||||
schedule_delayed_work(&headset_info->h_delayed_work[IPLIN],
|
||||
msecs_to_jiffies(50));
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
static irqreturn_t hook_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
DBG("---Hook_interrupt---\n");
|
||||
/* disable_irq_nosync(headset_info->irq[HOOK]); */
|
||||
schedule_delayed_work(&headset_info->h_delayed_work[HOOK],
|
||||
msecs_to_jiffies(100));
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void headsetobserve_work(struct work_struct *work)
|
||||
{
|
||||
int level = 0;
|
||||
int level2 = 0;
|
||||
struct rk_headset_pdata *pdata = headset_info->pdata;
|
||||
static unsigned int old_status = 0;
|
||||
|
||||
printk("---headsetobserve_work---\n");
|
||||
mutex_lock(&headset_info->mutex_lock[HEADSET]);
|
||||
level = read_gpio(pdata->headset_gpio);
|
||||
if (level < 0)
|
||||
goto out;
|
||||
msleep(100);
|
||||
level2 = read_gpio(pdata->headset_gpio);
|
||||
if (level2 < 0)
|
||||
goto out;
|
||||
if (level2 != level)
|
||||
goto out;
|
||||
old_status = headset_info->headset_status;
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
headset_info->headset_status = level ? HEADSET_IN : HEADSET_OUT;
|
||||
else
|
||||
headset_info->headset_status = level ? HEADSET_OUT : HEADSET_IN;
|
||||
|
||||
if (old_status == headset_info->headset_status) {
|
||||
pr_warn("old_status == headset_info->headset_status\n");
|
||||
goto out;
|
||||
}
|
||||
DBG("(headset in is %s)headset status is %s\n",
|
||||
pdata->headset_insert_type ? "high level" : "low level",
|
||||
headset_info->headset_status ? "in" : "out");
|
||||
if (headset_info->headset_status == HEADSET_IN) {
|
||||
headset_info->cur_headset_status = BIT_HEADSET_NO_MIC;
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_RISING);
|
||||
if (pdata->hook_gpio) {
|
||||
/* Start the timer, wait for switch to the headphone channel */
|
||||
del_timer(&headset_info->headset_timer);
|
||||
headset_info->headset_timer.expires = jiffies + 100;
|
||||
add_timer(&headset_info->headset_timer);
|
||||
goto out;
|
||||
}
|
||||
} else if (headset_info->headset_status == HEADSET_OUT) {
|
||||
headset_info->hook_status = HOOK_UP;
|
||||
if (headset_info->isHook_irq == enable) {
|
||||
DBG("disable headset_hook irq\n");
|
||||
headset_info->isHook_irq = disable;
|
||||
disable_irq(headset_info->irq[HOOK]);
|
||||
}
|
||||
headset_info->cur_headset_status = 0;
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_RISING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
}
|
||||
if (headset_info->cur_headset_status)
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_HEADPHONE,
|
||||
true);
|
||||
else
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_HEADPHONE,
|
||||
false);
|
||||
DBG("headset_info->cur_headset_status = %d\n",
|
||||
headset_info->cur_headset_status);
|
||||
out:
|
||||
mutex_unlock(&headset_info->mutex_lock[HEADSET]);
|
||||
}
|
||||
|
||||
static void linein_work(struct work_struct *work)
|
||||
{
|
||||
int level = 0;
|
||||
int level2 = 0;
|
||||
struct rk_headset_pdata *pdata = headset_info->pdata;
|
||||
static unsigned int old_status = 0;
|
||||
|
||||
printk("---linein_work---\n");
|
||||
mutex_lock(&headset_info->mutex_lock[LINEIN]);
|
||||
level = read_gpio(pdata->linein_gpio);
|
||||
if (level < 0)
|
||||
goto out;
|
||||
msleep(100);
|
||||
level2 = read_gpio(pdata->linein_gpio);
|
||||
if (level2 < 0)
|
||||
goto out;
|
||||
if (level2 != level)
|
||||
goto out;
|
||||
old_status = headset_info->linein_status;
|
||||
if (pdata->linein_insert_type == LINEIN_HIGH)
|
||||
headset_info->linein_status = level ? LINEIN_IN : LINEIN_OUT;
|
||||
else
|
||||
headset_info->linein_status = level ? LINEIN_OUT : LINEIN_IN;
|
||||
|
||||
if (old_status == headset_info->linein_status) {
|
||||
pr_warn("old_status == headset_info->linein_status\n");
|
||||
goto out;
|
||||
}
|
||||
DBG("(linein type is %s)linein status is %s\n",
|
||||
pdata->linein_insert_type ? "high level" : "low level",
|
||||
headset_info->linein_status ? "in" : "out");
|
||||
if (headset_info->linein_status == LINEIN_IN) {
|
||||
if (pdata->linein_insert_type == LINEIN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[LINEIN],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[LINEIN],
|
||||
IRQF_TRIGGER_RISING);
|
||||
} else if (headset_info->linein_status == LINEIN_OUT) {
|
||||
if (pdata->linein_insert_type == LINEIN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[LINEIN],
|
||||
IRQF_TRIGGER_RISING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[LINEIN],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
}
|
||||
if (headset_info->linein_status)
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_MICROPHONE,
|
||||
true);
|
||||
else
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_MICROPHONE,
|
||||
false);
|
||||
DBG("headset_info->linein_status = %d\n",
|
||||
headset_info->linein_status);
|
||||
out:
|
||||
mutex_unlock(&headset_info->mutex_lock[LINEIN]);
|
||||
}
|
||||
|
||||
static void iplin_work(struct work_struct *work)
|
||||
{
|
||||
int level = 0;
|
||||
int level2 = 0;
|
||||
struct rk_headset_pdata *pdata = headset_info->pdata;
|
||||
static unsigned int old_status = 0;
|
||||
|
||||
printk("---iplin_work---\n");
|
||||
mutex_lock(&headset_info->mutex_lock[IPLIN]);
|
||||
level = read_gpio(pdata->iplin_gpio);
|
||||
if (level < 0)
|
||||
goto out;
|
||||
msleep(100);
|
||||
level2 = read_gpio(pdata->iplin_gpio);
|
||||
if (level2 < 0)
|
||||
goto out;
|
||||
if (level2 != level)
|
||||
goto out;
|
||||
old_status = headset_info->iplin_status;
|
||||
if (pdata->iplin_insert_type == LINEIN_HIGH)
|
||||
headset_info->iplin_status = level ? LINEIN_IN : LINEIN_OUT;
|
||||
else
|
||||
headset_info->iplin_status = level ? LINEIN_OUT : LINEIN_IN;
|
||||
|
||||
if (old_status == headset_info->iplin_status) {
|
||||
pr_warn("old_status == headset_info->iplin_status\n");
|
||||
goto out;
|
||||
}
|
||||
DBG("(iplin type is %s)iplin status is %s\n",
|
||||
pdata->iplin_insert_type ? "high level" : "low level",
|
||||
headset_info->iplin_status ? "in" : "out");
|
||||
if (headset_info->iplin_status == LINEIN_IN) {
|
||||
if (pdata->iplin_insert_type == LINEIN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[IPLIN],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[IPLIN],
|
||||
IRQF_TRIGGER_RISING);
|
||||
} else if (headset_info->iplin_status == LINEIN_OUT) {
|
||||
if (pdata->iplin_insert_type == LINEIN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[IPLIN],
|
||||
IRQF_TRIGGER_RISING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[IPLIN],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
}
|
||||
if (headset_info->iplin_status)
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_LINE_IN,
|
||||
true);
|
||||
else
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_LINE_IN,
|
||||
false);
|
||||
DBG("headset_info->iplin_status = %d\n",
|
||||
headset_info->iplin_status);
|
||||
out:
|
||||
mutex_unlock(&headset_info->mutex_lock[IPLIN]);
|
||||
}
|
||||
|
||||
|
||||
static void hook_work(struct work_struct *work)
|
||||
{
|
||||
int level = 0;
|
||||
struct rk_headset_pdata *pdata = headset_info->pdata;
|
||||
static unsigned int old_status = HOOK_UP;
|
||||
|
||||
mutex_lock(&headset_info->mutex_lock[HOOK]);
|
||||
if (headset_info->headset_status == HEADSET_OUT) {
|
||||
DBG("Headset is out\n");
|
||||
goto RE_ERROR;
|
||||
}
|
||||
level = read_gpio(pdata->hook_gpio);
|
||||
if (level < 0)
|
||||
goto RE_ERROR;
|
||||
old_status = headset_info->hook_status;
|
||||
DBG("Hook_work -- level = %d\n", level);
|
||||
if (level == 0)
|
||||
headset_info->hook_status =
|
||||
pdata->hook_down_type == HOOK_DOWN_HIGH ? HOOK_UP :
|
||||
HOOK_DOWN;
|
||||
else if (level > 0)
|
||||
headset_info->hook_status =
|
||||
pdata->hook_down_type == HOOK_DOWN_HIGH ? HOOK_DOWN :
|
||||
HOOK_UP;
|
||||
if (old_status == headset_info->hook_status) {
|
||||
DBG("old_status == headset_info->hook_status\n");
|
||||
goto RE_ERROR;
|
||||
}
|
||||
DBG("Hook_work -- level = %d hook status is %s\n", level,
|
||||
headset_info->hook_status ? "key down" : "key up");
|
||||
if (headset_info->hook_status == HOOK_DOWN) {
|
||||
if (pdata->hook_down_type == HOOK_DOWN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HOOK],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HOOK],
|
||||
IRQF_TRIGGER_RISING);
|
||||
} else {
|
||||
if (pdata->hook_down_type == HOOK_DOWN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HOOK],
|
||||
IRQF_TRIGGER_RISING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HOOK],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
}
|
||||
input_report_key(headset_info->input_dev, HOOK_KEY_CODE,
|
||||
headset_info->hook_status);
|
||||
input_sync(headset_info->input_dev);
|
||||
RE_ERROR:
|
||||
mutex_unlock(&headset_info->mutex_lock[HOOK]);
|
||||
}
|
||||
|
||||
static void headset_timer_callback(struct timer_list *t)
|
||||
{
|
||||
struct headset_priv *headset = from_timer(headset, t, headset_timer);
|
||||
struct rk_headset_pdata *pdata = headset->pdata;
|
||||
int level = 0;
|
||||
|
||||
pr_info("headset_timer_callback, headset->headset_status %d\n",
|
||||
headset->headset_status);
|
||||
if (headset->headset_status == HEADSET_OUT) {
|
||||
pr_info("Headset is out\n");
|
||||
goto out;
|
||||
}
|
||||
level = read_gpio(pdata->hook_gpio);
|
||||
if (level < 0)
|
||||
goto out;
|
||||
if ((level > 0 && pdata->hook_down_type == HOOK_DOWN_LOW) ||
|
||||
(level == 0 && pdata->hook_down_type == HOOK_DOWN_HIGH)) {
|
||||
headset->isMic = 1;
|
||||
enable_irq(headset_info->irq[HOOK]);
|
||||
headset->isHook_irq = enable;
|
||||
headset_info->hook_status = HOOK_UP;
|
||||
if (pdata->hook_down_type == HOOK_DOWN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HOOK],
|
||||
IRQF_TRIGGER_RISING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HOOK],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
} else {
|
||||
headset->isMic = 0;
|
||||
}
|
||||
pr_info("headset->isMic = %d\n", headset->isMic);
|
||||
headset_info->cur_headset_status = headset_info->isMic ? 1 : 2;
|
||||
if (headset->isMic == 1)
|
||||
extcon_set_state_sync(headset_info->edev,
|
||||
EXTCON_JACK_MICROPHONE, true);
|
||||
else
|
||||
extcon_set_state_sync(headset_info->edev,
|
||||
EXTCON_JACK_MICROPHONE, false);
|
||||
DBG("headset_info->cur_headset_status = %d\n",
|
||||
headset_info->cur_headset_status);
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
static void headset_early_resume(struct early_suspend *h)
|
||||
{
|
||||
schedule_delayed_work(&headset_info->h_delayed_work[HEADSET],
|
||||
msecs_to_jiffies(10));
|
||||
//DBG(">>>>>headset_early_resume\n");
|
||||
}
|
||||
|
||||
static struct early_suspend hs_early_suspend;
|
||||
#endif
|
||||
|
||||
static int rk_hskey_open(struct input_dev *dev)
|
||||
{
|
||||
//struct rk28_adckey *adckey = input_get_drvdata(dev);
|
||||
//DBG("===========rk_Hskey_open===========\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rk_hskey_close(struct input_dev *dev)
|
||||
{
|
||||
//DBG("===========rk_Hskey_close===========\n");
|
||||
//struct rk28_adckey *adckey = input_get_drvdata(dev);
|
||||
}
|
||||
|
||||
static const unsigned int headset_cable[] = {
|
||||
EXTCON_JACK_MICROPHONE,
|
||||
EXTCON_JACK_HEADPHONE,
|
||||
EXTCON_JACK_LINE_IN,
|
||||
EXTCON_NONE,
|
||||
};
|
||||
|
||||
int rk_headset_probe(struct platform_device *pdev,
|
||||
struct rk_headset_pdata *pdata)
|
||||
{
|
||||
int ret = 0;
|
||||
struct headset_priv *headset;
|
||||
|
||||
headset = devm_kzalloc(&pdev->dev, sizeof(*headset), GFP_KERNEL);
|
||||
if (!headset) {
|
||||
dev_err(&pdev->dev, "failed to allocate driver data\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
headset_info = headset;
|
||||
headset->pdata = pdata;
|
||||
headset->headset_status = HEADSET_OUT;
|
||||
headset->hook_status = HOOK_UP;
|
||||
headset->linein_status = LINEIN_OUT;
|
||||
headset->iplin_status = LINEIN_OUT;
|
||||
headset->isHook_irq = disable;
|
||||
headset->cur_headset_status = 0;
|
||||
headset->edev = devm_extcon_dev_allocate(&pdev->dev, headset_cable);
|
||||
if (IS_ERR(headset->edev)) {
|
||||
dev_err(&pdev->dev, "failed to allocate extcon device\n");
|
||||
ret = -ENOMEM;
|
||||
goto failed;
|
||||
}
|
||||
ret = devm_extcon_dev_register(&pdev->dev, headset->edev);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "extcon_dev_register() failed: %d\n", ret);
|
||||
goto failed;
|
||||
}
|
||||
mutex_init(&headset->mutex_lock[HEADSET]);
|
||||
mutex_init(&headset->mutex_lock[HOOK]);
|
||||
INIT_DELAYED_WORK(&headset->h_delayed_work[HEADSET],
|
||||
headsetobserve_work);
|
||||
INIT_DELAYED_WORK(&headset->h_delayed_work[LINEIN], linein_work);
|
||||
INIT_DELAYED_WORK(&headset->h_delayed_work[IPLIN], iplin_work);
|
||||
INIT_DELAYED_WORK(&headset->h_delayed_work[HOOK], hook_work);
|
||||
headset->isMic = 0;
|
||||
timer_setup(&headset->headset_timer, headset_timer_callback, 0);
|
||||
/* Create and register the input driver */
|
||||
headset->input_dev = devm_input_allocate_device(&pdev->dev);
|
||||
if (!headset->input_dev) {
|
||||
dev_err(&pdev->dev, "failed to allocate input device\n");
|
||||
ret = -ENOMEM;
|
||||
goto failed;
|
||||
}
|
||||
headset->input_dev->name = pdev->name;
|
||||
headset->input_dev->open = rk_hskey_open;
|
||||
headset->input_dev->close = rk_hskey_close;
|
||||
headset->input_dev->dev.parent = &pdev->dev;
|
||||
/* input_dev->phys = KEY_PHYS_NAME; */
|
||||
headset->input_dev->id.vendor = 0x0001;
|
||||
headset->input_dev->id.product = 0x0001;
|
||||
headset->input_dev->id.version = 0x0100;
|
||||
/* Register the input device */
|
||||
ret = input_register_device(headset->input_dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register input device\n");
|
||||
goto failed;
|
||||
}
|
||||
input_set_capability(headset->input_dev, EV_KEY, HOOK_KEY_CODE);
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
hs_early_suspend.suspend = NULL;
|
||||
hs_early_suspend.resume = headset_early_resume;
|
||||
hs_early_suspend.level = ~0x0;
|
||||
register_early_suspend(&hs_early_suspend);
|
||||
#endif
|
||||
if (pdata->headset_gpio) {
|
||||
headset->irq[HEADSET] = gpio_to_irq(pdata->headset_gpio);
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
headset->irq_type[HEADSET] = IRQF_TRIGGER_RISING;
|
||||
else
|
||||
headset->irq_type[HEADSET] = IRQF_TRIGGER_FALLING;
|
||||
ret = devm_request_irq(&pdev->dev, headset->irq[HEADSET],
|
||||
headset_interrupt,
|
||||
headset->irq_type[HEADSET],
|
||||
"headset_input", NULL);
|
||||
if (ret)
|
||||
goto failed;
|
||||
if (pdata->headset_wakeup)
|
||||
enable_irq_wake(headset->irq[HEADSET]);
|
||||
} else {
|
||||
dev_err(&pdev->dev, "failed init headset, please full headset_gpio function in board\n");
|
||||
ret = -EEXIST;
|
||||
goto failed;
|
||||
}
|
||||
if (pdata->linein_gpio) {
|
||||
headset->irq[LINEIN] = gpio_to_irq(pdata->linein_gpio);
|
||||
if (pdata->linein_insert_type == LINEIN_HIGH)
|
||||
headset->irq_type[LINEIN] = IRQF_TRIGGER_RISING;
|
||||
else
|
||||
headset->irq_type[LINEIN] = IRQF_TRIGGER_FALLING;
|
||||
ret = devm_request_irq(&pdev->dev, headset->irq[LINEIN],
|
||||
linein_interrupt,
|
||||
headset->irq_type[LINEIN],
|
||||
"linein_input", NULL);
|
||||
if (ret)
|
||||
goto failed;
|
||||
}
|
||||
if (pdata->iplin_gpio) {
|
||||
headset->irq[IPLIN] = gpio_to_irq(pdata->iplin_gpio);
|
||||
if (pdata->iplin_insert_type == LINEIN_HIGH)
|
||||
headset->irq_type[IPLIN] = IRQF_TRIGGER_RISING;
|
||||
else
|
||||
headset->irq_type[IPLIN] = IRQF_TRIGGER_FALLING;
|
||||
ret = devm_request_irq(&pdev->dev, headset->irq[IPLIN],
|
||||
iplin_interrupt,
|
||||
headset->irq_type[IPLIN],
|
||||
"iplin_input", NULL);
|
||||
if (ret)
|
||||
goto failed;
|
||||
}
|
||||
if (pdata->hook_gpio) {
|
||||
headset->irq[HOOK] = gpio_to_irq(pdata->hook_gpio);
|
||||
headset->irq_type[HOOK] =
|
||||
pdata->hook_down_type == HOOK_DOWN_HIGH ?
|
||||
IRQF_TRIGGER_RISING :
|
||||
IRQF_TRIGGER_FALLING;
|
||||
ret = devm_request_irq(&pdev->dev, headset->irq[HOOK],
|
||||
hook_interrupt, headset->irq_type[HOOK],
|
||||
"headset_hook", NULL);
|
||||
if (ret)
|
||||
goto failed;
|
||||
disable_irq(headset->irq[HOOK]);
|
||||
}
|
||||
schedule_delayed_work(&headset->h_delayed_work[HEADSET],
|
||||
msecs_to_jiffies(500));
|
||||
if (pdata->linein_gpio) {
|
||||
schedule_delayed_work(&headset->h_delayed_work[LINEIN],
|
||||
msecs_to_jiffies(500));
|
||||
}
|
||||
if (pdata->iplin_gpio) {
|
||||
schedule_delayed_work(&headset->h_delayed_work[IPLIN],
|
||||
msecs_to_jiffies(500));
|
||||
}
|
||||
return 0;
|
||||
failed:
|
||||
dev_err(&pdev->dev, "failed to headset probe ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rk_headset_probe);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
482
sound/soc/headset_observe/rk_headset_irq_hook_adc.c
Executable file
482
sound/soc/headset_observe/rk_headset_irq_hook_adc.c
Executable file
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Rockchip Corporation.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/hrtimer.h>
|
||||
#include <linux/extcon-provider.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/iio/consumer.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#include <linux/rk_headset.h>
|
||||
|
||||
/* Debug */
|
||||
#if 1
|
||||
#define DBG(x...) printk(x)
|
||||
#else
|
||||
#define DBG(x...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define HOOK_ADC_SAMPLE_TIME 100
|
||||
|
||||
#define HOOK_LEVEL_HIGH 410 //1V*1024/2.5
|
||||
#define HOOK_LEVEL_LOW 204 //0.5V*1024/2.5
|
||||
#define HOOK_DEFAULT_VAL 1024
|
||||
|
||||
#define BIT_HEADSET BIT(0)
|
||||
#define BIT_HEADSET_NO_MIC BIT(1)
|
||||
|
||||
#define HEADSET 0
|
||||
#define HOOK 1
|
||||
|
||||
#define HEADSET_IN 1
|
||||
#define HEADSET_OUT 0
|
||||
#define HOOK_DOWN 1
|
||||
#define HOOK_UP 0
|
||||
#define enable 1
|
||||
#define disable 0
|
||||
|
||||
#define HEADSET_TIMER 1
|
||||
#define HOOK_TIMER 2
|
||||
|
||||
#define WAIT 2
|
||||
#define BUSY 1
|
||||
#define IDLE 0
|
||||
|
||||
#ifdef CONFIG_SND_SOC_WM8994
|
||||
extern int wm8994_headset_mic_detect(bool headset_status);
|
||||
#endif
|
||||
#ifdef CONFIG_SND_SOC_RT5631_PHONE
|
||||
extern int rt5631_headset_mic_detect(bool headset_status);
|
||||
#endif
|
||||
#if defined(CONFIG_SND_SOC_RT3261) || defined(CONFIG_SND_SOC_RT3224)
|
||||
extern int rt3261_headset_mic_detect(int jack_insert);
|
||||
#endif
|
||||
|
||||
|
||||
/* headset private data */
|
||||
struct headset_priv {
|
||||
struct input_dev *input_dev;
|
||||
struct rk_headset_pdata *pdata;
|
||||
unsigned int headset_status : 1;
|
||||
unsigned int hook_status : 1;
|
||||
int isMic;
|
||||
struct iio_channel *chan;
|
||||
/* headset interrupt working will not check hook key */
|
||||
unsigned int heatset_irq_working;
|
||||
int cur_headset_status;
|
||||
unsigned int irq[2];
|
||||
struct delayed_work h_delayed_work[2];
|
||||
struct extcon_dev *edev;
|
||||
struct mutex mutex_lock[2];
|
||||
unsigned char *keycodes;
|
||||
struct delayed_work hook_work;
|
||||
/* ms */
|
||||
unsigned int hook_time;
|
||||
};
|
||||
|
||||
static struct headset_priv *headset_info;
|
||||
|
||||
static irqreturn_t headset_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct rk_headset_pdata *pdata = headset_info->pdata;
|
||||
static unsigned int old_status = 0;
|
||||
int i, level = 0;
|
||||
|
||||
disable_irq_nosync(headset_info->irq[HEADSET]);
|
||||
if (headset_info->heatset_irq_working == BUSY ||
|
||||
headset_info->heatset_irq_working == WAIT)
|
||||
return IRQ_HANDLED;
|
||||
|
||||
headset_info->heatset_irq_working = BUSY;
|
||||
msleep(150);
|
||||
for (i = 0; i < 3; i++) {
|
||||
level = gpio_get_value(pdata->headset_gpio);
|
||||
if (level < 0) {
|
||||
pr_err("%s:get pin level again,pin=%d,i=%d\n",
|
||||
__func__, pdata->headset_gpio, i);
|
||||
msleep(1);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (level < 0) {
|
||||
pr_err("%s:get pin level err!\n", __func__);
|
||||
goto out;
|
||||
} else {
|
||||
pr_err("%s:get pin level again, pin=%d,i=%d\n",
|
||||
__func__, pdata->headset_gpio, i);
|
||||
}
|
||||
|
||||
old_status = headset_info->headset_status;
|
||||
switch (pdata->headset_insert_type) {
|
||||
case HEADSET_IN_HIGH:
|
||||
if (level > 0)
|
||||
headset_info->headset_status = HEADSET_IN;
|
||||
else if (level == 0)
|
||||
headset_info->headset_status = HEADSET_OUT;
|
||||
break;
|
||||
case HEADSET_IN_LOW:
|
||||
if (level == 0)
|
||||
headset_info->headset_status = HEADSET_IN;
|
||||
else if (level > 0)
|
||||
headset_info->headset_status = HEADSET_OUT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (old_status == headset_info->headset_status) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (headset_info->headset_status == HEADSET_IN) {
|
||||
if (pdata->chan != 0) {
|
||||
/* detect Hook key */
|
||||
schedule_delayed_work(
|
||||
&headset_info->h_delayed_work[HOOK],
|
||||
msecs_to_jiffies(200));
|
||||
} else {
|
||||
headset_info->isMic = 0;
|
||||
headset_info->cur_headset_status = BIT_HEADSET_NO_MIC;
|
||||
extcon_set_state_sync(headset_info->edev,
|
||||
EXTCON_JACK_HEADPHONE, true);
|
||||
DBG("headset notice android headset status = %d\n",
|
||||
headset_info->cur_headset_status);
|
||||
}
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_RISING);
|
||||
} else if (headset_info->headset_status == HEADSET_OUT) {
|
||||
headset_info->cur_headset_status = HEADSET_OUT;
|
||||
cancel_delayed_work(&headset_info->hook_work);
|
||||
if (headset_info->isMic) {
|
||||
if (headset_info->hook_status == HOOK_DOWN) {
|
||||
headset_info->hook_status = HOOK_UP;
|
||||
input_report_key(headset_info->input_dev, HOOK_KEY_CODE, headset_info->hook_status);
|
||||
input_sync(headset_info->input_dev);
|
||||
}
|
||||
#ifdef CONFIG_SND_SOC_WM8994
|
||||
//rt5625_headset_mic_detect(false);
|
||||
wm8994_headset_mic_detect(false);
|
||||
#endif
|
||||
#if defined(CONFIG_SND_SOC_RT3261) || defined(CONFIG_SND_SOC_RT3224)
|
||||
rt3261_headset_mic_detect(false);
|
||||
#endif
|
||||
#ifdef CONFIG_SND_SOC_RT5631_PHONE
|
||||
rt5631_headset_mic_detect(false);
|
||||
#endif
|
||||
headset_info->isMic = 0;
|
||||
}
|
||||
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_RISING);
|
||||
else
|
||||
irq_set_irq_type(headset_info->irq[HEADSET],
|
||||
IRQF_TRIGGER_FALLING);
|
||||
extcon_set_state_sync(headset_info->edev, EXTCON_JACK_HEADPHONE,
|
||||
false);
|
||||
extcon_set_state_sync(headset_info->edev,
|
||||
EXTCON_JACK_MICROPHONE, false);
|
||||
DBG("headset notice android headset status = %d\n",
|
||||
headset_info->cur_headset_status);
|
||||
}
|
||||
|
||||
/*rk_send_wakeup_key(); */
|
||||
out:
|
||||
headset_info->heatset_irq_working = IDLE;
|
||||
enable_irq(headset_info->irq[HEADSET]);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int headset_change_irqtype(int type, unsigned int irq_type)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
free_irq(headset_info->irq[type], NULL);
|
||||
|
||||
DBG("%s: type is %s irqtype is %s\n", __func__,
|
||||
type ? "hook" : "headset",
|
||||
(irq_type == IRQF_TRIGGER_RISING) ? "RISING" : "FALLING");
|
||||
// DBG("%s: type is %s irqtype is %s\n",__func__, type?"hook":"headset",(irq_type == IRQF_TRIGGER_LOW)?"LOW":"HIGH");
|
||||
switch (type) {
|
||||
case HEADSET:
|
||||
ret =
|
||||
request_threaded_irq(headset_info->irq[type], NULL,
|
||||
headset_interrupt, irq_type,
|
||||
"headset_input", NULL);
|
||||
if (ret < 0)
|
||||
DBG("headset_change_irqtype: request irq failed\n");
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hook_once_work(struct work_struct *work)
|
||||
{
|
||||
int ret, val;
|
||||
|
||||
#ifdef CONFIG_SND_SOC_WM8994
|
||||
wm8994_headset_mic_detect(true);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SND_SOC_RT3261) || defined(CONFIG_SND_SOC_RT3224)
|
||||
rt3261_headset_mic_detect(true);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SND_SOC_RT5631_PHONE
|
||||
rt5631_headset_mic_detect(true);
|
||||
#endif
|
||||
ret = iio_read_channel_raw(headset_info->chan, &val);
|
||||
if (ret < 0)
|
||||
pr_err("read hook_once_work adc channel() error: %d\n", ret);
|
||||
else
|
||||
DBG("hook_once_work read adc value: %d\n", val);
|
||||
|
||||
if (val >= 0 && val < HOOK_LEVEL_LOW) {
|
||||
headset_info->isMic = 0;
|
||||
#ifdef CONFIG_SND_SOC_WM8994
|
||||
wm8994_headset_mic_detect(false);
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
|
||||
rt3261_headset_mic_detect(false);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SND_SOC_RT5631_PHONE
|
||||
rt5631_headset_mic_detect(false);
|
||||
#endif
|
||||
} else if (val >= HOOK_LEVEL_HIGH) {
|
||||
headset_info->isMic = 1;
|
||||
schedule_delayed_work(&headset_info->hook_work,
|
||||
msecs_to_jiffies(100));
|
||||
}
|
||||
headset_info->cur_headset_status =
|
||||
headset_info->isMic ? BIT_HEADSET : BIT_HEADSET_NO_MIC;
|
||||
if (headset_info->cur_headset_status) {
|
||||
if (headset_info->isMic) {
|
||||
extcon_set_state_sync(headset_info->edev,
|
||||
EXTCON_JACK_MICROPHONE, true);
|
||||
} else {
|
||||
extcon_set_state_sync(headset_info->edev,
|
||||
EXTCON_JACK_HEADPHONE, true);
|
||||
}
|
||||
}
|
||||
DBG("%s notice android headset status = %d\n", __func__,
|
||||
headset_info->cur_headset_status);
|
||||
}
|
||||
|
||||
static void hook_work_callback(struct work_struct *work)
|
||||
{
|
||||
int ret, val;
|
||||
struct headset_priv *headset = headset_info;
|
||||
struct rk_headset_pdata *pdata = headset->pdata;
|
||||
static unsigned int old_status = HOOK_UP;
|
||||
|
||||
ret = iio_read_channel_raw(headset->chan, &val);
|
||||
if (ret < 0) {
|
||||
pr_err("read hook adc channel() error: %d\n", ret);
|
||||
goto out;
|
||||
} else {
|
||||
DBG("hook_work_callback read adc value=%d\n", val);
|
||||
}
|
||||
|
||||
if (headset->headset_status == HEADSET_OUT ||
|
||||
headset->heatset_irq_working == BUSY ||
|
||||
headset->heatset_irq_working == WAIT ||
|
||||
(pdata->headset_insert_type ?
|
||||
gpio_get_value(pdata->headset_gpio) == 0 :
|
||||
gpio_get_value(pdata->headset_gpio) > 0)) {
|
||||
DBG("Headset is out or waiting for headset is in or out, after same time check HOOK key\n");
|
||||
goto out;
|
||||
}
|
||||
old_status = headset->hook_status;
|
||||
if (val < HOOK_LEVEL_LOW && val >= 0)
|
||||
headset->hook_status = HOOK_DOWN;
|
||||
else if (val > HOOK_LEVEL_HIGH && val < HOOK_DEFAULT_VAL)
|
||||
headset->hook_status = HOOK_UP;
|
||||
DBG("HOOK status is %s , adc value = %d hook_time = %d\n",
|
||||
headset->hook_status ? "down" : "up", val, headset->hook_time);
|
||||
if (old_status == headset->hook_status) {
|
||||
DBG("Hook adc read old_status == headset->hook_status=%d hook_time = %d\n",
|
||||
headset->hook_status, headset->hook_time);
|
||||
goto status_error;
|
||||
}
|
||||
if (headset->headset_status == HEADSET_OUT ||
|
||||
headset->heatset_irq_working == BUSY ||
|
||||
headset->heatset_irq_working == WAIT ||
|
||||
(pdata->headset_insert_type ?
|
||||
gpio_get_value(pdata->headset_gpio) == 0 :
|
||||
gpio_get_value(pdata->headset_gpio) > 0)) {
|
||||
printk("headset is out, HOOK status must discard\n");
|
||||
goto out;
|
||||
} else {
|
||||
input_report_key(headset->input_dev,
|
||||
HOOK_KEY_CODE, headset->hook_status);
|
||||
input_sync(headset->input_dev);
|
||||
}
|
||||
status_error:
|
||||
schedule_delayed_work(&headset_info->hook_work, msecs_to_jiffies(100));
|
||||
out:;
|
||||
}
|
||||
|
||||
static int rk_hskey_open(struct input_dev *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rk_hskey_close(struct input_dev *dev)
|
||||
{
|
||||
}
|
||||
|
||||
static const unsigned int headset_cable[] = {
|
||||
EXTCON_JACK_MICROPHONE,
|
||||
EXTCON_JACK_HEADPHONE,
|
||||
EXTCON_NONE,
|
||||
};
|
||||
|
||||
int rk_headset_adc_probe(struct platform_device *pdev,
|
||||
struct rk_headset_pdata *pdata)
|
||||
{
|
||||
int ret;
|
||||
struct headset_priv *headset;
|
||||
|
||||
headset = devm_kzalloc(&pdev->dev, sizeof(*headset), GFP_KERNEL);
|
||||
if (!headset) {
|
||||
dev_err(&pdev->dev, "failed to allocate driver data\n");
|
||||
ret = -ENOMEM;
|
||||
goto failed;
|
||||
}
|
||||
headset_info = headset;
|
||||
headset->pdata = pdata;
|
||||
headset->headset_status = HEADSET_OUT;
|
||||
headset->heatset_irq_working = IDLE;
|
||||
headset->hook_status = HOOK_UP;
|
||||
headset->hook_time = HOOK_ADC_SAMPLE_TIME;
|
||||
headset->cur_headset_status = 0;
|
||||
headset->edev = devm_extcon_dev_allocate(&pdev->dev, headset_cable);
|
||||
if (IS_ERR(headset->edev)) {
|
||||
dev_err(&pdev->dev, "failed to allocate extcon device\n");
|
||||
ret = -ENOMEM;
|
||||
goto failed;
|
||||
}
|
||||
ret = devm_extcon_dev_register(&pdev->dev, headset->edev);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "extcon_dev_register() failed: %d\n", ret);
|
||||
goto failed;
|
||||
}
|
||||
INIT_DELAYED_WORK(&headset->h_delayed_work[HOOK], hook_once_work);
|
||||
headset->isMic = 0;
|
||||
//------------------------------------------------------------------
|
||||
// Create and register the input driver
|
||||
headset->input_dev = devm_input_allocate_device(&pdev->dev);
|
||||
if (!headset->input_dev) {
|
||||
dev_err(&pdev->dev, "failed to allocate input device\n");
|
||||
ret = -ENOMEM;
|
||||
goto failed;
|
||||
}
|
||||
headset->input_dev->name = pdev->name;
|
||||
headset->input_dev->open = rk_hskey_open;
|
||||
headset->input_dev->close = rk_hskey_close;
|
||||
headset->input_dev->dev.parent = &pdev->dev;
|
||||
//input_dev->phys = KEY_PHYS_NAME;
|
||||
headset->input_dev->id.vendor = 0x0001;
|
||||
headset->input_dev->id.product = 0x0001;
|
||||
headset->input_dev->id.version = 0x0100;
|
||||
// Register the input device
|
||||
ret = input_register_device(headset->input_dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register input device\n");
|
||||
goto failed;
|
||||
}
|
||||
input_set_capability(headset->input_dev, EV_KEY, HOOK_KEY_CODE);
|
||||
if (pdata->headset_gpio) {
|
||||
unsigned long irq_type;
|
||||
|
||||
headset->irq[HEADSET] = gpio_to_irq(pdata->headset_gpio);
|
||||
if (pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
irq_type = IRQF_TRIGGER_HIGH;
|
||||
else
|
||||
irq_type = IRQF_TRIGGER_LOW;
|
||||
irq_type |= IRQF_NO_SUSPEND | IRQF_ONESHOT;
|
||||
ret =
|
||||
devm_request_threaded_irq(&pdev->dev, headset->irq[HEADSET],
|
||||
NULL, headset_interrupt,
|
||||
irq_type, "headset_input",
|
||||
NULL);
|
||||
if (ret)
|
||||
goto failed;
|
||||
|
||||
if (pdata->headset_wakeup)
|
||||
enable_irq_wake(headset->irq[HEADSET]);
|
||||
} else {
|
||||
dev_err(&pdev->dev, "failed init headset,please full hook_io_init function in board\n");
|
||||
ret = -EEXIST;
|
||||
goto failed;
|
||||
}
|
||||
if (pdata->chan) {
|
||||
headset->chan = pdata->chan;
|
||||
INIT_DELAYED_WORK(&headset->hook_work, hook_work_callback);
|
||||
}
|
||||
return 0;
|
||||
failed:
|
||||
dev_err(&pdev->dev, "failed headset adc probe ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rk_headset_adc_probe);
|
||||
|
||||
int rk_headset_adc_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
{
|
||||
DBG("%s----%d\n", __func__, __LINE__);
|
||||
// disable_irq(headset_info->irq[HEADSET]);
|
||||
// del_timer(&headset_info->hook_timer);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rk_headset_adc_suspend);
|
||||
|
||||
int rk_headset_adc_resume(struct platform_device *pdev)
|
||||
{
|
||||
DBG("%s----%d\n", __func__, __LINE__);
|
||||
// enable_irq(headset_info->irq[HEADSET]);
|
||||
// if(headset_info->isMic)
|
||||
// mod_timer(&headset_info->hook_timer, jiffies + msecs_to_jiffies(1500));
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rk_headset_adc_resume);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
256
sound/soc/headset_observe/rockchip_headset_core.c
Executable file
256
sound/soc/headset_observe/rockchip_headset_core.c
Executable file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Rockchip Corporation.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/rk_headset.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/iio/consumer.h>
|
||||
|
||||
/* Debug */
|
||||
#if 1
|
||||
#define DBG(x...) printk(x)
|
||||
#else
|
||||
#define DBG(x...) do { } while (0)
|
||||
#endif
|
||||
|
||||
static struct rk_headset_pdata *pdata_info;
|
||||
|
||||
static int rockchip_headset_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
struct rk_headset_pdata *pdata;
|
||||
int ret;
|
||||
enum of_gpio_flags flags;
|
||||
|
||||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata) {
|
||||
printk("%s failed to allocate driver data\n", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
pdata_info = pdata;
|
||||
|
||||
/* headset */
|
||||
ret = of_get_named_gpio_flags(node, "headset_gpio", 0, &flags);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "Can not read property headset_gpio\n");
|
||||
goto err;
|
||||
} else {
|
||||
pdata->headset_gpio = ret;
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->headset_gpio,
|
||||
"headset_gpio");
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "headset_gpio request fail\n");
|
||||
goto err;
|
||||
}
|
||||
ret = gpio_direction_input(pdata->headset_gpio);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev,
|
||||
"headset_gpio set direction fail\n");
|
||||
goto err;
|
||||
}
|
||||
pdata->headset_insert_type = (flags & OF_GPIO_ACTIVE_LOW) ?
|
||||
HEADSET_IN_LOW :
|
||||
HEADSET_IN_HIGH;
|
||||
}
|
||||
/* 3.5mm line-in */
|
||||
ret = of_get_named_gpio_flags(node, "linein_gpio", 0, &flags);
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev, "no property linein_gpio\n");
|
||||
} else {
|
||||
pdata->linein_gpio = ret;
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->linein_gpio,
|
||||
"linein_gpio");
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "linein_gpio request fail\n");
|
||||
goto err;
|
||||
}
|
||||
ret = gpio_direction_input(pdata->linein_gpio);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev,
|
||||
"linein_gpio set direction fail\n");
|
||||
goto err;
|
||||
}
|
||||
pdata->linein_insert_type = (flags & OF_GPIO_ACTIVE_LOW) ?
|
||||
LINEIN_LOW :
|
||||
LINEIN_HIGH;
|
||||
}
|
||||
/* ip-board line-in */
|
||||
ret = of_get_named_gpio_flags(node, "iplin_gpio", 0, &flags);
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev, "no property iplin_gpio\n");
|
||||
} else {
|
||||
pdata->iplin_gpio = ret;
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->iplin_gpio,
|
||||
"iplin_gpio");
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "iplin_gpio request fail\n");
|
||||
goto err;
|
||||
}
|
||||
ret = gpio_direction_input(pdata->iplin_gpio);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev,
|
||||
"iplin_gpio set direction fail\n");
|
||||
goto err;
|
||||
}
|
||||
pdata->iplin_insert_type = (flags & OF_GPIO_ACTIVE_LOW) ?
|
||||
LINEIN_LOW :
|
||||
LINEIN_HIGH;
|
||||
}
|
||||
/* hook */
|
||||
ret = of_get_named_gpio_flags(node, "hook_gpio", 0, &pdata->hook_gpio);
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev, "Can not read property hook_gpio\n");
|
||||
pdata->hook_gpio = 0;
|
||||
/* adc mode */
|
||||
pdata->chan = iio_channel_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(pdata->chan)) {
|
||||
pdata->chan = NULL;
|
||||
dev_warn(&pdev->dev, "have not set adc chan\n");
|
||||
}
|
||||
} else {
|
||||
ret = of_property_read_u32(node, "hook_down_type",
|
||||
&pdata->hook_down_type);
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev,
|
||||
"have not set hook_down_type,set >hook< insert type low level default\n");
|
||||
pdata->hook_down_type = 0;
|
||||
}
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->hook_gpio,
|
||||
"hook_gpio");
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev,
|
||||
"devm_gpio_request hook_gpio request ERROR\n");
|
||||
goto err;
|
||||
}
|
||||
ret = gpio_direction_input(pdata->hook_gpio);
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev,
|
||||
"gpio_direction_input hook_gpio set ERROR\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MODEM_MIC_SWITCH
|
||||
/* mic */
|
||||
ret = of_get_named_gpio_flags(node, "mic_switch_gpio", 0, &flags);
|
||||
if (ret < 0) {
|
||||
DBG("%s() Can not read property mic_switch_gpio\n",
|
||||
__func__);
|
||||
} else {
|
||||
pdata->headset_gpio = ret;
|
||||
ret = of_property_read_u32(node, "hp_mic_io_value",
|
||||
&pdata->hp_mic_io_value);
|
||||
if (ret < 0) {
|
||||
DBG("%s() have not set hp_mic_io_value ,so default set pull down low level\n",
|
||||
__func__);
|
||||
pdata->hp_mic_io_value = 0;
|
||||
}
|
||||
ret = of_property_read_u32(node, "main_mic_io_value",
|
||||
&pdata->main_mic_io_value);
|
||||
if (ret < 0) {
|
||||
DBG("%s() have not set main_mic_io_value ,so default set pull down low level\n",
|
||||
__func__);
|
||||
pdata->main_mic_io_value = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ret = of_property_read_u32(node, "rockchip,headset_wakeup",
|
||||
&pdata->headset_wakeup);
|
||||
if (ret < 0)
|
||||
pdata->headset_wakeup = 1;
|
||||
if (pdata->chan) { /* hook adc mode */
|
||||
dev_info(&pdev->dev, "headset have hook adc mode\n");
|
||||
ret = rk_headset_adc_probe(pdev, pdata);
|
||||
if (ret < 0) {
|
||||
goto err;
|
||||
}
|
||||
} else { /* hook interrupt mode and not hook */
|
||||
dev_info(&pdev->dev, "headset have %s mode\n",
|
||||
pdata->hook_gpio ? "interrupt hook" : "no hook");
|
||||
ret = rk_headset_probe(pdev, pdata);
|
||||
if (ret < 0) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rockchip_headset_remove(struct platform_device *pdev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rockchip_headset_suspend(struct platform_device *pdev,
|
||||
pm_message_t state)
|
||||
{
|
||||
if (pdata_info->chan != 0) {
|
||||
return rk_headset_adc_suspend(pdev, state);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rockchip_headset_resume(struct platform_device *pdev)
|
||||
{
|
||||
if (pdata_info->chan != 0) {
|
||||
return rk_headset_adc_resume(pdev);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id rockchip_headset_of_match[] = {
|
||||
{ .compatible = "rockchip_headset", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rockchip_headset_of_match);
|
||||
|
||||
static struct platform_driver rockchip_headset_driver = {
|
||||
.probe = rockchip_headset_probe,
|
||||
.remove = rockchip_headset_remove,
|
||||
.resume = rockchip_headset_resume,
|
||||
.suspend = rockchip_headset_suspend,
|
||||
.driver = {
|
||||
.name = "rockchip_headset",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(rockchip_headset_of_match),
|
||||
},
|
||||
};
|
||||
|
||||
static int __init rockchip_headset_init(void)
|
||||
{
|
||||
platform_driver_register(&rockchip_headset_driver);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit rockchip_headset_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&rockchip_headset_driver);
|
||||
}
|
||||
late_initcall(rockchip_headset_init);
|
||||
module_exit(rockchip_headset_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Rockchip Headset Core Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
Reference in New Issue
Block a user