Re: [PATCH] ASoC: da7219: Use clk_round_rate to handle enabled bclk/wclk case

2019-05-01 Thread Mark Brown
On Mon, Apr 29, 2019 at 09:16:08AM +, Adam Thomson wrote:
> On 27 April 2019 18:20, Mark Brown wrote:

> > Don't we need to validate that the rounded rate is actually viable for
> > the parameters we're trying to set here?  If there's missing constraints
> > causing something to try to do something unsupportable then we should
> > return an error rather than silently accept.

> Thanks for directing my gaze to this again. Actually I don't think the SR 
> should
> be rounded at all. If it doesn't match exactly it should fail so I'll remove 
> the
> rounding here. Not sure what my brain was doing there.

Yeah, rounding is dubious with sample rate.  Many applications will be
able to tolerate *some* variation as there's tolerances in the crystals
if nothing else but intentionally allowing it is a bit different.


signature.asc
Description: PGP signature


RE: [PATCH] ASoC: da7219: Use clk_round_rate to handle enabled bclk/wclk case

2019-04-29 Thread Adam Thomson
On 27 April 2019 18:20, Mark Brown wrote:

> On Fri, Apr 26, 2019 at 01:59:24PM +0100, Adam Thomson wrote:
> 
> > +   /*
> > +* Rounding the rate here avoids failure trying to set a new
> > +* rate on an already enabled wclk. In that instance this will
> > +* just set the same rate as is currently in use, and so should
> > +* continue without problem.
> > +*/
> > +   sr = clk_round_rate(wclk, sr);
> > ret = clk_set_rate(wclk, sr);
> > if (ret) {
> > dev_err(component->dev,
> 
> Don't we need to validate that the rounded rate is actually viable for
> the parameters we're trying to set here?  If there's missing constraints
> causing something to try to do something unsupportable then we should
> return an error rather than silently accept.

Thanks for directing my gaze to this again. Actually I don't think the SR should
be rounded at all. If it doesn't match exactly it should fail so I'll remove the
rounding here. Not sure what my brain was doing there.

For the BCLK rate, I'll see what checking can be added there to make sure the
word length is compatible with the 'rounded' BCLK rate.


Re: [PATCH] ASoC: da7219: Use clk_round_rate to handle enabled bclk/wclk case

2019-04-27 Thread Mark Brown
On Fri, Apr 26, 2019 at 01:59:24PM +0100, Adam Thomson wrote:

> + /*
> +  * Rounding the rate here avoids failure trying to set a new
> +  * rate on an already enabled wclk. In that instance this will
> +  * just set the same rate as is currently in use, and so should
> +  * continue without problem.
> +  */
> + sr = clk_round_rate(wclk, sr);
>   ret = clk_set_rate(wclk, sr);
>   if (ret) {
>   dev_err(component->dev,

Don't we need to validate that the rounded rate is actually viable for
the parameters we're trying to set here?  If there's missing constraints
causing something to try to do something unsupportable then we should
return an error rather than silently accept.


signature.asc
Description: PGP signature