STRUCT LPG_CHANNEL(9)
π struct lpg_channel(9) π
okay so bestie, we're in the Kernel API Manual today and the star of the show is struct lpg_channel(9) β literally just per channel data. one struct, one channel, all the vibes. let's get into it π«Ά
β¨ NAME β¨
struct lpg_channel β per channel data. that's it, that's the whole name. short, sweet, iconic π
π SYNOPSIS π
struct lpg_channel {
struct lpg *lpg;
u32 base;
unsigned int triled_mask;
unsigned int lut_mask;
unsigned int subtype;
u32 sdam_offset;
bool in_use;
int color;
u32 dtest_line;
u32 dtest_value;
u16 pwm_value;
bool enabled;
u64 period;
unsigned int clk_sel;
unsigned int pre_div_sel;
unsigned int pre_div_exp;
unsigned int pwm_resolution_sel;
bool ramp_enabled;
bool ramp_ping_pong;
bool ramp_oneshot;
bool ramp_reverse;
unsigned short ramp_tick_ms;
unsigned long ramp_lo_pause_ms;
unsigned long ramp_hi_pause_ms;
unsigned int pattern_lo_idx;
unsigned int pattern_hi_idx;
};
no cap, that's a lot of fields, but every single one is doing its job π
π Members π
now the good part β meet the cast, one field at a time. everyone gets a moment to shine β¨
lpgβ reference to parentlpg. the main character it reports to πbaseβ base address of the PWM channel. the address, the whole address, nothing but the address πtriled_maskβ mask inTRILEDto enable this channel. it's the enable button, but make it a bitmask π₯lut_maskβ mask inLUTto start pattern generator for this channel. starts the pattern generator, lowkey a hype-man πsubtypeβ PMIC hardware block subtype. hardware lore, iykyk π§sdam_offsetβ channel offset in LPG SDAM. where it sits in the SDAM neighbourhood πin_useβ channel is exposed to LED framework.truemeans the LED framework has claimed it, so hands off πcolorβ color of the LED attached to this channel. the aesthetic, fr πdtest_lineβ DTEST line for output, or0if disabled. zero means nope, disabled, we're not doing that πdtest_valueβ DTEST line configuration. the settings for that DTEST line βοΈpwm_valueβ duty (in microseconds) of the generated pulses, overridden byLUT. yes unit is microseconds, and yesLUTcan just take over π€enabledβ output enabled? the question mark is load-bearing, bestie πperiodβ period (in nanoseconds) of the generated pulses. nanoseconds!! so tiny, so precise β±οΈclk_selβ reference clock frequency selector. picks which reference clock frequency we're on π°οΈpre_div_selβ divider selector of the reference clock. divider, but the selector one ποΈpre_div_expβ exponential divider of the reference clock. now it's exponential, she's fancy πpwm_resolution_selβ pwm resolution selector. how much resolution do we want? yes πramp_enabledβ duty cycle is driven by iterating over lookup table. the LUT is driving, buckle up πramp_ping_pongβ reverse through pattern, rather than wrapping to start. ping pong!! going back instead of loop-de-loop πramp_oneshotβ perform only a single pass over the pattern. one pass, no encore, periodt βramp_reverseβ iterate over pattern backwards. back, back, back it up πramp_tick_msβ length (in milliseconds) of one step in the pattern. one step = this many ms πΎramp_lo_pause_msβ pause (in milliseconds) before iterating over pattern. the pre-game pause π§ramp_hi_pause_msβ pause (in milliseconds) after iterating over pattern. the post-game pause π¬pattern_lo_idxβ start index of associated pattern. start here bestie π’pattern_hi_idxβ last index of associated pattern. and stop here π΄
heads up:pwm_valueis in microseconds andperiodis in nanoseconds β do not mix them up, that's a vibe check you will fail π
π¦ SEE ALSO π¦
Kernel file ./drivers/leds/rgb/leds-qcom-lpg.c β plus these certified besties: struct lpg_led(9), struct lpg(9), struct lpg_channel_data(9), struct lpg_data(9) β¨
and that's the page!! huge shoutout to ./drivers/leds/rgb for the source and October 2026 for the date β slay, go read the other structs, ily, bye πππ«Ά
π¦ 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