Commit c7578c1d authored by Vinod Koul's avatar Vinod Koul

soundwire: Add compute_params callback

This callback allows masters to compute the bus parameters required.
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20190813083550.5877-2-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent a2e48458
...@@ -1485,6 +1485,16 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream) ...@@ -1485,6 +1485,16 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream)
bus->params.bandwidth += m_rt->stream->params.rate * bus->params.bandwidth += m_rt->stream->params.rate *
m_rt->ch_count * m_rt->stream->params.bps; m_rt->ch_count * m_rt->stream->params.bps;
/* Compute params */
if (bus->compute_params) {
ret = bus->compute_params(bus);
if (ret < 0) {
dev_err(bus->dev, "Compute params failed: %d",
ret);
return ret;
}
}
/* Program params */ /* Program params */
ret = sdw_program_params(bus); ret = sdw_program_params(bus);
if (ret < 0) { if (ret < 0) {
......
...@@ -728,6 +728,7 @@ struct sdw_master_ops { ...@@ -728,6 +728,7 @@ struct sdw_master_ops {
* Bit set implies used number, bit clear implies unused number. * Bit set implies used number, bit clear implies unused number.
* @bus_lock: bus lock * @bus_lock: bus lock
* @msg_lock: message lock * @msg_lock: message lock
* @compute_params: points to Bus resource management implementation
* @ops: Master callback ops * @ops: Master callback ops
* @port_ops: Master port callback ops * @port_ops: Master port callback ops
* @params: Current bus parameters * @params: Current bus parameters
...@@ -750,6 +751,7 @@ struct sdw_bus { ...@@ -750,6 +751,7 @@ struct sdw_bus {
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES); DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
struct mutex bus_lock; struct mutex bus_lock;
struct mutex msg_lock; struct mutex msg_lock;
int (*compute_params)(struct sdw_bus *bus);
const struct sdw_master_ops *ops; const struct sdw_master_ops *ops;
const struct sdw_master_port_ops *port_ops; const struct sdw_master_port_ops *port_ops;
struct sdw_bus_params params; struct sdw_bus_params params;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment