Skip to content

soundwire: add BRA properties#5710

Open
bardliao wants to merge 5 commits into
thesofproject:topic/sof-devfrom
bardliao:bra-properties
Open

soundwire: add BRA properties#5710
bardliao wants to merge 5 commits into
thesofproject:topic/sof-devfrom
bardliao:bra-properties

Conversation

@bardliao
Copy link
Copy Markdown
Collaborator

Add mipi-sdw-bra-mode-max-data-per-frame and mipi-sdw-bra-mode-block-alignment properties support

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for new MIPI SoundWire DisCo/BRA device properties so BPT/BRA transfers can respect per-device constraints (max payload per frame and block alignment).

Changes:

  • Extend struct sdw_slave_prop with bra_block_alignment and bra_max_data_per_frame, and parse them from firmware properties.
  • Thread BRA constraints into Cadence BPT/BRA buffer-size calculations and Intel ACE2x BPT stream setup.
  • Update SDW_BPT_MSG_MAX_BYTES definition/comment to reference the DisCo spec limit.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
include/linux/soundwire/sdw.h Adds BRA properties to slave props; changes SDW_BPT_MSG_MAX_BYTES definition/comment.
drivers/soundwire/mipi_disco.c Reads the new BRA properties from device properties.
drivers/soundwire/intel_ace2x.c Uses new props to select max bytes/frame and pass alignment into buffer sizing.
drivers/soundwire/cadence_master.h Updates sdw_cdns_bpt_find_buffer_sizes() signature to accept alignment.
drivers/soundwire/cadence_master.c Applies block-alignment when computing actual bytes/frame in BPT/BRA sizing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/linux/soundwire/sdw.h Outdated
Comment thread include/linux/soundwire/sdw.h Outdated
Comment thread drivers/soundwire/cadence_master.c
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

drivers/soundwire/cadence_master.c:2181

  • When bra_block_alignment is set, the later clamp if (data_bytes < actual_bpt_bytes) actual_bpt_bytes = data_bytes; can re-introduce a per-frame payload length that is not a multiple of bra_block_alignment (e.g., a single short transfer or the last partial frame). This contradicts the new block-alignment requirement and can lead to invalid BRA frames on devices that enforce the alignment. Consider enforcing that data_bytes/remainder is a multiple of bra_block_alignment (return -EINVAL otherwise), or redesigning the sizing logic to keep an aligned actual_bpt_bytes and handle padding/trimming appropriately (read vs write).
	*data_per_frame = actual_bpt_bytes;

	if (data_bytes < actual_bpt_bytes)
		actual_bpt_bytes = data_bytes;


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/soundwire/intel_ace2x.c Outdated
Copilot AI review requested due to automatic review settings April 8, 2026 12:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/soundwire/cadence_master.h
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

drivers/soundwire/cadence_master.c:2181

  • *data_per_frame is set before actual_bpt_bytes may be reduced to data_bytes, so callers can observe a data_per_frame larger than the size actually used to compute num_frames/buffer sizes. With bra_block_alignment this also means the later actual_bpt_bytes = data_bytes path can bypass the alignment constraint for small transfers. Consider applying the min(data_bytes, ...) step (and any alignment enforcement/handling for the last frame) before assigning *data_per_frame so the returned frame size is consistent with subsequent calculations.
	*data_per_frame = actual_bpt_bytes;

	if (data_bytes < actual_bpt_bytes)
		actual_bpt_bytes = data_bytes;

Comment thread include/linux/soundwire/sdw.h
Comment thread drivers/soundwire/cadence_master.c Outdated
bardliao and others added 4 commits May 25, 2026 22:32
The header[1] indicates the BRA_NumBytes[7:0] and header[0] indicates
the BRA_NumBytes[8]. The existing code doesn't handle BRA_NumBytes[8]
therefore the maximum BRA number of a frame is limited to 255.

Fixes: fe8a9cf ("soundwire: pass sdw_bpt_section to cdns BPT helpers")
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Add a property to struct sdw_slave_prop equivalent to the Disco
property "mipi-sdw-bra-mode-block-alignment".

The SoundWire Disco specification defines this as:

"The data payload size for this BRA Mode shall be an integer
multiple of the value of this Property."

Change-Id: I27ab84b0ed0f236a5eae58600400a4c386132480
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Co-developed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
The data pre frame size should be a multiple of bra_block_alignment.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Get the mipi-sdw-bra-mode-max-data-per-frame property which indicates
the maximum data payload size (in bytes per frame excluding header,
CRC, and footer) for the BRA Mode.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +477 to +478
device_property_read_u32(dev, "mipi-sdw-bra-mode-max-data-per-frame",
&prop->bra_max_data_per_frame);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't check the DisCo table value here. We will check it when it is used instated.

The optional property indicates the maximum data payload size for the
BRA mode.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants