Linux audio alsa-uda134x driver document reading six (socket)

Reprint address: http://blog.chinaunix.net/uid-22917448-id-1765507.html

ASoC jack detection

ASoC Jack Detection
===================

ALSA has a standard API for representing physical jacks to user space,
the kernel side of which can be seen in include/sound/jack. h. ASoC
provides a version of this API adding two additional features:
ALSA provides a standard API to provide physical sockets to user space, and the API at the kernel level can be found in include/sound/jack.h.ASoC provides this API One version adds two features :

- It allows more than one jack detection method to work together on one
   user visible jack. In embedded systems it is common for multiple
   to be present on a single jack but handled by separate bits of
   hardware.
- It can allow more than one socket detection method to work together on a user-visible socket. In embedded systems , it is common for multiplexing of different hardware to be represented as a single socket.

- Integration with DAPM, allowing DAPM endpoints to be updated automatically based on the detected
   jack status (eg, turning off the
   headphone outputs if no headphones are present). For example, if the headphone output is turned off, the headphone will not be displayed). This is done by splitting the jacks up into three things working together: the jack itself represented by a struct snd_soc_jack, sets of snd_soc_jack_pins representing DAPM endpoints to update and blocks of code providing jack reporting mechanisms. We work together by splitting the jacks into three This is done by part of the socket itself: the socket itself is represented as a snd_soc_jack structure , the sets of snd_soc_jack_pins representing the SAPM endpoints are updated and there is a whole lot of code that provides the socket reporting mechanism. For example, a system may have a stereo headset jack with two reporting









mechanisms, one for the headphone and one for the microphone. Some
systems won't be able to use their speaker output while a headphone is
connected and so will want to make sure to update both speaker and
headphone when the headphone jack status changes.
For example , a system can have a stereo headset jack with two reporting mechanisms. One earphone and one microphone. Some systems don't allow speakers to sound when headphones are connected, so be sure to update both the speakers and headphones when the status of the headphone jack changes.

The jack - struct snd_soc_jack
socket-snd_soc_jack struct
===============================

This represents a physical jack on the system and is what is visible to
user space. The jack itself is completely passive, it is set up by the
machine driver and updated by jack detection methods.
This represents a physical jack of the system and is visible to user space. The socket itself is completely passive, it is activated by the machine driver and updated by the socket detection method.


Jacks are created by the machine driver calling snd_soc_jack_new().
机器驱动调用snd_soc_jack_new()时插口建立。

snd_soc_jack_pin
snd_soc_jack_pin结构体
================

These represent a DAPM pin to update depending on some of the status
bits supported by the jack.  Each snd_soc_jack has zero or more of these
which are updated automatically.  They are created by the machine driver
and associated with the jack using snd_soc_jack_add_pins().  The status
of the endpoint may configured to be the opposite of the jack status if
required (eg, enabling a built in microphone if a microphone is not
connected via a jack).
This means that the DAPM pins are updated according to some status bits supported by the socket. Each snd_soc_jack has 0 or more snd_soc_jack_pins that can be updated automatically. They are created by the machine driver and are associated with the jacks via the snd_soc_jack_add_pins() function . If desired, the endpoint status bits can be set to the opposite of the jack status (eg to enable a built-in headset when no headset is plugged in).


Jack detection methods
=====================
Actual

jack detection is done by code which is able to monitor some
input to the system and update a jack by calling snd_soc_jack_report(),
specifying a subset of bits to update. The jack detection code should
be set up by the machine driver, taking configuration for the jack to
update and the set of things to report when the jack is connected.
The actual jack Probing is done by code. These codes can indicate some system input and update the jack by calling snd_soc_jack_report() to update the state of some subset of bits. The socket detection code should be set by the machine driver and report a series of things when the socket is configured to update and when the socket is connected.

Often this is done based on the status of a GPIO - a handler for this is
provided by the snd_soc_jack_add_gpio() function. Other methods are
also available, for example integrated into CODECs. One example of
CODEC integrated jack detection can be see in the WM8350 driver.
Usually, these are done based on the state of a GPIO - its handle is provided by the snd_soc_jack_add_gpio() function. There are other methods available, such as those integrated in the decoder. An example of the decoder's integrated socket detection can be seen in the wm8350 driver.

Each jack may have multiple reporting mechanisms, though it will need at
least one to be useful
.

Machine drivers
==============
These

are all hooked together by the machine driver depending on the
system hardware. The machine driver will set up the snd_soc_jack and
the list of pins to update then set up one or more jack detection
mechanisms to update that jack based on their current status.
It all hangs together by the machine driver depending on the system hardware. The machine driver sets the snd_soc_jack and the list of pins to update, and then initiates an update of one or more socket detection mechanisms, depending on their current state.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324651537&siteId=291194637