@@ -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 */
@@ -290,6 +298,14 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
290298 for (l = 0 ; l < SDW_MAX_LANES ; l ++ ) {
291299 if (l > 0 && !bus -> params .lane_used_bandwidth [l ])
292300 continue ;
301+
302+ /*
303+ * Currently, BPT stream is only implemented on lane 0 which means all columns
304+ * are available for lane 1 and above. Set sel_col back.
305+ */
306+ if (l > 0 )
307+ sel_col = bus -> params .col ;
308+
293309 /* reset column_needed for each lane */
294310 column_needed = 0 ;
295311 for (i = 0 ; i < group -> count ; i ++ ) {
@@ -303,8 +319,13 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
303319 /* There is no control column for lane 1 and above */
304320 if (column_needed > sel_col )
305321 return - EINVAL ;
306- /* Column 0 is control column on lane 0 */
307- if (params [i ].lane == 0 && column_needed > sel_col - 1 )
322+ /*
323+ * Column 0 is the control column on lane 0. However, when sel_col is
324+ * reduced (e.g. due to a running BPT stream), sel_col already represents
325+ * usable audio columns.
326+ */
327+ if (sel_col == bus -> params .col && params [i ].lane == 0 &&
328+ column_needed > sel_col - 1 )
308329 return - EINVAL ;
309330 }
310331 }
@@ -570,8 +591,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
570591 struct sdw_master_runtime * m_rt ;
571592 struct sdw_slave_runtime * s_rt ;
572593 unsigned int curr_dr_freq = 0 ;
594+ bool is_bpt_running = false;
573595 int i , l , clk_values , ret ;
574596 bool is_gear = false;
597+ int available_col ;
575598 int m_lane = 0 ;
576599 u32 * clk_buf ;
577600
@@ -596,6 +619,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
596619 m_rt -> stream -> state < SDW_STREAM_DEPREPARED ) {
597620 clk_values = 1 ;
598621 clk_buf = NULL ;
622+ /*
623+ * If any BPT stream is active, the available audio columns should exclude
624+ * the BPT columns
625+ */
626+ if (m_rt -> stream -> state >= SDW_STREAM_PREPARED )
627+ is_bpt_running = true;
599628 }
600629 }
601630
@@ -618,7 +647,21 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
618647
619648 total_col = curr_dr_freq / mstr_prop -> default_frame_rate / mstr_prop -> default_row ;
620649
621- if (curr_dr_freq * (total_col - 1 ) >=
650+ /*
651+ * available columns for audio stream on lane 0:
652+ * - exclude control column 0
653+ * - if BPT is active, also exclude columns 1..bpt_hstop used by DP0
654+ */
655+ if (is_bpt_running )
656+ available_col = total_col - bus -> bpt_hstop - 1 ;
657+ else
658+ available_col = total_col - 1 ;
659+
660+ if (available_col <= 0 )
661+ continue ;
662+
663+ /* Keep formula consistent with sdw_select_row_col() */
664+ if (curr_dr_freq * available_col >=
622665 bus -> params .bandwidth * total_col )
623666 break ;
624667
0 commit comments