天天看點

linux音頻alsa-uda134x驅動文檔閱讀之六(插口)

轉自:http://blog.chinaunix.net/uid-22917448-id-1765507.html

ASoC jack detection

ASoC插口探測

===================

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用以向使用者空間提供實體插口,核心層面上的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.

我們通過把插口分為三個協同工作的部分而完成這一工作:插口本身表示為一個snd_soc_jack結構,幾組snd_soc_jack_pins表示SAPM端點來更新而且有一大堆代碼提供插口報告機制。

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

插口-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.

這表示系統的一個實體插口,而且對使用者空間可見。插口本身是完全被動的,它由機器驅動啟動,由插口探測方法更新。

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).

這代表DAPM引腳根據插口支援的一些狀态位進行更新。每個snd_soc_jack有0個或更多的snd_soc_jack_pin可以自動更新。 它們由機器驅動建立并且通過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.

實際上的插口探測是由代碼完成的。這些代碼可以訓示一些系統輸入而且通過調過snd_soc_jack_report()來更新插口,使一些位的子集更新狀态。插口探測代碼應由機器驅動設定,配置插口更新和插口連接配接時報告一系列的事情。

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()函數提供的。還有一些别的方法可用,如內建在解碼器裡的。解碼器內建的插口探測的一個例子可以在wm8350驅動中見到。

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和要更新的引腳清單,然後啟動一個或多個插口探測機制更新,這些插口是依賴于它們目前的狀态的。

君子注:

您現在所閱讀的,是君子閱讀Linux音頻SoC驅動時,寫下的文檔譯文。

君子寫些譯文,一方面是作為自己的筆記,幫助記憶,另一方面也希望能對他人有所幫助。

如果您能于君子的譯文中有所收獲,則吾心甚慰。

所有這幾個文檔原文,是見于linux-2.6.30/Documentation/sound/alsa/soc目錄下的全部内容。

由于君子對音頻方面的内容了解也不多,很多地方我自己也不了解,隻是照着原文生硬的譯出來。

其中錯誤願來來訪者之賓不吝指正。

張君再拜.

繼續閱讀