soundwire: qcom: allow multi-link on newer devices
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Fri, 5 Apr 2024 14:41:41 +0000 (16:41 +0200)
committerVinod Koul <vkoul@kernel.org>
Thu, 11 Apr 2024 13:57:17 +0000 (19:27 +0530)
Newer Qualcomm SoCs like X1E80100 might come with four speakers spread
over two Soundwire controllers, thus they need a multi-link Soundwire
stream runtime.

Cc: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240405144141.47217-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/qcom.c

index fb70afe64fcc902e24cd0fedd7b396b31a73e1df..ce5cf3ecceb58769d3e1f71bd574762846df1ac8 100644 (file)
@@ -905,6 +905,18 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
        return 0;
 }
 
+static int qcom_swrm_read_prop(struct sdw_bus *bus)
+{
+       struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus);
+
+       if (ctrl->version >= SWRM_VERSION_2_0_0) {
+               bus->multi_link = true;
+               bus->hw_sync_min_links = 3;
+       }
+
+       return 0;
+}
+
 static enum sdw_command_response qcom_swrm_xfer_msg(struct sdw_bus *bus,
                                                    struct sdw_msg *msg)
 {
@@ -1056,6 +1068,7 @@ static const struct sdw_master_port_ops qcom_swrm_port_ops = {
 };
 
 static const struct sdw_master_ops qcom_swrm_ops = {
+       .read_prop = qcom_swrm_read_prop,
        .xfer_msg = qcom_swrm_xfer_msg,
        .pre_bank_switch = qcom_swrm_pre_bank_switch,
 };
@@ -1173,6 +1186,15 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
 
        mutex_lock(&ctrl->port_lock);
        list_for_each_entry(m_rt, &stream->master_list, stream_node) {
+               /*
+                * For streams with multiple masters:
+                * Allocate ports only for devices connected to this master.
+                * Such devices will have ports allocated by their own master
+                * and its qcom_swrm_stream_alloc_ports() call.
+                */
+               if (ctrl->bus.id != m_rt->bus->id)
+                       continue;
+
                if (m_rt->direction == SDW_DATA_DIR_RX) {
                        maxport = ctrl->num_dout_ports;
                        port_mask = &ctrl->dout_port_mask;