STRUCT PWM_WAVEFORM(9)
β¨ 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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms