STRUCT PWM_WAVEFORM(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct pwm_waveform(9) ✨

okay so bestie, buckle up β€” this is a page from the Kernel API Manual, and it's literally all about struct pwm_waveform, which is… exactly what it sounds like πŸ’… a description of a PWM waveform. iconic behavior, no notes.


🌸 SYNOPSIS 🌸

struct pwm_waveform {
    u64 period_length_ns;
    u64 duty_length_ns;
    u64 duty_offset_ns;
 };

that's it, that's the whole struct. three u64s and a dream 🫢


πŸŽ€ Members πŸŽ€

  • period_length_ns β€” the PWM period, bestie. the whole cycle. the full loop-de-loop ⭐
  • duty_length_ns β€” the PWM duty cycle. the "on" chunk of the vibe 🌈
  • duty_offset_ns β€” where the rising edge sits, measured from the start of the period. like, it doesn't have to start at zero, it's got main character energy and shows up whenever it wants πŸ’…

πŸ¦‹ Description πŸ¦‹

so this struct is a whole other way to represent a PWM waveform β€” an alternative to struct pwm_state down below, and ngl it's the more expressive one πŸ‘‘

it's got a duty_offset_ns, which is huge, because that means it can represent offsets that aren't zero β€” the ones you'd get with .polarity = PWM_POLARITY_NORMAL β€” and it can also do period - duty_cycle β€” which is what you get with .polarity = PWM_POLARITY_INVERSED. so yeah, more range, more slay πŸ”₯

⚠️ heads up though: there is no explicit bool for enabled. none. zero. a "disabled" PWM is represented by .period_length_ns = 0. and like… note further that the behaviour of a "disabled" PWM is undefined 😭 depending on what the hardware can actually do, it might drive the active level, drive the inactive level, go high-z, or even literally keep toggling. so yeah, do not count on it bestie, it's giving chaos πŸ’€

and the unit for all three members? nanoseconds. all of them. every single one πŸ•βœ¨


πŸ’œ SEE ALSO πŸ’œ

the Kernel file ./include/linux/pwm.h, plus: enum pwm_polarity(9), struct pwm_args(9), struct pwm_device(9), pwm_get_state(9), pwm_init_state(9), pwm_get_relative_duty_cycle(9), pwm_set_relative_duty_cycle(9), struct pwm_capture(9), struct pwm_ops(9), struct pwm_chip(9), pwmchip_supports_waveform(9), pwm_config(9), pwm_enable(9), pwm_disable(9), pwm_might_sleep(9) β€” go read them, they're all right there, iykyk πŸ“šπŸ’–


and that's the page!! this one lives in ./include/linux, October 2026 edition, filed under struct pwm_waveform(9) β€” mwah, go forth and waveform responsibly πŸ§šπŸ’…βœ¨

πŸ“¦ where this page comes from