On Tue, 05 Mar 2024, Suraj Kandpal <suraj.kandpal@xxxxxxxxx> wrote: > As of now whenerver HDR is switched on we use the PWM to change the > backlight as opposed to AUX based backlight changes in terms of nits. > This patch writes to the appropriate DPCD registers to enable aux > based backlight using values in nits. > > Signed-off-by: Suraj Kandpal <suraj.kandpal@xxxxxxxxx> > --- > .../drm/i915/display/intel_dp_aux_backlight.c | 29 ++++++++++++++----- > 1 file changed, 21 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > index 4f58efdc688a..14144347f13f 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > @@ -40,11 +40,6 @@ > #include "intel_dp.h" > #include "intel_dp_aux_backlight.h" > > -/* TODO: > - * Implement HDR, right now we just implement the bare minimum to bring us back into SDR mode so we > - * can make people's backlights work in the mean time > - */ > - > /* > * DP AUX registers for Intel's proprietary HDR backlight interface. We define > * them here since we'll likely be the only driver to ever use these. > @@ -221,7 +216,7 @@ intel_dp_aux_hdr_set_backlight(const struct drm_connector_state *conn_state, u32 > struct intel_connector *connector = to_intel_connector(conn_state->connector); > struct intel_panel *panel = &connector->panel; > > - if (panel->backlight.edp.intel.sdr_uses_aux) { > + if (panel->backlight.edp.intel.sdr_uses_aux || conn_state->hdr_output_metadata) { > intel_dp_aux_hdr_set_aux_backlight(conn_state, level); > } else { > const u32 pwm_level = intel_backlight_level_to_pwm(connector, level); > @@ -251,8 +246,15 @@ intel_dp_aux_hdr_enable_backlight(const struct intel_crtc_state *crtc_state, > } > > ctrl = old_ctrl; > - if (panel->backlight.edp.intel.sdr_uses_aux) { > + if (panel->backlight.edp.intel.sdr_uses_aux || conn_state->hdr_output_metadata) { > ctrl |= INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE; > + > + if (conn_state->hdr_output_metadata) { > + ctrl |= INTEL_EDP_HDR_TCON_SEGMENTED_BACKLIGHT_ENABLE; > + ctrl |= INTEL_EDP_HDR_TCON_2084_DECODE_ENABLE; > + ctrl |= INTEL_EDP_HDR_TCON_2020_GAMUT_ENABLE; > + } > + > intel_dp_aux_hdr_set_aux_backlight(conn_state, level); > } else { > u32 pwm_level = intel_backlight_level_to_pwm(connector, level); > @@ -292,9 +294,11 @@ intel_dp_aux_hdr_setup_backlight(struct intel_connector *connector, enum pipe pi > { > struct drm_i915_private *i915 = to_i915(connector->base.dev); > struct intel_panel *panel = &connector->panel; > + struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder); > struct drm_luminance_range_info *luminance_range = > &connector->base.display_info.luminance_range; > int ret; > + u8 buf[4]; > > drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] SDR backlight is controlled through %s\n", > connector->base.base.id, connector->base.name, > @@ -318,11 +322,20 @@ intel_dp_aux_hdr_setup_backlight(struct intel_connector *connector, enum pipe pi > panel->backlight.min = 0; > } > > + buf[0] = panel->backlight.max & 0xFF; > + buf[1] = (panel->backlight.max & 0xFF00) >> 8; > + buf[2] = (connector->base.hdr_sink_metadata.hdmi_type1.max_fall & 0xFF) >> 16; > + buf[3] = (connector->base.hdr_sink_metadata.hdmi_type1.max_fall & 0xFF00) >> 24; These last two lines will always be 0, which, without looking at any specs, is not right... > + > + ret = drm_dp_dpcd_write(&intel_dp->aux, INTEL_EDP_HDR_CONTENT_LUMINANCE, buf, > + sizeof(buf) != sizeof(buf)); ...but then this doesn't write it to the sink anyway, and it's unclear to me what this actually ends up doing or returning. For certain it's all wrong. Someone(tm) will still need to properly review the rest of the patch, these just caught my eye at a quick glance. BR, Jani. > + if (ret) > + drm_dbg_kms(&i915->drm, "Not able to write content luminence to DPCD register\n"); > + > drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] Using AUX HDR interface for backlight control (range %d..%d)\n", > connector->base.base.id, connector->base.name, > panel->backlight.min, panel->backlight.max); > > - > panel->backlight.level = intel_dp_aux_hdr_get_backlight(connector, pipe); > panel->backlight.enabled = panel->backlight.level != 0; -- Jani Nikula, Intel