From: http://blog.chinaunix.net/uid-22917448-id-1765508.html
ASoC Machine Driver
ASoC machine driver
==============================
The ASoC machine (or board) driver is the code that glues together the platform
And codec drivers.
ASoC machines or board-level drivers are code that binds the platform and decoder drivers together.
The machine driver can contain codec and platform specific code. It registers
The audio subsystem with the kernel as a platform device and is represented
The following struct :-
The machine driver can contain decoder and platform-related code. It registers the Audio Subsystem as a platform device in the kernel and represents it by the following struct:
/* SoC machine */
Struct snd_soc_card {
Char * name;
Int (* probe) (struct platform_device * pdev );
Int (* remove) (struct platform_device * pdev );
/* The pre and post PM functions are used to do any PM work before and
* After the codec and DAIS do any PM work .*/
INT (* suspend_pre) (struct platform_device * pdev, pm_message_t State );
INT (* suspend_post) (struct platform_device * pdev, pm_message_t State );
INT (* resume_pre) (struct platform_device * pdev );
INT (* resume_post) (struct platform_device * pdev );
/* Machine stream operations */
Struct snd_soc_ops * OPS;
/* CPU <--> codec Dai links */
Struct snd_soc_dai_link * dai_link;
Int num_links;
};
Probe ()/remove ()
Probe and remove Functions
----------------
Probe/remove are optional. Do any machine specific probe here.
Probe/remove is optional. You can perform machine-related testing.
Suspend ()/resume ()
Suspension and restoration Functions
------------------
The machine driver has pre and post versions of suspend and resume to take care
Of any machine audio tasks that have to be done before or after the codec, DAIs
And DMA is suincluded and resumed. Optional.
The machine driver has two versions of suspension and restoration functions to manage the machine audio tasks to be completed before and after decoding. Both DAI and DMA must be suspended and restored. This is also optional.
Machine operations
Machine Operation
------------------
The machine specific audio operations can be set here. Again this is optional.
Machine-related audio operations can be set here. This is also optional.
Machine DAI Configuration
Machine digital audio interface configuration
-------------------------
The machine DAI configuration glues all the codec and CPU DAIs together. It can
Also be used to set up the DAI system clock and for any machine related DAI
Initialisation e.g. the machine audio map can be connected to the codec audio
Map, unconnected codec pins can be set as such. Please see corgi. c, spitz. c
For examples.
The DAI configuration of the machine binds all decoder and cpu dai together. It can also be used to start the DAI system clock or the initialization of the machine phase in DAI. For example, a machine audio image can be connected to a decoder audio image. This can also be set for non-connected decoder pins. For the example, see corgi. c, spitz. c.
Struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
The struct snd_soc_dai_link sets the DAI of your machine. For example:
/* Corgi digital audio interface glue-connects codec <--> CPU */
Static struct snd_soc_dai_link corgi_dai = {
. Name = "WM8731 ",
. Stream_name = "WM8731 ",
. Cpu_dai = & pxa_i2s_dai,
. Codec_dai = & wm8731_dai,
. Init = corgi_wm8731_init,
. Ops = & corgi_ops,
};
Struct snd_soc_card then sets up the machine with it's DAIs. e.g.
Then snd_soc_card uses this DAI to configure the machine, for example:
/* Corgi audio machine driver */
Static struct snd_soc_card snd_soc_corgi = {
. Name = "Corgi ",
. Dai_link = & corgi_dai,
. Num_links = 1,
};
Machine Audio Subsystem
Machine Audio Subsystem
-----------------------
The machine soc device glues the platform, machine and codec driver together.
Private data can also be set here. e.g.
The machine soc device integrates the platform, machine, and decoder driver.
Private data can also be set here.
/* Corgi audio private data */
Static struct wm8731_setup_data corgi_wm8731_setup = {
. I2c_address = 0x1b,
};
/* Corgi audio subsystem */
Static struct snd_soc_device corgi_snd_devdata = {
. Machine = & snd_soc_corgi,
. Platform = & pxa2xx_soc_platform,
. Codec_dev = & soc_codec_dev_wm8731,
. Codec_data = & corgi_wm8731_setup,
};
Machine Power Map
Machine Power Image
-----------------
The machine driver can optionally extend the codec power map and to become
Audio power map of the audio subsystem. This allows for automatic power up/down
Of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
Sockets in the machine init function. See soc/pxa/spitz. c and dapm.txt
Details.
The machine driver can expand the decoder's power image to become an audio power image of the Audio Subsystem. This allows automatic disconnection of sources such as speakers/HP amplifiers. The decoder pin can be connected to the machine plug-in the machine initialization function. For more information, see soc/pxa/spitx.cand dapm.txt.
Machine Controls
Machine Control
----------------
Machine specific audio mixer controls can be added in the DAI init function.
Machine-related audio mixing control can be added to the DAI initialization function.
Gentleman note:
What you are reading now is the document translation written by the gentleman when reading the Linux audio SoC driver.
The gentleman writes some translations. On the one hand, it serves as his own notes to help his memory, and on the other hand, he hopes to help others.
If you are able to get something from the gentleman's translation, I am very pleased.
All the original documents are all in the linux-2.6.30/Documentation/sound/alsa/soc directory.
Since the gentleman does not know much about the audio content, I do not understand it in many places, but just translated it in the original article.
Here, the guests who are willing to visit are not necessarily correct.
Zhang Jun again.