Skip to content

Commit

Permalink
fixup! soundwire: cadence: add BTP/BRA helpers to format data
Browse files Browse the repository at this point in the history
Change sdw_cdns_write_pdi1_buffer_size and sdw_cdns_read_pdi0_buffer_size
to static values as the maintainer suggested.

Signed-off-by: Bard Liao <[email protected]>
  • Loading branch information
bardliao committed Feb 27, 2025
1 parent 77ce44c commit 4567e28
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions drivers/soundwire/cadence_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,13 @@ static const u8 sdw_crc8_lookup_msb[CRC8_TABLE_SIZE] = {
#define SDW_CDNS_BRA_FOOTER_RESP 1 /* defined by MIPI */
#define SDW_CDNS_BRA_FOOTER_RESP_PAD 1 /* Cadence only */

#define SDW_CDNS_WRITE_PDI1_BUFFER_SIZE \
((SDW_CDNS_BRA_HDR_RESP + SDW_CDNS_BRA_HDR_RESP_PAD + \
SDW_CDNS_BRA_FOOTER_RESP + SDW_CDNS_BRA_FOOTER_RESP_PAD) * 2)

#define SDW_CDNS_READ_PDI0_BUFFER_SIZE \
((SDW_CDNS_BRA_HDR + SDW_CDNS_BRA_HDR_CRC + SDW_CDNS_BRA_HDR_CRC_PAD) * 2)

static unsigned int sdw_cdns_bra_actual_data_size(unsigned int allocated_bytes_per_frame)
{
unsigned int total;
Expand Down Expand Up @@ -2074,25 +2081,6 @@ static unsigned int sdw_cdns_write_pdi0_buffer_size(unsigned int actual_data_siz
return total * 2;
}

static unsigned int sdw_cdns_write_pdi1_buffer_size(unsigned int actual_data_size)
{
unsigned int total;

total = SDW_CDNS_BRA_HDR_RESP + SDW_CDNS_BRA_HDR_RESP_PAD +
SDW_CDNS_BRA_FOOTER_RESP + SDW_CDNS_BRA_FOOTER_RESP_PAD;

return total * 2;
}

static unsigned int sdw_cdns_read_pdi0_buffer_size(unsigned int actual_data_size)
{
unsigned int total;

total = SDW_CDNS_BRA_HDR + SDW_CDNS_BRA_HDR_CRC + SDW_CDNS_BRA_HDR_CRC_PAD;

return total * 2;
}

static unsigned int sdw_cdns_read_pdi1_buffer_size(unsigned int actual_data_size)
{
unsigned int total;
Expand Down Expand Up @@ -2151,7 +2139,7 @@ int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */
*num_frames = DIV_ROUND_UP(data_bytes, actual_bpt_bytes);

pdi0_tx_size = sdw_cdns_write_pdi0_buffer_size(actual_bpt_bytes);
pdi1_rx_size = sdw_cdns_write_pdi1_buffer_size(actual_bpt_bytes);
pdi1_rx_size = SDW_CDNS_WRITE_PDI1_BUFFER_SIZE;

*pdi0_buffer_size = pdi0_tx_size * *num_frames;
*pdi1_buffer_size = pdi1_rx_size * *num_frames;
Expand All @@ -2162,15 +2150,15 @@ int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */
*/
*num_frames = data_bytes / actual_bpt_bytes;

pdi0_tx_size = sdw_cdns_read_pdi0_buffer_size(actual_bpt_bytes);
pdi0_tx_size = SDW_CDNS_READ_PDI0_BUFFER_SIZE;
pdi1_rx_size = sdw_cdns_read_pdi1_buffer_size(actual_bpt_bytes);

*pdi0_buffer_size = pdi0_tx_size * *num_frames;
*pdi1_buffer_size = pdi1_rx_size * *num_frames;

remainder = data_bytes % actual_bpt_bytes;
if (remainder) {
pdi0_tx_size = sdw_cdns_read_pdi0_buffer_size(remainder);
pdi0_tx_size = SDW_CDNS_READ_PDI0_BUFFER_SIZE;
pdi1_rx_size = sdw_cdns_read_pdi1_buffer_size(remainder);

*num_frames = *num_frames + 1;
Expand Down

0 comments on commit 4567e28

Please sign in to comment.