18c2ecf20Sopenharmony_ci=================== 28c2ecf20Sopenharmony_ciASoC Machine Driver 38c2ecf20Sopenharmony_ci=================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThe ASoC machine (or board) driver is the code that glues together all the 68c2ecf20Sopenharmony_cicomponent drivers (e.g. codecs, platforms and DAIs). It also describes the 78c2ecf20Sopenharmony_cirelationships between each component which include audio paths, GPIOs, 88c2ecf20Sopenharmony_ciinterrupts, clocking, jacks and voltage regulators. 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciThe machine driver can contain codec and platform specific code. It registers 118c2ecf20Sopenharmony_cithe audio subsystem with the kernel as a platform device and is represented by 128c2ecf20Sopenharmony_cithe following struct:- 138c2ecf20Sopenharmony_ci:: 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci /* SoC machine */ 168c2ecf20Sopenharmony_ci struct snd_soc_card { 178c2ecf20Sopenharmony_ci char *name; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci ... 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci int (*probe)(struct platform_device *pdev); 228c2ecf20Sopenharmony_ci int (*remove)(struct platform_device *pdev); 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci /* the pre and post PM functions are used to do any PM work before and 258c2ecf20Sopenharmony_ci * after the codec and DAIs do any PM work. */ 268c2ecf20Sopenharmony_ci int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); 278c2ecf20Sopenharmony_ci int (*suspend_post)(struct platform_device *pdev, pm_message_t state); 288c2ecf20Sopenharmony_ci int (*resume_pre)(struct platform_device *pdev); 298c2ecf20Sopenharmony_ci int (*resume_post)(struct platform_device *pdev); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci ... 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci /* CPU <--> Codec DAI links */ 348c2ecf20Sopenharmony_ci struct snd_soc_dai_link *dai_link; 358c2ecf20Sopenharmony_ci int num_links; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci ... 388c2ecf20Sopenharmony_ci }; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciprobe()/remove() 418c2ecf20Sopenharmony_ci---------------- 428c2ecf20Sopenharmony_ciprobe/remove are optional. Do any machine specific probe here. 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cisuspend()/resume() 468c2ecf20Sopenharmony_ci------------------ 478c2ecf20Sopenharmony_ciThe machine driver has pre and post versions of suspend and resume to take care 488c2ecf20Sopenharmony_ciof any machine audio tasks that have to be done before or after the codec, DAIs 498c2ecf20Sopenharmony_ciand DMA is suspended and resumed. Optional. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciMachine DAI Configuration 538c2ecf20Sopenharmony_ci------------------------- 548c2ecf20Sopenharmony_ciThe machine DAI configuration glues all the codec and CPU DAIs together. It can 558c2ecf20Sopenharmony_cialso be used to set up the DAI system clock and for any machine related DAI 568c2ecf20Sopenharmony_ciinitialisation e.g. the machine audio map can be connected to the codec audio 578c2ecf20Sopenharmony_cimap, unconnected codec pins can be set as such. 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct snd_soc_dai_link is used to set up each DAI in your machine. e.g. 608c2ecf20Sopenharmony_ci:: 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* corgi digital audio interface glue - connects codec <--> CPU */ 638c2ecf20Sopenharmony_ci static struct snd_soc_dai_link corgi_dai = { 648c2ecf20Sopenharmony_ci .name = "WM8731", 658c2ecf20Sopenharmony_ci .stream_name = "WM8731", 668c2ecf20Sopenharmony_ci .cpu_dai_name = "pxa-is2-dai", 678c2ecf20Sopenharmony_ci .codec_dai_name = "wm8731-hifi", 688c2ecf20Sopenharmony_ci .platform_name = "pxa-pcm-audio", 698c2ecf20Sopenharmony_ci .codec_name = "wm8713-codec.0-001a", 708c2ecf20Sopenharmony_ci .init = corgi_wm8731_init, 718c2ecf20Sopenharmony_ci .ops = &corgi_ops, 728c2ecf20Sopenharmony_ci }; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistruct snd_soc_card then sets up the machine with its DAIs. e.g. 758c2ecf20Sopenharmony_ci:: 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci /* corgi audio machine driver */ 788c2ecf20Sopenharmony_ci static struct snd_soc_card snd_soc_corgi = { 798c2ecf20Sopenharmony_ci .name = "Corgi", 808c2ecf20Sopenharmony_ci .dai_link = &corgi_dai, 818c2ecf20Sopenharmony_ci .num_links = 1, 828c2ecf20Sopenharmony_ci }; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciMachine Power Map 868c2ecf20Sopenharmony_ci----------------- 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ciThe machine driver can optionally extend the codec power map and to become an 898c2ecf20Sopenharmony_ciaudio power map of the audio subsystem. This allows for automatic power up/down 908c2ecf20Sopenharmony_ciof speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack 918c2ecf20Sopenharmony_cisockets in the machine init function. 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciMachine Controls 958c2ecf20Sopenharmony_ci---------------- 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ciMachine specific audio mixer controls can be added in the DAI init function. 98