73 lines · plain
1===================2ASoC jack detection3===================4 5ALSA has a standard API for representing physical jacks to user space,6the kernel side of which can be seen in include/sound/jack.h. ASoC7provides a version of this API adding two additional features:8 9 - It allows more than one jack detection method to work together on one10 user visible jack. In embedded systems it is common for multiple11 to be present on a single jack but handled by separate bits of12 hardware.13 14 - Integration with DAPM, allowing DAPM endpoints to be updated15 automatically based on the detected jack status (eg, turning off the16 headphone outputs if no headphones are present).17 18This is done by splitting the jacks up into three things working19together: the jack itself represented by a struct snd_soc_jack, sets of20snd_soc_jack_pins representing DAPM endpoints to update and blocks of21code providing jack reporting mechanisms.22 23For example, a system may have a stereo headset jack with two reporting24mechanisms, one for the headphone and one for the microphone. Some25systems won't be able to use their speaker output while a headphone is26connected and so will want to make sure to update both speaker and27headphone when the headphone jack status changes.28 29The jack - struct snd_soc_jack30==============================31 32This represents a physical jack on the system and is what is visible to33user space. The jack itself is completely passive, it is set up by the34machine driver and updated by jack detection methods.35 36Jacks are created by the machine driver calling snd_soc_jack_new().37 38snd_soc_jack_pin39================40 41These represent a DAPM pin to update depending on some of the status42bits supported by the jack. Each snd_soc_jack has zero or more of these43which are updated automatically. They are created by the machine driver44and associated with the jack using snd_soc_jack_add_pins(). The status45of the endpoint may configured to be the opposite of the jack status if46required (eg, enabling a built in microphone if a microphone is not47connected via a jack).48 49Jack detection methods50======================51 52Actual jack detection is done by code which is able to monitor some53input to the system and update a jack by calling snd_soc_jack_report(),54specifying a subset of bits to update. The jack detection code should55be set up by the machine driver, taking configuration for the jack to56update and the set of things to report when the jack is connected.57 58Often this is done based on the status of a GPIO - a handler for this is59provided by the snd_soc_jack_add_gpio() function. Other methods are60also available, for example integrated into CODECs. One example of61CODEC integrated jack detection can be see in the WM8350 driver.62 63Each jack may have multiple reporting mechanisms, though it will need at64least one to be useful.65 66Machine drivers67===============68 69These are all hooked together by the machine driver depending on the70system hardware. The machine driver will set up the snd_soc_jack and71the list of pins to update then set up one or more jack detection72mechanisms to update that jack based on their current status.73