功能:rt5651 使用耳机时候无法录音,调试并解决
硬件:耳机使用的是MIC3P 对应到RT5651的IN3P引脚。
1.首先确认耳机检测上报的必须是带MIC的状态
MICROPHONE 代表带MIC的耳机,HEADPHONE代表不带MIC的耳机
rk3399_Android11:/sys/class/extcon/rk_headset # cd cable.0/
rk3399_Android11:/sys/class/extcon/rk_headset/cable.0 # cat name
MICROPHONE
rk3399_Android11:/sys/class/extcon/rk_headset/cable.0 # cat state
1
rk3399_Android11:/sys/class/extcon/rk_headset/cable.0 # cd ..
rk3399_Android11:/sys/class/extcon/rk_headset # cd ca
cable.0/ cable.1/
rk3399_Android11:/sys/class/extcon/rk_headset # cd cable.1/
rk3399_Android11:/sys/class/extcon/rk_headset/cable.1 # cat name
HEADPHONE
rk3399_Android11:/sys/class/extcon/rk_headset/cable.1 # cat state
0
驱动主要在
drivers/headset_observe/rk_headset_irq_hook_adc.c
drivers/headset_observe/rk_headset.c
由于我的硬件只支持四段耳机,所以直接将驱动中的状态上报都改成了MICROPHONE
diff --git a/drivers/headset_observe/rk_headset.c b/drivers/headset_observe/rk_headset.c
index 5b16db7..3c8ba57 100644
--- a/drivers/headset_observe/rk_headset.c
+++ b/drivers/headset_observe/rk_headset.c
@@ -49,7 +49,7 @@
#endif
#define BIT_HEADSET BIT(0)
-#define BIT_HEADSET_NO_MIC BIT(1)
+#define BIT_HEADSET_NO_MIC BIT(0)
#define HEADSET 0
#define HOOK 1
@@ -211,10 +211,10 @@ static void headsetobserve_work(struct work_struct *work)
IRQF_TRIGGER_FALLING);
}
if (headset_info->cur_headset_status)
- extcon_set_state_sync(headset_info->edev, EXTCON_JACK_HEADPHONE,
+ extcon_set_state_sync(headset_info->edev, EXTCON_JACK_MICROPHONE,
true);
else
- extcon_set_state_sync(headset_info->edev, EXTCON_JACK_HEADPHONE,
+ extcon_set_state_sync(headset_info->edev, EXTCON_JACK_MICROPHONE,
false);
DBG("headset_info->cur_headset_status = %d\n",
headset_info->cur_headset_status);
@@ -311,7 +311,7 @@ static void headset_timer_callback(struct timer_list *t)
EXTCON_JACK_MICROPHONE, true);
else
extcon_set_state_sync(headset_info->edev,
- EXTCON_JACK_MICROPHONE, false);
+ EXTCON_JACK_MICROPHONE, true);
DBG("headset_info->cur_headset_status = %d\n",
headset_info->cur_headset_status);
out:
diff --git a/drivers/headset_observe/rk_headset_irq_hook_adc.c b/drivers/headset_observe/rk_headset_irq_hook_adc.c
index ca3e0a6..b157cad 100644
--- a/drivers/headset_observe/rk_headset_irq_hook_adc.c
+++ b/drivers/headset_observe/rk_headset_irq_hook_adc.c
@@ -53,7 +53,7 @@
#define HOOK_DEFAULT_VAL 1024
#define BIT_HEADSET BIT(0)
-#define BIT_HEADSET_NO_MIC BIT(1)
+#define BIT_HEADSET_NO_MIC BIT(0)
#define HEADSET 0
#define HOOK 1
@@ -178,7 +178,7 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id)
headset_info->isMic = 0;
headset_info->cur_headset_status = BIT_HEADSET_NO_MIC;
extcon_set_state_sync(headset_info->edev,
- EXTCON_JACK_HEADPHONE, true);
+ EXTCON_JACK_MICROPHONE, true);
DBG("headset notice android headset status = %d\n",
headset_info->cur_headset_status);
}
@@ -312,7 +312,7 @@ static void hook_once_work(struct work_struct *work)
EXTCON_JACK_MICROPHONE, true);
} else {
extcon_set_state_sync(headset_info->edev,
2.修改完成后耳机录音的时候可以正常切换到耳机通路,但是声音太小,修改
hardware/rockchip/audio/tinyalsa
diff --git a/tinyalsa_hal/codec_config/rt5651_config.h b/tinyalsa_hal/codec_config/rt5651_config.h
index fa16c42..59095a1 100644
--- a/tinyalsa_hal/codec_config/rt5651_config.h
+++ b/tinyalsa_hal/codec_config/rt5651_config.h
@@ -756,7 +756,7 @@ const struct config_control rt5651_hands_free_mic_capture_controls[] = {
.int_val = {on, on},
},
{
- .ctl_name = "IN1 Boost",
+ .ctl_name = "IN3 Boost",
.int_val = {3},
}