mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
rk_headset: add headset type logic to compatible with cx2072x
Change-Id: I700dfc8484eee6b8b127ef91aeca951e9fe2e1ee Signed-off-by: zhangjun <zhangjun@rock-chips.com>
This commit is contained in:
@@ -84,6 +84,9 @@ extern int rt3261_headset_mic_detect(int jack_insert);
|
||||
#if defined(CONFIG_SND_SOC_ES8316)
|
||||
extern int es8316_headset_detect(int jack_insert);
|
||||
#endif
|
||||
#if defined(CONFIG_SND_SOC_CX2072X)
|
||||
extern int cx2072x_jack_report(void);
|
||||
#endif
|
||||
|
||||
/* headset private data */
|
||||
struct headset_priv {
|
||||
@@ -211,7 +214,7 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id)
|
||||
#endif
|
||||
#ifdef CONFIG_SND_SOC_RT5631_PHONE
|
||||
rt5631_headset_mic_detect(false);
|
||||
#endif
|
||||
#endif
|
||||
headset_info->isMic = 0;
|
||||
}
|
||||
|
||||
@@ -296,6 +299,13 @@ static void hook_once_work(struct work_struct *work)
|
||||
}
|
||||
|
||||
headset_info->cur_headset_status = headset_info->isMic ? BIT_HEADSET:BIT_HEADSET_NO_MIC;
|
||||
|
||||
#if defined(CONFIG_SND_SOC_CX2072X)
|
||||
if (cx2072x_jack_report() != -1)
|
||||
headset_info->cur_headset_status =
|
||||
(cx2072x_jack_report() == 3) ?
|
||||
BIT_HEADSET : BIT_HEADSET_NO_MIC;
|
||||
#endif
|
||||
|
||||
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);
|
||||
@@ -463,13 +473,8 @@ int rk_headset_adc_probe(struct platform_device *pdev,struct rk_headset_pdata *p
|
||||
}
|
||||
|
||||
input_set_capability(headset->input_dev, EV_KEY, HOOK_KEY_CODE);
|
||||
//------------------------------------------------------------------
|
||||
if (pdata->headset_gpio) {
|
||||
if(!pdata->headset_gpio){
|
||||
dev_err(&pdev->dev,"failed init headset,please full hook_io_init function in board\n");
|
||||
goto failed_free_dev;
|
||||
}
|
||||
|
||||
if (pdata->headset_gpio) {
|
||||
headset->irq[HEADSET] = gpio_to_irq(pdata->headset_gpio);
|
||||
|
||||
if(pdata->headset_insert_type == HEADSET_IN_HIGH)
|
||||
@@ -481,10 +486,11 @@ int rk_headset_adc_probe(struct platform_device *pdev,struct rk_headset_pdata *p
|
||||
goto failed_free_dev;
|
||||
if (pdata->headset_wakeup)
|
||||
enable_irq_wake(headset->irq[HEADSET]);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
dev_err(&pdev->dev, "failed init headset,please full hook_io_init function in board\n");
|
||||
goto failed_free_dev;
|
||||
//------------------------------------------------------------------
|
||||
}
|
||||
|
||||
if(pdata->chan != NULL)
|
||||
{
|
||||
headset->chan = pdata->chan;
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
#define PLAT_CLK_FORCE_OFF 2
|
||||
#endif
|
||||
|
||||
static struct snd_soc_codec *cx2072x_codec;
|
||||
|
||||
/* FIXME: need to move the EQ/DRC setting to device tree */
|
||||
static unsigned char cx2072x_eq_coeff_array[MAX_EQ_BAND][MAC_EQ_COEFF] = {
|
||||
{0x77, 0x26, 0x13, 0xb3, 0x76, 0x26, 0x0a, 0x3d, 0xd4, 0xe2, 0x04},
|
||||
@@ -1315,7 +1317,25 @@ int cx2072x_hs_jack_report(struct snd_soc_codec *codec)
|
||||
type, state);
|
||||
return state;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cx2072x_hs_jack_report);
|
||||
|
||||
int cx2072x_jack_report(void)
|
||||
{
|
||||
u32 state, old_state;
|
||||
|
||||
if (!cx2072x_codec)
|
||||
return -1;
|
||||
|
||||
msleep(400);
|
||||
|
||||
do {
|
||||
old_state = cx2072x_hs_jack_report(cx2072x_codec);
|
||||
msleep(50);
|
||||
state = cx2072x_hs_jack_report(cx2072x_codec);
|
||||
} while (state != old_state);
|
||||
|
||||
return state;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cx2072x_jack_report);
|
||||
|
||||
static int cx2072x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
||||
unsigned int rx_mask, int slots, int slot_width)
|
||||
@@ -1751,6 +1771,7 @@ static int cx2072x_probe(struct snd_soc_codec *codec)
|
||||
int ret = 0;
|
||||
unsigned int ven_id;
|
||||
|
||||
cx2072x_codec = codec;
|
||||
cx2072x->codec = codec;
|
||||
codec->control_data = cx2072x->regmap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user