mtk平台耳机检测流程记录
耳機檢測方案
檢測方案1(主流方案):耳機插拔中斷接的PMIC?(HP_EINT+ACCDET)
CONFIG_ACCDET_EINT_IRQ? &&? CONFIG_ACCDET_SUPPORT_EINT0
CONFIG_ACCDET_EINT_IRQ? &&? CONFIG_ACCDET_SUPPORT_EINT1//平臺默認的是EINT0,EINT1不確定具體作用
采用默認的方案,工程師不用調試,接上耳機,手機就能識別到耳機,很方便。
? ? ? ?
?檢測方案2:耳機插拔中斷接AP(EINT_EAR+ACCDET)? 這種方式,需要稍微修改下代碼
?
共同點:ACCDET用來檢測mic的存在
差異:用不同的中斷來檢測耳機的插拔,默認都是用PMIC上的中斷來檢測耳機的插入,使用AP中斷的方式來檢測耳機感覺像是替補。
先看下耳機檢測流程(HP_EINT+ACCDET kernel4.14)
pmic_register_interrupt_callback(INT_ACCDET_EINT0,accdet_eint_handler);static void accdet_eint_handler(void) {accdet_irq_handle(); }void accdet_irq_handle(void) { ...pmic_eint_queue_work(eintID); ... }static int pmic_eint_queue_work(int eintID) { ... #ifdef CONFIG_ACCDET_SUPPORT_EINT0if (cur_eint_state == EINT_PIN_PLUG_IN) {cur_eint_state = EINT_PIN_PLUG_OUT;} else {cur_eint_state = EINT_PIN_PLUG_IN;}queue_work(eint_workqueue, &eint_work); //INIT_WORK(&eint_work, eint_work_callback); #endif ... }static void eint_work_callback(struct work_struct *work) {if (cur_eint_state == EINT_PIN_PLUG_IN) {accdet_init();/* set PWM IDLE on */pmic_write(ACCDET_STATE_SWCTRL,(pmic_read(ACCDET_STATE_SWCTRL) | ACCDET_PWM_IDLE)); #ifdef CONFIG_ACCDET_EINT_IRQ #ifdef CONFIG_ACCDET_SUPPORT_EINT0enable_accdet(ACCDET_EINT0_PWM_IDLE_B11 | ACCDET_PWM_EN); #endif #elseenable_accdet(ACCDET_PWM_EN);//開啟micbias #endif} else {/* clc Accdet PWM idle */pmic_write(ACCDET_STATE_SWCTRL,pmic_read(ACCDET_STATE_SWCTRL) & (~ACCDET_PWM_IDLE));disable_accdet();headset_plug_out();}#ifdef CONFIG_ACCDET_EINTenable_irq(accdet_irq);pr_info("accdet %s enable_irq !!\n", __func__); #endif }這時就可以觸發accdet中斷(檢測耳機類型)
pmic_register_interrupt_callback(INT_ACCDET, accdet_int_handler); static void accdet_int_handler(void) {accdet_irq_handle(); }void accdet_irq_handle(void) { ... #ifdef CONFIG_ACCDET_EINT_IRQeintID = get_triggered_eint(); #endifirq_status = pmic_read(ACCDET_IRQ_STS);if ((irq_status & ACCDET_IRQ_B0) && (eintID == 0)) {accdet_queue_work();} } ... }static void accdet_queue_work(void) { ... ret = queue_work(accdet_workqueue, &accdet_work);//INIT_WORK(&accdet_work, accdet_work_callback); ... }static void accdet_work_callback(struct work_struct *work) { ... check_cable_type(); ... }注意到了沒有accdet_irq_handle函數跑了兩遍,分別跑里面不同的部分。
以后的按鍵檢測重復跑accdet_int_handler。
以上是根據代碼分析到的流程。為什么要分析上述流程呢,因為樓主使用的硬件的需要用accdect only的方式來檢測typce非標耳機(pmic不帶cc腳,不能識別到標準typec耳機,如果使用其他ic來檢測耳機會增加成本)。accdect only的方式,mtk說kernel3.18以后都沒有維護了,只能自己來實現了,調完了再記錄下吧。
總結
以上是生活随笔為你收集整理的mtk平台耳机检测流程记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SQL SERVER-约束
- 下一篇: 关于单片机串口发送和接收的问题