@@ -228,8 +228,9 @@ static void _sdw_compute_port_params(struct sdw_bus *bus, struct sdw_group_param
228228 /*
229229 * hstart = hstop - params->hwidth + 1.
230230 * At this point after hstop = hstop - params[i].hwidth above,
231- * the hstart is equal to hstop + 1, and bus->bpt_hstop should
232- * be hstart - 1. so we can set bpt_hstop to hstop directly.
231+ * the hstart is equal to hstop + 1, and bus->params.bpt_hstop
232+ * should be hstart - 1. so we can set bpt_hstop to hstop
233+ * directly.
233234 */
234235 bus -> params .bpt_hstop = hstop ;
235236 }
@@ -267,8 +268,16 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
267268 */
268269 if (m_rt -> stream -> state != SDW_STREAM_ENABLED &&
269270 m_rt -> stream -> state != SDW_STREAM_PREPARED &&
270- m_rt -> stream -> state != SDW_STREAM_DISABLED )
271+ m_rt -> stream -> state != SDW_STREAM_DISABLED ) {
271272 continue ;
273+ } else if (m_rt -> stream -> type == SDW_STREAM_BPT ) {
274+ /*
275+ * If any BPT stream is running or pause, exclude the BPT columns
276+ * BPT: col 0.. bus->params.bpt_hstop
277+ * Audio: col bus->params.bpt_hstop + 1 .. bus->params.col - 1
278+ */
279+ sel_col = bus -> params .col - bus -> params .bpt_hstop - 1 ;
280+ }
272281 }
273282
274283 /* Don't count BPT stream bandwidth, it will use the remaining bandwidth */
@@ -290,6 +299,14 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
290299 for (l = 0 ; l < SDW_MAX_LANES ; l ++ ) {
291300 if (l > 0 && !bus -> params .lane_used_bandwidth [l ])
292301 continue ;
302+
303+ /*
304+ * Currently, BPT stream is only implemented on lane 0 which means all columns
305+ * are available for lane 1 and above. Set sel_col back.
306+ */
307+ if (l > 0 )
308+ sel_col = bus -> params .col ;
309+
293310 /* reset column_needed for each lane */
294311 column_needed = 0 ;
295312 for (i = 0 ; i < group -> count ; i ++ ) {
@@ -303,8 +320,13 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
303320 /* There is no control column for lane 1 and above */
304321 if (column_needed > sel_col )
305322 return - EINVAL ;
306- /* Column 0 is control column on lane 0 */
307- if (params [i ].lane == 0 && column_needed > sel_col - 1 )
323+ /*
324+ * Column 0 is the control column on lane 0. However, when sel_col is
325+ * reduced (e.g. due to a running BPT stream), sel_col already represents
326+ * usable audio columns.
327+ */
328+ if (sel_col == bus -> params .col && params [i ].lane == 0 &&
329+ column_needed > sel_col - 1 )
308330 return - EINVAL ;
309331 }
310332 }
@@ -570,8 +592,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
570592 struct sdw_master_runtime * m_rt ;
571593 struct sdw_slave_runtime * s_rt ;
572594 unsigned int curr_dr_freq = 0 ;
595+ bool is_bpt_running = false;
573596 int i , l , clk_values , ret ;
574597 bool is_gear = false;
598+ int available_col ;
575599 int m_lane = 0 ;
576600 u32 * clk_buf ;
577601
@@ -596,6 +620,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
596620 m_rt -> stream -> state < SDW_STREAM_DEPREPARED ) {
597621 clk_values = 1 ;
598622 clk_buf = NULL ;
623+ /*
624+ * If any BPT stream is active, the available audio columns should exclude
625+ * the BPT columns
626+ */
627+ if (m_rt -> stream -> state >= SDW_STREAM_PREPARED )
628+ is_bpt_running = true;
599629 }
600630 }
601631
@@ -618,7 +648,21 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
618648
619649 total_col = curr_dr_freq / mstr_prop -> default_frame_rate / mstr_prop -> default_row ;
620650
621- if (curr_dr_freq * (total_col - 1 ) >=
651+ /*
652+ * available columns for audio stream on lane 0:
653+ * - exclude control column 0
654+ * - if BPT is active, also exclude columns 1..bpt_hstop used by DP0
655+ */
656+ if (is_bpt_running )
657+ available_col = total_col - bus -> params .bpt_hstop - 1 ;
658+ else
659+ available_col = total_col - 1 ;
660+
661+ if (available_col <= 0 )
662+ continue ;
663+
664+ /* Keep formula consistent with sdw_select_row_col() */
665+ if (curr_dr_freq * available_col >=
622666 bus -> params .bandwidth * total_col )
623667 break ;
624668
0 commit comments