Linux-PWM Archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: David Lechner <dlechner@baylibre.com>
Cc: Trevor Gamblin <tgamblin@baylibre.com>,
	linux-pwm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	michael.hennerich@analog.com, nuno.sa@analog.com
Subject: Re: [RFC PATCH 0/3] pwm: add support for duty_offset
Date: Fri, 5 Apr 2024 21:55:54 +0200	[thread overview]
Message-ID: <gcibnofcdvs3qwygsuvwobckoyipj2a3t72remo5ohauuvf2cb@4ae4byeom67d> (raw)
In-Reply-To: <CAMknhBFgXdH63_N738qMt6tzK_zWdB-OWvYTWitmBuQNqrN+LQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2698 bytes --]

Hello David,

On Fri, Apr 05, 2024 at 12:03:56PM -0500, David Lechner wrote:
> On Fri, Apr 5, 2024 at 1:23 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > On Thu, Apr 04, 2024 at 08:30:22PM -0400, Trevor Gamblin wrote:
> 
> ...
> 
> > > 2. Should __pwm_apply() explicitly disallow PWM_POLARITY_INVERSED and
> > > duty_offset together?
> >
> > While there is no technical need for that, a configuration with both
> > PWM_POLARITY_INVERSED and duty_offset > 0 is irritating. So I'd say yes,
> > it should be disallowed. When I created the cdev API I even considered
> > dropping .polarity for lowlevel drivers and convert them all to
> > .duty_offset.
> >
> > Having said that I don't like the addition of .supports_offset to
> > struct pwm_chip, which only signals a new incomplete evolution of the
> > pwm framework. Better adapt all drivers and then assume all of them
> > support it.
> 
> But not all chips can fully support this feature. I envisioned this
> flag as something consumer drivers would check when they require a
> chip capable of providing a phase offset between two PWM output
> channels. This way, the consumer driver could fail to probe if the PWM
> chip is not up to the task.
> 
> For example the consumer driver might require two coordinated signals like this:
>       _                   _
> PWM0 | |_________________| |_________________
>            ___                 ___
> PWM1 _____|   |_______________|   |__________
> 
> PWM0: duty_offset = 0, duty_cycle = 1, period = 10
> PWM1: duty_offset = 2, duty_cycle = 2, period = 10
> 
> Do we need to do additional work to support cases like this? Or should
> we just let it fail silently and let it generate incorrect signals if
> someone attempts to use an unsupported hardware configuration?

My vision here is that you can do the following:

	state.duty_offset = 0;
	state.duty_cycle = 1;
	state.period = 10;
	ret = pwm_round_state(pwm, &state);
	if (!is_good_enough(state))
		goto err;

This way pwm_apply_* could just continue to work as it does now (i.e.
implement the biggest period not bigger than requested. For that
implement the biggest duty_offset not bigger than requested and for
these values of period and duty_offset implement the biggest duty_cycle
not bigger than requested.)

This has the advantage that the lowlevel driver doesn't need to judge if
the setting it implements is good enough.

To get there, quite some work has to be invested.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2024-04-05 19:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05  0:30 [RFC PATCH 0/3] pwm: add support for duty_offset Trevor Gamblin
2024-04-05  0:30 ` [RFC PATCH 1/3] pwm: add duty offset support Trevor Gamblin
2024-04-05  0:30 ` [RFC PATCH 2/3] pwm: axi-pwmgen: " Trevor Gamblin
2024-04-05  0:30 ` [RFC PATCH 3/3] pwm: add pwm_config_full to pwm.h Trevor Gamblin
2024-04-05  6:23 ` [RFC PATCH 0/3] pwm: add support for duty_offset Uwe Kleine-König
2024-04-05 14:19   ` Trevor Gamblin
2024-04-05 15:14     ` Uwe Kleine-König
2024-04-05 17:03   ` David Lechner
2024-04-05 19:55     ` Uwe Kleine-König [this message]

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=gcibnofcdvs3qwygsuvwobckoyipj2a3t72remo5ohauuvf2cb@4ae4byeom67d \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=dlechner@baylibre.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=tgamblin@baylibre.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).