ALSA Drive Framework and drive Development (ii) __ Frame

Source: Internet
Author: User
Tags prepare

This article mainly goes on to say, in the ALSA drive framework, the kernel calls to drive the whole process

Ten The whole process of calling from the kernel to the driver

1. Open/dev/dsp

Open operation, through the previous structure diagram, we know that when the kernel calls the Open function, the first call is Soundcore_open, through the __look_for_unit find chain[3], that is, the DSP sound_unit pointer, The operation pointer to the value file is then assigned to the operation pointer of the DSP device file.

This method also applies to other files, for example, for/dev/mixer, when the open operation is invoked, the same call to Soundcore_open is done, and then the next action is to redefine the operation pointer of the file as the action pointer of the mixer file and invoke the Mixer_ The Open function in OPS,

Later, the operation of the file is to invoke the updated OPS.

Here is a call to open in PCM_OSS.C, the specific flow chart is as follows,

Specific,

Cpu_dai.ops->startup for At91_ssc_startup This function is mainly to set the transmission direction of the mask (serial port only allow one-way transmission)

Platform->pcm_ops->open for At91_pcm_open This function is mainly set At91_pcm_hardware, including Pcm_info,period_bytes_min,period_bytes_ Max

Periods_min,periods_max,buffer_bytes_max and so on,

Codec_dai->ops.startup is null

Machine->ops->startup is Epayment_snd_startup, the number of functions is mainly set Cpu_dai CLK for system clock At91_sysclk_mck, set codec_ Dai's CLK for PCMXXX_SYSCLK, and then make it possible to Codec_dai CLK

2. Open/dev/mixer

The approximate process of open/dev/mixer is similar to the above OPEN/DEV/DSP, except that the following action pointer is mixer OPS

The specific thing is to call the Snd_mixer_oss_open in MIXER_OSS.C, which basically completes the struct Snd_mixer_oss_file *fmixer,fmixer fill and assigns it to the file's private data.

3. Procedures for configuring parameters (DSP IOCTL)

The process of configuring parameters is implemented through IOCTL

For example, in the library file, the parameter settings are implemented through the IOCTL, generally including, sync,channel,fmt,rate and other parameters of the settings.

To set the sampling rate as an example, the flow chart is as follows,

Similarly, in the function Soc_pcm_hw_params, the CPUÀPLATFORMÀCODEC is still followed

The approximate order.

Specific,

A) Machine->ops->hw_params, (the machine is a dai_link structure pointer), for function Epayment_snd_hw_params, the main completion settings Cpu_dai,codec_da FMT of I, set Cpu_dai cmr_div and period (computed by sampling)

b) Codec_dai->ops.hw_params to pcmxxx_hw_params null

c) Cpu_dai->ops.hw_params for At91_ssc_hw_params, the main completion of initialization of a struct at91_pcm_dma_params *dma_params, and Dma_par AMS is populated, including the PDC Register,ssc_base,pdc_xfer_size (in bytes) and some of the SSC registers, such as RCMR, RFMR, TCMR, TFMR.

Finally, reset SSC and its PDC registers, request interrupts, interrupt service routines for At91_ssc_interrupt, and, during transmission, interrupt the service routines when they receive data and all data is sent out.

d) Platform->pcm_ops->hw_params for At91_pcm_hw_params, the main completion of the at91_runtime_data data filling, here is also populated with a Dma_intr_handl ER is AT91_PCM_DMA_IRQ (actually a hardware-generated interrupt)

The relationship between this interrupt service routine and the At91_ssc_interrupt interrupt mentioned above is,

In the At91_ssc_interrupt interrupt service routine, the interrupt type is judged first and then the interrupt service routine is called AT91_PCM_DMA_IRQ to complete the interrupt service.

and the main task of AT91_PCM_DMA_IRQ interrupt service is to

If the interrupt type is the interrupt after the end of the transmit data, reset the prtd->period_ptr pointer (if it happens to be dma_buffer_end, set to the Dma_buffer head pointer, or the pointer moves down period_size bytes), Set up PDC->XNPR and PDC->XNCR.

If the interrupt type is dma_buffer full, close the PDC first, reposition the prtd->period_ptr pointer (set to the Dma_buffer head pointer), set PDC->XPR,PDC->XCR, and then reopen the PDC.

4. Mixer_ioctl

Ditto, mixer's related operations are implemented through IOCTL, which does not even require read and write.

Because the PCMXXX does not support volume adjustment, slightly.

5. PCM Prepare

Snd_pcm_oss_make_ready is invoked to prepare before the synchronization clock and Write/read are set.

The same is done through IOCTL.

Flowchart similar,

-----àsnd_pcm_prepare First wait for the power, after

-----àsnd_pcm_action_nonatomic (&snd_pcm_action_prepare,

Substream, F_flags);

static struct Action_ops Snd_pcm_action_prepare = {

               . pre_action = Snd_pcm_pre_ Prepare,

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.