[Alsa Document]9, jack.txt

本篇来介绍插头——jack,主要是插头插拔状态检测。
基于4.9.123版本内核 Documentation/sound/alsa/soc/jack.txt

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有一个标准API,用于向用户空间表示物理插孔,其内核端可以在include/sound/jack.h中
看到。 ASoC提供此API的一个版本,增加了两个附加功能:

 - 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.
    - 它允许多个插孔检测方法在一个用户可见插孔上一起工作。 在嵌入式系统中,通常在单个
    插孔上存在多个,但由单独的硬件位处理。

 - 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).
    - 与DAPM集成,允许DAPM端点根据检测到的插孔状态自动更新(例如,如果没有耳机,
    则关闭耳机输出)。

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.
这是通过将插孔分成三个一起工作来完成的:插孔本身由struct snd_soc_jack表示,
snd_soc_jack_pins表示要更新的DAPM端点,以及代码块提供插孔报告机制。

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.
例如,系统可以具有带有两个报告机制的立体声耳机插孔,一个用于耳机,一个用于麦克风。 
有些系统在连接耳机时将无法使用扬声器输出,因此在耳机插孔状态发生变化时,需要确保更
新扬声器和耳机。

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

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.
这表示系统上的物理插孔,是用户空间可见的。 Jack本身是完全被动的,它由机器驱动器设置并通过Jack检测方法更新。

Jacks are created by the machine driver calling snd_soc_jack_new().
Jacks 是由机器驱动程序调用snd_soc_jack_new() 创建的。

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).
这些代表DAPM引脚,根据插孔支持的某些状态位进行更新。 每个snd_soc_jack都有零个或多
个自动更新的。 它们由机器驱动程序创建,并使用snd_soc_jack_add_pins()与插孔相关
联。 如果需要,端点的状态可以被配置为与插孔状态相反(例如,如果没有通过插孔连接麦
克风则启用内置麦克风)。

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.
实际jack检测由代码完成,该代码能够监视系统的一些输入并通过调用snd_soc_jack_report()
来更新jack,指定要更新的位子集。jack检测代码应由机器驱动程序设置,配置jack更新
以及连接jack时要报告的事物集。

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.
通常这是基于GPIO的状态完成的 - 这个处理程序由snd_soc_jack_add_gpio() 函数提供。 
其他方法也是可用的,例如集成到CODEC中。 可以在WM8350驱动程序中看到CODEC集成
jack 检测的一个示例。

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.
这些都由机器驱动程序连接在一起,具体取决于系统硬件。 机器驱动程序将设置snd_soc_jack
和要更新的引脚列表,然后设置一个或多个插孔检测机制,以根据其当前状态更新该插孔。

猜你喜欢

转载自blog.csdn.net/wangyijieonline/article/details/88237007