Re: [PATCH] leds: rgb: leds-qcom-lpg: Fix LED color balancing in HW pattern mode
From: Dmitry Baryshkov
Date: Sun Jun 07 2026 - 16:24:30 EST
On Fri, Jun 05, 2026 at 01:18:24AM -0700, Fenglin Wu wrote:
> Currently, when the LED is configured as a RGB LED or a multi-color
> LED device, the same pattern is programmed for all LED channels
> regardless of the sub-led intensities when triggered by HW pattern.
> It results that the LED device is always working in a white-balanced
> mode regardless of the intensity settings.
>
> To fix this, scale the pattern data according to the sub-led intensity
> and program the HW pattern separately for each LPG channel.
>
> Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG")
> Fixes: 6ab1f766a80a ("leds: rgb: leds-qcom-lpg: Add support for PPG through single SDAM")
> Fixes: 5e9ff626861a ("leds: rgb: leds-qcom-lpg: Include support for PPG with dedicated LUT SDAM")
> Assisted-by: Claude:claude-4-6-sonnet
> Signed-off-by: Fenglin Wu <fenglin.wu@xxxxxxxxxxxxxxxx>
> ---
> drivers/leds/rgb/leds-qcom-lpg.c | 174 +++++++++++++++++++++++++++++++--------
> 1 file changed, 141 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index d7d6518de30f..ca84da563e09 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -148,6 +148,24 @@ struct lpg_channel {
> unsigned int pattern_hi_idx;
> };
>
> +/**
> + * struct lpg_pattern - The LPG pattern normalized from the LED pattern
> + * @data: The pattern data array (caller must kfree)
> + * @len: number of entries to write to the LUT
> + * @delta_t: common step duration in ms
> + * @lo_pause: low-pause duration in ms
> + * @hi_pause: high-pause duration in ms
> + * @ping_pong: true if the pattern support reverse
> + */
> +struct lpg_pattern {
> + struct led_pattern *data;
This looks like an overkill. Can you embed the struct here instead of
embedding a pointer?
> + unsigned int len;
> + unsigned int delta_t;
> + unsigned int lo_pause;
> + unsigned int hi_pause;
> + bool ping_pong;
> +};
> +
> /**
> * struct lpg_led - logical LED object
> * @lpg: lpg context reference
--
With best wishes
Dmitry