요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===================
ASoC Machine Driver
===================
The ASoC machine (or board) driver is the code that glues together all the
component drivers (e.g. codecs, platforms and DAIs). It also describes the
relationships between each component which include audio paths, GPIOs,
interrupts, clocking, jacks and voltage regulators.
The machine driver can contain codec and platform specific code. It registers
the audio subsystem with the kernel as a platform device and is represented by
the following struct:-
::
/* SoC machine */
struct snd_soc_card {
char *name;
...
int (*probe)(struct platform_device *pdev);
int (*remove)(struct platform_device *pdev);
/* the pre and post PM functions are used to do any PM work before and
* after the codec and DAIs do any PM work. */
int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
int (*resume_pre)(struct platform_device *pdev);
int (*resume_post)(struct platform_device *pdev);
...
/* CPU <--> Codec DAI links */
struct snd_soc_dai_link *dai_link;
int num_links;
...
};
probe()/remove()
----------------
probe/remove are optional. Do any machine specific probe here.
suspend()/resume()
------------------
The machine driver has pre and post versions of suspend and resume to take care
of any machine audio tasks that have to be done before or after the codec, DAIs
and DMA is suspended and resumed. Optional.
Machine DAI Configuration
-------------------------
The machine DAI configuration glues all the codec and CPU DAIs together. It can
also be used to set up the DAI system clock and for any machine related DAI
initialisation e.g. the machine audio map can be connected to the codec audio
map, unconnected codec pins can be set as such.
struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
::
/* corgi digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link corgi_dai = {
.name = "WM8731",
.stream_name = "WM8731",
.cpu_dai_name = "pxa-is2-dai",
.codec_dai_name = "wm8731-hifi",
.platform_name = "pxa-pcm-audio",
.codec_name = "wm8713-codec.0-001a",
.init = corgi_wm8731_init,
.ops = &corgi_ops,
};
In the above struct, dai’s are registered using names but you can pass
either dai name or device tree node but not both. Also, names used here
for cpu/codec/platform dais should be globally unique.
Additionally below example macro can be used to register cpu, codec and
platform dai::
SND_SOC_DAILINK_DEFS(wm2200_cpu_dsp,
DAILINK_COMP_ARRAY(COMP_CPU("samsung-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("spi0.0", "wm0010-sdi1")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("samsung-i2s.0")));
struct snd_soc_card then sets up the machine with its DAIs. e.g.
::
/* corgi audio machine driver */
static struct snd_soc_card snd_soc_corgi = {
.name = "Corgi",
.dai_link = &corgi_dai,
.num_links = 1,
};
Following this, ``devm_snd_soc_register_card`` can be used to register
the sound card. During the registration, the individual components
such as the codec, CPU, and platform are probed. If all these components
are successfully probed, the sound card gets registered.
Machine Power Map
-----------------
The machine driver can optionally extend the codec power map and to become an
audio power map of the audio subsystem. This allows for automatic power up/down
of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
sockets in the machine init function.
Machine Controls
----------------
Machine specific audio mixer controls can be added in the DAI init function.
Clocking Controls
-----------------
As previously noted, clock configuration is handled within the machine driver.
For details on the clock APIs that the machine driver can utilize for
setup, please refer to Documentation/sound/soc/clocking.rst. However, the
callback needs to be registered by the CPU/Codec/Platform drivers to configure
the clocks that is needed for the corresponding device operation.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Machine driver와 snd_soc_card
1-39ASoC machine 또는 board driver는 codec, platform, DAI 같은 모든 component driver를 결합하는 코드다. Audio path, GPIO, interrupt, clocking, jack, voltage regulator를 포함한 component 사이 관계도 기술한다.
Machine driver에는 codec·platform 종속 코드를 넣을 수 있다. Audio subsystem을 platform device로 kernel에 등록하며 `struct snd_soc_card`로 표현한다.
`snd_soc_card`에는 card 이름, 선택적 `probe`·`remove`, codec·DAI의 PM 작업 전후에 실행되는 `suspend_pre`, `suspend_post`, `resume_pre`, `resume_post`, CPU↔Codec DAI link array와 `num_links`가 포함된다.
원문 구조체에서 machine lifecycle과 DAI 구성을 담당하는 field다.
Board의 실제 배선과 정책을 component driver 위에 구성한다.
===================
ASoC Machine Driver
===================
The ASoC machine (or board) driver is the code that glues together all the
component drivers (e.g. codecs, platforms and DAIs). It also describes the
relationships between each component which include audio paths, GPIOs,
interrupts, clocking, jacks and voltage regulators.
The machine driver can contain codec and platform specific code. It registers
the audio subsystem with the kernel as a platform device and is represented by
the following struct:-
::
/* SoC machine */
struct snd_soc_card {
char *name;
...
int (*probe)(struct platform_device *pdev);
int (*remove)(struct platform_device *pdev);
/* the pre and post PM functions are used to do any PM work before and
* after the codec and DAIs do any PM work. */
int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
int (*resume_pre)(struct platform_device *pdev);
int (*resume_post)(struct platform_device *pdev);
...
/* CPU <--> Codec DAI links */
struct snd_soc_dai_link *dai_link;
int num_links;
...
};
probe()와 remove()
40-44`probe()`와 `remove()`는 선택 사항이다. Machine별 probe와 teardown이 필요하면 이 callback에서 수행한다.
선택적 card 초기화와 해제 지점이다.
probe()/remove()
----------------
probe/remove are optional. Do any machine specific probe here.
suspend()와 resume()
45-51Machine driver는 suspend와 resume의 pre·post 버전을 제공할 수 있다. Codec, DAI, DMA가 suspend·resume되기 전이나 후에 필요한 machine audio 작업을 처리한다. 이 callback도 선택 사항이다.
Machine 작업을 component PM 경계 앞뒤에 배치한다.
suspend()/resume()
------------------
The machine driver has pre and post versions of suspend and resume to take care
of any machine audio tasks that have to be done before or after the codec, DAIs
and DMA is suspended and resumed. Optional.
Machine DAI 설정과 card 등록
52-100Machine DAI 설정은 codec DAI와 CPU DAI를 결합한다. DAI system clock을 설정하고, machine audio map을 codec audio map에 연결하거나 연결되지 않은 codec pin을 표시하는 machine별 DAI 초기화에도 사용할 수 있다.
각 DAI는 `struct snd_soc_dai_link`로 설정한다. Corgi 예제는 CPU DAI `pxa-is2-dai`, codec DAI `wm8731-hifi`, platform `pxa-pcm-audio`, codec device `wm8713-codec.0-001a`를 연결하고 `corgi_wm8731_init`, `corgi_ops`를 지정한다. 원문의 `wm8713` 표기는 그대로 보존한다.
DAI를 이름으로 등록할 때 DAI 이름과 Device Tree node 중 하나만 전달할 수 있고 둘을 함께 사용할 수 없다. CPU·codec·platform DAI에 쓰는 이름은 전역에서 고유해야 한다.
`SND_SOC_DAILINK_DEFS` macro는 CPU `samsung-i2s.0`, codec device `spi0.0`의 DAI `wm0010-sdi1`, platform `samsung-i2s.0`을 component array로 선언한다.
그 다음 `struct snd_soc_card snd_soc_corgi`가 card 이름 `Corgi`, `corgi_dai` pointer, link 수 1을 설정한다. `devm_snd_soc_register_card()`로 card를 등록하면 codec, CPU, platform component가 각각 probe되고, 모두 성공해야 sound card 등록이 완료된다.
Machine DAI link가 결합하는 component와 callback이다.
이름 기반과 firmware node 기반 등록의 제약이다.
DAI link 선언에서 component probe와 card 등록 완료까지의 순서다.
Machine DAI Configuration
-------------------------
The machine DAI configuration glues all the codec and CPU DAIs together. It can
also be used to set up the DAI system clock and for any machine related DAI
initialisation e.g. the machine audio map can be connected to the codec audio
map, unconnected codec pins can be set as such.
struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
::
/* corgi digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link corgi_dai = {
.name = "WM8731",
.stream_name = "WM8731",
.cpu_dai_name = "pxa-is2-dai",
.codec_dai_name = "wm8731-hifi",
.platform_name = "pxa-pcm-audio",
.codec_name = "wm8713-codec.0-001a",
.init = corgi_wm8731_init,
.ops = &corgi_ops,
};
In the above struct, dai’s are registered using names but you can pass
either dai name or device tree node but not both. Also, names used here
for cpu/codec/platform dais should be globally unique.
Additionally below example macro can be used to register cpu, codec and
platform dai::
SND_SOC_DAILINK_DEFS(wm2200_cpu_dsp,
DAILINK_COMP_ARRAY(COMP_CPU("samsung-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("spi0.0", "wm0010-sdi1")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("samsung-i2s.0")));
struct snd_soc_card then sets up the machine with its DAIs. e.g.
::
/* corgi audio machine driver */
static struct snd_soc_card snd_soc_corgi = {
.name = "Corgi",
.dai_link = &corgi_dai,
.num_links = 1,
};
Following this, ``devm_snd_soc_register_card`` can be used to register
the sound card. During the registration, the individual components
such as the codec, CPU, and platform are probed. If all these components
are successfully probed, the sound card gets registered.
Machine power map
101-109Machine driver는 선택적으로 codec power map을 확장해 audio subsystem 전체 power map으로 만들 수 있다. 그러면 speaker·headphone amplifier 같은 board component를 자동으로 power up·down할 수 있다.
Machine init function에서 codec pin을 machine의 jack socket에 연결할 수 있다.
Codec graph를 board-level amplifier와 jack까지 연결한다.
Machine Power Map
-----------------
The machine driver can optionally extend the codec power map and to become an
audio power map of the audio subsystem. This allows for automatic power up/down
of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
sockets in the machine init function.
Machine audio control
110-115Machine별 audio mixer control은 DAI init function에서 추가할 수 있다.
Board-specific mixer control의 등록 지점이다.
Machine Controls
----------------
Machine specific audio mixer controls can be added in the DAI init function.
Clocking control
116-123Clock configuration은 machine driver가 담당한다. Machine driver가 사용할 수 있는 clock API의 자세한 내용은 `Documentation/sound/soc/clocking.rst`를 참조한다.
다만 실제 장치 동작에 필요한 clock을 설정하려면 CPU·Codec·Platform driver가 대응 callback을 등록해야 한다.
Machine policy가 각 component driver callback을 통해 hardware clock을 구성한다.
Clocking Controls
-----------------
As previously noted, clock configuration is handled within the machine driver.
For details on the clock APIs that the machine driver can utilize for
setup, please refer to Documentation/sound/soc/clocking.rst. However, the
callback needs to be registered by the CPU/Codec/Platform drivers to configure
the clocks that is needed for the corresponding device operation.
요약·해설
machine.rst:1-123ASoC machine driver가 CPU·codec·platform DAI와 board의 GPIO·IRQ·clock·jack·regulator 관계를 `snd_soc_card`와 `snd_soc_dai_link`로 결합하는 방법을 설명합니다. PM callback, 이름·Device Tree 규칙, card 등록, power map과 clock 책임을 원문 코드 좌표에 맞춰 정리합니다.