Android underlying development-audio input channel hardware and software analysis, android audio input

Source: Internet
Author: User

Android underlying development-audio input channel hardware and software analysis, android audio input

Android underlying development-audio input channel software and hardware analysis

We all know that the four-section earphone Mic plug integrated with the headset Mic is commonly used on Android devices. However, there will also be separate cases. This is the case if the Android system is installed on a common PC. Therefore, it is necessary to conduct a unified analysis of the audio input channel software and hardware, and then analyze an instance.

The hardware connection of the device is a channel switch based on the 3157 analog switch.

 

The device is completely implemented by hardware, so there is no software work. However, this is not an ideal implementation method. The actual implementation method should be that all the microphones are parallel, and each Mic channel has an enabling pin. Let the system control which Mic is used as input. In fact, the rk616 audio Code contains the code for switching:

Static int rk616_capture_path_put (struct snd_kcontrol * kcontrol,

Struct snd_ctl_elem_value * ucontrol)

{

Struct rk616_codec_priv * rk616 = rk616_priv;

Long int pre_path;

 

If (! Rk616 ){

Printk ("% s: rk616_priv is NULL \ n", _ func __);

Return-EINVAL;

}

 

If (rk616-> capture_path = ucontrol-> value. integer. value [0]) {

DBG ("% s: capture_path is not changed! \ N ", _ func __);

Return 0;

}

 

Pre_path = rk616-> capture_path;

Rk616-> capture_path = ucontrol-> value. integer. value [0];

 

DBG ("% s: set capture_path % ld, pre_path % ld \ n", _ func __,

Rk616-> capture_path, pre_path );

 

Switch (rk616-> capture_path ){

CaseMIC_OFF:

If (pre_path! = MIC_OFF)

Rk616_codec_power_down (RK616_CODEC_CAPTURE );

Break;

CaseMain_Mic:

If (pre_path = MIC_OFF)

Rk616_codec_power_up (RK616_CODEC_CAPTURE );

 

# Ifdef RK616_HPMIC_FROM_LINEIN

Snd_soc_write (codec, 0x848, 0x06); // MIXINL power up and unmute, MININL from MICMUX, MICMUX from BST_L

# Endif

Rk616_set_gpio (RK616_CODEC_SET_MIC, GPIO _HIGH);

Break;

CaseHands_Free_Mic:

If (pre_path = MIC_OFF)

Rk616_codec_power_up (RK616_CODEC_CAPTURE );

 

# Ifdef RK616_HPMIC_FROM_LINEIN

Snd_soc_write (codec, 0x848, 0x03); // MIXINL power up and unmute, MININL from MICMUX, MICMUX from IN3L

# Endif

Rk616_set_gpio (RK616_CODEC_SET_MIC, GPIO_LOW );

Break;

CaseBT_Sco_Mic:

Break;

Default:

Return-EINVAL;

}

 

Return 0;

}

This problem occurs during hardware implementation. When Using bt sco as the input, the Main Mic or Hands Mic will also be input.


If necessary, you can achieve this:

@-796,6 + 796,7 @ static struct rk616_platform_data rk616_pdata = {

. Hdmi_irq = RK30_PIN2_PD6,

. Spk_ctl_gpio = RK30_PIN2_PD7,

. Hp_ctl_gpio = INVALID_GPIO,

+. Mic_sel_gpio = RK30_PIN0_PD5,

};

# Endif

After the Capture MIC Path is switched, the level of RK30_PIN0_PD5 changes accordingly.

 

I think the ideal method for Mic input is:

 

Text description: All Mic channels areParallelAnd keep an enabling pin, the CPU can freely control the disconnection of each channel.

Any channel adjustment on the hardware isSuperfluous.

 

Android does not have an accurate processing method for separate Mic 3.5mm jack, because the supported methods shown in WiredAccessoryManager. java do not yet support separate Mic 3.5mm jack. That is to say, the kernel does not know how to tell the Android system about the Mic insertion detected by the kernel, or it is useless.

 

Headset + Mic BIT_HEADSET = (1 <0 );

Headset-Mic BIT_HEADSET_NO_MIC = (1 <1 );

Other BIT_USB_HEADSET_ANLG = (1 <2 );

Other BIT_USB_HEADSET_DGTL = (1 <3 );

Other BIT_HDMI_AUDIO = (1 <4 );

 

The split-type headset is shown as follows:

 

Insert only Mic, not headset.

Which of the following statements is incomplete?Even if the kernel determines that only an independent Mic is inserted on the hardware, it does not know what number is entered in/sys/class/switch/h2w/state to indicate this status..


For Android underlying development, do you need to clarify the Android source code structure? Help

Install a code management software, such as Source insight. By using this tool to view the code, you can easily find the definition of functions and variables, so that you can easily understand the internal structure of a project. As for the relationship between multiple projects, we recommend that you first learn about Android. mk files are written and developed. Android internal files are all written through Android. mk is organized and compiled, similar to Makefile in Linux, so that you know how to organize things in a folder. The Framework layer is not very well described in books, so when you encounter problems, you can search through the network and then find and find out based on your own code, because Android platforms have been changed, most of the books are not reliable. There is no better way to do this.

Android underlying development problems?

Android underlying layer?
Do you mean android platform code development or development of android scripts and version control?
For android platform code development:
Download the source code from the google website and study the underlying Java basics.
If you want to develop scripts, version control, or C code at the bottom of android:
Then you need to be very familiar with C and have a good understanding of the android source code structure, and you need to understand JNI and other technologies.

Related Article

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.