@@ -267,8 +267,16 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
267267 */
268268 if (m_rt -> stream -> state != SDW_STREAM_ENABLED &&
269269 m_rt -> stream -> state != SDW_STREAM_PREPARED &&
270- m_rt -> stream -> state != SDW_STREAM_DISABLED )
270+ m_rt -> stream -> state != SDW_STREAM_DISABLED ) {
271271 continue ;
272+ } else if (m_rt -> stream -> type == SDW_STREAM_BPT ) {
273+ /*
274+ * If any BPT stream is running, exclude the BPT columns
275+ * BPT: col 0.. bus->bpt_hstop
276+ * Audio: col bus->bpt_hstop + 1 .. bus->params.col - 1
277+ */
278+ sel_col = bus -> params .col - bus -> bpt_hstop - 1 ;
279+ }
272280 }
273281
274282 /* Don't count BPT stream bandwidth, it will use the remaining bandwidth */
@@ -303,8 +311,13 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
303311 /* There is no control column for lane 1 and above */
304312 if (column_needed > sel_col )
305313 return - EINVAL ;
306- /* Column 0 is control column on lane 0 */
307- if (params [i ].lane == 0 && column_needed > sel_col - 1 )
314+ /*
315+ * Column 0 is the control column on lane 0. However, when sel_col is
316+ * reduced (e.g. due to a running BPT stream), sel_col already represents
317+ * usable audio columns.
318+ */
319+ if (sel_col == bus -> params .col && params [i ].lane == 0 &&
320+ column_needed > sel_col - 1 )
308321 return - EINVAL ;
309322 }
310323 }
@@ -570,8 +583,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
570583 struct sdw_master_runtime * m_rt ;
571584 struct sdw_slave_runtime * s_rt ;
572585 unsigned int curr_dr_freq = 0 ;
586+ bool is_bpt_running = false;
573587 int i , l , clk_values , ret ;
574588 bool is_gear = false;
589+ int available_col ;
575590 int m_lane = 0 ;
576591 u32 * clk_buf ;
577592
@@ -596,6 +611,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
596611 m_rt -> stream -> state < SDW_STREAM_DEPREPARED ) {
597612 clk_values = 1 ;
598613 clk_buf = NULL ;
614+ /*
615+ * If any BPT stream is active, the available audio columns should exclude
616+ * the BPT columns
617+ */
618+ if (m_rt -> stream -> state >= SDW_STREAM_PREPARED )
619+ is_bpt_running = true;
599620 }
600621 }
601622
@@ -618,7 +639,21 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
618639
619640 total_col = curr_dr_freq / mstr_prop -> default_frame_rate / mstr_prop -> default_row ;
620641
621- if (curr_dr_freq * (total_col - 1 ) >=
642+ /*
643+ * available columns for audio stream on lane 0:
644+ * - exclude control column 0
645+ * - if BPT is active, also exclude columns 1..bpt_hstop used by DP0
646+ */
647+ if (is_bpt_running )
648+ available_col = total_col - bus -> bpt_hstop - 1 ;
649+ else
650+ available_col = total_col - 1 ;
651+
652+ if (available_col <= 0 )
653+ continue ;
654+
655+ /* Keep formula consistent with sdw_select_row_col() */
656+ if (curr_dr_freq * available_col >=
622657 bus -> params .bandwidth * total_col )
623658 break ;
624659
0 commit comments