Skip to content

Commit 3ddd303

Browse files
bardliaovinodkoul
authored andcommitted
Soundwire: generic_bandwidth_allocation: set frame shape on fly
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> Link: https://lore.kernel.org/r/20241218080155.102405-9-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 645291c commit 3ddd303

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,19 @@ static int sdw_select_row_col(struct sdw_bus *bus, int clk_freq)
327327
return -EINVAL;
328328
}
329329

330+
static bool is_clock_scaling_supported(struct sdw_bus *bus)
331+
{
332+
struct sdw_master_runtime *m_rt;
333+
struct sdw_slave_runtime *s_rt;
334+
335+
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node)
336+
list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node)
337+
if (!is_clock_scaling_supported_by_slave(s_rt->slave))
338+
return false;
339+
340+
return true;
341+
}
342+
330343
/**
331344
* sdw_compute_bus_params: Compute bus parameters
332345
*
@@ -352,6 +365,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
352365
clk_buf = NULL;
353366
}
354367

368+
/* If dynamic scaling is not supported, don't try higher freq */
369+
if (!is_clock_scaling_supported(bus))
370+
clk_values = 1;
371+
355372
for (i = 0; i < clk_values; i++) {
356373
if (!clk_buf)
357374
curr_dr_freq = bus->params.max_dr_freq;
@@ -378,6 +395,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
378395
return -EINVAL;
379396
}
380397

398+
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
399+
return -EINVAL;
400+
401+
mstr_prop->default_col = curr_dr_freq / mstr_prop->default_frame_rate /
402+
mstr_prop->default_row;
403+
381404
ret = sdw_select_row_col(bus, curr_dr_freq);
382405
if (ret < 0) {
383406
dev_err(bus->dev, "%s: could not find frame configuration for bus dr_freq %d\n",

0 commit comments

Comments
 (0)