<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 2, 2017 at 11:25 AM, Pandiyan, Dhinakaran <span dir="ltr"><<a href="mailto:dhinakaran.pandiyan@intel.com" target="_blank" class="gmail-cremed cremed">dhinakaran.pandiyan@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Fri, 2017-05-26 at 18:42 -0700, Puthikorn Voravootivat wrote:<br>
</span><div><div class="gmail-h5">> This patch adds option to enable dynamic backlight for eDP<br>
> panel that supports this feature via DPCD register and<br>
> set minimum / maximum brightness to 0% and 100% of the<br>
> normal brightness.<br>
><br>
> Signed-off-by: Puthikorn Voravootivat <<a href="mailto:puthik@chromium.org" class="gmail-cremed cremed">puthik@chromium.org</a>><br>
> ---<br>
>  drivers/gpu/drm/i915/i915_<wbr>params.c            |  5 ++++<br>
>  drivers/gpu/drm/i915/i915_<wbr>params.h            |  3 +-<br>
>  drivers/gpu/drm/i915/intel_dp_<wbr>aux_backlight.c | 42 ++++++++++++++++++++++-----<br>
>  3 files changed, 41 insertions(+), 9 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/i915/i915_<wbr>params.c b/drivers/gpu/drm/i915/i915_<wbr>params.c<br>
> index 3758ae1f11b4..ce033d58134e 100644<br>
> --- a/drivers/gpu/drm/i915/i915_<wbr>params.c<br>
> +++ b/drivers/gpu/drm/i915/i915_<wbr>params.c<br>
> @@ -65,6 +65,7 @@ struct i915_params i915 __read_mostly = {<br>
>       .inject_load_failure = 0,<br>
>       .enable_dpcd_backlight = -1,<br>
>       .enable_gvt = false,<br>
> +     .enable_dbc = false,<br>
>  };<br>
><br>
>  module_param_named(modeset, i915.modeset, int, 0400);<br>
> @@ -254,3 +255,7 @@ MODULE_PARM_DESC(enable_dpcd_<wbr>backlight,<br>
>  module_param_named(enable_gvt, i915.enable_gvt, bool, 0400);<br>
>  MODULE_PARM_DESC(enable_gvt,<br>
>       "Enable support for Intel GVT-g graphics virtualization host support(default:false)");<br>
> +<br>
> +module_param_named_unsafe(<wbr>enable_dbc, i915.enable_dbc, bool, 0600);<br>
> +MODULE_PARM_DESC(enable_dbc,<br>
> +     "Enable support for dynamic backlight control (default:false)");<br>
> diff --git a/drivers/gpu/drm/i915/i915_<wbr>params.h b/drivers/gpu/drm/i915/i915_<wbr>params.h<br>
> index ac02efce6e22..2de3e2850b54 100644<br>
> --- a/drivers/gpu/drm/i915/i915_<wbr>params.h<br>
> +++ b/drivers/gpu/drm/i915/i915_<wbr>params.h<br>
> @@ -67,7 +67,8 @@<br>
>       func(bool, nuclear_pageflip); \<br>
>       func(bool, enable_dp_mst); \<br>
>       func(int, enable_dpcd_backlight); \<br>
> -     func(bool, enable_gvt)<br>
> +     func(bool, enable_gvt); \<br>
> +     func(bool, enable_dbc)<br>
><br>
>  #define MEMBER(T, member) T member<br>
>  struct i915_params {<br>
> diff --git a/drivers/gpu/drm/i915/intel_<wbr>dp_aux_backlight.c b/drivers/gpu/drm/i915/intel_<wbr>dp_aux_backlight.c<br>
> index c89aae804659..f55af41ce3bd 100644<br>
> --- a/drivers/gpu/drm/i915/intel_<wbr>dp_aux_backlight.c<br>
> +++ b/drivers/gpu/drm/i915/intel_<wbr>dp_aux_backlight.c<br>
> @@ -100,11 +100,26 @@ intel_dp_aux_set_backlight(<wbr>struct intel_connector *connector, u32 level)<br>
>       }<br>
>  }<br>
><br>
> +/*<br>
> + * Set minimum / maximum dynamic brightness percentage. This value is expressed<br>
> + * as the percentage of normal brightness in 5% increments.<br>
> + */<br>
> +static void<br>
> +intel_dp_aux_set_dynamic_<wbr>backlight_percent(struct intel_dp *intel_dp,<br>
> +                                        u32 min, u32 max)<br>
> +{<br>
> +     u8 dbc[] = { DIV_ROUND_CLOSEST(min, 5), DIV_ROUND_CLOSEST(max, 5) };<br>
> +<br>
> +     if (drm_dp_dpcd_write(&intel_dp-><wbr>aux, DP_EDP_DBC_MINIMUM_BRIGHTNESS_<wbr>SET,<br>
> +                       dbc, sizeof(dbc)) < 0) {<br>
> +             DRM_DEBUG_KMS("Failed to write aux DBC brightness level\n");<br>
> +     }<br>
> +}<br>
> +<br>
>  static void intel_dp_aux_enable_backlight(<wbr>struct intel_connector *connector)<br>
>  {<br>
>       struct intel_dp *intel_dp = enc_to_intel_dp(&connector-><wbr>encoder->base);<br>
> -     uint8_t dpcd_buf = 0;<br>
> -     uint8_t edp_backlight_mode = 0;<br>
> +     uint8_t dpcd_buf, new_dpcd_buf, edp_backlight_mode;<br>
><br>
>       if (drm_dp_dpcd_readb(&intel_dp-><wbr>aux,<br>
>                       DP_EDP_BACKLIGHT_MODE_SET_<wbr>REGISTER, &dpcd_buf) != 1) {<br>
> @@ -113,18 +128,15 @@ static void intel_dp_aux_enable_backlight(<wbr>struct intel_connector *connector)<br>
>               return;<br>
>       }<br>
><br>
> +     new_dpcd_buf = dpcd_buf;<br>
>       edp_backlight_mode = dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_<wbr>MASK;<br>
><br>
>       switch (edp_backlight_mode) {<br>
>       case DP_EDP_BACKLIGHT_CONTROL_MODE_<wbr>PWM:<br>
>       case DP_EDP_BACKLIGHT_CONTROL_MODE_<wbr>PRESET:<br>
>       case DP_EDP_BACKLIGHT_CONTROL_MODE_<wbr>PRODUCT:<br>
> -             dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_<wbr>MODE_MASK;<br>
> -             dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_<wbr>DPCD;<br>
> -             if (drm_dp_dpcd_writeb(&intel_dp-<wbr>>aux,<br>
> -                     DP_EDP_BACKLIGHT_MODE_SET_<wbr>REGISTER, dpcd_buf) < 0) {<br>
> -                     DRM_DEBUG_KMS("Failed to write aux backlight mode\n");<br>
> -             }<br>
> +             new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_<wbr>MODE_MASK;<br>
> +             new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_<wbr>DPCD;<br>
>               break;<br>
><br>
>       /* Do nothing when it is already DPCD mode */<br>
> @@ -133,6 +145,20 @@ static void intel_dp_aux_enable_backlight(<wbr>struct intel_connector *connector)<br>
>               break;<br>
>       }<br>
><br>
> +     if (i915.enable_dbc &&<br>
> +         (intel_dp->edp_dpcd[2] & DP_EDP_DYNAMIC_BACKLIGHT_CAP)) {<br>
> +             new_dpcd_buf |= DP_EDP_DYNAMIC_BACKLIGHT_<wbr>ENABLE;<br>
> +             intel_dp_aux_set_dynamic_<wbr>backlight_percent(intel_dp, 0, 100);<br>
> +             DRM_DEBUG_KMS("Enable dynamic brightness.\n");<br>
> +     }<br>
> +<br>
<br>
<br>
</div></div>Just curious, does DBC require DP AUX brightness control?<br><br></blockquote><div>No. Here is quote from the spec.</div><div>"The Dynamic Backlight Control (DBC) and color engine modes are not listed in Table 10-1,</div><div>because when they are available, they are available for all supported modes."<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-DK<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> +     if (new_dpcd_buf != dpcd_buf) {<br>
> +             if (drm_dp_dpcd_writeb(&intel_dp-<wbr>>aux,<br>
> +                     DP_EDP_BACKLIGHT_MODE_SET_<wbr>REGISTER, new_dpcd_buf) < 0) {<br>
> +                     DRM_DEBUG_KMS("Failed to write aux backlight mode\n");<br>
> +             }<br>
> +     }<br>
> +<br>
>       set_aux_backlight_enable(<wbr>intel_dp, true);<br>
>       intel_dp_aux_set_backlight(<wbr>connector, connector->panel.backlight.<wbr>level);<br>
>  }<br>
<br>
</div></div></blockquote></div><br></div></div>