diff options
author | Vinod Koul <vkoul@kernel.org> | 2019-08-13 04:35:46 -0400 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2019-09-04 05:27:19 -0400 |
commit | c7578c1d6285252d862b324f6fc26dd5adc8517c (patch) | |
tree | df8b857395a35ee11673115f6ea70c26bcefdb75 | |
parent | a2e484585ad306aa8ac84140ef54d722ac8f45df (diff) |
soundwire: Add compute_params callback
This callback allows masters to compute the bus parameters required.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20190813083550.5877-2-srinivas.kandagatla@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r-- | drivers/soundwire/stream.c | 10 | ||||
-rw-r--r-- | include/linux/soundwire/sdw.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 8d6c13528b68..0bc1b4dbd14b 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c | |||
@@ -1485,6 +1485,16 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream) | |||
1485 | bus->params.bandwidth += m_rt->stream->params.rate * | 1485 | bus->params.bandwidth += m_rt->stream->params.rate * |
1486 | m_rt->ch_count * m_rt->stream->params.bps; | 1486 | m_rt->ch_count * m_rt->stream->params.bps; |
1487 | 1487 | ||
1488 | /* Compute params */ | ||
1489 | if (bus->compute_params) { | ||
1490 | ret = bus->compute_params(bus); | ||
1491 | if (ret < 0) { | ||
1492 | dev_err(bus->dev, "Compute params failed: %d", | ||
1493 | ret); | ||
1494 | return ret; | ||
1495 | } | ||
1496 | } | ||
1497 | |||
1488 | /* Program params */ | 1498 | /* Program params */ |
1489 | ret = sdw_program_params(bus); | 1499 | ret = sdw_program_params(bus); |
1490 | if (ret < 0) { | 1500 | if (ret < 0) { |
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index be9fe08d4e9c..9932eabcb581 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h | |||
@@ -728,6 +728,7 @@ struct sdw_master_ops { | |||
728 | * Bit set implies used number, bit clear implies unused number. | 728 | * Bit set implies used number, bit clear implies unused number. |
729 | * @bus_lock: bus lock | 729 | * @bus_lock: bus lock |
730 | * @msg_lock: message lock | 730 | * @msg_lock: message lock |
731 | * @compute_params: points to Bus resource management implementation | ||
731 | * @ops: Master callback ops | 732 | * @ops: Master callback ops |
732 | * @port_ops: Master port callback ops | 733 | * @port_ops: Master port callback ops |
733 | * @params: Current bus parameters | 734 | * @params: Current bus parameters |
@@ -750,6 +751,7 @@ struct sdw_bus { | |||
750 | DECLARE_BITMAP(assigned, SDW_MAX_DEVICES); | 751 | DECLARE_BITMAP(assigned, SDW_MAX_DEVICES); |
751 | struct mutex bus_lock; | 752 | struct mutex bus_lock; |
752 | struct mutex msg_lock; | 753 | struct mutex msg_lock; |
754 | int (*compute_params)(struct sdw_bus *bus); | ||
753 | const struct sdw_master_ops *ops; | 755 | const struct sdw_master_ops *ops; |
754 | const struct sdw_master_port_ops *port_ops; | 756 | const struct sdw_master_port_ops *port_ops; |
755 | struct sdw_bus_params params; | 757 | struct sdw_bus_params params; |