jack.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ===================
  2. ASoC jack detection
  3. ===================
  4. ALSA has a standard API for representing physical jacks to user space,
  5. the kernel side of which can be seen in include/sound/jack.h. ASoC
  6. provides a version of this API adding two additional features:
  7. - It allows more than one jack detection method to work together on one
  8. user visible jack. In embedded systems it is common for multiple
  9. to be present on a single jack but handled by separate bits of
  10. hardware.
  11. - Integration with DAPM, allowing DAPM endpoints to be updated
  12. automatically based on the detected jack status (eg, turning off the
  13. headphone outputs if no headphones are present).
  14. This is done by splitting the jacks up into three things working
  15. together: the jack itself represented by a struct snd_soc_jack, sets of
  16. snd_soc_jack_pins representing DAPM endpoints to update and blocks of
  17. code providing jack reporting mechanisms.
  18. For example, a system may have a stereo headset jack with two reporting
  19. mechanisms, one for the headphone and one for the microphone. Some
  20. systems won't be able to use their speaker output while a headphone is
  21. connected and so will want to make sure to update both speaker and
  22. headphone when the headphone jack status changes.
  23. The jack - struct snd_soc_jack
  24. ==============================
  25. This represents a physical jack on the system and is what is visible to
  26. user space. The jack itself is completely passive, it is set up by the
  27. machine driver and updated by jack detection methods.
  28. Jacks are created by the machine driver calling snd_soc_jack_new().
  29. snd_soc_jack_pin
  30. ================
  31. These represent a DAPM pin to update depending on some of the status
  32. bits supported by the jack. Each snd_soc_jack has zero or more of these
  33. which are updated automatically. They are created by the machine driver
  34. and associated with the jack using snd_soc_jack_add_pins(). The status
  35. of the endpoint may configured to be the opposite of the jack status if
  36. required (eg, enabling a built in microphone if a microphone is not
  37. connected via a jack).
  38. Jack detection methods
  39. ======================
  40. Actual jack detection is done by code which is able to monitor some
  41. input to the system and update a jack by calling snd_soc_jack_report(),
  42. specifying a subset of bits to update. The jack detection code should
  43. be set up by the machine driver, taking configuration for the jack to
  44. update and the set of things to report when the jack is connected.
  45. Often this is done based on the status of a GPIO - a handler for this is
  46. provided by the snd_soc_jack_add_gpio() function. Other methods are
  47. also available, for example integrated into CODECs. One example of
  48. CODEC integrated jack detection can be see in the WM8350 driver.
  49. Each jack may have multiple reporting mechanisms, though it will need at
  50. least one to be useful.
  51. Machine drivers
  52. ===============
  53. These are all hooked together by the machine driver depending on the
  54. system hardware. The machine driver will set up the snd_soc_jack and
  55. the list of pins to update then set up one or more jack detection
  56. mechanisms to update that jack based on their current status.