2016-11-10 22:23:02 +01:00
===================
2006-10-06 18:34:51 +02:00
ASoC Machine Driver
===================
2013-09-20 18:19:08 +01:00
The ASoC machine (or board) driver is the code that glues together all the
component drivers (e.g. codecs, platforms and DAIs). It also describes the
2016-05-21 13:44:21 +02:00
relationships between each component which include audio paths, GPIOs,
2013-09-20 18:19:08 +01:00
interrupts, clocking, jacks and voltage regulators.
2006-10-06 18:34:51 +02:00
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:-
2016-11-10 22:23:02 +01:00
::
2006-10-06 18:34:51 +02:00
2016-11-10 22:23:02 +01:00
/* SoC machine * /
struct snd_soc_card {
2006-10-06 18:34:51 +02:00
char *name;
2011-01-13 11:08:21 +09:00
...
2006-10-06 18:34:51 +02:00
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
2008-01-23 08:41:46 +01:00
* after the codec and DAIs do any PM work. */
2006-10-06 18:34:51 +02:00
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);
2011-01-13 11:08:21 +09:00
...
2006-10-06 18:34:51 +02:00
/* CPU <--> Codec DAI links * /
struct snd_soc_dai_link *dai_link;
int num_links;
2011-01-13 11:08:21 +09:00
...
2016-11-10 22:23:02 +01:00
};
2006-10-06 18:34:51 +02:00
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
2008-01-23 08:41:46 +01:00
of any machine audio tasks that have to be done before or after the codec, DAIs
2006-10-06 18:34:51 +02:00
and DMA is suspended and resumed. Optional.
Machine DAI Configuration
-------------------------
2008-01-23 08:41:46 +01:00
The machine DAI configuration glues all the codec and CPU DAIs together. It can
2006-10-06 18:34:51 +02:00
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
2011-12-05 18:27:25 +00:00
map, unconnected codec pins can be set as such.
2006-10-06 18:34:51 +02:00
struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
2016-11-10 22:23:02 +01:00
::
2006-10-06 18:34:51 +02:00
2016-11-10 22:23:02 +01:00
/* corgi digital audio interface glue - connects codec <--> CPU * /
static struct snd_soc_dai_link corgi_dai = {
2006-10-06 18:34:51 +02:00
.name = "WM8731",
.stream_name = "WM8731",
2011-01-13 11:08:21 +09:00
.cpu_dai_name = "pxa-is2-dai",
.codec_dai_name = "wm8731-hifi",
.platform_name = "pxa-pcm-audio",
.codec_name = "wm8713-codec.0-001a",
2006-10-06 18:34:51 +02:00
.init = corgi_wm8731_init,
2007-02-08 17:06:09 +01:00
.ops = &corgi_ops,
2016-11-10 22:23:02 +01:00
};
2006-10-06 18:34:51 +02:00
2010-04-23 00:08:02 +02:00
struct snd_soc_card then sets up the machine with its DAIs. e.g.
2016-11-10 22:23:02 +01:00
::
2006-10-06 18:34:51 +02:00
2016-11-10 22:23:02 +01:00
/* corgi audio machine driver * /
static struct snd_soc_card snd_soc_corgi = {
2006-10-06 18:34:51 +02:00
.name = "Corgi",
.dai_link = &corgi_dai,
.num_links = 1,
2016-11-10 22:23:02 +01:00
};
2006-10-06 18:34:51 +02:00
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
2011-12-05 18:27:25 +00:00
sockets in the machine init function.
2006-10-06 18:34:51 +02:00
Machine Controls
----------------
2008-01-23 08:41:46 +01:00
Machine specific audio mixer controls can be added in the DAI init function.