Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

From: Clemens Gruber
Date: Mon Dec 07 2020 - 18:25:36 EST


On Mon, Dec 07, 2020 at 05:34:58PM -0500, Sven Van Asbroeck wrote:
> Hi Uwe,
>
> On Mon, Dec 7, 2020 at 5:00 PM Uwe Kleine-König
> <u.kleine-koenig@xxxxxxxxxxxxxx> wrote:
> >
> > This is not acceptable, if you have two PWM outputs and a consumer
> > modifies one of them the other must change. So if this chip only
> > supports a single period length of all channels, the first consumer
> > enabling a channel defines the period to be used. All later consumers
> > must live with that. (Also the first must be denied modifying the period
> > if a second consumer has enabled its PWM.)
>
> That makes sense. However, a possible wrinkle: when more than one pwm channel
> is requested, which one is able to change the period?
>
> Example:
> 1. start with all pwms free
> 2. pwm_request(0), pwm_apply(period=200Hz)
> 3. pwm_request(1)
> 4. pwm_apply(1, period=400Hz) fails?
> 5. pwm_apply(0, period=400Hz) succeeds?
>
> And if (5) succeeds, then pwm_get_state(1) will still return period=200Hz,
> because the pwm core doesn't realize anything has changed. Are you ok
> with this behaviour?

I think we'd have to deny the pwm_apply in step 5 as well. So, only the
first consumer is allowed to change the period and only as long as it is
the only one that is in use / was requested.

But that's definitely a breaking change.

Thanks,
Clemens