Skip to content

Commit 8db4392

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 43c33a2 commit 8db4392

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
@@ -588,16 +588,23 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
588588
if (!is_clock_scaling_supported(bus))
589589
clk_values = 1;
590590

591+
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
592+
return -EINVAL;
593+
591594
for (i = 0; i < clk_values; i++) {
595+
int total_col;
596+
592597
if (!clk_buf)
593598
curr_dr_freq = bus->params.max_dr_freq;
594599
else
595600
curr_dr_freq = (is_gear) ?
596601
(bus->params.max_dr_freq >> clk_buf[i]) :
597602
clk_buf[i] * SDW_DOUBLE_RATE_FACTOR;
598603

599-
if (curr_dr_freq * (mstr_prop->default_col - 1) >=
600-
bus->params.bandwidth * mstr_prop->default_col)
604+
total_col = curr_dr_freq / mstr_prop->default_frame_rate / mstr_prop->default_row;
605+
606+
if (curr_dr_freq * (total_col - 1) >=
607+
bus->params.bandwidth * total_col)
601608
break;
602609

603610
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
@@ -659,9 +666,6 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
659666
}
660667
}
661668

662-
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
663-
return -EINVAL;
664-
665669
mstr_prop->default_col = curr_dr_freq / mstr_prop->default_frame_rate /
666670
mstr_prop->default_row;
667671

0 commit comments

Comments
 (0)