Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 1 | ASoC Machine Driver |
| 2 | =================== |
| 3 | |
| 4 | The ASoC machine (or board) driver is the code that glues together the platform |
| 5 | and codec drivers. |
| 6 | |
| 7 | The machine driver can contain codec and platform specific code. It registers |
| 8 | the audio subsystem with the kernel as a platform device and is represented by |
| 9 | the following struct:- |
| 10 | |
| 11 | /* SoC machine */ |
Mark Brown | 4f90473 | 2008-11-21 15:08:23 +0000 | [diff] [blame] | 12 | struct snd_soc_card { |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 13 | char *name; |
| 14 | |
Seungwhan Youn | 379c4bf | 2011-01-13 11:08:21 +0900 | [diff] [blame] | 15 | ... |
| 16 | |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 17 | 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 Brown | 7c4dbbd | 2008-01-23 08:41:46 +0100 | [diff] [blame] | 21 | * after the codec and DAIs do any PM work. */ |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 22 | 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 Youn | 379c4bf | 2011-01-13 11:08:21 +0900 | [diff] [blame] | 27 | ... |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 28 | |
| 29 | /* CPU <--> Codec DAI links */ |
| 30 | struct snd_soc_dai_link *dai_link; |
| 31 | int num_links; |
Seungwhan Youn | 379c4bf | 2011-01-13 11:08:21 +0900 | [diff] [blame] | 32 | |
| 33 | ... |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | probe()/remove() |
| 37 | ---------------- |
| 38 | probe/remove are optional. Do any machine specific probe here. |
| 39 | |
| 40 | |
| 41 | suspend()/resume() |
| 42 | ------------------ |
| 43 | The machine driver has pre and post versions of suspend and resume to take care |
Mark Brown | 7c4dbbd | 2008-01-23 08:41:46 +0100 | [diff] [blame] | 44 | of any machine audio tasks that have to be done before or after the codec, DAIs |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 45 | and DMA is suspended and resumed. Optional. |
| 46 | |
| 47 | |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 48 | Machine DAI Configuration |
| 49 | ------------------------- |
Mark Brown | 7c4dbbd | 2008-01-23 08:41:46 +0100 | [diff] [blame] | 50 | The machine DAI configuration glues all the codec and CPU DAIs together. It can |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 51 | also be used to set up the DAI system clock and for any machine related DAI |
| 52 | initialisation e.g. the machine audio map can be connected to the codec audio |
Mark Brown | 7c4dbbd | 2008-01-23 08:41:46 +0100 | [diff] [blame] | 53 | map, unconnected codec pins can be set as such. Please see corgi.c, spitz.c |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 54 | for examples. |
| 55 | |
| 56 | struct 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 */ |
| 59 | static struct snd_soc_dai_link corgi_dai = { |
| 60 | .name = "WM8731", |
| 61 | .stream_name = "WM8731", |
Seungwhan Youn | 379c4bf | 2011-01-13 11:08:21 +0900 | [diff] [blame] | 62 | .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 Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 66 | .init = corgi_wm8731_init, |
Liam Girdwood | 10b9852 | 2007-02-08 17:06:09 +0100 | [diff] [blame] | 67 | .ops = &corgi_ops, |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
Francis Galiegue | a33f322 | 2010-04-23 00:08:02 +0200 | [diff] [blame] | 70 | struct snd_soc_card then sets up the machine with its DAIs. e.g. |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 71 | |
| 72 | /* corgi audio machine driver */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 73 | static struct snd_soc_card snd_soc_corgi = { |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 74 | .name = "Corgi", |
| 75 | .dai_link = &corgi_dai, |
| 76 | .num_links = 1, |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | |
Liam Girdwood | eb1a6af | 2006-10-06 18:34:51 +0200 | [diff] [blame] | 80 | Machine Power Map |
| 81 | ----------------- |
| 82 | |
| 83 | The machine driver can optionally extend the codec power map and to become an |
| 84 | audio power map of the audio subsystem. This allows for automatic power up/down |
| 85 | of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack |
| 86 | sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for |
| 87 | details. |
| 88 | |
| 89 | |
| 90 | Machine Controls |
| 91 | ---------------- |
| 92 | |
Mark Brown | 7c4dbbd | 2008-01-23 08:41:46 +0100 | [diff] [blame] | 93 | Machine specific audio mixer controls can be added in the DAI init function. |