Skip to content

Commit 08f6954

Browse files
committed
soundwire: subtract BPT columns in bandwidth calculation
When a BPT stream is running, we should subtract the columns that is used by the BPT stream in bandwidth calculation. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 619b6ae commit 08f6954

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
567567
struct sdw_master_runtime *m_rt;
568568
struct sdw_slave_runtime *s_rt;
569569
unsigned int curr_dr_freq = 0;
570+
bool is_bpt_running = false;
570571
int i, l, clk_values, ret;
571572
bool is_gear = false;
573+
int available_col;
572574
int m_lane = 0;
573575
u32 *clk_buf;
574576

@@ -593,6 +595,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
593595
m_rt->stream->state < SDW_STREAM_DEPREPARED) {
594596
clk_values = 1;
595597
clk_buf = NULL;
598+
/*
599+
* If any BPT stream is active, the available audio colums should exclude
600+
* the BPT columns
601+
*/
602+
if (m_rt->stream->state >= SDW_STREAM_PREPARED)
603+
s_bpt_running = true;
596604
}
597605
}
598606

@@ -615,7 +623,21 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
615623

616624
total_col = curr_dr_freq / mstr_prop->default_frame_rate / mstr_prop->default_row;
617625

618-
if (curr_dr_freq * (total_col - 1) >=
626+
/*
627+
* available columns for audio stream on lane 0:
628+
* - exclude control column 0
629+
* - if BPT is active, also exclude columns 1..bpt_hstop used by DP0
630+
*/
631+
if (is_bpt_running)
632+
available_col = total_col - bus->bpt_hstop - 1;
633+
else
634+
available_col = total_col - 1;
635+
636+
if (available_col <= 0)
637+
continue;
638+
639+
/* Keep formula consistent with sdw_select_row_col() */
640+
if (curr_dr_freq * available_col >=
619641
bus->params.bandwidth * total_col)
620642
break;
621643

0 commit comments

Comments
 (0)