From: Puthikorn Voravootivat <puthik@chromium.org>
To: intel-gfx@lists.freedesktop.org,
Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Puthikorn Voravootivat <puthik@chromium.org>,
dri-devel@lists.freedesktop.org
Subject: [PATCH v6 6/9] drm/i915: Support dynamic backlight via DPCD register
Date: Tue, 9 May 2017 16:40:49 -0700 [thread overview]
Message-ID: <20170509234052.189575-7-puthik@chromium.org> (raw)
In-Reply-To: <20170509234052.189575-1-puthik@chromium.org>
This patch enables dynamic backlight by default for eDP
panel that supports this feature via DPCD register and
set minimum / maximum brightness to 0% and 100% of the
normal brightness.
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
---
drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 39 ++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
index 5ef3ade7c40e..7d323af96636 100644
--- a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
+++ b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
@@ -97,10 +97,27 @@ intel_dp_aux_set_backlight(struct intel_connector *connector, u32 level)
}
}
+/*
+ * Set minimum / maximum dynamic brightness percentage. This value is expressed
+ * as the percentage of normal brightness in 5% increments.
+ */
+static void
+intel_dp_aux_set_dynamic_backlight_percent(struct intel_dp *intel_dp,
+ u32 min, u32 max)
+{
+ u8 dbc[] = { DIV_ROUND_CLOSEST(min, 5), DIV_ROUND_CLOSEST(max, 5) };
+
+ if (drm_dp_dpcd_write(&intel_dp->aux, DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET,
+ dbc, sizeof(dbc) < 0)) {
+ DRM_DEBUG_KMS("Failed to write aux DBC brightness level\n");
+ }
+}
+
static void intel_dp_aux_enable_backlight(struct intel_connector *connector)
{
struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base);
uint8_t dpcd_buf = 0;
+ uint8_t new_dpcd_buf = 0;
uint8_t edp_backlight_mode = 0;
if (drm_dp_dpcd_readb(&intel_dp->aux,
@@ -110,18 +127,15 @@ static void intel_dp_aux_enable_backlight(struct intel_connector *connector)
return;
}
+ new_dpcd_buf = dpcd_buf;
edp_backlight_mode = dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
switch (edp_backlight_mode) {
case DP_EDP_BACKLIGHT_CONTROL_MODE_PWM:
case DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET:
case DP_EDP_BACKLIGHT_CONTROL_MODE_PRODUCT:
- dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
- dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
- if (drm_dp_dpcd_writeb(&intel_dp->aux,
- DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf) < 0) {
- DRM_DEBUG_KMS("Failed to write aux backlight mode\n");
- }
+ new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
+ new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
break;
/* Do nothing when it is already DPCD mode */
@@ -130,6 +144,19 @@ static void intel_dp_aux_enable_backlight(struct intel_connector *connector)
break;
}
+ if (intel_dp->edp_dpcd[2] & DP_EDP_DYNAMIC_BACKLIGHT_CAP) {
+ new_dpcd_buf |= DP_EDP_DYNAMIC_BACKLIGHT_ENABLE;
+ intel_dp_aux_set_dynamic_backlight_percent(intel_dp, 0, 100);
+ DRM_DEBUG_KMS("Enable dynamic brightness.\n");
+ }
+
+ if (new_dpcd_buf != dpcd_buf) {
+ if (drm_dp_dpcd_writeb(&intel_dp->aux,
+ DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf) < 0) {
+ DRM_DEBUG_KMS("Failed to write aux backlight mode\n");
+ }
+ }
+
set_aux_backlight_enable(intel_dp, true);
}
--
2.13.0.rc2.291.g57267f2277-goog
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-05-09 23:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 23:40 [PATCH v6 0/9] Enhancement to intel_dp_aux_backlight driver Puthikorn Voravootivat
2017-05-09 23:40 ` [PATCH v6 1/9] drm/i915: Fix cap check for " Puthikorn Voravootivat
2017-05-11 0:14 ` Pandiyan, Dhinakaran
2017-05-09 23:40 ` [PATCH v6 2/9] drm/i915: Correctly enable backlight brightness adjustment via DPCD Puthikorn Voravootivat
2017-05-09 23:40 ` [PATCH v6 3/9] drm/i915: Drop AUX backlight enable check for backlight control Puthikorn Voravootivat
2017-05-11 0:39 ` Pandiyan, Dhinakaran
2017-05-11 21:01 ` Puthikorn Voravootivat
2017-05-09 23:40 ` [PATCH v6 4/9] drm/i915: Allow choosing how to adjust brightness if both supported Puthikorn Voravootivat
2017-05-11 0:50 ` Pandiyan, Dhinakaran
2017-05-09 23:40 ` [PATCH v6 5/9] drm/i915: Set backlight mode before enable backlight Puthikorn Voravootivat
2017-05-09 23:40 ` Puthikorn Voravootivat [this message]
2017-05-11 5:45 ` [PATCH v6 6/9] drm/i915: Support dynamic backlight via DPCD register Pandiyan, Dhinakaran
2017-05-09 23:40 ` [PATCH v6 7/9] drm/i915: Restore brightness level in aux backlight driver Puthikorn Voravootivat
2017-05-09 23:40 ` [PATCH v6 8/9] drm: Add definition for eDP backlight frequency Puthikorn Voravootivat
2017-05-11 1:09 ` Pandiyan, Dhinakaran
2017-05-09 23:40 ` [PATCH v6 9/9] drm/i915: Set PWM divider to match desired frequency in vbt Puthikorn Voravootivat
2017-05-10 7:45 ` ✗ Fi.CI.BAT: failure for Enhancement to intel_dp_aux_backlight driver (rev5) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170509234052.189575-7-puthik@chromium.org \
--to=puthik@chromium.org \
--cc=dhinakaran.pandiyan@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox