Skip to content

Commit e7098ee

Browse files
committed
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 <[email protected]>
1 parent 11b00c7 commit e7098ee

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
@@ -2098,6 +2098,36 @@ static unsigned int sdw_cdns_read_pdi1_buffer_size(unsigned int actual_data_size
20982098
return total * 2;
20992099
}
21002100

2101+
int sdw_cdns_bpt_find_bandwidth(int command, /* 0: write, 1: read */
2102+
int row, int col, int frame_rate,
2103+
unsigned int *tx_dma_bandwidth,
2104+
unsigned int *rx_dma_bandwidth)
2105+
{
2106+
unsigned int bpt_bits = row * (col - 1);
2107+
unsigned int bpt_bytes = bpt_bits >> 3;
2108+
unsigned int pdi0_buffer_size;
2109+
unsigned int pdi1_buffer_size;
2110+
unsigned int data_per_frame;
2111+
2112+
data_per_frame = sdw_cdns_bra_actual_data_size(bpt_bytes);
2113+
if (!data_per_frame)
2114+
return -EINVAL;
2115+
2116+
if (command == 0) {
2117+
pdi0_buffer_size = sdw_cdns_write_pdi0_buffer_size(data_per_frame);
2118+
pdi1_buffer_size = SDW_CDNS_WRITE_PDI1_BUFFER_SIZE;
2119+
} else {
2120+
pdi0_buffer_size = SDW_CDNS_READ_PDI0_BUFFER_SIZE;
2121+
pdi1_buffer_size = sdw_cdns_read_pdi1_buffer_size(data_per_frame);
2122+
}
2123+
2124+
*tx_dma_bandwidth = pdi0_buffer_size * 8 * frame_rate;
2125+
*rx_dma_bandwidth = pdi1_buffer_size * 8 * frame_rate;
2126+
2127+
return 0;
2128+
}
2129+
EXPORT_SYMBOL(sdw_cdns_bpt_find_bandwidth);
2130+
21012131
int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */
21022132
int row, int col, unsigned int data_bytes,
21032133
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)