^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) ASoC Machine Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) The ASoC machine (or board) driver is the code that glues together all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) component drivers (e.g. codecs, platforms and DAIs). It also describes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) relationships between each component which include audio paths, GPIOs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) interrupts, clocking, jacks and voltage regulators.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) The machine driver can contain codec and platform specific code. It registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) the audio subsystem with the kernel as a platform device and is represented by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) the following struct:-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /* SoC machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct snd_soc_card {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int (*probe)(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int (*remove)(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /* the pre and post PM functions are used to do any PM work before and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * after the codec and DAIs do any PM work. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int (*resume_pre)(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int (*resume_post)(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* CPU <--> Codec DAI links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct snd_soc_dai_link *dai_link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int num_links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) probe()/remove()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) probe/remove are optional. Do any machine specific probe here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) suspend()/resume()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) The machine driver has pre and post versions of suspend and resume to take care
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) of any machine audio tasks that have to be done before or after the codec, DAIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) and DMA is suspended and resumed. Optional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) Machine DAI Configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) The machine DAI configuration glues all the codec and CPU DAIs together. It can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) also be used to set up the DAI system clock and for any machine related DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) initialisation e.g. the machine audio map can be connected to the codec audio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) map, unconnected codec pins can be set as such.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* corgi digital audio interface glue - connects codec <--> CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static struct snd_soc_dai_link corgi_dai = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) .name = "WM8731",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .stream_name = "WM8731",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .cpu_dai_name = "pxa-is2-dai",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .codec_dai_name = "wm8731-hifi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .platform_name = "pxa-pcm-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .codec_name = "wm8713-codec.0-001a",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .init = corgi_wm8731_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .ops = &corgi_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct snd_soc_card then sets up the machine with its DAIs. e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* corgi audio machine driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static struct snd_soc_card snd_soc_corgi = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .name = "Corgi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .dai_link = &corgi_dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .num_links = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) Machine Power Map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) The machine driver can optionally extend the codec power map and to become an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) audio power map of the audio subsystem. This allows for automatic power up/down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) sockets in the machine init function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) Machine Controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) Machine specific audio mixer controls can be added in the DAI init function.