soundwire/ASoC: add fake BRA frame to align Intel DMA buffer size#5512
Conversation
The existing code uses i as the frame index which is 0 based. And "bad frame %d/%d", i, num_frames where num_frames is 1 based. Change the frame index to i + 1 to align with num_frames and more readable. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
DP0 is only for BPT stream. We should not compute and update the port params of the normal audio streams. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
e0b533d to
8e3a8f0
Compare
plbossart
left a comment
There was a problem hiding this comment.
Interesting that there are DMA restrictions, they were not known to me :-)
drivers/soundwire/cadence_master.c
Outdated
| } | ||
|
|
||
| /* Add fack frame */ | ||
| header[0] &= ~GENMASK(7, 6); /* Mark inactive to the fack frame */ |
There was a problem hiding this comment.
you should explain what a 'fake frame' is, looks like you are using a flag in the BPT header.
There was a problem hiding this comment.
Currently, I just make it inactive. Hope it is good enough for the codec to ignore the frame.
There was a problem hiding this comment.
suggested edit: change comment to say "set inactive flag in BPT/BRA frame header".
drivers/soundwire/intel_ace2x.c
Outdated
| * Add at most 3 fake frames for read command to make the pdi0_buffer_size a | ||
| * mutiple of rx alignment and pdi1_buffer_size a mutiple of TX_BUF_ALIGNMENT. | ||
| */ | ||
| for (i = 1; i < data_per_frame * 3; i++) { |
There was a problem hiding this comment.
this looks suspect, looks like you are mixing frame counter and data counter. You may want to use a better index name than 'i'...
There was a problem hiding this comment.
i is the fake data size and I need to set a maximum number which is currently 3 frames. But I am not quite sure if at most 3 fake frames is reasonable or not.
There was a problem hiding this comment.
looks like you'd need something like a LCM to find out how many invalid/inactive BRA/BTP frames to add. An iterative loop could fail to find the right amount, no?
There was a problem hiding this comment.
Yeah, it would be better if I calculate the required frames instead of finding it with a loop.
data_per_frame will be used for preparing the TX buffer and we may add some fake frames to ensure the data in the buffer will be flushed. So that it should indicate the the frame capability even if the required data bytes are less than the frame capability. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Currently, we calculate the required bandwidth after the PDI buffer size is calculated. However as we need to add some fake frame to align the data block size, the final PDI size and the frame number will change. Besides, we need the required bandwidth to decide the DMA channel number and the channel number will be used to calculate the data block size. Therefore, we calculate the required bandwidth and export a helper for the caller to get the required bandwidth. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
8e3a8f0 to
e720e51
Compare
e720e51 to
97fd645
Compare
The dma buffer need to be a multiple of data block size and the fifo size. Export a function to return the LCM of data block size and the fifo size. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
…e_read_dma_buffer We may need to add few fake frames to fit the aligned read dma buffer size. Add a fake_size parameter to allow the caller to set the fake data size. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Intel DMA buffer size need to be a mutiple of data block size. Find the minimal fake data size and extra buffer size to meet the requirement. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
97fd645 to
8707df5
Compare
|
@plbossart Are you good with this PR? |
shumingfan
left a comment
There was a problem hiding this comment.
Tested-by: Shuming Fan shumingf@realtek.com
|
SOFCI TEST |
There is a constraint on Intel DMA buffer size that needs to be a multiple of data block size. This series adds some fake BRA frames to add some extra buffer size to meet the constraint .