blob: f370e7db86af6a970de14433523af4b1ca71d390 [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 */
12struct snd_soc_machine {
13 char *name;
14
15 int (*probe)(struct platform_device *pdev);
16 int (*remove)(struct platform_device *pdev);
17
18 /* the pre and post PM functions are used to do any PM work before and
Mark Brown7c4dbbd2008-01-23 08:41:46 +010019 * after the codec and DAIs do any PM work. */
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020020 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
21 int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
22 int (*resume_pre)(struct platform_device *pdev);
23 int (*resume_post)(struct platform_device *pdev);
24
25 /* machine stream operations */
26 struct snd_soc_ops *ops;
27
28 /* CPU <--> Codec DAI links */
29 struct snd_soc_dai_link *dai_link;
30 int num_links;
31};
32
33probe()/remove()
34----------------
35probe/remove are optional. Do any machine specific probe here.
36
37
38suspend()/resume()
39------------------
40The machine driver has pre and post versions of suspend and resume to take care
Mark Brown7c4dbbd2008-01-23 08:41:46 +010041of any machine audio tasks that have to be done before or after the codec, DAIs
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020042and DMA is suspended and resumed. Optional.
43
44
45Machine operations
46------------------
47The machine specific audio operations can be set here. Again this is optional.
48
49
50Machine DAI Configuration
51-------------------------
Mark Brown7c4dbbd2008-01-23 08:41:46 +010052The machine DAI configuration glues all the codec and CPU DAIs together. It can
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020053also 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
Mark Brown7c4dbbd2008-01-23 08:41:46 +010055map, unconnected codec pins can be set as such. Please see corgi.c, spitz.c
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020056for examples.
57
58struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
59
60/* corgi digital audio interface glue - connects codec <--> CPU */
61static struct snd_soc_dai_link corgi_dai = {
62 .name = "WM8731",
63 .stream_name = "WM8731",
64 .cpu_dai = &pxa_i2s_dai,
65 .codec_dai = &wm8731_dai,
66 .init = corgi_wm8731_init,
Liam Girdwood10b98522007-02-08 17:06:09 +010067 .ops = &corgi_ops,
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020068};
69
Mark Brown7c4dbbd2008-01-23 08:41:46 +010070struct snd_soc_machine then sets up the machine with it's DAIs. e.g.
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020071
72/* corgi audio machine driver */
73static struct snd_soc_machine snd_soc_machine_corgi = {
74 .name = "Corgi",
75 .dai_link = &corgi_dai,
76 .num_links = 1,
Liam Girdwoodeb1a6af2006-10-06 18:34:51 +020077};
78
79
80Machine Audio Subsystem
81-----------------------
82
83The machine soc device glues the platform, machine and codec driver together.
84Private data can also be set here. e.g.
85
86/* corgi audio private data */
87static struct wm8731_setup_data corgi_wm8731_setup = {
88 .i2c_address = 0x1b,
89};
90
91/* corgi audio subsystem */
92static struct snd_soc_device corgi_snd_devdata = {
93 .machine = &snd_soc_machine_corgi,
94 .platform = &pxa2xx_soc_platform,
95 .codec_dev = &soc_codec_dev_wm8731,
96 .codec_data = &corgi_wm8731_setup,
97};
98
99
100Machine Power Map
101-----------------
102
103The machine driver can optionally extend the codec power map and to become an
104audio power map of the audio subsystem. This allows for automatic power up/down
105of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
106sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for
107details.
108
109
110Machine Controls
111----------------
112
Mark Brown7c4dbbd2008-01-23 08:41:46 +0100113Machine specific audio mixer controls can be added in the DAI init function.