From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jesse Barnes <jbarnes@virtuousgeek.org>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/i915/vlv: use per-pipe backlight controls
Date: Mon, 30 Sep 2013 11:33:31 +0300 [thread overview]
Message-ID: <87eh864skk.fsf@intel.com> (raw)
In-Reply-To: <1380317977-1009-2-git-send-email-jbarnes@virtuousgeek.org>
On Sat, 28 Sep 2013, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
> With the connector and pipe passed around, we can now set the backlight
> on the right pipe on VLV/BYT.
>
> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> ---
> drivers/gpu/drm/i915/i915_reg.h | 10 ++++++
> drivers/gpu/drm/i915/intel_panel.c | 65 +++++++++++++++++++++++++++++++-------
> 2 files changed, 63 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 96fd2ce..a3b9508 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -2295,6 +2295,16 @@
>
> #define PFIT_AUTO_RATIOS (dev_priv->info->display_mmio_offset + 0x61238)
>
> +#define _VLV_BLC_PWM_CTL2_A (dev_priv->info->display_mmio_offset + 0x61250)
> +#define _VLV_BLC_PWM_CTL2_B (dev_priv->info->display_mmio_offset + 0x61350)
> +#define VLV_BLC_PWM_CTL2(pipe) _PIPE(pipe, _VLV_BLC_PWM_CTL2_A, \
> + _VLV_BLC_PWM_CTL2_B)
> +
> +#define _VLV_BLC_PWM_CTL_A (dev_priv->info->display_mmio_offset + 0x61254)
> +#define _VLV_BLC_PWM_CTL_B (dev_priv->info->display_mmio_offset + 0x61354)
> +#define VLV_BLC_PWM_CTL(pipe) _PIPE(pipe, _VLV_BLC_PWM_CTL_A, \
> + _VLV_BLC_PWM_CTL_B)
> +
> /* Backlight control */
> #define BLC_PWM_CTL2 (dev_priv->info->display_mmio_offset + 0x61250) /* 965+ only */
> #define BLM_PWM_ENABLE (1 << 31)
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 5122f58..03f8450 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -329,6 +329,9 @@ static int is_backlight_combination_mode(struct drm_device *dev)
> {
> struct drm_i915_private *dev_priv = dev->dev_private;
>
> + if (IS_VALLEYVIEW(dev))
> + return 0;
> +
Superfluous since
commit d17d711d3e34d71dada5da5b508738197d749112
Author: Jani Nikula <jani.nikula@intel.com>
Date: Tue Sep 24 16:44:39 2013 +0300
drm/i915: backlight combination mode bit is gen4 only
> if (IS_GEN4(dev))
> return I915_READ(BLC_PWM_CTL2) & BLM_COMBINATION_MODE;
>
> @@ -358,6 +361,21 @@ static u32 i915_read_blc_pwm_ctl(struct drm_device *dev, enum pipe pipe)
> val = dev_priv->regfile.saveBLC_PWM_CTL2;
> I915_WRITE(BLC_PWM_PCH_CTL2, val);
> }
> + } else if (IS_VALLEYVIEW(dev)) {
> + val = I915_READ(VLV_BLC_PWM_CTL(pipe));
> + if (dev_priv->regfile.saveBLC_PWM_CTL == 0) {
> + dev_priv->regfile.saveBLC_PWM_CTL = val;
> + dev_priv->regfile.saveBLC_PWM_CTL2 =
> + I915_READ(VLV_BLC_PWM_CTL2(pipe));
> + } else if (val == 0) {
> + val = dev_priv->regfile.saveBLC_PWM_CTL;
> + I915_WRITE(VLV_BLC_PWM_CTL(pipe), val);
> + I915_WRITE(VLV_BLC_PWM_CTL2(pipe),
> + dev_priv->regfile.saveBLC_PWM_CTL2);
> + }
> +
> + if (!val)
> + val = 0x0f42ffff;
I really really wish I knew what this stuff in this function is (was)
really needed for.
commit 0b0b053a3949f5c467c3b3ba135d4c161f9fbd00
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Tue Nov 23 09:45:50 2010 +0000
drm/i915/panel: Restore saved value of BLC_PWM_CTL
After a GPU reset, the backlight controller registers may be also reset
to 0. In that case we should restore those to the original values
programmed by the BIOS. Note that we still lack the code to handle the
case where the BIOS failed to program those registers at all...
...if backlight controller registers _may_ be reset to 0, what else can?
Anyway, I think you need to add per pipe save/restore to
i915_save_display/i915_restore_display too.
> } else {
> val = I915_READ(BLC_PWM_CTL);
> if (dev_priv->regfile.saveBLC_PWM_CTL == 0) {
> @@ -372,9 +390,6 @@ static u32 i915_read_blc_pwm_ctl(struct drm_device *dev, enum pipe pipe)
> I915_WRITE(BLC_PWM_CTL2,
> dev_priv->regfile.saveBLC_PWM_CTL2);
> }
> -
> - if (IS_VALLEYVIEW(dev) && !val)
> - val = 0x0f42ffff;
> }
>
> return val;
> @@ -435,13 +450,19 @@ static u32 intel_panel_get_backlight(struct drm_device *dev,
> struct drm_i915_private *dev_priv = dev->dev_private;
> u32 val;
> unsigned long flags;
> + int reg;
>
> spin_lock_irqsave(&dev_priv->backlight.lock, flags);
>
> if (HAS_PCH_SPLIT(dev)) {
> val = I915_READ(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
> } else {
> - val = I915_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
> + if (IS_VALLEYVIEW(dev))
> + reg = VLV_BLC_PWM_CTL(pipe);
> + else
> + reg = BLC_PWM_CTL;
> +
> + val = I915_READ(reg) & BACKLIGHT_DUTY_CYCLE_MASK;
> if (INTEL_INFO(dev)->gen < 4)
> val >>= 1;
>
> @@ -473,6 +494,7 @@ static void intel_panel_actually_set_backlight(struct drm_device *dev,
> {
> struct drm_i915_private *dev_priv = dev->dev_private;
> u32 tmp;
> + int reg;
>
> DRM_DEBUG_DRIVER("set backlight PWM = %d\n", level);
> level = intel_panel_compute_brightness(dev, pipe, level);
> @@ -493,11 +515,16 @@ static void intel_panel_actually_set_backlight(struct drm_device *dev,
> pci_write_config_byte(dev->pdev, PCI_LBPC, lbpc);
> }
>
> - tmp = I915_READ(BLC_PWM_CTL);
> + if (IS_VALLEYVIEW(dev))
> + reg = VLV_BLC_PWM_CTL(pipe);
> + else
> + reg = BLC_PWM_CTL;
> +
> + tmp = I915_READ(reg);
> if (INTEL_INFO(dev)->gen < 4)
> level <<= 1;
> tmp &= ~BACKLIGHT_DUTY_CYCLE_MASK;
> - I915_WRITE(BLC_PWM_CTL, tmp | level);
> + I915_WRITE(reg, tmp | level);
> }
>
> /* set backlight brightness to level in range [0..max] */
> @@ -560,7 +587,12 @@ void intel_panel_disable_backlight(struct intel_connector *connector)
> if (INTEL_INFO(dev)->gen >= 4) {
> uint32_t reg, tmp;
>
> - reg = HAS_PCH_SPLIT(dev) ? BLC_PWM_CPU_CTL2 : BLC_PWM_CTL2;
> + if (HAS_PCH_SPLIT(dev))
> + reg = BLC_PWM_CPU_CTL2;
> + else if (IS_VALLEYVIEW(dev))
> + reg = VLV_BLC_PWM_CTL2(pipe);
> + else
> + reg = BLC_PWM_CTL2;
>
> I915_WRITE(reg, I915_READ(reg) & ~BLM_PWM_ENABLE);
>
> @@ -596,8 +628,12 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
> if (INTEL_INFO(dev)->gen >= 4) {
> uint32_t reg, tmp;
>
> - reg = HAS_PCH_SPLIT(dev) ? BLC_PWM_CPU_CTL2 : BLC_PWM_CTL2;
> -
> + if (HAS_PCH_SPLIT(dev))
> + reg = BLC_PWM_CPU_CTL2;
> + else if (IS_VALLEYVIEW(dev))
> + reg = VLV_BLC_PWM_CTL2(pipe);
> + else
> + reg = BLC_PWM_CTL2;
>
> tmp = I915_READ(reg);
>
> @@ -649,9 +685,14 @@ static void intel_panel_init_backlight_regs(struct drm_device *dev)
> struct drm_i915_private *dev_priv = dev->dev_private;
>
> if (IS_VALLEYVIEW(dev)) {
> - u32 cur_val = I915_READ(BLC_PWM_CTL) &
> - BACKLIGHT_DUTY_CYCLE_MASK;
> - I915_WRITE(BLC_PWM_CTL, (0xf42 << 16) | cur_val);
> + enum pipe pipe;
> +
> + for_each_pipe(pipe) {
> + u32 cur_val = I915_READ(VLV_BLC_PWM_CTL(pipe)) &
> + BACKLIGHT_DUTY_CYCLE_MASK;
> + I915_WRITE(VLV_BLC_PWM_CTL(pipe), (0xf42 << 16) |
> + cur_val);
> + }
As follow-up, we should probably check if the freq is there, and only
write the magic value if it isn't.
BR,
Jani.
> }
> }
>
> --
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2013-09-30 8:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-27 21:39 [PATCH 1/2] drm/i915: make backlight functions take a connector Jesse Barnes
2013-09-27 21:39 ` [PATCH 2/2] drm/i915/vlv: use per-pipe backlight controls Jesse Barnes
2013-09-30 8:33 ` Jani Nikula [this message]
2013-09-30 11:25 ` Daniel Vetter
2013-09-30 8:18 ` [PATCH 1/2] drm/i915: make backlight functions take a connector Jani Nikula
2013-09-30 12:15 ` Ville Syrjälä
2013-09-30 12:26 ` Daniel Vetter
2013-10-01 17:52 ` Jesse Barnes
2013-10-01 17:50 ` Jesse Barnes
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=87eh864skk.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jbarnes@virtuousgeek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.