Skip to content

Commit d6055b8

Browse files
committed
soundwire: generic_bandwidth_allocation: update bpt_hstop
Update bus->bpt_hstop to record the hstop of the BPT stream. And return -EAGAIN when there is no bandwidth for the BPT stream. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 283f407 commit d6055b8

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ static void sdw_compute_master_ports(struct sdw_master_runtime *m_rt,
190190
sdw_compute_slave_ports(m_rt, &t_data);
191191
}
192192

193-
static void _sdw_compute_port_params(struct sdw_bus *bus,
194-
struct sdw_group_params *params, int count)
193+
static void _sdw_compute_port_params(struct sdw_bus *bus, struct sdw_group_params *params,
194+
int count, bool update_bpt_hstop)
195195
{
196196
struct sdw_master_runtime *m_rt;
197197
int port_bo, i, l;
@@ -223,6 +223,16 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
223223
}
224224

225225
hstop = hstop - params[i].hwidth;
226+
if (l == 0 && update_bpt_hstop && bus->bpt_hstop > hstop) {
227+
/* Assume BPT stream uses lane 0 */
228+
/*
229+
* hstart = hstop - params->hwidth + 1.
230+
* 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.
233+
*/
234+
bus->bpt_hstop = hstop;
235+
}
226236
}
227237
}
228238
}
@@ -421,7 +431,7 @@ static int sdw_compute_port_params(struct sdw_bus *bus, struct sdw_stream_runtim
421431
if (ret < 0)
422432
goto free_params;
423433

424-
_sdw_compute_port_params(bus, params, group.count);
434+
_sdw_compute_port_params(bus, params, group.count, stream->type == SDW_STREAM_BPT);
425435

426436
free_params:
427437
kfree(params);
@@ -695,11 +705,16 @@ int sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
695705
if (ret < 0)
696706
return ret;
697707

698-
bus->bpt_hstop = bus->params.col - 1;
699-
if (stream->type == SDW_STREAM_BPT) {
700-
sdw_compute_dp0_port_params(bus);
701-
return 0;
702-
}
708+
/*
709+
* Set the initial bpt_hstop and reserve 2 columns for future audio stream if there
710+
* are equal or more than 6 columns in the frame shape. We don't reserve columns for
711+
* future audio stream if there are no enough columns available, but BPT stream can
712+
* still use the available columns along with the existing audio streams.
713+
* bpt_hstop will be updated in sdw_compute_port_params() below.
714+
*/
715+
if (stream->type == SDW_STREAM_BPT && stream->state != SDW_STREAM_DEPREPARED &&
716+
bus->params.col >= 6)
717+
bus->bpt_hstop = bus->params.col - 3;
703718

704719
/* Compute transport and port params */
705720
ret = sdw_compute_port_params(bus, stream);
@@ -708,6 +723,15 @@ int sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
708723
return ret;
709724
}
710725

726+
if (stream->type == SDW_STREAM_BPT) {
727+
if (bus->bpt_hstop < 1) {
728+
dev_err(bus->dev, "%s: No bandwidth for BPT stream\n",
729+
__func__);
730+
return -EAGAIN;
731+
}
732+
sdw_compute_dp0_port_params(bus);
733+
}
734+
711735
return 0;
712736
}
713737
EXPORT_SYMBOL(sdw_compute_params);

0 commit comments

Comments
 (0)