Documentation/driver-api/soundwire/bra.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

Bulk Register Access (BRA)

SoundWire BRA의 bandwidth·packet·CRC·address 제약, async bus API, port stream과 DMA model을 다루는 전문 번역입니다.

Source pathDocumentation/driver-api/soundwire/bra.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

bra.rst:1-336

SoundWire BRA는 audio payload bandwidth를 BPT packet에 재사용해 register transfer를 가속합니다. Contiguous 32-bit addressing, DP0·frame shape·CRC·response와 Active marker 제약을 따르며, Linux는 Manager-specific packet 처리를 감추고 async send/wait, link-local port stream, platform DMA bandwidth 표현을 사용합니다.

문서 구성
원문 줄내용
1-75BRA 목적과 10가지 설계 제약
77-141CRC·response와 packet frame
142-218Addressing, unsupported 기능과 abstraction
219-280Concurrency, bus API와 regmap 방향
281-336Port stream과 audio DMA model

2. 영어 원문 전체

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

원문 전체 펼치기
1 ==========================
2 Bulk Register Access (BRA)
3 ==========================
4
5 Conventions
6 -----------
7
8 Capitalized words used in this documentation are intentional and refer
9 to concepts of the SoundWire 1.x specification.
10
11 Introduction
12 ------------
13
14 The SoundWire 1.x specification provides a mechanism to speed-up
15 command/control transfers by reclaiming parts of the audio
16 bandwidth. The Bulk Register Access (BRA) protocol is a standard
17 solution based on the Bulk Payload Transport (BPT) definitions.
18
19 The regular control channel uses Column 0 and can only send/retrieve
20 one byte per frame with write/read commands. With a typical 48kHz
21 frame rate, only 48kB/s can be transferred.
22
23 The optional Bulk Register Access capability can transmit up to 12
24 Mbits/s and reduce transfer times by several orders of magnitude, but
25 has multiple design constraints:
26
27 (1) Each frame can only support a read or a write transfer, with a
28 10-byte overhead per frame (header and footer response).
29
30 (2) The read/writes SHALL be from/to contiguous register addresses
31 in the same frame. A fragmented register space decreases the
32 efficiency of the protocol by requiring multiple BRA transfers
33 scheduled in different frames.
34
35 (3) The targeted Peripheral device SHALL support the optional Data
36 Port 0, and likewise the Manager SHALL expose audio-like Ports
37 to insert BRA packets in the audio payload using the concepts of
38 Sample Interval, HSTART, HSTOP, etc.
39
40 (4) The BRA transport efficiency depends on the available
41 bandwidth. If there are no on-going audio transfers, the entire
42 frame minus Column 0 can be reclaimed for BRA. The frame shape
43 also impacts efficiency: since Column0 cannot be used for
44 BTP/BRA, the frame should rely on a large number of columns and
45 minimize the number of rows. The bus clock should be as high as
46 possible.
47
48 (5) The number of bits transferred per frame SHALL be a multiple of
49 8 bits. Padding bits SHALL be inserted if necessary at the end
50 of the data.
51
52 (6) The regular read/write commands can be issued in parallel with
53 BRA transfers. This is convenient to e.g. deal with alerts, jack
54 detection or change the volume during firmware download, but
55 accessing the same address with two independent protocols has to
56 be avoided to avoid undefined behavior.
57
58 (7) Some implementations may not be capable of handling the
59 bandwidth of the BRA protocol, e.g. in the case of a slow I2C
60 bus behind the SoundWire IP. In this case, the transfers may
61 need to be spaced in time or flow-controlled.
62
63 (8) Each BRA packet SHALL be marked as 'Active' when valid data is
64 to be transmitted. This allows for software to allocate a BRA
65 stream but not transmit/discard data while processing the
66 results or preparing the next batch of data, or allowing the
67 peripheral to deal with the previous transfer. In addition BRA
68 transfer can be started early on without data being ready.
69
70 (9) Up to 470 bytes may be transmitted per frame.
71
72 (10) The address is represented with 32 bits and does not rely on
73 the paging registers used for the regular command/control
74 protocol in Column 0.
75
76
77 Error checking
78 --------------
79
80 Firmware download is one of the key usages of the Bulk Register Access
81 protocol. To make sure the binary data integrity is not compromised by
82 transmission or programming errors, each BRA packet provides:
83
84 (1) A CRC on the 7-byte header. This CRC helps the Peripheral Device
85 check if it is addressed and set the start address and number of
86 bytes. The Peripheral Device provides a response in Byte 7.
87
88 (2) A CRC on the data block (header excluded). This CRC is
89 transmitted as the last-but-one byte in the packet, prior to the
90 footer response.
91
92 The header response can be one of:
93 (a) Ack
94 (b) Nak
95 (c) Not Ready
96
97 The footer response can be one of:
98 (1) Ack
99 (2) Nak (CRC failure)
100 (3) Good (operation completed)
101 (4) Bad (operation failed)
102
103 Example frame
104 -------------
105
106 The example below is not to scale and makes simplifying assumptions
107 for clarity. The different chunks in the BRA packets are not required
108 to start on a new SoundWire Row, and the scale of data may vary.
109
110 ::
111
112 +---+--------------------------------------------+
113 + | |
114 + | BRA HEADER |
115 + | |
116 + +--------------------------------------------+
117 + C | HEADER CRC |
118 + O +--------------------------------------------+
119 + M | HEADER RESPONSE |
120 + M +--------------------------------------------+
121 + A | |
122 + N | |
123 + D | DATA |
124 + | |
125 + | |
126 + | |
127 + +--------------------------------------------+
128 + | DATA CRC |
129 + +--------------------------------------------+
130 + | FOOTER RESPONSE |
131 +---+--------------------------------------------+
132
133
134 Assuming the frame uses N columns, the configuration shown above can
135 be programmed by setting the DP0 registers as:
136
137 - HSTART = 1
138 - HSTOP = N - 1
139 - Sampling Interval = N
140 - WordLength = N - 1
141
142 Addressing restrictions
143 -----------------------
144
145 The Device Number specified in the Header follows the SoundWire
146 definitions, and broadcast and group addressing are permitted. For now
147 the Linux implementation only allows for a single BPT transfer to a
148 single device at a time. This might be revisited at a later point as
149 an optimization to send the same firmware to multiple devices, but
150 this would only be beneficial for single-link solutions.
151
152 In the case of multiple Peripheral devices attached to different
153 Managers, the broadcast and group addressing is not supported by the
154 SoundWire specification. Each device must be handled with separate BRA
155 streams, possibly in parallel - the links are really independent.
156
157 Unsupported features
158 --------------------
159
160 The Bulk Register Access specification provides a number of
161 capabilities that are not supported in known implementations, such as:
162
163 (1) Transfers initiated by a Peripheral Device. The BRA Initiator is
164 always the Manager Device.
165
166 (2) Flow-control capabilities and retransmission based on the
167 'NotReady' header response require extra buffering in the
168 SoundWire IP and are not implemented.
169
170 Bi-directional handling
171 -----------------------
172
173 The BRA protocol can handle writes as well as reads, and in each
174 packet the header and footer response are provided by the Peripheral
175 Target device. On the Peripheral device, the BRA protocol is handled
176 by a single DP0 data port, and at the low-level the bus ownership can
177 will change for header/footer response as well as the data transmitted
178 during a read.
179
180 On the host side, most implementations rely on a Port-like concept,
181 with two FIFOs consuming/generating data transfers in parallel
182 (Host->Peripheral and Peripheral->Host). The amount of data
183 consumed/produced by these FIFOs is not symmetrical, as a result
184 hardware typically inserts markers to help software and hardware
185 interpret raw data
186
187 Each packet will typically have:
188
189 (1) a 'Start of Packet' indicator.
190
191 (2) an 'End of Packet' indicator.
192
193 (3) a packet identifier to correlate the data requested and
194 transmitted, and the error status for each frame
195
196 Hardware implementations can check errors at the frame level, and
197 retry a transfer in case of errors. However, as for the flow-control
198 case, this requires extra buffering and intelligence in the
199 hardware. The Linux support assumes that the entire transfer is
200 cancelled if a single error is detected in one of the responses.
201
202 Abstraction required
203 ~~~~~~~~~~~~~~~~~~~~
204
205 There are no standard registers or mandatory implementation at the
206 Manager level, so the low-level BPT/BRA details must be hidden in
207 Manager-specific code. For example the Cadence IP format above is not
208 known to the codec drivers.
209
210 Likewise, codec drivers should not have to know the frame size. The
211 computation of CRC and handling of responses is handled in helpers and
212 Manager-specific code.
213
214 The host BRA driver may also have restrictions on pages allocated for
215 DMA, or other host-DSP communication protocols. The codec driver
216 should not be aware of any of these restrictions, since it might be
217 reused in combination with different implementations of Manager IPs.
218
219 Concurrency between BRA and regular read/write
220 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221
222 The existing 'nread/nwrite' API already relies on a notion of start
223 address and number of bytes, so it would be possible to extend this
224 API with a 'hint' requesting BPT/BRA be used.
225
226 However BRA transfers could be quite long, and the use of a single
227 mutex for regular read/write and BRA is a show-stopper. Independent
228 operation of the control/command and BRA transfers is a fundamental
229 requirement, e.g. to change the volume level with the existing regmap
230 interface while downloading firmware. The integration must however
231 ensure that there are no concurrent access to the same address with
232 the command/control protocol and the BRA protocol.
233
234 In addition, the 'sdw_msg' structure hard-codes support for 16-bit
235 addresses and paging registers which are irrelevant for BPT/BRA
236 support based on native 32-bit addresses. A separate API with
237 'sdw_bpt_msg' makes more sense.
238
239 One possible strategy to speed-up all initialization tasks would be to
240 start a BRA transfer for firmware download, then deal with all the
241 "regular" read/writes in parallel with the command channel, and last
242 to wait for the BRA transfers to complete. This would allow for a
243 degree of overlap instead of a purely sequential solution. As such,
244 the BRA API must support async transfers and expose a separate wait
245 function.
246
247
248 Peripheral/bus interface
249 ------------------------
250
251 The bus interface for BPT/BRA is made of two functions:
252
253 - sdw_bpt_send_async(bpt_message)
254
255 This function sends the data using the Manager
256 implementation-defined capabilities (typically DMA or IPC
257 protocol).
258
259 Queueing is currently not supported, the caller
260 needs to wait for completion of the requested transfer.
261
262 - sdw_bpt_wait()
263
264 This function waits for the entire message provided by the
265 codec driver in the 'send_async' stage. Intermediate status for
266 smaller chunks will not be provided back to the codec driver,
267 only a return code will be provided.
268
269 Regmap use
270 ~~~~~~~~~~
271
272 Existing codec drivers rely on regmap to download firmware to
273 Peripherals. regmap exposes an async interface similar to the
274 send/wait API suggested above, so at a high-level it would seem
275 natural to combine BRA and regmap. The regmap layer could check if BRA
276 is available or not, and use a regular read-write command channel in
277 the latter case.
278
279 The regmap integration will be handled in a second step.
280
281 BRA stream model
282 ----------------
283
284 For regular audio transfers, the machine driver exposes a dailink
285 connecting CPU DAI(s) and Codec DAI(s).
286
287 This model is not required BRA support:
288
289 (1) The SoundWire DAIs are mainly wrappers for SoundWire Data
290 Ports, with possibly some analog or audio conversion
291 capabilities bolted behind the Data Port. In the context of
292 BRA, the DP0 is the destination. DP0 registers are standard and
293 can be programmed blindly without knowing what Peripheral is
294 connected to each link. In addition, if there are multiple
295 Peripherals on a link and some of them do not support DP0, the
296 write commands to program DP0 registers will generate harmless
297 COMMAND_IGNORED responses that will be wired-ORed with
298 responses from Peripherals which support DP0. In other words,
299 the DP0 programming can be done with broadcast commands, and
300 the information on the Target device can be added only in the
301 BRA Header.
302
303 (2) At the CPU level, the DAI concept is not useful for BRA; the
304 machine driver will not create a dailink relying on DP0. The
305 only concept that is needed is the notion of port.
306
307 (3) The stream concept relies on a set of master_rt and slave_rt
308 concepts. All of these entities represent ports and not DAIs.
309
310 (4) With the assumption that a single BRA stream is used per link,
311 that stream can connect master ports as well as all peripheral
312 DP0 ports.
313
314 (5) BRA transfers only make sense in the context of one
315 Manager/Link, so the BRA stream handling does not rely on the
316 concept of multi-link aggregation allowed by regular DAI links.
317
318 Audio DMA support
319 -----------------
320
321 Some DMAs, such as HDaudio, require an audio format field to be
322 set. This format is in turn used to define acceptable bursts. BPT/BRA
323 support is not fully compatible with these definitions in that the
324 format and bandwidth may vary between read and write commands.
325
326 In addition, on Intel HDaudio Intel platforms the DMAs need to be
327 programmed with a PCM format matching the bandwidth of the BPT/BRA
328 transfer. The format is based on 192kHz 32-bit samples, and the number
329 of channels varies to adjust the bandwidth. The notion of channel is
330 completely notional since the data is not typical audio
331 PCM. Programming such channels helps reserve enough bandwidth and adjust
332 FIFO sizes to avoid xruns.
333
334 Alignment requirements are currently not enforced at the core level
335 but at the platform-level, e.g. for Intel the data sizes must be
336 equal to or larger than 16 bytes.
337

3. 한국어 전문 번역

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

BRA 문서 표기 규칙

1-10

이 문서는 SoundWire Bulk Register Access(BRA)를 설명합니다. 문서에서 대문자로 시작하는 단어는 의도된 표기이며 SoundWire 1.x specification의 concept를 가리킵니다.

문서 식별 정보
항목
문서Bulk Register Access (BRA)
SpecificationSoundWire 1.x
표기Capitalized word는 specification concept

==========================
Bulk Register Access (BRA)
==========================

Conventions
-----------

Capitalized words used in this documentation are intentional and refer
to concepts of the SoundWire 1.x specification.

BPT 기반 고속 register access

11-25

SoundWire 1.x specification은 audio bandwidth 일부를 회수해 command/control transfer를 가속하는 mechanism을 제공합니다. BRA protocol은 Bulk Payload Transport(BPT) 정의에 기반한 표준 solution입니다.

일반 control channel은 Column 0을 사용하며 frame마다 write/read command로 1 byte만 보내거나 가져올 수 있습니다. 일반적인 48 kHz frame rate에서는 48 kB/s만 전송할 수 있습니다.

Optional BRA capability는 최대 12 Mbit/s를 전송해 transfer time을 몇 order of magnitude 줄일 수 있지만 여러 설계 제약이 있습니다.

Control channel과 BRA 대역폭
Column 0 control1 byte/frame at 48 kHz48 kB/s
Audio bandwidth reclaimedBPTBRAUp to 12 Mbit/s

BRA가 audio payload 영역을 BPT packet에 재사용해 Column 0 control보다 훨씬 높은 throughput을 제공합니다.

Introduction
------------

The SoundWire 1.x specification provides a mechanism to speed-up
command/control transfers by reclaiming parts of the audio
bandwidth. The Bulk Register Access (BRA) protocol is a standard
solution based on the Bulk Payload Transport (BPT) definitions.

The regular control channel uses Column 0 and can only send/retrieve
one byte per frame with write/read commands. With a typical 48kHz
frame rate, only 48kB/s can be transferred.

The optional Bulk Register Access capability can transmit up to 12
Mbits/s and reduce transfer times by several orders of magnitude, but
has multiple design constraints:

Frame·address·port·bandwidth 제약

26-50

한 frame에는 read 또는 write transfer 하나만 넣을 수 있으며 header와 footer response로 frame당 10-byte overhead가 생깁니다.

같은 frame의 read/write는 연속 register address를 대상으로 해야 합니다. Fragmented register space는 서로 다른 frame에 여러 BRA transfer를 schedule해야 하므로 효율이 떨어집니다.

Target Peripheral은 optional Data Port 0(DP0)을 지원해야 하고 Manager도 Sample Interval, HSTART, HSTOP 같은 audio port concept로 BRA packet을 payload에 넣을 port를 노출해야 합니다.

효율은 가용 bandwidth에 의존합니다. Audio transfer가 없으면 Column 0을 뺀 frame 전체를 BRA에 쓸 수 있습니다. Column 0은 BPT/BRA에 사용할 수 없으므로 column 수를 늘리고 row 수를 줄이는 frame shape가 유리하며 bus clock은 가능한 높아야 합니다.

Frame당 전송 bit 수는 8의 배수여야 하며 필요하면 data 끝에 padding bit를 삽입합니다.

BRA 설계 제약 1-5
번호제약
1Frame당 read 또는 write 하나, 10-byte overhead
2한 frame 안에서 contiguous register address
3Peripheral DP0와 Manager audio-like port 필요
4Large columns, few rows, high bus clock이 효율적
5전송 bit 수는 8의 배수, 필요 시 tail padding


(1) Each frame can only support a read or a write transfer, with a
    10-byte overhead per frame (header and footer response).

(2) The read/writes SHALL be from/to contiguous register addresses
    in the same frame. A fragmented register space decreases the
    efficiency of the protocol by requiring multiple BRA transfers
    scheduled in different frames.

(3) The targeted Peripheral device SHALL support the optional Data
    Port 0, and likewise the Manager SHALL expose audio-like Ports
    to insert BRA packets in the audio payload using the concepts of
    Sample Interval, HSTART, HSTOP, etc.

(4) The BRA transport efficiency depends on the available
    bandwidth. If there are no on-going audio transfers, the entire
    frame minus Column 0 can be reclaimed for BRA. The frame shape
    also impacts efficiency: since Column0 cannot be used for
    BTP/BRA, the frame should rely on a large number of columns and
    minimize the number of rows. The bus clock should be as high as
    possible.

(5) The number of bits transferred per frame SHALL be a multiple of
    8 bits. Padding bits SHALL be inserted if necessary at the end
    of the data.

Concurrency·flow·Active·address 제약

51-76

일반 read/write command는 BRA와 병렬 실행할 수 있어 firmware download 중 alert·jack detection·volume 변경을 처리할 수 있습니다. 다만 두 protocol이 같은 address에 동시에 access하면 undefined behavior가 되므로 피해야 합니다.

SoundWire IP 뒤에 느린 I2C bus가 있는 경우처럼 구현이 BRA bandwidth를 처리하지 못할 수 있습니다. 이때 transfer 사이에 시간 간격을 두거나 flow control이 필요합니다.

유효 data를 보낼 BRA packet은 `Active`로 표시해야 합니다. Software는 stream을 allocate한 뒤 result 처리·다음 batch 준비·Peripheral의 이전 transfer 처리 동안 data를 보내거나 받지 않을 수 있고, data 준비 전에도 transfer를 일찍 시작할 수 있습니다.

Frame당 최대 470 byte를 전송할 수 있습니다. Address는 32 bit로 표현하며 Column 0 control protocol의 paging register를 사용하지 않습니다.

BRA 설계 제약 6-10
번호제약
6Control과 BRA 병렬 가능, 동일 address 동시 access 금지
7느린 backend는 spacing 또는 flow control 필요
8Valid packet은 `Active`, idle allocation 허용
9Frame당 최대 470 byte
10Native 32-bit address, paging register 불필요


(6) The regular read/write commands can be issued in parallel with
    BRA transfers. This is convenient to e.g. deal with alerts, jack
    detection or change the volume during firmware download, but
    accessing the same address with two independent protocols has to
    be avoided to avoid undefined behavior.

(7) Some implementations may not be capable of handling the
    bandwidth of the BRA protocol, e.g. in the case of a slow I2C
    bus behind the SoundWire IP. In this case, the transfers may
    need to be spaced in time or flow-controlled.

(8) Each BRA packet SHALL be marked as 'Active' when valid data is
    to be transmitted. This allows for software to allocate a BRA
    stream but not transmit/discard data while processing the
    results or preparing the next batch of data, or allowing the
    peripheral to deal with the previous transfer. In addition BRA
    transfer can be started early on without data being ready.

(9) Up to 470 bytes may be transmitted per frame.

(10) The address is represented with 32 bits and does not rely on
     the paging registers used for the regular command/control
     protocol in Column 0.

Header·data CRC와 response

77-102

Firmware download는 BRA의 핵심 use case이므로 transmission 또는 programming error로 binary data integrity가 손상되지 않게 packet마다 error check를 제공합니다.

7-byte header의 CRC로 Peripheral은 자신이 target인지, start address와 byte count가 무엇인지 확인합니다. Peripheral은 Byte 7에 header response를 제공하며 값은 `Ack`, `Nak`, `Not Ready` 중 하나입니다.

Header를 제외한 data block에도 CRC가 있으며 footer response 직전 packet의 끝에서 두 번째 byte로 전송합니다. Footer response는 `Ack`, CRC failure를 뜻하는 `Nak`, operation 완료를 뜻하는 `Good`, operation 실패를 뜻하는 `Bad` 중 하나입니다.

BRA error checking
단계검사·응답
7-byte headerHeader CRC
Byte 7`Ack` / `Nak` / `Not Ready`
Data blockData CRC, last-but-one byte
Footer`Ack` / `Nak (CRC failure)` / `Good` / `Bad`

Error checking
--------------

Firmware download is one of the key usages of the Bulk Register Access
protocol. To make sure the binary data integrity is not compromised by
transmission or programming errors, each BRA packet provides:

  (1) A CRC on the 7-byte header. This CRC helps the Peripheral Device
      check if it is addressed and set the start address and number of
      bytes. The Peripheral Device provides a response in Byte 7.

  (2) A CRC on the data block (header excluded). This CRC is
      transmitted as the last-but-one byte in the packet, prior to the
      footer response.

The header response can be one of:
  (a) Ack
  (b) Nak
  (c) Not Ready

The footer response can be one of:
  (1) Ack
  (2) Nak  (CRC failure)
  (3) Good (operation completed)
  (4) Bad  (operation failed)

BRA packet frame와 DP0 설정

103-141

원문 example은 scale이 정확하지 않고 명확성을 위한 단순화를 사용합니다. BRA packet의 각 chunk가 새 SoundWire Row에서 시작할 필요는 없고 data scale도 달라질 수 있습니다.

Packet은 BRA header, header CRC, header response, data, data CRC, footer response 순서로 command 영역에 배치됩니다.

Frame이 N개의 column을 사용한다고 가정하면 DP0는 `HSTART = 1`, `HSTOP = N - 1`, `Sampling Interval = N`, `WordLength = N - 1`로 설정합니다.

BRA packet phase
순서Chunk역할
1BRA HEADERTarget, address, byte count
2HEADER CRCHeader integrity
3HEADER RESPONSEPeripheral acceptance/readiness
4DATARegister payload
5DATA CRCPayload integrity
6FOOTER RESPONSETransfer result

원문의 세로 ASCII frame을 packet 순서표로 재구성했습니다.

Example frame
-------------

The example below is not to scale and makes simplifying assumptions
for clarity. The different chunks in the BRA packets are not required
to start on a new SoundWire Row, and the scale of data may vary.

      ::

        +---+--------------------------------------------+
        +   |                                            |
        +   |             BRA HEADER                     |
        +   |                                            |
        +   +--------------------------------------------+
        + C |             HEADER CRC                     |
        + O +--------------------------------------------+
        + M |                   HEADER RESPONSE                |
        + M +--------------------------------------------+
        + A |                                            |
        + N |                                            |
        + D |                 DATA                       |
        +   |                                            |
        +   |                                            |
        +   |                                            |
        +   +--------------------------------------------+
        +   |             DATA CRC                       |
        +   +--------------------------------------------+
        +   |                   FOOTER RESPONSE                |
        +---+--------------------------------------------+


Assuming the frame uses N columns, the configuration shown above can
be programmed by setting the DP0 registers as:

    - HSTART = 1
    - HSTOP = N - 1
    - Sampling Interval = N
    - WordLength = N - 1

Single-link addressing 제한

142-156

Header의 Device Number는 SoundWire 정의를 따르며 broadcast와 group addressing을 허용합니다. 현재 Linux 구현은 한 번에 single device로 향하는 single BPT transfer만 허용합니다.

동일 firmware를 여러 device에 보내는 optimization으로 바뀔 수 있지만 single-link solution에서만 이점이 있습니다.

서로 다른 Manager에 연결된 여러 Peripheral에서는 SoundWire specification이 broadcast·group addressing을 지원하지 않습니다. Link가 독립적이므로 각 device를 별도 BRA stream으로 처리하며 필요하면 병렬 실행합니다.

BRA addressing scope
Current LinuxSingle BPT transferSingle target device
Single link future optimizationBroadcast/group same firmware
Different ManagersIndependent linksSeparate BRA streamsOptional parallelism

Broadcast 이점은 한 link 안에서만 가능하며 multi-manager topology는 link별 stream을 사용합니다.

Addressing restrictions
-----------------------

The Device Number specified in the Header follows the SoundWire
definitions, and broadcast and group addressing are permitted. For now
the Linux implementation only allows for a single BPT transfer to a
single device at a time. This might be revisited at a later point as
an optimization to send the same firmware to multiple devices, but
this would only be beneficial for single-link solutions.

In the case of multiple Peripheral devices attached to different
Managers, the broadcast and group addressing is not supported by the
SoundWire specification. Each device must be handled with separate BRA
streams, possibly in parallel - the links are really independent.

지원하지 않는 BRA 기능

157-169

알려진 구현에서는 Peripheral이 시작하는 transfer를 지원하지 않으며 BRA Initiator는 항상 Manager Device입니다.

`NotReady` header response에 기반한 flow control과 retransmission은 SoundWire IP에 추가 buffering이 필요해 구현되지 않았습니다.

Unsupported feature
기능상태·이유
Peripheral-initiated transfer미지원, Manager가 항상 initiator
`NotReady` flow control추가 buffer 필요
Retransmission추가 buffer와 hardware logic 필요

Unsupported features
--------------------

The Bulk Register Access specification provides a number of
capabilities that are not supported in known implementations, such as:

  (1) Transfers initiated by a Peripheral Device. The BRA Initiator is
      always the Manager Device.

  (2) Flow-control capabilities and retransmission based on the
      'NotReady' header response require extra buffering in the
      SoundWire IP and are not implemented.

Bidirectional ownership과 packet marker

170-201

BRA는 write와 read를 모두 처리하며 각 packet의 header·footer response는 Peripheral Target이 제공합니다. Peripheral에서는 단일 DP0가 protocol을 처리하고, low level에서 response와 read data 동안 bus ownership이 바뀝니다.

Host 구현은 보통 Port-like concept와 병렬로 data를 소비·생성하는 두 FIFO, 즉 Host-to-Peripheral과 Peripheral-to-Host 경로를 사용합니다.

두 FIFO의 data 양은 대칭이 아니므로 hardware는 raw data 해석을 돕는 marker를 넣습니다. Packet에는 보통 Start of Packet, End of Packet, 요청·전송 data와 frame별 error status를 correlate하는 packet identifier가 있습니다.

Hardware가 frame-level error를 검사하고 retry할 수 있지만 추가 buffering과 intelligence가 필요합니다. Linux support는 response 하나에서 error가 검출되어도 entire transfer를 취소한다고 가정합니다.

Bidirectional BRA packet
Host TX FIFOHeader / write dataPeripheral DP0Header/footer response and read dataHost RX FIFO
SOP + EOP + packet IDCorrelate request, response and frame error
Any response errorCancel entire Linux transfer

DP0 bus ownership 전환과 두 host FIFO를 packet marker·ID로 correlate합니다.

Bi-directional handling
-----------------------

The BRA protocol can handle writes as well as reads, and in each
packet the header and footer response are provided by the Peripheral
Target device. On the Peripheral device, the BRA protocol is handled
by a single DP0 data port, and at the low-level the bus ownership can
will change for header/footer response as well as the data transmitted
during a read.

On the host side, most implementations rely on a Port-like concept,
with two FIFOs consuming/generating data transfers in parallel
(Host->Peripheral and Peripheral->Host). The amount of data
consumed/produced by these FIFOs is not symmetrical, as a result
hardware typically inserts markers to help software and hardware
interpret raw data

Each packet will typically have:

  (1) a 'Start of Packet' indicator.

  (2) an 'End of Packet' indicator.

  (3) a packet identifier to correlate the data requested and
      transmitted, and the error status for each frame

Hardware implementations can check errors at the frame level, and
retry a transfer in case of errors. However, as for the flow-control
case, this requires extra buffering and intelligence in the
hardware. The Linux support assumes that the entire transfer is
cancelled if a single error is detected in one of the responses.

Manager-specific 구현 은닉

202-218

Manager level에는 표준 register나 필수 구현이 없으므로 low-level BPT/BRA detail을 Manager-specific code에 숨겨야 합니다. Cadence IP format도 codec driver에는 노출되지 않습니다.

Codec driver는 frame size도 알 필요가 없습니다. CRC 계산과 response 처리는 helper와 Manager-specific code가 담당합니다.

Host BRA driver는 DMA page allocation이나 host-DSP communication protocol 제약도 가질 수 있습니다. Codec driver는 여러 Manager IP 구현과 재사용될 수 있으므로 이런 제약을 알아서는 안 됩니다.

BRA abstraction boundary
Codec driverGeneric BRA messageHelpers / Manager-specific codePacket format + CRC + responsesManager IP
Host DMA / DSP restrictionsManager-specific code

Codec driver에는 logical transfer만 노출하고 format·CRC·DMA·IPC는 Manager implementation 안에 둡니다.

Abstraction required
~~~~~~~~~~~~~~~~~~~~

There are no standard registers or mandatory implementation at the
Manager level, so the low-level BPT/BRA details must be hidden in
Manager-specific code. For example the Cadence IP format above is not
known to the codec drivers.

Likewise, codec drivers should not have to know the frame size. The
computation of CRC and handling of responses is handled in helpers and
Manager-specific code.

The host BRA driver may also have restrictions on pages allocated for
DMA, or other host-DSP communication protocols. The codec driver
should not be aware of any of these restrictions, since it might be
reused in combination with different implementations of Manager IPs.

Control과 BRA concurrency 및 별도 API

219-247

기존 `nread/nwrite` API는 start address와 byte count를 사용하므로 BPT/BRA 사용 hint를 추가할 수도 있습니다. 그러나 BRA transfer가 길 수 있어 일반 read/write와 BRA에 단일 mutex를 쓰는 방식은 적합하지 않습니다.

Firmware download 중 기존 regmap으로 volume을 변경하려면 control/command와 BRA가 독립적으로 동작해야 합니다. 단, 두 protocol이 같은 address에 concurrent access하지 않도록 integration이 보장해야 합니다.

`sdw_msg`는 16-bit address와 paging register를 전제로 하지만 BPT/BRA는 native 32-bit address를 사용하므로 별도 `sdw_bpt_msg` API가 더 타당합니다.

초기화 가속 전략은 firmware BRA transfer를 시작한 뒤 command channel의 일반 read/write를 병렬 처리하고 마지막에 BRA completion을 기다리는 것입니다. 순차 처리보다 overlap하려면 BRA API가 asynchronous transfer와 별도 wait function을 지원해야 합니다.

BRA initialization overlap
`sdw_bpt_msg` async firmwareBRA transfer runningSeparate wait
Regular `sdw_msg` / regmapCommand channel work in parallel
Address arbitrationPrevent same-address concurrent access

별도 message와 lock domain으로 firmware transfer와 control transaction을 겹칩니다.

Concurrency between BRA and regular read/write
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The existing 'nread/nwrite' API already relies on a notion of start
address and number of bytes, so it would be possible to extend this
API with a 'hint' requesting BPT/BRA be used.

However BRA transfers could be quite long, and the use of a single
mutex for regular read/write and BRA is a show-stopper. Independent
operation of the control/command and BRA transfers is a fundamental
requirement, e.g. to change the volume level with the existing regmap
interface while downloading firmware. The integration must however
ensure that there are no concurrent access to the same address with
the command/control protocol and the BRA protocol.

In addition, the 'sdw_msg' structure hard-codes support for 16-bit
addresses and paging registers which are irrelevant for BPT/BRA
support based on native 32-bit addresses. A separate API with
'sdw_bpt_msg' makes more sense.

One possible strategy to speed-up all initialization tasks would be to
start a BRA transfer for firmware download, then deal with all the
"regular" read/writes in parallel with the command channel, and last
to wait for the BRA transfers to complete. This would allow for a
degree of overlap instead of a purely sequential solution. As such,
the BRA API must support async transfers and expose a separate wait
function.

BPT/BRA bus send·wait API

248-268

BPT/BRA bus interface는 `sdw_bpt_send_async(bpt_message)`와 `sdw_bpt_wait()` 두 function으로 구성됩니다.

`sdw_bpt_send_async()`는 보통 DMA나 IPC protocol인 Manager implementation-defined capability로 data를 보냅니다. 현재 queueing은 지원하지 않으므로 caller가 요청 transfer 완료를 기다린 뒤 다음 요청을 보내야 합니다.

`sdw_bpt_wait()`는 codec driver가 send_async 단계에서 제공한 entire message를 기다립니다. 작은 chunk의 intermediate status는 codec driver에 반환하지 않고 최종 return code만 제공합니다.

BPT/BRA bus API
Function동작제약
`sdw_bpt_send_async()`DMA/IPC로 message 전송 시작Queueing 미지원
`sdw_bpt_wait()`Entire message 완료 대기Intermediate status 없음

Peripheral/bus interface
------------------------

The bus interface for BPT/BRA is made of two functions:

    - sdw_bpt_send_async(bpt_message)

      This function sends the data using the Manager
      implementation-defined capabilities (typically DMA or IPC
      protocol).

      Queueing is currently not supported, the caller
      needs to wait for completion of the requested transfer.

   - sdw_bpt_wait()

      This function waits for the entire message provided by the
      codec driver in the 'send_async' stage. Intermediate status for
      smaller chunks will not be provided back to the codec driver,
      only a return code will be provided.

Regmap integration 방향

269-280

기존 codec driver는 regmap으로 Peripheral firmware를 download합니다. Regmap의 async interface가 제안된 send/wait API와 비슷하므로 high level에서 BRA와 regmap을 결합하는 것이 자연스럽습니다.

Regmap layer가 BRA availability를 확인하고 사용할 수 없으면 일반 read/write command channel로 fallback할 수 있습니다. 이 integration은 두 번째 단계에서 처리할 예정입니다.

Future regmap integration
Codec regmap requestBRA available?BRA async send/wait
BRA unavailableRegular read/write command channel

Regmap이 BRA capability를 선택하고 없으면 command channel을 사용하는 fallback을 제공합니다.

Regmap use
~~~~~~~~~~

Existing codec drivers rely on regmap to download firmware to
Peripherals. regmap exposes an async interface similar to the
send/wait API suggested above, so at a high-level it would seem
natural to combine BRA and regmap. The regmap layer could check if BRA
is available or not, and use a regular read-write command channel in
the latter case.

The regmap integration will be handled in a second step.

Port 기반 BRA stream model

281-317

일반 audio transfer에서는 machine driver가 CPU DAI와 Codec DAI를 연결하는 dailink를 노출하지만 BRA에는 이 model이 필요하지 않습니다.

SoundWire DAI는 주로 Data Port wrapper입니다. BRA에서는 DP0가 destination이며 standard register를 Peripheral identity 없이 program할 수 있습니다. DP0 미지원 Peripheral의 `COMMAND_IGNORED` response는 지원 device response와 wired-OR되므로 broadcast command로 DP0를 설정하고 target 정보는 BRA Header에만 넣을 수 있습니다.

CPU 측에서도 DAI는 필요 없고 machine driver가 DP0 기반 dailink를 만들지 않습니다. 필요한 concept은 port뿐입니다. `master_rt`와 `slave_rt` entity도 DAI가 아니라 port를 나타냅니다.

Link당 single BRA stream을 가정하면 그 stream이 master port와 모든 Peripheral DP0 port를 연결합니다. BRA는 한 Manager/Link 안에서만 의미가 있으므로 일반 DAI link의 multi-link aggregation을 사용하지 않습니다.

BRA port stream
Manager/link portSingle BRA streamPeripheral DP0 ports
Broadcast DP0 programming`COMMAND_IGNORED` from unsupported devicesWired-OR valid responses
Target Device NumberBRA Header only
No multi-link aggregationOne Manager/Link scope

DAI/dailink 대신 link-local stream이 manager port와 모든 Peripheral DP0를 직접 연결합니다.

BRA stream model
----------------

For regular audio transfers, the machine driver exposes a dailink
connecting CPU DAI(s) and Codec DAI(s).

This model is not required BRA support:

   (1) The SoundWire DAIs are mainly wrappers for SoundWire Data
       Ports, with possibly some analog or audio conversion
       capabilities bolted behind the Data Port. In the context of
       BRA, the DP0 is the destination. DP0 registers are standard and
       can be programmed blindly without knowing what Peripheral is
       connected to each link. In addition, if there are multiple
       Peripherals on a link and some of them do not support DP0, the
       write commands to program DP0 registers will generate harmless
       COMMAND_IGNORED responses that will be wired-ORed with
       responses from Peripherals which support DP0. In other words,
       the DP0 programming can be done with broadcast commands, and
       the information on the Target device can be added only in the
       BRA Header.

   (2) At the CPU level, the DAI concept is not useful for BRA; the
       machine driver will not create a dailink relying on DP0. The
       only concept that is needed is the notion of port.

   (3) The stream concept relies on a set of master_rt and slave_rt
       concepts. All of these entities represent ports and not DAIs.

   (4) With the assumption that a single BRA stream is used per link,
       that stream can connect master ports as well as all peripheral
       DP0 ports.

   (5) BRA transfers only make sense in the context of one
       Manager/Link, so the BRA stream handling does not rely on the
       concept of multi-link aggregation allowed by regular DAI links.

Audio DMA bandwidth representation

318-336

HDaudio 같은 일부 DMA는 acceptable burst를 정의하기 위한 audio format field가 필요합니다. BPT/BRA는 read와 write에서 format과 bandwidth가 달라질 수 있어 이 정의와 완전히 호환되지 않습니다.

Intel HDaudio platform에서는 BPT/BRA transfer bandwidth와 맞는 PCM format으로 DMA를 program해야 합니다. 192 kHz 32-bit sample을 기준으로 channel 수를 바꿔 bandwidth를 조절합니다.

Data가 일반 audio PCM이 아니므로 channel은 명목상의 개념입니다. 그래도 channel programming은 충분한 bandwidth를 reserve하고 FIFO size를 조절해 xrun을 방지합니다.

Alignment requirement는 core가 아니라 platform level에서 강제합니다. 예를 들어 Intel에서는 data size가 16 byte 이상이어야 합니다.

BRA DMA representation
항목Intel HDaudio 예
Base format192 kHz, 32-bit sample
Bandwidth adjustmentNotional channel count
효과Bandwidth reservation, FIFO sizing, xrun 방지
Minimum data size16 byte 이상
EnforcementPlatform level

Audio DMA support
-----------------

Some DMAs, such as HDaudio, require an audio format field to be
set. This format is in turn used to define acceptable bursts. BPT/BRA
support is not fully compatible with these definitions in that the
format and bandwidth may vary between read and write commands.

In addition, on Intel HDaudio Intel platforms the DMAs need to be
programmed with a PCM format matching the bandwidth of the BPT/BRA
transfer. The format is based on 192kHz 32-bit samples, and the number
of channels varies to adjust the bandwidth. The notion of channel is
completely notional since the data is not typical audio
PCM. Programming such channels helps reserve enough bandwidth and adjust
FIFO sizes to avoid xruns.

Alignment requirements are currently not enforced at the core level
but at the platform-level, e.g. for Intel the data sizes must be
equal to or larger than 16 bytes.