← Documents Documentation/sound/soc/jack.rst GitHub 원문 ↗

Linux 6.18.37 · Sound / ASoC

ASoC jack detection

ASoC가 여러 jack detection mechanism을 하나의 `snd_soc_jack`에 결합하고 `snd_soc_jack_pin`을 통해 DAPM endpoint를 자동 갱신하는 구조를 설명합니다. GPIO·CODEC detector와 machine driver의 설정 책임을 원문 API 좌표에 맞춰 정리합니다.

Source pathDocumentation/sound/soc/jack.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

jack.rst:1-72

ASoC가 여러 jack detection mechanism을 하나의 `snd_soc_jack`에 결합하고 `snd_soc_jack_pin`을 통해 DAPM endpoint를 자동 갱신하는 구조를 설명합니다. GPIO·CODEC detector와 machine driver의 설정 책임을 원문 API 좌표에 맞춰 정리합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

ASoC jack API와 DAPM 연동

1-28

ALSA에는 물리적 jack을 user space에 표현하는 표준 API가 있고 kernel 측 정의는 `include/sound/jack.h`에서 볼 수 있다. ASoC는 이 API에 두 기능을 더한다.

첫째, user에게 하나로 보이는 jack에서 둘 이상의 detection method를 함께 사용할 수 있다. Embedded system에서는 하나의 jack에 여러 감지 기능이 있지만 서로 다른 hardware block이 처리하는 경우가 흔하다.

둘째, DAPM과 통합해 감지된 jack 상태에 따라 DAPM endpoint를 자동으로 갱신한다. Headphone이 없을 때 headphone output을 끄는 것이 예다.

이 구조는 물리 jack을 나타내는 `struct snd_soc_jack`, 갱신할 DAPM endpoint 집합인 `snd_soc_jack_pins`, jack 상태를 보고하는 코드 block 세 요소가 함께 동작한다.

Stereo headset jack은 headphone과 microphone에 서로 다른 reporting mechanism을 둘 수 있다. Headphone 연결 중 speaker를 사용할 수 없는 시스템이라면 headphone 상태가 바뀔 때 speaker와 headphone endpoint를 모두 갱신해야 한다.

ASoC jack 구성요소
요소역할
struct snd_soc_jack물리 jack과 user-visible 상태
snd_soc_jack_pins상태에 따라 갱신할 DAPM endpoints
Reporting mechanismsGPIO·CODEC 등 실제 감지 결과 제공

하나의 user-visible jack 상태를 만드는 세 요소다.

Headset jack 상태 전파
Headphone detectorsnd_soc_jack status
Microphone detectorsnd_soc_jack status
snd_soc_jack statussnd_soc_jack_pinsDAPM Headphone / Speaker / Mic endpoints

여러 감지 결과를 한 jack에 합치고 DAPM endpoint를 갱신한다.

===================
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:

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

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.

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.

struct snd_soc_jack

29-37

`struct snd_soc_jack`은 시스템의 물리 jack을 나타내며 user space에 보이는 객체다. Jack 자체는 완전히 수동적이다. Machine driver가 설정하고 jack detection method가 상태를 갱신한다.

Machine driver는 `snd_soc_jack_new()`를 호출해 jack을 만든다.

snd_soc_jack 수명
단계주체동작
생성Machine driversnd_soc_jack_new()
상태 감지Detection methodHardware input monitor
상태 갱신Detection methodJack report

객체 생성과 상태 갱신의 책임을 구분한다.

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.

Jacks are created by the machine driver calling snd_soc_jack_new().

snd_soc_jack_pin과 endpoint 상태

38-48

`snd_soc_jack_pin`은 jack이 지원하는 상태 bit 일부에 따라 갱신할 DAPM pin을 나타낸다. 각 `snd_soc_jack`에는 0개 이상의 pin이 있고 상태가 자동 갱신된다.

Machine driver가 pin을 만들고 `snd_soc_jack_add_pins()`로 jack에 연결한다. 필요한 경우 endpoint 상태를 jack 상태의 반대로 설정할 수 있다. 예를 들어 jack microphone이 연결되지 않았을 때 내장 microphone을 enable할 수 있다.

Jack pin 상태 mapping
Mapping
NormalHeadphone detected → Headphone endpoint ON
InvertedExternal Mic absent → Built-in Mic endpoint ON

같은 jack status를 정방향 또는 반전해 endpoint에 적용할 수 있다.

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

Jack detection method

49-65

실제 jack detection은 시스템 input을 감시할 수 있는 코드가 수행한다. 이 코드는 `snd_soc_jack_report()`를 호출해 갱신할 bit subset을 지정한다.

Machine driver는 대상 jack과 연결 시 보고할 항목 집합을 detection 코드에 전달해 설정해야 한다. 흔한 방식은 GPIO 상태를 이용하는 것이며 `snd_soc_jack_add_gpio()`가 handler를 제공한다.

CODEC 내장 감지 같은 다른 방식도 가능하다. WM8350 driver가 CODEC 통합 jack detection 예다. 하나의 jack은 여러 reporting mechanism을 가질 수 있지만 유용하려면 적어도 하나는 필요하다.

Jack detection 방식
방식API·예제
GPIOsnd_soc_jack_add_gpio()
CODEC integratedWM8350 driver
Custom input monitorsnd_soc_jack_report()

여러 mechanism이 하나의 snd_soc_jack을 갱신할 수 있다.

Detection report
GPIO / CODEC detectorsnd_soc_jack_report(bit subset)snd_soc_jackAssociated pinsDAPM endpoints

Hardware 상태의 일부 bit만 선택해 jack과 DAPM에 반영한다.

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.

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.

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

Machine driver의 통합 책임

66-72

Machine driver는 시스템 hardware에 맞춰 모든 요소를 연결한다. `snd_soc_jack`과 갱신할 pin list를 만들고, 현재 상태에 따라 jack을 갱신할 하나 이상의 detection mechanism을 설정한다.

Machine driver 설정 순서
snd_soc_jack_new()Create snd_soc_jacksnd_soc_jack_add_pins()Configure one or more detectorsRuntime jack reports

Jack object, DAPM pin, detector를 한 시스템 구성으로 묶는다.

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.