Android4.4 Headphone Detection Analysis

Source: Internet
Author: User

In the ALSA architecture, ASOC is made up of 3 parts: Platform, CODEC & Machine. and headphone detection is generally implemented in machine driver, of course, can also be achieved in codec driver. Headphone plug-in interface Jack's structure is shown in Figure 1 (iphone and Nokia headset mic & ground are just the opposite).

Figure 1. Jack Structure diagram

The headset heartbeat hp_det# can be passed to the SOC side in two ways:

1. Direct the hp_det# signal to the SOC side;

2. The hp_det# signal is first received to the codec end, and then the codec end GPIO/IRQ PIN transmits the signal to the SOC end;

To implement Method 2, you need to perform a series of configurations on the codec driver side, such as jd# power on the Coedc-side headset, GPIO/IRQ output for jd# status detection & IRQ debounce clock selection interal clock, etc. This will enable the codec end hp_det# signal to be received and the interrupt signal escalated.

Similarly, the following 3 operations are also done in machine driver:

1. Define a struct variable hs_gpio of type "Snd_soc_jack_gpios", which is used to configure the Gpio for headphone detection. Hs_gpio struct variables such as name, Report, Debounce_time, Jack_status_check & Irq_flags of the Gpio are initialized in the structure, where name indicates the name of the Gpio The report indicates the types of states that will be reported, altogether headset, headphone & Button;debounce_time for jitter delay, Jack_status_check for medium-to-medium processing functions, irq_ Flags indicate whether the interrupt handler is triggered by a rising or falling edge.

1 Static structSnd_soc_jack_gpio hs_gpio[] = {2[Hsdet] = {3. Name ="Audiocodec_int",4. Report = Snd_jack_headset | Snd_jack_headphone |Snd_jack_btn_0,5. Debounce_time = -,6         . Jack_status_check = JACK_GPIO_DETECT_BP,7. irq_flags = irqf_trigger_falling |irqf_trigger_rising,8     },9};

2. Create a new jack with the Snd_soc_jack_new () function, point the jack to the machine corresponding to the codec, and make the jack contact codec.

3. Connect the defined Gpio pins with the ASOC jack via the Snd_soc_jack_add_gpios () function and implement the GPIO pins interrupt request Irq_request & via Snd_jack_ Report Jack_status.

  

Summing up, the realization of kernel layer headphone detection, mainly through the system release out of the function interface to achieve GPIO pins configuration, Gpio pins and codec establish contact & Gpio pins and ASOC to establish a link to the 3 parts.

"Reference article: http://blog.csdn.net/piaozhiye/article/details/25101891"

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.