Repository navigation
Conversation
Currently, we set only peripheral frequency when the peripheral is initialized. However, curr_dr_freq may change after a stream is prepared. Expose the function allow we set peripheral frequency when needed. Signed-off-by: Bard Liao <[email protected]>
ujfalusi
left a comment
There was a problem hiding this comment.
@bardliao, @plbossart, amazing find!!
However the commit messages are in need for update.
| } | ||
|
|
||
| static int sdw_slave_set_frequency(struct sdw_slave *slave) | ||
| int sdw_slave_set_frequency(struct sdw_slave *slave) |
There was a problem hiding this comment.
Can you reword the commit message, it is hard to follow.
Expose the sdw_slave_set_frequency() to allow re-programming the peripheral frequency to follow the curr_dr_freq, which can change after the stream is prepared.
Or something.
| /* Program transport & port parameters for Slave(s) */ | ||
| list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { | ||
| list_for_each_entry(p_rt, &s_rt->port_list, port_node) { | ||
| ret = sdw_slave_set_frequency(s_rt->slave); |
There was a problem hiding this comment.
in my quick reading of the function, it will always program registers, even if they don't change, is that OK?
There was a problem hiding this comment.
in my quick reading of the function, it will always program registers, even if they don't change, is that OK?
Yes, it should be ok
| list_for_each_entry(p_rt, &s_rt->port_list, port_node) { | ||
| ret = sdw_slave_set_frequency(s_rt->slave); | ||
| if (ret < 0) | ||
| return ret; |
There was a problem hiding this comment.
Commit message: it is a good practice if the "commit title" and the "commit message" alone can be understood, generally referring from the message to the title is not nice as one needs to connect the dots...
Message:
Update the peripheral frequency before setting the port params as the curr_dr_freq might have been changed since it's initialization.
There was a problem hiding this comment.
Commit message: it is a good practice if the "commit title" and the "commit message" alone can be understood, generally referring from the message to the title is not nice as one needs to connect the dots...
Message: Update the peripheral frequency before setting the port params as the curr_dr_freq might have been changed since it's initialization.
Updated
…calculated Update the peripheral frequency before setting the port params as the curr_dr_freq might have been changed since it's initialization. Signed-off-by: Bard Liao <[email protected]>
| int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size); | ||
| void sdw_compute_slave_ports(struct sdw_master_runtime *m_rt, | ||
| struct sdw_transport_data *t_data); | ||
| int sdw_slave_set_frequency(struct sdw_slave *slave); |
There was a problem hiding this comment.
sorry, no this is not the right direction @bardliao
It is intentional that this initialization is done on startup. The base clock is programmed once, and then we use initial default clock scale registers.
If and when we implement support for the clock change, the only thing that will be updated will be the clock scale registers. The base will NEVER be updated because this breaks audio functionality.
So no I don't think this helper should be used when starting a stream. It's not what it was designed for.
| /* Program transport & port parameters for Slave(s) */ | ||
| list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { | ||
| list_for_each_entry(p_rt, &s_rt->port_list, port_node) { | ||
| ret = sdw_slave_set_frequency(s_rt->slave); |
There was a problem hiding this comment.
if we want to check the clock frequency, it would be done by writing the same clock scale for all the peripherals on a link, and then we would do it atomically with a bank switch.
In other words, changing the clock is NOT related to the notion of stream. It's something that impacts all peripherals and managers.
|
@plbossart The issue is that bus->params.curr_dr_freq will be assigned in sdw_compute_bus_params(). But we call sdw_slave_set_frequency() only when a peripheral is attached. And we set scale based on mclk and curr_dr_freq in sdw_slave_set_frequency(). The bus->params.curr_dr_freq is set to bus->params.max_dr_freq in sdw_bus_master_add(), and will be calculated in sdw_compute_bus_params() based on required bandwidth. It means peripherals may use a scale based on a wrong curr_dr_freq value. |
|
Close it as we will use single clock rate for now. |
Currently, we set only peripheral frequency when the peripheral is initialized. However, curr_dr_freq may change after a stream is
prepared. set peripheral frequency before sdw_program_slave_port_params() to ensure peripheral frequency is correct when a stream starts.