← Documents Documentation/sound/soc/codec-to-codec.rst GitHub 원문 ↗

Linux 6.18.37 · Sound / ASoC

ALSA DAPM용 codec-to-codec DAI 링크 만들기

CPU를 거치지 않고 Bluetooth codec의 오디오를 speaker codec으로 전달하는 ASoC codec-to-codec DAI 링크를 설명합니다. 고정 PCM 제약을 담는 `c2c_params`, DAPM playback·capture route, endpoint 이름 규칙과 `simple-audio-card` 자동 감지 조건을 원문 예제와 함께 정리합니다.

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

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

1. 요약·해설

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

요약·해설

codec-to-codec.rst:1-115

CPU를 거치지 않고 Bluetooth codec의 오디오를 speaker codec으로 전달하는 ASoC codec-to-codec DAI 링크를 설명합니다. 고정 PCM 제약을 담는 `c2c_params`, DAPM playback·capture route, endpoint 이름 규칙과 `simple-audio-card` 자동 감지 조건을 원문 예제와 함께 정리합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ==============================================
2 Creating codec to codec dai link for ALSA dapm
3 ==============================================
4
5 Mostly the flow of audio is always from CPU to codec so your system
6 will look as below:
7 ::
8
9 --------- ---------
10 | | dai | |
11 CPU -------> codec
12 | | | |
13 --------- ---------
14
15 In case your system looks as below:
16 ::
17
18 ---------
19 | |
20 codec-2
21 | |
22 ---------
23 |
24 dai-2
25 |
26 ---------- ---------
27 | | dai-1 | |
28 CPU -------> codec-1
29 | | | |
30 ---------- ---------
31 |
32 dai-3
33 |
34 ---------
35 | |
36 codec-3
37 | |
38 ---------
39
40 Suppose codec-2 is a bluetooth chip and codec-3 is connected to
41 a speaker and you have a below scenario:
42 codec-2 will receive the audio data and the user wants to play that
43 audio through codec-3 without involving the CPU.This
44 aforementioned case is the ideal case when codec to codec
45 connection should be used.
46
47 Your dai_link should appear as below in your machine
48 file:
49 ::
50
51 /*
52 * this pcm stream only supports 24 bit, 2 channel and
53 * 48k sampling rate.
54 */
55 static const struct snd_soc_pcm_stream dsp_codec_params = {
56 .formats = SNDRV_PCM_FMTBIT_S24_LE,
57 .rate_min = 48000,
58 .rate_max = 48000,
59 .channels_min = 2,
60 .channels_max = 2,
61 };
62
63 {
64 .name = "CPU-DSP",
65 .stream_name = "CPU-DSP",
66 .cpu_dai_name = "samsung-i2s.0",
67 .codec_name = "codec-2,
68 .codec_dai_name = "codec-2-dai_name",
69 .platform_name = "samsung-i2s.0",
70 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
71 | SND_SOC_DAIFMT_CBP_CFP,
72 .ignore_suspend = 1,
73 .c2c_params = &dsp_codec_params,
74 .num_c2c_params = 1,
75 },
76 {
77 .name = "DSP-CODEC",
78 .stream_name = "DSP-CODEC",
79 .cpu_dai_name = "wm0010-sdi2",
80 .codec_name = "codec-3,
81 .codec_dai_name = "codec-3-dai_name",
82 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
83 | SND_SOC_DAIFMT_CBP_CFP,
84 .ignore_suspend = 1,
85 .c2c_params = &dsp_codec_params,
86 .num_c2c_params = 1,
87 },
88
89 Above code snippet is motivated from sound/soc/samsung/speyside.c.
90
91 Note the "c2c_params" callback which lets the dapm know that this
92 dai_link is a codec to codec connection.
93
94 In dapm core a route is created between cpu_dai playback widget
95 and codec_dai capture widget for playback path and vice-versa is
96 true for capture path. In order for this aforementioned route to get
97 triggered, DAPM needs to find a valid endpoint which could be either
98 a sink or source widget corresponding to playback and capture path
99 respectively.
100
101 In order to trigger this dai_link widget, a thin codec driver for
102 the speaker amp can be created as demonstrated in wm8727.c file, it
103 sets appropriate constraints for the device even if it needs no control.
104
105 Make sure to name your corresponding cpu and codec playback and capture
106 dai names ending with "Playback" and "Capture" respectively as dapm core
107 will link and power those dais based on the name.
108
109 A dai_link in a "simple-audio-card" will automatically be detected as
110 codec to codec when all DAIs on the link belong to codec components.
111 The dai_link will be initialized with the subset of stream parameters
112 (channels, format, sample rate) supported by all DAIs on the link. Since
113 there is no way to provide these parameters in the device tree, this is
114 mostly useful for communication with simple fixed-function codecs, such
115 as a Bluetooth controller or cellular modem.
116

3. 한국어 전문 번역

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

일반적인 CPU에서 codec으로의 오디오 흐름

1-14

대부분의 시스템에서 오디오는 CPU에서 codec으로 흐른다. 이 일반 구성에서는 CPU DAI가 codec DAI로 데이터를 직접 전달한다.

일반적인 DAI 연결
CPUDAICodec

CPU가 오디오 데이터 경로의 시작점인 기본 구성이다.

==============================================
Creating codec to codec dai link for ALSA dapm
==============================================

Mostly the flow of audio is always from CPU to codec so your system
will look as below:
::

   ---------          ---------
  |         |  dai   |         |
      CPU    ------->    codec
  |         |        |         |
   ---------          ---------

여러 codec 사이의 직접 경로

15-45

보다 복잡한 시스템에서는 CPU가 `dai-1`으로 `codec-1`에 연결되고, `codec-1`이 다시 `dai-2`와 `dai-3`을 통해 각각 `codec-2`, `codec-3`에 연결될 수 있다.

예를 들어 `codec-2`가 Bluetooth chip이고 `codec-3`이 speaker에 연결되어 있다고 하자. `codec-2`가 받은 오디오를 CPU의 개입 없이 `codec-3`으로 재생하려는 경우가 codec-to-codec 연결을 사용하기에 적합한 대표 사례다.

Codec-to-codec 토폴로지
CPUdai-1codec-1dai-2codec-2 / Bluetooth
codec-2 / Bluetoothdai-2codec-1dai-3codec-3 / Speaker

Codec-1이 CPU와 두 codec 사이의 DAI 연결점을 제공한다.

예제 구성요소
구성요소역할
CPU일반 오디오 경로의 처리 주체
codec-1CPU와 codec-2·codec-3을 잇는 중심 component
codec-2오디오를 수신하는 Bluetooth chip
codec-3Speaker에 연결된 출력 codec

원문의 세 codec 예제에서 각 구성요소가 맡는 역할이다.

In case your system looks as below:
::

                       ---------
                      |         |
                        codec-2
                      |         |
                      ---------
                           |
                         dai-2
                           |
   ----------          ---------
  |          |  dai-1 |         |
      CPU     ------->  codec-1
  |          |        |         |
   ----------          ---------
                           |
                         dai-3
                           |
                       ---------
                      |         |
                        codec-3
                      |         |
                       ---------

Suppose codec-2 is a bluetooth chip and codec-3 is connected to
a speaker and you have a below scenario:
codec-2 will receive the audio data and the user wants to play that
audio through codec-3 without involving the CPU.This
aforementioned case is the ideal case when codec to codec
connection should be used.

DAPM route와 endpoint 이름 규칙

91-108

`c2c_params` callback은 이 `dai_link`가 codec-to-codec 연결임을 DAPM에 알린다. DAPM core는 playback 경로에서 `cpu_dai` playback widget과 `codec_dai` capture widget 사이에 route를 만들고, capture 경로에서는 반대 방향의 route를 만든다.

이 route가 활성화되려면 DAPM이 유효한 endpoint를 찾아야 한다. Playback 경로에는 sink widget, capture 경로에는 source widget이 각각 필요하다.

Speaker amplifier처럼 별도 control이 필요 없는 장치도 `wm8727.c` 예제와 같은 얇은 codec driver를 만들어 적절한 제약을 설정하면 `dai_link` widget을 활성화할 수 있다.

DAPM core는 이름을 기준으로 DAI를 연결하고 전원을 관리하므로, 대응하는 CPU와 codec의 playback DAI 이름은 `Playback`, capture DAI 이름은 `Capture`로 끝나야 한다.

DAPM widget 연결
cpu_dai Playback widgetPlayback routecodec_dai Capture widgetSink endpoint
codec_dai Playback widgetCapture routecpu_dai Capture widgetSource endpoint

Playback과 capture에서 cpu_dai와 codec_dai의 widget 역할이 서로 바뀐다.

Note the "c2c_params" callback which lets the dapm know that this
dai_link is a codec to codec connection.

In dapm core a route is created between cpu_dai playback widget
and codec_dai capture widget for playback path and vice-versa is
true for capture path. In order for this aforementioned route to get
triggered, DAPM needs to find a valid endpoint which could be either
a sink or source widget corresponding to playback and capture path
respectively.

In order to trigger this dai_link widget, a thin codec driver for
the speaker amp can be created as demonstrated in wm8727.c file, it
sets appropriate constraints for the device even if it needs no control.

Make sure to name your corresponding cpu and codec playback and capture
dai names ending with "Playback" and "Capture" respectively as dapm core
will link and power those dais based on the name.

simple-audio-card의 자동 감지

109-115

`simple-audio-card`의 한 `dai_link`에 속한 모든 DAI가 codec component 소속이면 해당 링크는 codec-to-codec로 자동 감지된다.

이 링크는 모든 DAI가 공통으로 지원하는 channel, format, sample rate의 교집합으로 초기화된다. Device tree에서 이 parameter를 직접 제공할 방법이 없으므로, 이 기능은 Bluetooth controller나 cellular modem처럼 단순한 고정 기능 codec과 통신할 때 주로 유용하다.

자동 초기화 대상
Stream parameter초기화 기준
Channels모든 DAI의 공통 channel 범위
Format모든 DAI의 공통 PCM format
Sample rate모든 DAI의 공통 rate

링크의 모든 DAI가 공통 지원하는 부분만 선택된다.

A dai_link in a "simple-audio-card" will automatically be detected as
codec to codec when all DAIs on the link belong to codec components.
The dai_link will be initialized with the subset of stream parameters
(channels, format, sample rate) supported by all DAIs on the link. Since
there is no way to provide these parameters in the device tree, this is
mostly useful for communication with simple fixed-function codecs, such
as a Bluetooth controller or cellular modem.