public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Alex Ivanov <gnidorah@ya.ru>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH] drm/i915: Allow user to override PWM backlight frequency and duty cycle
Date: Wed, 17 Jan 2018 10:22:56 +0300	[thread overview]
Message-ID: <20180117072256.17185-1-gnidorah@ya.ru> (raw)
In-Reply-To: <20180116134039.24178-1-gnidorah@ya.ru>

Fixed to merge against drm-tip branch

Signed-off-by: Alex Ivanov <gnidorah@ya.ru>
---
 drivers/gpu/drm/i915/i915_params.c |  6 ++++++
 drivers/gpu/drm/i915/i915_params.h |  2 ++
 drivers/gpu/drm/i915/intel_panel.c | 17 +++++++++++++++++
 3 files changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index b5f3eb4fa8a3..2a7b0c20f1d0 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -175,6 +175,12 @@ i915_param_named(enable_dpcd_backlight, bool, 0600,
 i915_param_named(enable_gvt, bool, 0400,
 	"Enable support for Intel GVT-g graphics virtualization host support(default:false)");
 
+i915_param_named_unsafe(backlight_freq, uint, 0400,
+	"Override PWM backlight frequency (set in Hz, 0=ignore [default])");
+
+i915_param_named_unsafe(backlight_min_level, uint, 0400,
+	"Override PWM backlight minimum level (duty cycle, 0=ignore [default])");
+
 static __always_inline void _print_param(struct drm_printer *p,
 					 const char *name,
 					 const char *type,
diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
index c96360398072..5e2c077c6f2c 100644
--- a/drivers/gpu/drm/i915/i915_params.h
+++ b/drivers/gpu/drm/i915/i915_params.h
@@ -55,6 +55,8 @@ struct drm_printer;
 	param(int, edp_vswing, 0) \
 	param(int, reset, 2) \
 	param(unsigned int, inject_load_failure, 0) \
+	param(unsigned int, backlight_freq, 0) \
+	param(unsigned int, backlight_min_level, 0) \
 	/* leave bools at the end to not create holes */ \
 	param(bool, alpha_support, IS_ENABLED(CONFIG_DRM_I915_ALPHA_SUPPORT)) \
 	param(bool, enable_cmd_parser, true) \
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index fa6831f8c004..eb5f0665b5f9 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1479,6 +1479,12 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
 
 	WARN_ON(panel->backlight.max == 0);
 
+	if (i915_modparams.backlight_min_level) {
+		DRM_DEBUG_KMS("Override backlight duty cycle %u\n",
+						i915_modparams.backlight_min_level);
+		return i915_modparams.backlight_min_level;
+	}
+
 	/*
 	 * XXX: If the vbt value is 255, it makes min equal to max, which leads
 	 * to problems. There are such machines out there. Either our
@@ -1795,6 +1801,7 @@ int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe)
 	struct intel_connector *intel_connector = to_intel_connector(connector);
 	struct intel_panel *panel = &intel_connector->panel;
 	int ret;
+	u32 pwm;
 
 	if (!dev_priv->vbt.backlight.present) {
 		if (dev_priv->quirks & QUIRK_BACKLIGHT_PRESENT) {
@@ -1812,6 +1819,16 @@ int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe)
 	/* set level and max in panel struct */
 	mutex_lock(&dev_priv->backlight_lock);
 	ret = panel->backlight.setup(intel_connector, pipe);
+	if (i915_modparams.backlight_freq) {
+		if (panel->backlight.hz_to_pwm &&
+				(pwm = panel->backlight.hz_to_pwm(intel_connector, i915_modparams.backlight_freq))) {
+			panel->backlight.max = pwm;
+			DRM_DEBUG_KMS("Override backlight frequency %u Hz\n",
+							i915_modparams.backlight_freq);
+		} else {
+			DRM_DEBUG_KMS("failed to override backlight frequency\n");
+		}
+	}
 	mutex_unlock(&dev_priv->backlight_lock);
 
 	if (ret) {
-- 
2.15.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-01-17  7:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 13:40 [PATCH] drm/i915: Allow user to override PWM backlight frequency and duty cycle Alex Ivanov
2018-01-16 14:41 ` ✗ Fi.CI.BAT: failure for " Patchwork
2018-01-16 15:36   ` gnidorah
2018-01-16 19:26     ` Saarinen, Jani
2018-01-17  7:22 ` Alex Ivanov [this message]
2018-01-17  7:46 ` ✓ Fi.CI.BAT: success for drm/i915: Allow user to override PWM backlight frequency and duty cycle (rev2) Patchwork
2018-01-17  8:59 ` ✗ Fi.CI.IGT: warning " Patchwork
2018-01-17 13:12 ` [PATCH] drm/i915: Allow user to override PWM backlight frequency and duty cycle Jani Nikula
2018-01-17 17:49   ` Alex Ivanov

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=20180117072256.17185-1-gnidorah@ya.ru \
    --to=gnidorah@ya.ru \
    --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