From: Imre Deak <imre.deak@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 08/13] drm/i915: use the initialized backlight max value instead of reading it
Date: Wed, 13 Nov 2013 00:42:34 +0200 [thread overview]
Message-ID: <1384296154.2462.58.camel@ideak-mobl> (raw)
In-Reply-To: <56855dfc8f586ee486e0e0a9e26ba9f390d87dfc.1383920621.git.jani.nikula@intel.com>
On Fri, 2013-11-08 at 16:49 +0200, Jani Nikula wrote:
> We now have the max backlight value cached. Use it.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/intel_panel.c | 45 +++++++++++++++++++-----------------
> 1 file changed, 24 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index ed6b1ec..9a55b36 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -436,9 +436,6 @@ static u32 vlv_get_max_backlight(struct intel_connector *connector)
> return _vlv_get_max_backlight(dev, pipe);
> }
>
> -/* XXX: query mode clock or hardware clock and program max PWM appropriately
> - * when it's 0.
> - */
> static u32 intel_panel_get_max_backlight(struct intel_connector *connector)
> {
> struct drm_device *dev = connector->base.dev;
> @@ -466,15 +463,16 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector,
> {
> struct drm_device *dev = connector->base.dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> + struct intel_panel *panel = &connector->panel;
> +
> + WARN_ON(panel->backlight.max == 0);
Just to clarify that I understood this: we can't hit this any more since
setup_backlight returns now -ENODEV if backlight.max == 0 and so we
won't register the backlight device in that case. I assume then that
during booting the BIOS always leaves us with a valid max PWM value in
one of the PWM_CTL regs and it can only get zeroed due to suspend, which
isn't a problem after patch 4. With this:
Reviewed-by: Imre Deak <imre.deak@intel.com>
>
> if (i915_panel_invert_brightness < 0)
> return val;
>
> if (i915_panel_invert_brightness > 0 ||
> dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) {
> - u32 max = intel_panel_get_max_backlight(connector);
> - if (max)
> - return max - val;
> + return panel->backlight.max - val;
> }
>
> return val;
> @@ -555,17 +553,15 @@ static void i9xx_set_backlight(struct intel_connector *connector, u32 level)
> {
> struct drm_device *dev = connector->base.dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> + struct intel_panel *panel = &connector->panel;
> u32 tmp, mask;
>
> + WARN_ON(panel->backlight.max == 0);
> +
> if (is_backlight_combination_mode(dev)) {
> - u32 max = intel_panel_get_max_backlight(connector);
> u8 lbpc;
>
> - /* we're screwed, but keep behaviour backwards compatible */
> - if (!max)
> - max = 1;
> -
> - lbpc = level * 0xfe / max + 1;
> + lbpc = level * 0xfe / panel->backlight.max + 1;
> level /= lbpc;
> pci_write_config_byte(dev->pdev, PCI_LBPC, lbpc);
> }
> @@ -620,13 +616,10 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
>
> spin_lock_irqsave(&dev_priv->backlight_lock, flags);
>
> - freq = intel_panel_get_max_backlight(connector);
> - if (!freq) {
> - /* we are screwed, bail out */
> - goto out;
> - }
> + WARN_ON(panel->backlight.max == 0);
>
> - /* scale to hardware, but be careful to not overflow */
> + /* scale to hardware max, but be careful to not overflow */
> + freq = panel->backlight.max;
> if (freq < max)
> level = level * freq / max;
> else
> @@ -638,7 +631,7 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
>
> if (panel->backlight.enabled)
> intel_panel_actually_set_backlight(connector, level);
> -out:
> +
> spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
> }
>
> @@ -839,8 +832,13 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
>
> spin_lock_irqsave(&dev_priv->backlight_lock, flags);
>
> + /* XXX: transitional, call to make sure freq is set */
> + intel_panel_get_max_backlight(connector);
> +
> + WARN_ON(panel->backlight.max == 0);
> +
> if (panel->backlight.level == 0) {
> - panel->backlight.level = intel_panel_get_max_backlight(connector);
> + panel->backlight.level = panel->backlight.max;
> if (panel->backlight.device)
> panel->backlight.device->props.brightness =
> panel->backlight.level;
> @@ -960,7 +958,12 @@ static void intel_backlight_device_unregister(struct intel_connector *connector)
> }
> #endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
>
> -/* Note: The setup hooks can't assume pipe is set! */
> +/*
> + * Note: The setup hooks can't assume pipe is set!
> + *
> + * XXX: Query mode clock or hardware clock and program PWM modulation frequency
> + * appropriately when it's 0. Use VBT and/or sane defaults.
> + */
> static int pch_setup_backlight(struct intel_connector *connector)
> {
> struct intel_panel *panel = &connector->panel;
next prev parent reply other threads:[~2013-11-12 22:42 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 14:48 [PATCH 00/13] drm/i915: backlight rewrite Jani Nikula
2013-11-08 14:48 ` [PATCH 01/13] drm/i915: clean up backlight conditional build Jani Nikula
2013-11-12 21:23 ` Imre Deak
2013-11-08 14:48 ` [PATCH 02/13] drm/i915: make backlight info per-connector Jani Nikula
2013-11-12 21:29 ` Imre Deak
2013-11-08 14:48 ` [PATCH 03/13] drm/i915: make asle notifications update backlight on all connectors Jani Nikula
2013-11-12 21:29 ` Imre Deak
2013-11-08 14:48 ` [PATCH 04/13] drm/i915: handle backlight through chip specific functions Jani Nikula
2013-11-12 21:36 ` Imre Deak
2013-11-12 23:19 ` Daniel Vetter
2013-11-08 14:48 ` [PATCH 05/13] drm/i915: fix gen2-gen3 backlight set Jani Nikula
2013-11-12 22:00 ` Imre Deak
2013-11-13 8:27 ` Jani Nikula
2013-11-13 9:04 ` Daniel Vetter
2013-11-13 9:12 ` Imre Deak
2013-11-08 14:48 ` [PATCH 06/13] drm/i915: vlv does not have pipe field in backlight registers Jani Nikula
2013-11-12 22:00 ` Imre Deak
2013-11-08 14:48 ` [PATCH 07/13] drm/i915: move backlight level setting in enable/disable to hooks Jani Nikula
2013-11-12 22:01 ` Imre Deak
2013-11-08 14:49 ` [PATCH 08/13] drm/i915: use the initialized backlight max value instead of reading it Jani Nikula
2013-11-12 22:42 ` Imre Deak [this message]
2013-11-13 8:39 ` Jani Nikula
2013-11-13 9:12 ` Daniel Vetter
2013-11-08 14:49 ` [PATCH 09/13] drm/i915: debug print on backlight register Jani Nikula
2013-11-12 22:48 ` Imre Deak
2013-11-13 10:22 ` Daniel Vetter
2013-11-08 14:49 ` [PATCH 10/13] drm/i915: gather backlight information at setup Jani Nikula
2013-11-13 17:01 ` Imre Deak
2013-11-14 5:19 ` Jani Nikula
2013-11-14 8:22 ` Imre Deak
2013-11-08 14:49 ` [PATCH 11/13] drm/i915: do full backlight setup at enable time Jani Nikula
2013-11-13 17:53 ` Imre Deak
2013-11-14 5:43 ` Jani Nikula
2013-11-14 8:27 ` Daniel Vetter
2013-11-14 8:28 ` Imre Deak
2013-11-14 10:13 ` [PATCH v2 " Jani Nikula
2013-11-14 10:46 ` Imre Deak
2013-11-14 10:14 ` [PATCH 11.5/13] drm/i915: remove QUIRK_NO_PCH_PWM_ENABLE Jani Nikula
2013-11-14 10:50 ` Imre Deak
2013-11-08 14:49 ` [PATCH 12/13] drm/i915: nuke get max backlight functions Jani Nikula
2013-11-13 17:54 ` Imre Deak
2013-11-08 14:49 ` [PATCH 13/13] drm/i915: do not save/restore backlight registers Jani Nikula
2013-11-12 23:25 ` Daniel Vetter
2013-11-13 8:40 ` Jani Nikula
2013-11-13 10:56 ` [PATCH v2] drm/i915: do not save/restore backlight registers in KMS Jani Nikula
2013-11-13 18:05 ` Imre Deak
2013-11-14 11:22 ` Daniel Vetter
2013-11-11 8:36 ` [PATCH 00/13] drm/i915: backlight rewrite Jani Nikula
2013-11-12 21:22 ` Imre Deak
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=1384296154.2462.58.camel@ideak-mobl \
--to=imre.deak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
/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