]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/backlight: Modify function to get VESA brightness in Nits
authorSuraj Kandpal <suraj.kandpal@intel.com>
Thu, 6 Feb 2025 06:32:50 +0000 (12:02 +0530)
committerSuraj Kandpal <suraj.kandpal@intel.com>
Thu, 6 Feb 2025 16:44:42 +0000 (22:14 +0530)
Modify vesa_get_brightness function to take into account
luminance_control_support and based on that read the appropriate
register and return the value.

--v2
-Changes since we now use luminance instead of nits

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Tested-by: Ben Kao <ben.kao@intel.com>
Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250206063253.2827017-6-suraj.kandpal@intel.com
drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c

index 2599aa39b21df3b915e72ef824b751d313654295..ca5fc40fa13af336b3d132d3ad0a9297529364a7 100644 (file)
@@ -451,6 +451,26 @@ intel_dp_aux_hdr_setup_backlight(struct intel_connector *connector, enum pipe pi
 /* VESA backlight callbacks */
 static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, enum pipe unused)
 {
+       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_panel *panel = &connector->panel;
+       u8 buf[3];
+       u32 val = 0;
+       int ret;
+
+       if (panel->backlight.edp.vesa.luminance_control_support) {
+               ret = drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_PANEL_TARGET_LUMINANCE_VALUE, buf,
+                                      sizeof(buf));
+               if (ret < 0) {
+                       drm_err(intel_dp->aux.drm_dev,
+                               "[CONNECTOR:%d:%s] Failed to read Luminance from DPCD\n",
+                               connector->base.base.id, connector->base.name);
+                       return 0;
+               }
+
+               val |= buf[0] | buf[1] << 8 | buf[2] << 16;
+               return val / 1000;
+       }
+
        return connector->panel.backlight.level;
 }