<div dir="ltr">Sorry forgot to remove Gerrit Change-ID before sending the email.<div><br></div><div>Do you want me to send the same patches again with your reviewed-by tag and</div><div>the Gerrit change-Id removed?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 5, 2017 at 11:49 AM, Pandiyan, Dhinakaran <span dir="ltr"><<a href="mailto:dhinakaran.pandiyan@intel.com" target="_blank">dhinakaran.pandiyan@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, 2017-06-02 at 19:04 -0700, Puthikorn Voravootivat wrote:<br>
> 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>
> Change-Id: I52f04b814bb4cd9df570ab59094ae<wbr>974b9baec5b<br>
> Signed-off-by: Puthikorn Voravootivat <<a href="mailto:puthik@chromium.org">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 | 26 ++++++++++++++++++++++++++<br>
>  3 files changed, 33 insertions(+), 1 deletion(-)<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..d84042ddf1fc 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 = true,<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:true)");<br>
> diff --git a/drivers/gpu/drm/i915/i915_<wbr>params.h b/drivers/gpu/drm/i915/i915_<wbr>params.h<br>
> index 643dfaf41c1f..99f68d853c18 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, verbose_state_checks); \<br>
>       func(bool, nuclear_pageflip); \<br>
>       func(bool, enable_dp_mst); \<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 b73b3d431a82..b2f4cc975a3e 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>
> @@ -172,6 +172,24 @@ static bool intel_dp_aux_set_pwm_freq(<wbr>struct intel_connector *connector)<br>
>       return true;<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 bool<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>
> +             return false;<br>
> +     }<br>
> +     return true;<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>
> @@ -205,6 +223,14 @@ static void intel_dp_aux_enable_backlight(<wbr>struct intel_connector *connector)<br>
>               if (intel_dp_aux_set_pwm_freq(<wbr>connector))<br>
>                       new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_<wbr>ENABLE;<br>
><br>
> +     if (i915.enable_dbc &&<br>
> +         (intel_dp->edp_dpcd[2] & DP_EDP_DYNAMIC_BACKLIGHT_CAP)) {<br>
> +             if(intel_dp_aux_set_dynamic_<wbr>backlight_percent(intel_dp, 0, 100)) {<br>
> +                     new_dpcd_buf |= DP_EDP_DYNAMIC_BACKLIGHT_<wbr>ENABLE;<br>
> +                     DRM_DEBUG_KMS("Enable dynamic brightness.\n");<br>
> +             }<br>
> +     }<br>
> +<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>
<br>
</div></div>1) The Gerrit Change-ID's you've added in this version *may* be a<br>
problem, haven't seen any patches here with those before.<br>
2) The PWM v/s AUX heuristics function looks likes a reasonable start<br>
that can be adjusted later. We should be taking into account the number<br>
of brightness levels b/w PWM pin and AUX options IMO.<br>
3) The DPCD r/w needs optimization.<br>
<br>
However things lgtm for now. So,<br>
Reviewed-by: Dhinakaran Pandiyan <<a href="mailto:dhinakaran.pandiyan@intel.com">dhinakaran.pandiyan@intel.com</a><wbr>> for<br>
this series.<br>
<br>
</blockquote></div><br></div>