Skip to content

Commit 0371546

Browse files
committed
soundwire: generic_bandwidth_allocation: check bandwidth with real
colume The existing code assumes the column number will not change, but it could change if curr_dr_freq changes. Calculate the new column number before checking the bandwidth to make the checking be more accurate. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 9a3d244 commit 0371546

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,23 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
590590
if (!is_clock_scaling_supported(bus))
591591
clk_values = 1;
592592

593+
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
594+
return -EINVAL;
595+
593596
for (i = 0; i < clk_values; i++) {
597+
int total_col;
598+
594599
if (!clk_buf)
595600
curr_dr_freq = bus->params.max_dr_freq;
596601
else
597602
curr_dr_freq = (is_gear) ?
598603
(bus->params.max_dr_freq >> clk_buf[i]) :
599604
clk_buf[i] * SDW_DOUBLE_RATE_FACTOR;
600605

601-
if (curr_dr_freq * (mstr_prop->default_col - 1) >=
602-
bus->params.bandwidth * mstr_prop->default_col)
606+
total_col = curr_dr_freq / mstr_prop->default_frame_rate / mstr_prop->default_row;
607+
608+
if (curr_dr_freq * (total_col - 1) >=
609+
bus->params.bandwidth * total_col)
603610
break;
604611

605612
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
@@ -661,9 +668,6 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
661668
}
662669
}
663670

664-
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
665-
return -EINVAL;
666-
667671
mstr_prop->default_col = curr_dr_freq / mstr_prop->default_frame_rate /
668672
mstr_prop->default_row;
669673

0 commit comments

Comments
 (0)