Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: linux-sound@vger.kernel.org, vkoul@kernel.org
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
	pierre-louis.bossart@linux.dev, bard.liao@intel.com
Subject: [PATCH 08/12] Soundwire: generic_bandwidth_allocation: set frame shape on fly
Date: Mon,  4 Nov 2024 03:23:54 +0000	[thread overview]
Message-ID: <20241104032358.669705-9-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20241104032358.669705-1-yung-chuan.liao@linux.intel.com>

We need to recalculate frame shape when sdw bus clock is changed.
And need to make sure all Peripherals connected to the Manager support
dynamic clock change.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 .../soundwire/generic_bandwidth_allocation.c  | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/soundwire/generic_bandwidth_allocation.c b/drivers/soundwire/generic_bandwidth_allocation.c
index 2950a3d002ce..d847413141d3 100644
--- a/drivers/soundwire/generic_bandwidth_allocation.c
+++ b/drivers/soundwire/generic_bandwidth_allocation.c
@@ -327,6 +327,19 @@ static int sdw_select_row_col(struct sdw_bus *bus, int clk_freq)
 	return -EINVAL;
 }
 
+static bool is_clock_scaling_supported(struct sdw_bus *bus)
+{
+	struct sdw_master_runtime *m_rt;
+	struct sdw_slave_runtime *s_rt;
+
+	list_for_each_entry(m_rt, &bus->m_rt_list, bus_node)
+		list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node)
+			if (!is_clock_scaling_supported_by_slave(s_rt->slave))
+				return false;
+
+	return true;
+}
+
 /**
  * sdw_compute_bus_params: Compute bus parameters
  *
@@ -352,6 +365,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
 		clk_buf = NULL;
 	}
 
+	/* If dynamic scaling is not supported, don't try higher freq */
+	if (!is_clock_scaling_supported(bus))
+		clk_values = 1;
+
 	for (i = 0; i < clk_values; i++) {
 		if (!clk_buf)
 			curr_dr_freq = bus->params.max_dr_freq;
@@ -378,6 +395,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
 		return -EINVAL;
 	}
 
+	if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
+		return -EINVAL;
+
+	mstr_prop->default_col = curr_dr_freq / mstr_prop->default_frame_rate /
+				 mstr_prop->default_row;
+
 	ret = sdw_select_row_col(bus, curr_dr_freq);
 	if (ret < 0) {
 		dev_err(bus->dev, "%s: could not find frame configuration for bus dr_freq %d\n",
-- 
2.34.1


  parent reply	other threads:[~2024-11-04  3:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04  3:23 [PATCH 00/12] soundwire: add multi-lane support Bard Liao
2024-11-04  3:23 ` [PATCH 01/12] soundwire: add lane field in sdw_port_runtime Bard Liao
2024-11-04  3:23 ` [PATCH 02/12] soundwire: mipi_disco: read lane mapping properties from ACPI Bard Liao
2024-11-04  3:23 ` [PATCH 03/12] soundwire: add lane_used_bandwidth in struct sdw_bus Bard Liao
2024-11-04  3:23 ` [PATCH 04/12] soundwire: stream: set DEPREPARED state earlier Bard Liao
2024-11-04  3:23 ` [PATCH 05/12] soundwire: generic_bandwidth_allocation: skip DEPREPARED streams Bard Liao
2024-11-04  3:23 ` [PATCH 06/12] Soundwire: add sdw_slave_get_scale_index helper Bard Liao
2024-11-04  3:23 ` [PATCH 07/12] Soundwire: stream: program BUSCLOCK_SCALE Bard Liao
2024-11-04  3:23 ` Bard Liao [this message]
2024-11-04  3:23 ` [PATCH 09/12] soundwire: generic_bandwidth_allocation: correct clk_freq check in sdw_select_row_col Bard Liao
2024-11-04  3:23 ` [PATCH 10/12] soundwire: generic_bandwidth_allocation: check required freq accurately Bard Liao
2024-11-04  3:23 ` [PATCH 11/12] soundwire: generic_bandwidth_allocation: select data lane Bard Liao
2024-11-04  3:23 ` [PATCH 12/12] soundwire: generic_bandwidth_allocation: add lane in sdw_group_params Bard Liao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241104032358.669705-9-yung-chuan.liao@linux.intel.com \
    --to=yung-chuan.liao@linux.intel.com \
    --cc=bard.liao@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=vinod.koul@linaro.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox