Back to home page

OSCL-LXR

 
 

    


0001 ===================
0002 ASoC Machine Driver
0003 ===================
0004 
0005 The ASoC machine (or board) driver is the code that glues together all the
0006 component drivers (e.g. codecs, platforms and DAIs). It also describes the
0007 relationships between each component which include audio paths, GPIOs,
0008 interrupts, clocking, jacks and voltage regulators.
0009 
0010 The machine driver can contain codec and platform specific code. It registers
0011 the audio subsystem with the kernel as a platform device and is represented by
0012 the following struct:-
0013 ::
0014 
0015   /* SoC machine */
0016   struct snd_soc_card {
0017         char *name;
0018 
0019         ...
0020 
0021         int (*probe)(struct platform_device *pdev);
0022         int (*remove)(struct platform_device *pdev);
0023 
0024         /* the pre and post PM functions are used to do any PM work before and
0025          * after the codec and DAIs do any PM work. */
0026         int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
0027         int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
0028         int (*resume_pre)(struct platform_device *pdev);
0029         int (*resume_post)(struct platform_device *pdev);
0030 
0031         ...
0032 
0033         /* CPU <--> Codec DAI links  */
0034         struct snd_soc_dai_link *dai_link;
0035         int num_links;
0036 
0037         ...
0038   };
0039 
0040 probe()/remove()
0041 ----------------
0042 probe/remove are optional. Do any machine specific probe here.
0043 
0044 
0045 suspend()/resume()
0046 ------------------
0047 The machine driver has pre and post versions of suspend and resume to take care
0048 of any machine audio tasks that have to be done before or after the codec, DAIs
0049 and DMA is suspended and resumed. Optional.
0050 
0051 
0052 Machine DAI Configuration
0053 -------------------------
0054 The machine DAI configuration glues all the codec and CPU DAIs together. It can
0055 also be used to set up the DAI system clock and for any machine related DAI
0056 initialisation e.g. the machine audio map can be connected to the codec audio
0057 map, unconnected codec pins can be set as such.
0058 
0059 struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
0060 ::
0061 
0062   /* corgi digital audio interface glue - connects codec <--> CPU */
0063   static struct snd_soc_dai_link corgi_dai = {
0064         .name = "WM8731",
0065         .stream_name = "WM8731",
0066         .cpu_dai_name = "pxa-is2-dai",
0067         .codec_dai_name = "wm8731-hifi",
0068         .platform_name = "pxa-pcm-audio",
0069         .codec_name = "wm8713-codec.0-001a",
0070         .init = corgi_wm8731_init,
0071         .ops = &corgi_ops,
0072   };
0073 
0074 struct snd_soc_card then sets up the machine with its DAIs. e.g.
0075 ::
0076 
0077   /* corgi audio machine driver */
0078   static struct snd_soc_card snd_soc_corgi = {
0079         .name = "Corgi",
0080         .dai_link = &corgi_dai,
0081         .num_links = 1,
0082   };
0083 
0084 
0085 Machine Power Map
0086 -----------------
0087 
0088 The machine driver can optionally extend the codec power map and to become an
0089 audio power map of the audio subsystem. This allows for automatic power up/down
0090 of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
0091 sockets in the machine init function.
0092 
0093 
0094 Machine Controls
0095 ----------------
0096 
0097 Machine specific audio mixer controls can be added in the DAI init function.