← Documents Documentation/sound/designs/tracepoints.rst GitHub 원문 ↗

Linux 6.18.37 · Sound

ALSA의 Tracepoint

ALSA PCM core의 여섯 tracepoint, 활성화 configuration, snd_pcm_hw_params 협상과 field, runtime constraint rule, hw_mask_param·hw_interval_param 출력 형식을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

tracepoints.rst:1-172

ALSA PCM core의 여섯 tracepoint, 활성화 configuration, snd_pcm_hw_params 협상과 field, runtime constraint rule, hw_mask_param·hw_interval_param 출력 형식을 설명합니다.

핵심은 `HW_REFINE`이 가능한 집합을 좁히고 `HW_PARAMS`가 값을 확정한다는 점, driver가 `open`에서 capability와 constraint를 등록한 뒤 `hw_params`에서는 결과를 바꾸지 않고 참조만 해야 한다는 점입니다.

빠른 참조
관찰 대상주요 event 또는 field
PCM buffer 위치·XRUNhwptr, applptr, xrun, hw_ptr_error
Format·access mask 협상hw_mask_param
Rate·period·buffer 범위 협상hw_interval_param
변경 허용·실제 변경rmask, cmask
Hardware capabilityinfo, snd_pcm_hardware

문제 상황별로 볼 tracepoint와 field입니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ===================
2 Tracepoints in ALSA
3 ===================
4
5 2017/07/02
6 Takasahi Sakamoto
7
8 Tracepoints in ALSA PCM core
9 ============================
10
11 ALSA PCM core registers ``snd_pcm`` subsystem to kernel tracepoint system.
12 This subsystem includes two categories of tracepoints; for state of PCM buffer
13 and for processing of PCM hardware parameters. These tracepoints are available
14 when corresponding kernel configurations are enabled. When ``CONFIG_SND_DEBUG``
15 is enabled, the latter tracepoints are available. When additional
16 ``SND_PCM_XRUN_DEBUG`` is enabled too, the former trace points are enabled.
17
18 Tracepoints for state of PCM buffer
19 ------------------------------------
20
21 This category includes four tracepoints; ``hwptr``, ``applptr``, ``xrun`` and
22 ``hw_ptr_error``.
23
24 Tracepoints for processing of PCM hardware parameters
25 -----------------------------------------------------
26
27 This category includes two tracepoints; ``hw_mask_param`` and
28 ``hw_interval_param``.
29
30 In a design of ALSA PCM core, data transmission is abstracted as PCM substream.
31 Applications manage PCM substream to maintain data transmission for PCM frames.
32 Before starting the data transmission, applications need to configure PCM
33 substream. In this procedure, PCM hardware parameters are decided by
34 interaction between applications and ALSA PCM core. Once decided, runtime of
35 the PCM substream keeps the parameters.
36
37 The parameters are described in struct snd_pcm_hw_params. This
38 structure includes several types of parameters. Applications set preferable
39 value to these parameters, then execute ioctl(2) with SNDRV_PCM_IOCTL_HW_REFINE
40 or SNDRV_PCM_IOCTL_HW_PARAMS. The former is used just for refining available
41 set of parameters. The latter is used for an actual decision of the parameters.
42
43 The struct snd_pcm_hw_params structure has below members:
44
45 ``flags``
46 Configurable. ALSA PCM core and some drivers handle this flag to select
47 convenient parameters or change their behaviour.
48 ``masks``
49 Configurable. This type of parameter is described in
50 struct snd_mask and represent mask values. As of PCM protocol
51 v2.0.13, three types are defined.
52
53 - SNDRV_PCM_HW_PARAM_ACCESS
54 - SNDRV_PCM_HW_PARAM_FORMAT
55 - SNDRV_PCM_HW_PARAM_SUBFORMAT
56 ``intervals``
57 Configurable. This type of parameter is described in
58 struct snd_interval and represent values with a range. As of
59 PCM protocol v2.0.13, twelve types are defined.
60
61 - SNDRV_PCM_HW_PARAM_SAMPLE_BITS
62 - SNDRV_PCM_HW_PARAM_FRAME_BITS
63 - SNDRV_PCM_HW_PARAM_CHANNELS
64 - SNDRV_PCM_HW_PARAM_RATE
65 - SNDRV_PCM_HW_PARAM_PERIOD_TIME
66 - SNDRV_PCM_HW_PARAM_PERIOD_SIZE
67 - SNDRV_PCM_HW_PARAM_PERIOD_BYTES
68 - SNDRV_PCM_HW_PARAM_PERIODS
69 - SNDRV_PCM_HW_PARAM_BUFFER_TIME
70 - SNDRV_PCM_HW_PARAM_BUFFER_SIZE
71 - SNDRV_PCM_HW_PARAM_BUFFER_BYTES
72 - SNDRV_PCM_HW_PARAM_TICK_TIME
73 ``rmask``
74 Configurable. This is evaluated at ioctl(2) with
75 SNDRV_PCM_IOCTL_HW_REFINE only. Applications can select which
76 mask/interval parameter can be changed by ALSA PCM core. For
77 SNDRV_PCM_IOCTL_HW_PARAMS, this mask is ignored and all of parameters
78 are going to be changed.
79 ``cmask``
80 Read-only. After returning from ioctl(2), buffer in user space for
81 struct snd_pcm_hw_params includes result of each operation.
82 This mask represents which mask/interval parameter is actually changed.
83 ``info``
84 Read-only. This represents hardware/driver capabilities as bit flags
85 with SNDRV_PCM_INFO_XXX. Typically, applications execute ioctl(2) with
86 SNDRV_PCM_IOCTL_HW_REFINE to retrieve this flag, then decide candidates
87 of parameters and execute ioctl(2) with SNDRV_PCM_IOCTL_HW_PARAMS to
88 configure PCM substream.
89 ``msbits``
90 Read-only. This value represents available bit width in MSB side of
91 a PCM sample. When a parameter of SNDRV_PCM_HW_PARAM_SAMPLE_BITS was
92 decided as a fixed number, this value is also calculated according to
93 it. Else, zero. But this behaviour depends on implementations in driver
94 side.
95 ``rate_num``
96 Read-only. This value represents numerator of sampling rate in fraction
97 notation. Basically, when a parameter of SNDRV_PCM_HW_PARAM_RATE was
98 decided as a single value, this value is also calculated according to
99 it. Else, zero. But this behaviour depends on implementations in driver
100 side.
101 ``rate_den``
102 Read-only. This value represents denominator of sampling rate in
103 fraction notation. Basically, when a parameter of
104 SNDRV_PCM_HW_PARAM_RATE was decided as a single value, this value is
105 also calculated according to it. Else, zero. But this behaviour depends
106 on implementations in driver side.
107 ``fifo_size``
108 Read-only. This value represents the size of FIFO in serial sound
109 interface of hardware. Basically, each driver can assigns a proper
110 value to this parameter but some drivers intentionally set zero with
111 a care of hardware design or data transmission protocol.
112
113 ALSA PCM core handles buffer of struct snd_pcm_hw_params when
114 applications execute ioctl(2) with SNDRV_PCM_HW_REFINE or SNDRV_PCM_HW_PARAMS.
115 Parameters in the buffer are changed according to
116 struct snd_pcm_hardware and rules of constraints in the runtime. The
117 structure describes capabilities of handled hardware. The rules describes
118 dependencies on which a parameter is decided according to several parameters.
119 A rule has a callback function, and drivers can register arbitrary functions
120 to compute the target parameter. ALSA PCM core registers some rules to the
121 runtime as a default.
122
123 Each driver can join in the interaction as long as it prepared for two stuffs
124 in a callback of struct snd_pcm_ops.open.
125
126 1. In the callback, drivers are expected to change a member of
127 struct snd_pcm_hardware type in the runtime, according to
128 capacities of corresponding hardware.
129 2. In the same callback, drivers are also expected to register additional rules
130 of constraints into the runtime when several parameters have dependencies
131 due to hardware design.
132
133 The driver can refers to result of the interaction in a callback of
134 struct snd_pcm_ops.hw_params, however it should not change the
135 content.
136
137 Tracepoints in this category are designed to trace changes of the
138 mask/interval parameters. When ALSA PCM core changes them, ``hw_mask_param`` or
139 ``hw_interval_param`` event is probed according to type of the changed parameter.
140
141 ALSA PCM core also has a pretty print format for each of the tracepoints. Below
142 is an example for ``hw_mask_param``.
143
144 ::
145
146 hw_mask_param: pcmC0D0p 001/023 FORMAT 00000000000000000000001000000044 00000000000000000000001000000044
147
148
149 Below is an example for ``hw_interval_param``.
150
151 ::
152
153 hw_interval_param: pcmC0D0p 000/023 BUFFER_SIZE 0 0 [0 4294967295] 0 1 [0 4294967295]
154
155 The first three fields are common. They represent name of ALSA PCM character
156 device, rules of constraint and name of the changed parameter, in order. The
157 field for rules of constraint consists of two sub-fields; index of applied rule
158 and total number of rules added to the runtime. As an exception, the index 000
159 means that the parameter is changed by ALSA PCM core, regardless of the rules.
160
161 The rest of field represent state of the parameter before/after changing. These
162 fields are different according to type of the parameter. For parameters of mask
163 type, the fields represent hexadecimal dump of content of the parameter. For
164 parameters of interval type, the fields represent values of each member of
165 ``empty``, ``integer``, ``openmin``, ``min``, ``max``, ``openmax`` in
166 struct snd_interval in this order.
167
168 Tracepoints in drivers
169 ======================
170
171 Some drivers have tracepoints for developers' convenience. For them, please
172 refer to each documentation or implementation.
173

3. 한국어 전문 번역

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

ALSA PCM core tracepoint와 활성화 조건

1-29

이 문서는 2017년 7월 2일 Takasahi Sakamoto가 작성한 ALSA tracepoint 설명입니다. `Documentation/sound/designs/tracepoints.rst`의 PCM core tracepoint를 buffer 상태와 PCM hardware parameter 처리라는 두 범주로 나눕니다.

ALSA PCM core는 kernel tracepoint system에 `snd_pcm` subsystem을 등록합니다. PCM hardware parameter 처리 tracepoint는 `CONFIG_SND_DEBUG`를 켰을 때 사용할 수 있습니다. PCM buffer 상태 tracepoint는 여기에 `SND_PCM_XRUN_DEBUG`까지 추가로 켜야 사용할 수 있습니다.

PCM buffer 상태 범주에는 `hwptr`, `applptr`, `xrun`, `hw_ptr_error` 네 event가 있습니다. PCM hardware parameter 처리 범주에는 `hw_mask_param`, `hw_interval_param` 두 event가 있습니다.

Tracepoint 활성화 조건
범주Event필요한 설정
PCM buffer 상태hwptr, applptr, xrun, hw_ptr_errorCONFIG_SND_DEBUG + SND_PCM_XRUN_DEBUG
PCM hardware parameter 처리hw_mask_param, hw_interval_paramCONFIG_SND_DEBUG

두 범주와 필요한 kernel configuration을 구분합니다.

Tracepoint 가용성 판단
ALSA PCM core가 snd_pcm trace subsystem 등록CONFIG_SND_DEBUG 확인hw_mask_param과 hw_interval_param 활성화SND_PCM_XRUN_DEBUG 추가 확인hwptr, applptr, xrun, hw_ptr_error 활성화

Build configuration에서 event 범주가 열리는 순서입니다.

===================
Tracepoints in ALSA
===================

2017/07/02
Takasahi Sakamoto

Tracepoints in ALSA PCM core
============================

ALSA PCM core registers ``snd_pcm`` subsystem to kernel tracepoint system.
This subsystem includes two categories of tracepoints; for state of PCM buffer
and for processing of PCM hardware parameters. These tracepoints are available
when corresponding kernel configurations are enabled. When ``CONFIG_SND_DEBUG``
is enabled, the latter tracepoints are available. When additional
``SND_PCM_XRUN_DEBUG`` is enabled too, the former trace points are enabled.

Tracepoints for state of PCM buffer
------------------------------------

This category includes four tracepoints; ``hwptr``, ``applptr``, ``xrun`` and
``hw_ptr_error``.

Tracepoints for processing of PCM hardware parameters
-----------------------------------------------------

This category includes two tracepoints; ``hw_mask_param`` and
``hw_interval_param``.

PCM hardware parameter 협상

30-42

ALSA PCM core 설계에서 data 전송은 PCM substream으로 추상화됩니다. Application은 PCM frame 전송을 유지하기 위해 substream을 관리하며, 전송을 시작하기 전에 substream을 구성해야 합니다. 이 과정에서 application과 ALSA PCM core가 상호작용해 hardware parameter를 결정하고, 결정된 값은 substream runtime에 보관됩니다.

Parameter는 `struct snd_pcm_hw_params`에 표현됩니다. Application은 선호 값을 넣은 뒤 `SNDRV_PCM_IOCTL_HW_REFINE` 또는 `SNDRV_PCM_IOCTL_HW_PARAMS`로 `ioctl(2)`를 실행합니다. 전자는 사용 가능한 parameter 집합을 좁히기만 하고, 후자는 parameter를 실제로 확정합니다.

Hardware parameter 협상 흐름
Application이 선호 parameter 설정SNDRV_PCM_IOCTL_HW_REFINE으로 가능한 집합 정제ALSA PCM core와 driver constraint 적용SNDRV_PCM_IOCTL_HW_PARAMS로 값 확정확정 parameter를 PCM substream runtime에 보관

후보를 좁힌 뒤 실제 substream 설정으로 확정합니다.

두 ioctl의 역할
명령목적결과
SNDRV_PCM_IOCTL_HW_REFINE사용 가능한 parameter 후보 정제허용 집합을 반환하지만 실제 설정은 확정하지 않음
SNDRV_PCM_IOCTL_HW_PARAMS실제 hardware parameter 결정PCM substream runtime의 설정으로 확정

동일한 구조체를 사용하지만 결과를 적용하는 단계가 다릅니다.

In a design of ALSA PCM core, data transmission is abstracted as PCM substream.
Applications manage PCM substream to maintain data transmission for PCM frames.
Before starting the data transmission, applications need to configure PCM
substream. In this procedure, PCM hardware parameters are decided by
interaction between applications and ALSA PCM core. Once decided, runtime of
the PCM substream keeps the parameters.

The parameters are described in struct snd_pcm_hw_params. This
structure includes several types of parameters. Applications set preferable
value to these parameters, then execute ioctl(2) with SNDRV_PCM_IOCTL_HW_REFINE
or SNDRV_PCM_IOCTL_HW_PARAMS. The former is used just for refining available
set of parameters. The latter is used for an actual decision of the parameters.

struct snd_pcm_hw_params 필드

43-112

`flags`는 구성 가능한 field입니다. ALSA PCM core와 일부 driver는 편리한 parameter를 고르거나 동작을 바꾸는 데 이 flag를 사용합니다.

`masks`도 구성 가능합니다. 각 parameter는 `struct snd_mask`로 표현되며 PCM protocol v2.0.13에는 access, format, subformat 세 종류가 정의되어 있습니다.

Mask parameter 3종
Symbol의미
SNDRV_PCM_HW_PARAM_ACCESSPCM frame에 접근하는 방식
SNDRV_PCM_HW_PARAM_FORMATPCM sample format
SNDRV_PCM_HW_PARAM_SUBFORMATPCM sample subformat

`struct snd_mask`로 표현되는 parameter입니다.

`intervals` 역시 구성 가능하며 `struct snd_interval`의 범위 값으로 표현됩니다. PCM protocol v2.0.13에는 다음 12종이 정의되어 있습니다.

Interval parameter 12종
Symbol의미
SNDRV_PCM_HW_PARAM_SAMPLE_BITSsample 하나의 bit 수
SNDRV_PCM_HW_PARAM_FRAME_BITSframe 하나의 bit 수
SNDRV_PCM_HW_PARAM_CHANNELSchannel 수
SNDRV_PCM_HW_PARAM_RATEsampling rate
SNDRV_PCM_HW_PARAM_PERIOD_TIMEperiod 시간
SNDRV_PCM_HW_PARAM_PERIOD_SIZEperiod의 frame 수
SNDRV_PCM_HW_PARAM_PERIOD_BYTESperiod의 byte 수
SNDRV_PCM_HW_PARAM_PERIODSbuffer 안의 period 수
SNDRV_PCM_HW_PARAM_BUFFER_TIME전체 buffer 시간
SNDRV_PCM_HW_PARAM_BUFFER_SIZE전체 buffer의 frame 수
SNDRV_PCM_HW_PARAM_BUFFER_BYTES전체 buffer의 byte 수
SNDRV_PCM_HW_PARAM_TICK_TIMEtick 시간

최솟값·최댓값과 경계 상태를 가진 범위 parameter입니다.

`rmask`는 `SNDRV_PCM_IOCTL_HW_REFINE`에만 평가되는 구성 가능 mask입니다. Application은 ALSA PCM core가 바꿀 수 있는 mask/interval parameter를 선택할 수 있습니다. `SNDRV_PCM_IOCTL_HW_PARAMS`에서는 이 mask를 무시하고 모든 parameter를 변경 대상으로 삼습니다.

`cmask`는 읽기 전용입니다. `ioctl(2)`가 반환된 뒤 userspace의 `struct snd_pcm_hw_params` buffer에는 연산 결과가 들어 있으며, 이 mask는 실제로 변경된 mask/interval parameter를 나타냅니다.

`info`는 읽기 전용이며 `SNDRV_PCM_INFO_XXX` bit flag로 hardware/driver capability를 나타냅니다. 일반적으로 application은 `SNDRV_PCM_IOCTL_HW_REFINE`으로 이 flag를 가져온 뒤 parameter 후보를 정하고, `SNDRV_PCM_IOCTL_HW_PARAMS`로 PCM substream을 구성합니다.

`msbits`는 PCM sample의 MSB 쪽에서 사용할 수 있는 bit width를 나타내는 읽기 전용 값입니다. `SNDRV_PCM_HW_PARAM_SAMPLE_BITS`가 하나의 고정값으로 정해지면 그에 따라 계산되고, 그렇지 않으면 0입니다. 세부 동작은 driver 구현에 따라 달라집니다.

`rate_num`과 `rate_den`은 sampling rate를 분수로 나타내는 분자와 분모입니다. 일반적으로 `SNDRV_PCM_HW_PARAM_RATE`가 단일 값으로 정해지면 함께 계산되고, 그렇지 않으면 0입니다. 이 동작도 driver 구현에 따라 달라집니다.

`fifo_size`는 hardware serial sound interface의 FIFO 크기를 나타내는 읽기 전용 값입니다. Driver가 적절한 값을 지정할 수 있지만, hardware 설계나 data 전송 protocol을 고려해 일부 driver는 의도적으로 0을 설정합니다.

snd_pcm_hw_params 필드 성격
Field접근역할
flags구성 가능parameter 선택 또는 core/driver 동작 변경
masks구성 가능access·format·subformat의 bit mask
intervals구성 가능sample·frame·rate·period·buffer 범위
rmask구성 가능HW_REFINE에서 변경을 허용할 parameter 선택
cmask읽기 전용실제로 변경된 parameter 표시
info읽기 전용SNDRV_PCM_INFO_XXX capability
msbits읽기 전용sample MSB 쪽의 유효 bit width
rate_num / rate_den읽기 전용sampling rate 분수의 분자·분모
fifo_size읽기 전용serial sound interface FIFO 크기

구성 가능 field와 결과로 읽는 field를 구분합니다.

The struct snd_pcm_hw_params structure has below members:

``flags``
        Configurable. ALSA PCM core and some drivers handle this flag to select
        convenient parameters or change their behaviour.
``masks``
        Configurable. This type of parameter is described in
        struct snd_mask and represent mask values. As of PCM protocol
        v2.0.13, three types are defined.

        - SNDRV_PCM_HW_PARAM_ACCESS
        - SNDRV_PCM_HW_PARAM_FORMAT
        - SNDRV_PCM_HW_PARAM_SUBFORMAT
``intervals``
        Configurable. This type of parameter is described in
        struct snd_interval and represent values with a range. As of
        PCM protocol v2.0.13, twelve types are defined.

        - SNDRV_PCM_HW_PARAM_SAMPLE_BITS
        - SNDRV_PCM_HW_PARAM_FRAME_BITS
        - SNDRV_PCM_HW_PARAM_CHANNELS
        - SNDRV_PCM_HW_PARAM_RATE
        - SNDRV_PCM_HW_PARAM_PERIOD_TIME
        - SNDRV_PCM_HW_PARAM_PERIOD_SIZE
        - SNDRV_PCM_HW_PARAM_PERIOD_BYTES
        - SNDRV_PCM_HW_PARAM_PERIODS
        - SNDRV_PCM_HW_PARAM_BUFFER_TIME
        - SNDRV_PCM_HW_PARAM_BUFFER_SIZE
        - SNDRV_PCM_HW_PARAM_BUFFER_BYTES
        - SNDRV_PCM_HW_PARAM_TICK_TIME
``rmask``
        Configurable. This is evaluated at ioctl(2) with
        SNDRV_PCM_IOCTL_HW_REFINE only. Applications can select which
        mask/interval parameter can be changed by ALSA PCM core. For
        SNDRV_PCM_IOCTL_HW_PARAMS, this mask is ignored and all of parameters
        are going to be changed.
``cmask``
        Read-only. After returning from ioctl(2), buffer in user space for
        struct snd_pcm_hw_params includes result of each operation.
        This mask represents which mask/interval parameter is actually changed.
``info``
        Read-only. This represents hardware/driver capabilities as bit flags
        with SNDRV_PCM_INFO_XXX. Typically, applications execute ioctl(2) with
        SNDRV_PCM_IOCTL_HW_REFINE to retrieve this flag, then decide candidates
        of parameters and execute ioctl(2) with SNDRV_PCM_IOCTL_HW_PARAMS to
        configure PCM substream.
``msbits``
        Read-only. This value represents available bit width in MSB side of
        a PCM sample. When a parameter of SNDRV_PCM_HW_PARAM_SAMPLE_BITS was
        decided as a fixed number, this value is also calculated according to
        it. Else, zero. But this behaviour depends on implementations in driver
        side.
``rate_num``
        Read-only. This value represents numerator of sampling rate in fraction
        notation. Basically, when a parameter of SNDRV_PCM_HW_PARAM_RATE was
        decided as a single value, this value is also calculated according to
        it. Else, zero. But this behaviour depends on implementations in driver
        side.
``rate_den``
        Read-only. This value represents denominator of sampling rate in
        fraction notation. Basically, when a parameter of
        SNDRV_PCM_HW_PARAM_RATE was decided as a single value, this value is
        also calculated according to it. Else, zero. But this behaviour depends
        on implementations in driver side.
``fifo_size``
        Read-only. This value represents the size of FIFO in serial sound
        interface of hardware. Basically, each driver can assigns a proper
        value to this parameter but some drivers intentionally set zero with
        a care of hardware design or data transmission protocol.

Runtime constraint와 driver 참여

113-140

Application이 `SNDRV_PCM_HW_REFINE` 또는 `SNDRV_PCM_HW_PARAMS`로 `ioctl(2)`를 실행하면 ALSA PCM core가 `struct snd_pcm_hw_params` buffer를 처리합니다. Buffer의 parameter는 `struct snd_pcm_hardware`와 runtime의 constraint rule에 따라 바뀝니다.

`struct snd_pcm_hardware`는 대상 hardware의 capability를 설명합니다. Constraint rule은 여러 parameter 사이의 의존 관계를 설명하며 target parameter를 계산하는 callback을 가집니다. Driver는 임의의 callback을 등록할 수 있고 ALSA PCM core도 기본 rule 몇 가지를 runtime에 등록합니다.

Driver가 이 상호작용에 참여하려면 `struct snd_pcm_ops.open` callback에서 두 가지를 준비해야 합니다. 첫째, 해당 hardware capability에 맞춰 runtime의 `struct snd_pcm_hardware` member를 변경합니다. 둘째, hardware 설계 때문에 parameter 사이에 의존성이 있다면 추가 constraint rule을 runtime에 등록합니다.

Driver는 `struct snd_pcm_ops.hw_params` callback에서 협상 결과를 참조할 수 있지만 그 내용을 변경해서는 안 됩니다.

이 범주의 tracepoint는 mask/interval parameter의 변경을 추적합니다. ALSA PCM core가 parameter를 바꾸면 변경된 parameter type에 따라 `hw_mask_param` 또는 `hw_interval_param` event가 probe됩니다.

Core와 driver의 constraint 적용
snd_pcm_ops.open callback 진입runtime의 snd_pcm_hardware capability 설정hardware 의존성을 나타내는 constraint rule 등록HW_REFINE 또는 HW_PARAMS에서 core가 rule 실행mask/interval 변경에 맞는 trace event 발생snd_pcm_ops.hw_params는 확정 결과를 읽기만 함

Open 시 capability와 rule을 준비하고 ioctl 처리에서 협상합니다.

변경 type과 trace event
Parameter 표현Tracepoint기록 내용
struct snd_maskhw_mask_param변경 전후 mask의 16진수 dump
struct snd_intervalhw_interval_param경계와 정수성 등 interval member

변경된 parameter 표현에 따라 event가 갈립니다.

ALSA PCM core handles buffer of struct snd_pcm_hw_params when
applications execute ioctl(2) with SNDRV_PCM_HW_REFINE or SNDRV_PCM_HW_PARAMS.
Parameters in the buffer are changed according to
struct snd_pcm_hardware and rules of constraints in the runtime. The
structure describes capabilities of handled hardware. The rules describes
dependencies on which a parameter is decided according to several parameters.
A rule has a callback function, and drivers can register arbitrary functions
to compute the target parameter. ALSA PCM core registers some rules to the
runtime as a default.

Each driver can join in the interaction as long as it prepared for two stuffs
in a callback of struct snd_pcm_ops.open.

1. In the callback, drivers are expected to change a member of
   struct snd_pcm_hardware type in the runtime, according to
   capacities of corresponding hardware.
2. In the same callback, drivers are also expected to register additional rules
   of constraints into the runtime when several parameters have dependencies
   due to hardware design.

The driver can refers to result of the interaction in a callback of
struct snd_pcm_ops.hw_params, however it should not change the
content.

Tracepoints in this category are designed to trace changes of the
mask/interval parameters. When ALSA PCM core changes them, ``hw_mask_param`` or
``hw_interval_param`` event is probed according to type of the changed parameter.

Trace 출력 형식과 필드 해석

141-167

ALSA PCM core는 두 tracepoint 각각에 읽기 쉬운 출력 형식을 제공합니다. `hw_mask_param`의 예는 다음과 같습니다.

hw_mask_param: pcmC0D0p 001/023 FORMAT 00000000000000000000001000000044 00000000000000000000001000000044

`hw_interval_param`의 예는 다음과 같습니다.

hw_interval_param: pcmC0D0p 000/023 BUFFER_SIZE 0 0 [0 4294967295] 0 1 [0 4294967295]

첫 세 field는 공통입니다. 순서대로 ALSA PCM character device 이름, constraint rule 정보, 변경된 parameter 이름을 나타냅니다. Rule field는 적용된 rule index와 runtime에 추가된 전체 rule 수의 두 하위 field로 구성됩니다. 예외적으로 index `000`은 rule과 무관하게 ALSA PCM core가 parameter를 변경했음을 뜻합니다.

나머지 field는 변경 전과 변경 후의 parameter 상태입니다. Mask type은 parameter 내용의 16진수 dump를 표시합니다. Interval type은 `struct snd_interval`의 `empty`, `integer`, `openmin`, `min`, `max`, `openmax` member 값을 이 순서로 표시합니다.

공통 trace field
순서의미
1pcmC0D0pALSA PCM character device 이름
2001/023 또는 000/023적용 rule index / runtime의 전체 rule 수
3FORMAT 또는 BUFFER_SIZE변경된 hardware parameter 이름

두 event의 앞 세 field는 같은 의미와 순서를 가집니다.

Interval 상태 출력 순서
순서Member의미
1empty유효한 값이 없는 interval인지 여부
2integer정수 값만 허용하는지 여부
3openmin최솟값 경계가 열린 구간인지 여부
4min최솟값
5max최댓값
6openmax최댓값 경계가 열린 구간인지 여부

변경 전과 변경 후에 각각 같은 member 순서가 적용됩니다.

Trace 한 줄 해석
PCM device 식별적용 rule index와 전체 rule 수 확인변경된 parameter 이름 확인mask면 16진수 before/after 비교interval이면 여섯 member의 before/after 비교

공통 header 뒤에 type별 before/after 상태가 이어집니다.

ALSA PCM core also has a pretty print format for each of the tracepoints. Below
is an example for ``hw_mask_param``.

::

    hw_mask_param: pcmC0D0p 001/023 FORMAT 00000000000000000000001000000044 00000000000000000000001000000044


Below is an example for ``hw_interval_param``.

::

    hw_interval_param: pcmC0D0p 000/023 BUFFER_SIZE 0 0 [0 4294967295] 0 1 [0 4294967295]

The first three fields are common. They represent name of ALSA PCM character
device, rules of constraint and name of the changed parameter, in order. The
field for rules of constraint consists of two sub-fields; index of applied rule
and total number of rules added to the runtime. As an exception, the index 000
means that the parameter is changed by ALSA PCM core, regardless of the rules.

The rest of field represent state of the parameter before/after changing. These
fields are different according to type of the parameter. For parameters of mask
type, the fields represent hexadecimal dump of content of the parameter. For
parameters of interval type, the fields represent values of each member of
``empty``, ``integer``, ``openmin``, ``min``, ``max``, ``openmax`` in
struct snd_interval in this order.

Driver별 tracepoint

168-172

일부 ALSA driver는 개발 편의를 위한 자체 tracepoint를 제공합니다. 구체적인 event와 출력 형식은 각 driver 문서 또는 구현을 확인해야 합니다.

Driver tracepoint 확인 위치
대상확인 위치
Driver 전용 event해당 driver documentation
문서화되지 않은 세부 형식해당 driver implementation

PCM core 공통 event 밖의 기능은 driver별 자료가 기준입니다.

Tracepoints in drivers
======================

Some drivers have tracepoints for developers' convenience. For them, please
refer to each documentation or implementation.