Hi, On Mon, Mar 03, 2025 at 01:52:51PM +0200, Abel Vesa wrote: > Ideally, the requested duty cycle should never translate to a PWM > value higher than the selected resolution (PWM size), but currently the > best matched period is never reported back to the PWM consumer, so the > consumer will still be using the requested period which is higher than > the best matched one. This will result in PWM consumer requesting > duty cycle values higher than the allowed PWM value. > > In case of Hi-Res PWMs, the current implementation is capping the PWM > value at a 15-bit resolution, even when the lower resolutions are > selected. > > Fix the issue by capping the PWM value to the maximum value allowed by > the selected resolution. > > Cc: stable@xxxxxxxxxxxxxxx # 6.4 > Fixes: b00d2ed37617 ("leds: rgb: leds-qcom-lpg: Add support for high resolution PWM") > Reviewed-by: Bjorn Andersson <andersson@xxxxxxxxxx> > Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxx> > --- Reviewed-by: Sebastian Reichel <sre@xxxxxxxxxx> Greetings, -- Sebastian > drivers/leds/rgb/leds-qcom-lpg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c > index 4454fc6a38480b61916318dd170f3eddc32976d6..0b6310184988c299d82ee7181982c03d306407a4 100644 > --- a/drivers/leds/rgb/leds-qcom-lpg.c > +++ b/drivers/leds/rgb/leds-qcom-lpg.c > @@ -530,7 +530,7 @@ static void lpg_calc_duty(struct lpg_channel *chan, uint64_t duty) > unsigned int clk_rate; > > if (chan->subtype == LPG_SUBTYPE_HI_RES_PWM) { > - max = LPG_RESOLUTION_15BIT - 1; > + max = BIT(lpg_pwm_resolution_hi_res[chan->pwm_resolution_sel]) - 1; > clk_rate = lpg_clk_rates_hi_res[chan->clk_sel]; > } else { > max = BIT(lpg_pwm_resolution[chan->pwm_resolution_sel]) - 1; > > -- > 2.34.1 >
Attachment:
signature.asc
Description: PGP signature