machine.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ASoC Machine Driver
  2. ===================
  3. The ASoC machine (or board) driver is the code that glues together the platform
  4. and codec drivers.
  5. The machine driver can contain codec and platform specific code. It registers
  6. the audio subsystem with the kernel as a platform device and is represented by
  7. the following struct:-
  8. /* SoC machine */
  9. struct snd_soc_card {
  10. char *name;
  11. int (*probe)(struct platform_device *pdev);
  12. int (*remove)(struct platform_device *pdev);
  13. /* the pre and post PM functions are used to do any PM work before and
  14. * after the codec and DAIs do any PM work. */
  15. int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
  16. int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
  17. int (*resume_pre)(struct platform_device *pdev);
  18. int (*resume_post)(struct platform_device *pdev);
  19. /* machine stream operations */
  20. struct snd_soc_ops *ops;
  21. /* CPU <--> Codec DAI links */
  22. struct snd_soc_dai_link *dai_link;
  23. int num_links;
  24. };
  25. probe()/remove()
  26. ----------------
  27. probe/remove are optional. Do any machine specific probe here.
  28. suspend()/resume()
  29. ------------------
  30. The machine driver has pre and post versions of suspend and resume to take care
  31. of any machine audio tasks that have to be done before or after the codec, DAIs
  32. and DMA is suspended and resumed. Optional.
  33. Machine operations
  34. ------------------
  35. The machine specific audio operations can be set here. Again this is 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. Please see corgi.c, spitz.c
  42. for examples.
  43. struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
  44. /* corgi digital audio interface glue - connects codec <--> CPU */
  45. static struct snd_soc_dai_link corgi_dai = {
  46. .name = "WM8731",
  47. .stream_name = "WM8731",
  48. .cpu_dai = &pxa_i2s_dai,
  49. .codec_dai = &wm8731_dai,
  50. .init = corgi_wm8731_init,
  51. .ops = &corgi_ops,
  52. };
  53. struct snd_soc_card then sets up the machine with it's DAIs. e.g.
  54. /* corgi audio machine driver */
  55. static struct snd_soc_card snd_soc_corgi = {
  56. .name = "Corgi",
  57. .dai_link = &corgi_dai,
  58. .num_links = 1,
  59. };
  60. Machine Audio Subsystem
  61. -----------------------
  62. The machine soc device glues the platform, machine and codec driver together.
  63. Private data can also be set here. e.g.
  64. /* corgi audio private data */
  65. static struct wm8731_setup_data corgi_wm8731_setup = {
  66. .i2c_address = 0x1b,
  67. };
  68. /* corgi audio subsystem */
  69. static struct snd_soc_device corgi_snd_devdata = {
  70. .machine = &snd_soc_corgi,
  71. .platform = &pxa2xx_soc_platform,
  72. .codec_dev = &soc_codec_dev_wm8731,
  73. .codec_data = &corgi_wm8731_setup,
  74. };
  75. Machine Power Map
  76. -----------------
  77. The machine driver can optionally extend the codec power map and to become an
  78. audio power map of the audio subsystem. This allows for automatic power up/down
  79. of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
  80. sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for
  81. details.
  82. Machine Controls
  83. ----------------
  84. Machine specific audio mixer controls can be added in the DAI init function.