Re: [PATCH 1/2] drm/ssd130x: Scale ssd133x per-channel contrast by brightness on init

From: Javier Martinez Canillas

Date: Thu Jul 30 2026 - 04:13:43 EST


Amit Barzilai <amit.barzilai22@xxxxxxxxx> writes:

Hello Amit,

Thanks for your patch.

> ssd133x_init() wrote the SSD133X_CONTRAST_A/B/C commands with magic hex
> values (0x91/0x50/0x7d). These are a per-channel white-balance
> calibration: the A/B/C channels drive sub-pixels whose OLED materials
> differ in luminous efficiency, so the values set the white point at full
> brightness.
>
> Extract them into ssd133x_set_contrast(), which scales each channel by a
> requested brightness via ssd130x_scale_contrast(), instead of writing the
> calibration unconditionally. This makes the sequence readable, avoids
> repetition, and is a prerequisite for wiring up an ssd133x backlight
> controller that dims while preserving the white point.
>
> Note this changes the ssd133x power-on brightness. Previously the init
> wrote the calibration unscaled and ignored ssd130x->contrast, so the
> panel always booted at full brightness. It now scales by the shared
> default contrast of 127, i.e. half of MAX_CONTRAST (255). This is
> intentional and matches ssd130x, whose contrast register also defaults
> to 127 (mid-scale), so all families now power on at ~50% and report
> props.brightness = 127 / max_brightness = 255 to userspace.
>
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Amit Barzilai <amit.barzilai22@xxxxxxxxx>
> ---

Looks good to me.

Reviewed-by: Javier Martinez Canillas <javierm@xxxxxxxxxx>

--
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat