All of lore.kernel.org
 help / color / mirror / Atom feed
* PWM and rounding for pwm-ir-tx
@ 2025-11-21 16:04 Uwe Kleine-König
  2025-11-21 22:12 ` Sean Young
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2025-11-21 16:04 UTC (permalink / raw)
  To: Sean Young; +Cc: linux-pwm

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

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.

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?

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.

Best regards
Uwe

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-22 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 16:04 PWM and rounding for pwm-ir-tx Uwe Kleine-König
2025-11-21 22:12 ` Sean Young
2025-11-22 17:40   ` Uwe Kleine-König

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.