]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/dp: Modify drm_edp_backlight_set_level
authorSuraj Kandpal <suraj.kandpal@intel.com>
Fri, 20 Jun 2025 06:34:40 +0000 (12:04 +0530)
committerSuraj Kandpal <suraj.kandpal@intel.com>
Mon, 30 Jun 2025 15:11:46 +0000 (20:41 +0530)
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.

--v2
-Add comment regarding the unit [Arun]

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
Link: https://lore.kernel.org/r/20250620063445.3603086-9-suraj.kandpal@intel.com
drivers/gpu/drm/display/drm_dp_helper.c

index c22d97e0f18707bd6d82a52dc3d3a0da499a999c..c29c327a72afc5d1e2ae0bae1daeb51c4c7af5dd 100644 (file)
@@ -3944,20 +3944,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) {
+       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",