blob: 3e2ec9cbf3976d0d21c6ee90d7fe075a210a33eb [file] [log] [blame]
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +02001ASoC Machine Driver
2===================
3
4The ASoC machine (or board) driver is the code that glues together the platform
5and codec drivers.
6
7The machine driver can contain codec and platform specific code. It registers
8the audio subsystem with the kernel as a platform device and is represented by
9the following struct:-
10
11/* SoC machine */
Mark Brown4f904732008-11-21 15:08:23 +000012struct snd_soc_card {
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020013 char *name;
14
Seungwhan Youn379c4bf2011-01-13 11:08:21 +090015 ...
16
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020017 int (*probe)(struct platform_device *pdev);
18 int (*remove)(struct platform_device *pdev);
19
20 /* the pre and post PM functions are used to do any PM work before and
Mark Brown7c4dbbd2008-01-23 08:41:46 +010021 * after the codec and DAIs do any PM work. */
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020022 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
23 int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
24 int (*resume_pre)(struct platform_device *pdev);
25 int (*resume_post)(struct platform_device *pdev);
26
Seungwhan Youn379c4bf2011-01-13 11:08:21 +090027 ...
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020028
29 /* CPU <--> Codec DAI links */
30 struct snd_soc_dai_link *dai_link;
31 int num_links;
Seungwhan Youn379c4bf2011-01-13 11:08:21 +090032
33 ...
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020034};
35
36probe()/remove()
37----------------
38probe/remove are optional. Do any machine specific probe here.
39
40
41suspend()/resume()
42------------------
43The machine driver has pre and post versions of suspend and resume to take care
Mark Brown7c4dbbd2008-01-23 08:41:46 +010044of any machine audio tasks that have to be done before or after the codec, DAIs
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020045and DMA is suspended and resumed. Optional.
46
47
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020048Machine DAI Configuration
49-------------------------
Mark Brown7c4dbbd2008-01-23 08:41:46 +010050The machine DAI configuration glues all the codec and CPU DAIs together. It can
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020051also be used to set up the DAI system clock and for any machine related DAI
52initialisation e.g. the machine audio map can be connected to the codec audio
Mark Brown7c4dbbd2008-01-23 08:41:46 +010053map, unconnected codec pins can be set as such. Please see corgi.c, spitz.c
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020054for examples.
55
56struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
57
58/* corgi digital audio interface glue - connects codec <--> CPU */
59static struct snd_soc_dai_link corgi_dai = {
60 .name = "WM8731",
61 .stream_name = "WM8731",
Seungwhan Youn379c4bf2011-01-13 11:08:21 +090062 .cpu_dai_name = "pxa-is2-dai",
63 .codec_dai_name = "wm8731-hifi",
64 .platform_name = "pxa-pcm-audio",
65 .codec_name = "wm8713-codec.0-001a",
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020066 .init = corgi_wm8731_init,
Liam Girdwood10b98522007-02-08 17:06:09 +010067 .ops = &corgi_ops,
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020068};
69
Francis Galieguea33f3222010-04-23 00:08:02 +020070struct snd_soc_card then sets up the machine with its DAIs. e.g.
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020071
72/* corgi audio machine driver */
Mark Brown87506542008-11-18 20:50:34 +000073static struct snd_soc_card snd_soc_corgi = {
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020074 .name = "Corgi",
75 .dai_link = &corgi_dai,
76 .num_links = 1,
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020077};
78
79
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020080Machine Power Map
81-----------------
82
83The machine driver can optionally extend the codec power map and to become an
84audio power map of the audio subsystem. This allows for automatic power up/down
85of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
86sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for
87details.
88
89
90Machine Controls
91----------------
92
Mark Brown7c4dbbd2008-01-23 08:41:46 +010093Machine specific audio mixer controls can be added in the DAI init function.