All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: linux-pwm@vger.kernel.org
Subject: Re: PWM and rounding for pwm-ir-tx
Date: Fri, 21 Nov 2025 22:12:08 +0000	[thread overview]
Message-ID: <aSDjuAcJRhDFhmgc@gofer.mess.org> (raw)
In-Reply-To: <o7fry6bjh3trqrjb5vethqq4mumg37wjnvqafjlzuxc2ynedck@nb4x43jajm3j>

Hello Uwe,

On Fri, Nov 21, 2025 at 05:04:41PM +0100, Uwe Kleine-König wrote:
> Hello Sean,
> 
> I'm currently working on the pwm-bcm2835 driver, converting it to the
> waveform PWM API.
> 
> A result of that conversation is that calling pwm_apply_atomic() will
> result in the period being rounded down instead of rounded to the
> nearest possible value. Looking at commit 11fc4edc483b ("pwm: bcm2835:
> Improve precision of PWM") I guess you will be unhappy about that.
> 
> The obvious way forward is to let the pwm-ir-tx driver make use of the
> waveform API which allows better control over the actual hardware
> output.

That's very interesting, I must have missed the new waveform API. I agree,
this is a great way forward.

> I looked into the pwm-ir-tx driver to check if I can do the conversion,
> but didn't understand the protocol good enough to try that.
> 
> I wonder if you are still interested enough in the driver to do the
> conversion yourself? Alternatively can you point me to some documention
> resource explaining the protocol? Maybe there is even an easy way to
> test changes?

I'm more than happy to do the conversion, then I can also test that works
correctly with a logic analyizer.

> One thing that I noticed is that
> 
> 	pwm_ir->state->enabled = !(pwm_ir->txbuf_index % 2);
> 	pwm_apply_atomic(pwm_ir->pwm, pwm_ir->state);
> 
> is conceptually broken because the output of a disabled PWM is
> undefined. Many hardwares emit a constant inactive level, but others
> might emit active instead, or a random level or might even continue to
> toggle. If you want to be sure to drive the inactive level, keep the PWM
> enabled but use duty_cycle = 0.

That's very useful, I did not know that. I'll write a fix for that.

For the pwm-bcm2835 driver: do you have a draft commit that enables the
waveform API? That way I can start testing any changes I make to pwm-ir-tx
on RPi.

Thank you for keeping in the loop on this, I should pay closer attention
to the list.


Sean

  reply	other threads:[~2025-11-21 22:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 16:04 PWM and rounding for pwm-ir-tx Uwe Kleine-König
2025-11-21 22:12 ` Sean Young [this message]
2025-11-22 17:40   ` Uwe Kleine-König

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=aSDjuAcJRhDFhmgc@gofer.mess.org \
    --to=sean@mess.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=u.kleine-koenig@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.