machine.txt 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
ASoC Machine Driver
===================

The ASoC machine (or board) driver is the code that glues together the platform
and codec drivers.

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 by
the following struct:-

/* SoC machine */
12
struct snd_soc_card {
13 14
	char *name;

S
Seungwhan Youn 已提交
15 16
	...

17 18 19 20
	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
M
Mark Brown 已提交
21
	 * after the codec and DAIs do any PM work. */
22 23 24 25 26
	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);

S
Seungwhan Youn 已提交
27
	...
28 29 30 31

	/* CPU <--> Codec DAI links  */
	struct snd_soc_dai_link *dai_link;
	int num_links;
S
Seungwhan Youn 已提交
32 33

	...
34 35 36 37 38 39 40 41 42 43
};

probe()/remove()
----------------
probe/remove are optional. Do any machine specific probe here.


suspend()/resume()
------------------
The machine driver has pre and post versions of suspend and resume to take care
M
Mark Brown 已提交
44
of any machine audio tasks that have to be done before or after the codec, DAIs
45 46 47 48 49
and DMA is suspended and resumed. Optional.


Machine DAI Configuration
-------------------------
M
Mark Brown 已提交
50
The machine DAI configuration glues all the codec and CPU DAIs together. It can
51 52
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
53
map, unconnected codec pins can be set as such.
54 55 56 57 58 59 60

struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.

/* corgi digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link corgi_dai = {
	.name = "WM8731",
	.stream_name = "WM8731",
S
Seungwhan Youn 已提交
61 62 63 64
	.cpu_dai_name = "pxa-is2-dai",
	.codec_dai_name = "wm8731-hifi",
	.platform_name = "pxa-pcm-audio",
	.codec_name = "wm8713-codec.0-001a",
65
	.init = corgi_wm8731_init,
66
	.ops = &corgi_ops,
67 68
};

69
struct snd_soc_card then sets up the machine with its DAIs. e.g.
70 71

/* corgi audio machine driver */
72
static struct snd_soc_card snd_soc_corgi = {
73 74 75 76 77 78 79 80 81 82 83 84
	.name = "Corgi",
	.dai_link = &corgi_dai,
	.num_links = 1,
};


Machine Power Map
-----------------

The machine driver can optionally extend the codec power map and to become an
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
85
sockets in the machine init function.
86 87 88 89 90


Machine Controls
----------------

M
Mark Brown 已提交
91
Machine specific audio mixer controls can be added in the DAI init function.