Skip to content

Commit 57b3a7b

Browse files
bardliaovinodkoul
authored andcommitted
soundwire: cadence: export sdw_cdns_bpt_find_bandwidth
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> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://patch.msgid.link/20251014031450.3781789-5-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 5a838e0 commit 57b3a7b

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

drivers/soundwire/cadence_master.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,36 @@ static unsigned int sdw_cdns_read_pdi1_buffer_size(unsigned int actual_data_size
20942094
return total * 2;
20952095
}
20962096

2097+
int sdw_cdns_bpt_find_bandwidth(int command, /* 0: write, 1: read */
2098+
int row, int col, int frame_rate,
2099+
unsigned int *tx_dma_bandwidth,
2100+
unsigned int *rx_dma_bandwidth)
2101+
{
2102+
unsigned int bpt_bits = row * (col - 1);
2103+
unsigned int bpt_bytes = bpt_bits >> 3;
2104+
unsigned int pdi0_buffer_size;
2105+
unsigned int pdi1_buffer_size;
2106+
unsigned int data_per_frame;
2107+
2108+
data_per_frame = sdw_cdns_bra_actual_data_size(bpt_bytes);
2109+
if (!data_per_frame)
2110+
return -EINVAL;
2111+
2112+
if (command == 0) {
2113+
pdi0_buffer_size = sdw_cdns_write_pdi0_buffer_size(data_per_frame);
2114+
pdi1_buffer_size = SDW_CDNS_WRITE_PDI1_BUFFER_SIZE;
2115+
} else {
2116+
pdi0_buffer_size = SDW_CDNS_READ_PDI0_BUFFER_SIZE;
2117+
pdi1_buffer_size = sdw_cdns_read_pdi1_buffer_size(data_per_frame);
2118+
}
2119+
2120+
*tx_dma_bandwidth = pdi0_buffer_size * 8 * frame_rate;
2121+
*rx_dma_bandwidth = pdi1_buffer_size * 8 * frame_rate;
2122+
2123+
return 0;
2124+
}
2125+
EXPORT_SYMBOL(sdw_cdns_bpt_find_bandwidth);
2126+
20972127
int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */
20982128
int row, int col, unsigned int data_bytes,
20992129
unsigned int requested_bytes_per_frame,

drivers/soundwire/cadence_master.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ void sdw_cdns_config_update(struct sdw_cdns *cdns);
209209
int sdw_cdns_config_update_set_wait(struct sdw_cdns *cdns);
210210

211211
/* SoundWire BPT/BRA helpers to format data */
212+
int sdw_cdns_bpt_find_bandwidth(int command, /* 0: write, 1: read */
213+
int row, int col, int frame_rate,
214+
unsigned int *tx_dma_bandwidth,
215+
unsigned int *rx_dma_bandwidth);
216+
212217
int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */
213218
int row, int col, unsigned int data_bytes,
214219
unsigned int requested_bytes_per_frame,

0 commit comments

Comments
 (0)