<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Yeah, looks fine to me.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-DK<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> puthik@google.com [mailto:puthik@google.com]
<b>On Behalf Of </b>Puthikorn Voravootivat<br>
<b>Sent:</b> Friday, May 19, 2017 2:00 PM<br>
<b>To:</b> Pandiyan, Dhinakaran <dhinakaran.pandiyan@intel.com><br>
<b>Cc:</b> puthik@chromium.org; dri-devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; jani.nikula@linux.intel.com<br>
<b>Subject:</b> Re: [Intel-gfx] [PATCH v8 3/5] drm/i915: Add option to support dynamic backlight via DPCD<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi Dhinakaran,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Quick question<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">So what is the update about adding new option in i<span style="font-size:9.5pt">915_params?</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt">Is this patch good to go after fixing the 2 points you mentioned?</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt">Thanks</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, May 17, 2017 at 1:33 PM, Pandiyan, Dhinakaran <<a href="mailto:dhinakaran.pandiyan@intel.com" target="_blank">dhinakaran.pandiyan@intel.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">On Tue, 2017-05-16 at 17:34 -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>
> Signed-off-by: Puthikorn Voravootivat <<a href="mailto:puthik@chromium.org">puthik@chromium.org</a>><br>
> ---<br>
>  drivers/gpu/drm/i915/i915_params.c            |  5 ++++<br>
>  drivers/gpu/drm/i915/i915_params.h            |  3 +-<br>
>  drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 40 +++++++++++++++++++++++----<br>
>  3 files changed, 41 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c<br>
> index 13cf3f1572ab..6eaf660e74da 100644<br>
> --- a/drivers/gpu/drm/i915/i915_params.c<br>
> +++ b/drivers/gpu/drm/i915/i915_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>
> @@ -255,3 +256,7 @@ MODULE_PARM_DESC(enable_dpcd_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(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_params.h b/drivers/gpu/drm/i915/i915_params.h<br>
> index ac02efce6e22..2de3e2850b54 100644<br>
> --- a/drivers/gpu/drm/i915/i915_params.h<br>
> +++ b/drivers/gpu/drm/i915/i915_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_dp_aux_backlight.c b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c<br>
> index 16ba1924308d..c0eeb8fc2013 100644<br>
> --- a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c<br>
> +++ b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c<br>
> @@ -100,10 +100,27 @@ intel_dp_aux_set_backlight(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_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->aux, DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET,<br>
> +                       dbc, sizeof(dbc) < 0)) {<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">Incorrect parentheses placement and return value check.<br>
<br>
> +             DRM_DEBUG_KMS("Failed to write aux DBC brightness level\n");<br>
> +     }<br>
> +}<br>
> +<br>
>  static void intel_dp_aux_enable_backlight(struct intel_connector *connector)<br>
>  {<br>
>       struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base);<br>
>       uint8_t dpcd_buf = 0;<br>
> +     uint8_t new_dpcd_buf = 0;<br>
<br>
nit: unnecessary initialization.<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
>       uint8_t edp_backlight_mode = 0;<br>
><br>
>       if (drm_dp_dpcd_readb(&intel_dp->aux,<br>
> @@ -113,18 +130,15 @@ static void intel_dp_aux_enable_backlight(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_MASK;<br>
><br>
>       switch (edp_backlight_mode) {<br>
>       case DP_EDP_BACKLIGHT_CONTROL_MODE_PWM:<br>
>       case DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET:<br>
>       case DP_EDP_BACKLIGHT_CONTROL_MODE_PRODUCT:<br>
> -             dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;<br>
> -             dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;<br>
> -             if (drm_dp_dpcd_writeb(&intel_dp->aux,<br>
> -                     DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf) < 0) {<br>
> -                     DRM_DEBUG_KMS("Failed to write aux backlight mode\n");<br>
> -             }<br>
> +             new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;<br>
> +             new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;<br>
>               break;<br>
><br>
>       /* Do nothing when it is already DPCD mode */<br>
> @@ -133,6 +147,20 @@ static void intel_dp_aux_enable_backlight(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_ENABLE;<br>
> +             intel_dp_aux_set_dynamic_backlight_percent(intel_dp, 0, 100);<br>
> +             DRM_DEBUG_KMS("Enable dynamic brightness.\n");<br>
> +     }<br>
> +<br>
> +     if (new_dpcd_buf != dpcd_buf) {<br>
> +             if (drm_dp_dpcd_writeb(&intel_dp->aux,<br>
> +                     DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf) < 0) {<br>
> +                     DRM_DEBUG_KMS("Failed to write aux backlight mode\n");<br>
> +             }<br>
> +     }<br>
> +<br>
>       set_aux_backlight_enable(intel_dp, true);<br>
>       intel_dp_aux_set_backlight(connector, connector->panel.backlight.level);<br>
>  }<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>