1ASoC Machine Driver 2=================== 3 4The ASoC machine (or board) driver is the code that glues together all the 5component drivers (e.g. codecs, platforms and DAIs). It also describes the 6relationships between each componnent which include audio paths, GPIOs, 7interrupts, clocking, jacks and voltage regulators. 8 9The machine driver can contain codec and platform specific code. It registers 10the audio subsystem with the kernel as a platform device and is represented by 11the following struct:- 12 13/* SoC machine */ 14struct snd_soc_card { 15 char *name; 16 17 ... 18 19 int (*probe)(struct platform_device *pdev); 20 int (*remove)(struct platform_device *pdev); 21 22 /* the pre and post PM functions are used to do any PM work before and 23 * after the codec and DAIs do any PM work. */ 24 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); 25 int (*suspend_post)(struct platform_device *pdev, pm_message_t state); 26 int (*resume_pre)(struct platform_device *pdev); 27 int (*resume_post)(struct platform_device *pdev); 28 29 ... 30 31 /* CPU <--> Codec DAI links */ 32 struct snd_soc_dai_link *dai_link; 33 int num_links; 34 35 ... 36}; 37 38probe()/remove() 39---------------- 40probe/remove are optional. Do any machine specific probe here. 41 42 43suspend()/resume() 44------------------ 45The machine driver has pre and post versions of suspend and resume to take care 46of any machine audio tasks that have to be done before or after the codec, DAIs 47and DMA is suspended and resumed. Optional. 48 49 50Machine DAI Configuration 51------------------------- 52The machine DAI configuration glues all the codec and CPU DAIs together. It can 53also be used to set up the DAI system clock and for any machine related DAI 54initialisation e.g. the machine audio map can be connected to the codec audio 55map, unconnected codec pins can be set as such. 56 57struct snd_soc_dai_link is used to set up each DAI in your machine. e.g. 58 59/* corgi digital audio interface glue - connects codec <--> CPU */ 60static struct snd_soc_dai_link corgi_dai = { 61 .name = "WM8731", 62 .stream_name = "WM8731", 63 .cpu_dai_name = "pxa-is2-dai", 64 .codec_dai_name = "wm8731-hifi", 65 .platform_name = "pxa-pcm-audio", 66 .codec_name = "wm8713-codec.0-001a", 67 .init = corgi_wm8731_init, 68 .ops = &corgi_ops, 69}; 70 71struct snd_soc_card then sets up the machine with its DAIs. e.g. 72 73/* corgi audio machine driver */ 74static struct snd_soc_card snd_soc_corgi = { 75 .name = "Corgi", 76 .dai_link = &corgi_dai, 77 .num_links = 1, 78}; 79 80 81Machine Power Map 82----------------- 83 84The machine driver can optionally extend the codec power map and to become an 85audio power map of the audio subsystem. This allows for automatic power up/down 86of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack 87sockets in the machine init function. 88 89 90Machine Controls 91---------------- 92 93Machine specific audio mixer controls can be added in the DAI init function. 94