← Documents Documentation/sound/designs/jack-controls.rst GitHub 원문 ↗

Linux 6.18.37 · Sound

ALSA Jack Control

모든 process가 jack 상태를 읽도록 embedded kcontrol을 제공하는 이유와 snd_jack_new()의 initial_kctl·phantom_jack 규칙을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

jack-controls.rst:1-48

모든 process가 jack 상태를 읽도록 embedded kcontrol을 제공하는 이유와 snd_jack_new()의 initial_kctl·phantom_jack 규칙을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ==================
2 ALSA Jack Controls
3 ==================
4
5 Why we need Jack kcontrols
6 ==========================
7
8 ALSA uses kcontrols to export audio controls(switch, volume, Mux, ...)
9 to user space. This means userspace applications like pulseaudio can
10 switch off headphones and switch on speakers when no headphones are
11 plugged in.
12
13 The old ALSA jack code only created input devices for each registered
14 jack. These jack input devices are not readable by userspace devices
15 that run as non root.
16
17 The new jack code creates embedded jack kcontrols for each jack that
18 can be read by any process.
19
20 This can be combined with UCM to allow userspace to route audio more
21 intelligently based on jack insertion or removal events.
22
23 Jack Kcontrol Internals
24 =======================
25
26 Each jack will have a kcontrol list, so that we can create a kcontrol
27 and attach it to the jack, at jack creation stage. We can also add a
28 kcontrol to an existing jack, at anytime when required.
29
30 Those kcontrols will be freed automatically when the Jack is freed.
31
32 How to use jack kcontrols
33 =========================
34
35 In order to keep compatibility, snd_jack_new() has been modified by
36 adding two params:
37
38 initial_kctl
39 if true, create a kcontrol and add it to the jack list.
40 phantom_jack
41 Don't create a input device for phantom jacks.
42
43 HDA jacks can set phantom_jack to true in order to create a phantom
44 jack and set initial_kctl to true to create an initial kcontrol with
45 the correct id.
46
47 ASoC jacks should set initial_kctl as false. The pin name will be
48 assigned as the jack kcontrol name.
49

3. 한국어 전문 번역

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

Jack kcontrol이 필요한 이유

1-22

ALSA는 switch, volume, Mux 같은 audio control을 kcontrol로 사용자 공간에 공개한다. PulseAudio 같은 응용 프로그램은 이를 이용해 headphone이 꽂혀 있지 않을 때 headphone 출력을 끄고 speaker를 켤 수 있다.

옛 ALSA jack code는 등록한 jack마다 input device만 만들었다. 이 jack input device는 root가 아닌 권한으로 실행하는 사용자 공간 process가 읽을 수 없었다.

새 jack code는 jack마다 내장 jack kcontrol을 만들며 모든 process가 읽을 수 있다. UCM과 결합하면 사용자 공간이 jack 삽입·제거 event에 따라 audio route를 더 지능적으로 선택할 수 있다.

Jack event의 사용자 공간 전달
물리 jack 삽입·제거embedded jack kcontrol모든 process가 읽음UCM / PulseAudioheadphone·speaker route 전환

권한 제약이 있던 input device 대신 readable kcontrol을 제공한다.

==================
ALSA Jack Controls
==================

Why we need Jack kcontrols
==========================

ALSA uses kcontrols to export audio controls(switch, volume, Mux, ...)
to user space. This means userspace applications like pulseaudio can
switch off headphones and switch on speakers when no headphones are
plugged in.

The old ALSA jack code only created input devices for each registered
jack. These jack input devices are not readable by userspace devices
that run as non root.

The new jack code creates embedded jack kcontrols for each jack that
can be read by any process.

This can be combined with UCM to allow userspace to route audio more
intelligently based on jack insertion or removal events.

Jack kcontrol 내부 생명주기

23-31

각 jack은 kcontrol list를 가진다. Jack 생성 시 kcontrol을 만들어 list에 연결할 수 있고, 필요하면 기존 jack에도 언제든 kcontrol을 추가할 수 있다. Jack을 해제하면 연결된 kcontrol도 자동으로 해제된다.

Jack kcontrol 생명주기
시점동작
Jack 생성kcontrol 생성 후 jack list에 연결 가능
Jack 사용 중기존 jack에 kcontrol 추가 가능
Jack 해제연결된 kcontrol 자동 해제

생성·추가·해제의 소유 관계다.

Jack Kcontrol Internals
=======================

Each jack will have a kcontrol list, so that we can create a kcontrol
and attach it to the jack, at jack creation stage. We can also add a
kcontrol to an existing jack, at anytime when required.

Those kcontrols will be freed automatically when the Jack is freed.

snd_jack_new() 매개변수와 HDA·ASoC

32-48

호환성을 유지하기 위해 `snd_jack_new()`에 `initial_kctl`과 `phantom_jack` 두 매개변수를 추가했다. `initial_kctl`이 true면 kcontrol을 만들고 jack list에 추가한다. `phantom_jack`이 true면 phantom jack용 input device를 만들지 않는다.

HDA jack은 `phantom_jack=true`로 phantom jack을 만들고 `initial_kctl=true`로 올바른 ID의 초기 kcontrol을 만들 수 있다. ASoC jack은 `initial_kctl=false`를 사용해야 하며 pin 이름이 jack kcontrol 이름으로 지정된다.

snd_jack_new() jack 설정
대상initial_kctlphantom_jack결과
일반true면 생성true면 input device 생략jack list에 kcontrol 연결
HDA phantom jacktruetrue올바른 ID의 초기 kcontrol
ASoC jackfalse구성에 따름pin 이름을 kcontrol 이름으로 사용

HDA와 ASoC의 권장 조합이다.

How to use jack kcontrols
=========================

In order to keep compatibility, snd_jack_new() has been modified by
adding two params:

initial_kctl
  if true, create a kcontrol and add it to the jack list.
phantom_jack
  Don't create a input device for phantom jacks.

HDA jacks can set phantom_jack to true in order to create a phantom
jack and set initial_kctl to true to create an initial kcontrol with
the correct id.

ASoC jacks should set initial_kctl as false. The pin name will be
assigned as the jack kcontrol name.