Skip to content

Commit 621993e

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 c8b36b8 commit 621993e

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
@@ -593,16 +593,23 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
593593
if (!is_clock_scaling_supported(bus))
594594
clk_values = 1;
595595

596+
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
597+
return -EINVAL;
598+
596599
for (i = 0; i < clk_values; i++) {
600+
int total_col;
601+
597602
if (!clk_buf)
598603
curr_dr_freq = bus->params.max_dr_freq;
599604
else
600605
curr_dr_freq = (is_gear) ?
601606
(bus->params.max_dr_freq >> clk_buf[i]) :
602607
clk_buf[i] * SDW_DOUBLE_RATE_FACTOR;
603608

604-
if (curr_dr_freq * (mstr_prop->default_col - 1) >=
605-
bus->params.bandwidth * mstr_prop->default_col)
609+
total_col = curr_dr_freq / mstr_prop->default_frame_rate / mstr_prop->default_row;
610+
611+
if (curr_dr_freq * (total_col - 1) >=
612+
bus->params.bandwidth * total_col)
606613
break;
607614

608615
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
@@ -664,9 +671,6 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
664671
}
665672
}
666673

667-
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
668-
return -EINVAL;
669-
670674
mstr_prop->default_col = curr_dr_freq / mstr_prop->default_frame_rate /
671675
mstr_prop->default_row;
672676

0 commit comments

Comments
 (0)