> -----Original Message-----
> From: Kandpal, Suraj <[email protected]>
> Sent: Friday, May 9, 2025 10:48 AM
> To: [email protected]; [email protected]; intel-
> [email protected]; [email protected]
> Cc: Nautiyal, Ankit K <[email protected]>; Murthy, Arun R
> <[email protected]>; Kandpal, Suraj <[email protected]>
> Subject: [PATCH 08/13] drm/dp: Modify drm_edp_backlight_set_level
> 
> Modify drm_edp_backlight_set_level to be able to set the value for register in
> DP_EDP_PANEL_TARGET_LUMINANCE_VALUE. We multiply the level with 1000
> since we get the value in Nits and the register accepts it in milliNits.
> 
> Signed-off-by: Suraj Kandpal <[email protected]>
> ---
>  drivers/gpu/drm/display/drm_dp_helper.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/display/drm_dp_helper.c
> b/drivers/gpu/drm/display/drm_dp_helper.c
> index b17f9e75d93f..b0688945649b 100644
> --- a/drivers/gpu/drm/display/drm_dp_helper.c
> +++ b/drivers/gpu/drm/display/drm_dp_helper.c
> @@ -3936,20 +3936,28 @@ int drm_edp_backlight_set_level(struct
> drm_dp_aux *aux, const struct drm_edp_bac
>                               u32 level)
>  {
>       int ret;
> -     u8 buf[2] = { 0 };
> +     unsigned int offset = DP_EDP_BACKLIGHT_BRIGHTNESS_MSB;
> +     u8 buf[3] = { 0 };
> 
>       /* The panel uses the PWM for controlling brightness levels */
> -     if (!bl->aux_set)
> +     if (!(bl->aux_set || bl->luminance_set))
>               return 0;
> 
> -     if (bl->lsb_reg_used) {
Can a comment be added to specify the units?

Thanks and Regards,
Arun R Murthy
--------------------

> +     if (bl->luminance_set) {
> +             level = level * 1000;
> +             level &= 0xffffff;
> +             buf[0] = (level & 0x0000ff);
> +             buf[1] = (level & 0x00ff00) >> 8;
> +             buf[2] = (level & 0xff0000) >> 16;
> +             offset = DP_EDP_PANEL_TARGET_LUMINANCE_VALUE;
> +     } else if (bl->lsb_reg_used) {
>               buf[0] = (level & 0xff00) >> 8;
>               buf[1] = (level & 0x00ff);
>       } else {
>               buf[0] = level;
>       }
> 
> -     ret = drm_dp_dpcd_write_data(aux,
> DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, buf, sizeof(buf));
> +     ret = drm_dp_dpcd_write_data(aux, offset, buf, sizeof(buf));
>       if (ret < 0) {
>               drm_err(aux->drm_dev,
>                       "%s: Failed to write aux backlight level: %d\n",
> --
> 2.34.1

Reply via email to