Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Bard Liao and committed by
Vinod Koul
57b3a7b2 5a838e01

+35
+30
drivers/soundwire/cadence_master.c
··· 2094 2094 return total * 2; 2095 2095 } 2096 2096 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 + 2097 2127 int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */ 2098 2128 int row, int col, unsigned int data_bytes, 2099 2129 unsigned int requested_bytes_per_frame,
+5
drivers/soundwire/cadence_master.h
··· 209 209 int sdw_cdns_config_update_set_wait(struct sdw_cdns *cdns); 210 210 211 211 /* 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 + 212 217 int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */ 213 218 int row, int col, unsigned int data_bytes, 214 219 unsigned int requested_bytes_per_frame,