machine.txt 2.8 KB

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