From 733442ee16a371796f586b575777965f44935050 Mon Sep 17 00:00:00 2001 From: Aurabindo Jayamohanan Date: Sat, 14 Sep 2019 21:12:50 +0530 Subject: [PATCH] Enable overriding of arbitrary min brightness Some systems exist with invalid value for its minimum brightness exposed in the vbt resulting in display flickering or other stability issues. To Work around this, arbitrary value of 25% of max brightness was chosen as the min brightness. This patch adds a module parameter so that the user can disable such a restriction if they do not have any issues with their display. Signed-off-by: Aurabindo Jayamohanan --- drivers/gpu/drm/i915/display/intel_panel.c | 26 +++++++++++++++++----- drivers/gpu/drm/i915/i915_params.c | 7 ++++++ drivers/gpu/drm/i915/i915_params.h | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c index 39d742094065..af6ed8b53cf5 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.c +++ b/drivers/gpu/drm/i915/display/intel_panel.c @@ -1545,6 +1545,7 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector) struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct intel_panel *panel = &connector->panel; int min; + int min_override; WARN_ON(panel->backlight.max == 0); @@ -1553,12 +1554,27 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector) * to problems. There are such machines out there. Either our * interpretation is wrong or the vbt has bogus data. Or both. Safeguard * against this by letting the minimum be at most (arbitrarily chosen) - * 25% of the max. + * 25% of the max. Also allow users to override this value as it may be + * too high for some people. */ - min = clamp_t(int, dev_priv->vbt.backlight.min_brightness, 0, 64); - if (min != dev_priv->vbt.backlight.min_brightness) { - DRM_DEBUG_KMS("clamping VBT min backlight %d/255 to %d/255\n", - dev_priv->vbt.backlight.min_brightness, min); + + min_override = i915_modparams.min_brightness; + + if (min_override > 0) { + min = clamp_t(int, dev_priv->vbt.backlight.min_brightness, 0, + 64); + if (min != dev_priv->vbt.backlight.min_brightness) { + DRM_DEBUG_KMS( + "clamping VBT min backlight %d/255 to %d/255\n", + dev_priv->vbt.backlight.min_brightness, min); + } + } else if (min_override == 0) { + min = dev_priv->vbt.backlight.min_brightness; + DRM_DEBUG_KMS("Using minimum brightness value from VBT: %d\n", + min); + } else { + min = 0; + DRM_DEBUG_KMS("Overriding minimum brightness value to 0\n"); } /* vbt value is a coefficient in range [0..255] */ diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 5b07766a1c26..914c5ad2c275 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -105,6 +105,13 @@ i915_param_named(fastboot, int, 0600, "(0=disabled, 1=enabled) " "Default: -1 (use per-chip default)"); +i915_param_named(min_brightness, int, 0600, + "Override minimum brightness " + "(1=minimum brightness capped to an arbitrary value, " + "0=Use minimum value reported from VBT, " + "-1=Use 0 as the minimum brightness value) " + "Default: 1 (Uses 25% of maximum brightness)"); + i915_param_named_unsafe(prefault_disable, bool, 0600, "Disable page prefaulting for pread/pwrite/reloc (default:false). " "For developers only."); diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h index a4770ce46bd2..5428ef1cd2e1 100644 --- a/drivers/gpu/drm/i915/i915_params.h +++ b/drivers/gpu/drm/i915/i915_params.h @@ -65,6 +65,7 @@ struct drm_printer; param(unsigned int, inject_load_failure, 0) \ param(int, fastboot, -1) \ param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE) \ + param(int, min_brightness, 1) \ /* leave bools at the end to not create holes */ \ param(bool, alpha_support, IS_ENABLED(CONFIG_DRM_I915_ALPHA_SUPPORT)) \ param(bool, enable_hangcheck, true) \ -- 2.23.0