On Wed, Nov 20, 2019 at 12:53 PM Stephan Gerhold stephan@gerhold.net wrote:
On Thu, Nov 14, 2019 at 02:15:25PM +0100, Linus Walleij wrote:
/* Calculate the PWM duty cycle in n/256's */
pwm_ratio = max(((duty_ns * 256) / period_ns) - 1, 1);
pwm_div = max(1,
((FOSC * period_ns) / 256) /
SCALE_FACTOR_NS_DIV_MHZ);
Does this handle the case where brightness = 0 (usually display off)?
Yeah for brightness = 0 it will get duty_ns = 0 and the max() clause will set the duty cycle to 1.
I have also often seen code like
if (bl->props.power != FB_BLANK_UNBLANK || bl->props.fb_blank != FB_BLANK_UNBLANK || bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) brightness = 0;
to handle the blanking states. Not sure.
It makes sense to wind down the brightness to minimum when blanking to save power, but that code seems a bit hairy, so not sure what is the right thing to do here :/
I guess I could just implement enable/disable for the backlight and wind it down to 0 in disable and back to whatever brightness is in enable. But I don't know if that is a good idea since I don't really enable/disable the backlight (it cannot be disable without shutting down the display).
Yours, Linus Walleij