drm/i915/vlv: hack to init backlight regs if BIOS fails to do so
Subsystems (2)
PATCH 1/1 drm/i915/vlv: hack to init backlight regs if BIOS fails to do so
Still digging up the actual VBT info for this, but wanted to get this out there for testing, or in case others are also bugged by this.
This can happen if you boot with an external display connected. In that case, the attached eDP backlight modulation frequency may not be programmed, so we need to use something (in this case the value my BIOS normally programs with just the internal display enabled).
--- drivers/gpu/drm/i915/intel_panel.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/i915/intel_panel.c +17 -0
@@ -372,6 +372,9 @@ static u32 i915_read_blc_pwm_ctl(struct drm_device *dev)I915_WRITE (BLC_PWM_CTL2 , dev_priv->regfile.saveBLC_PWM_CTL2); } + +if (IS_VALLEYVIEW (dev) && !val) + val =0xffffffff ; }return val;
@@ -629,10 +632,24 @@ set_level:spin_unlock_irqrestore (&dev_priv->backlight.lock, flags); } +/* FIXME: use VBT vals to init PWM_CTL and PWM_CTL2 correctly */ +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); + } +} +static void intel_panel_init_backlight (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +intel_panel_init_backlight_regs (dev); + dev_priv->backlight.level =intel_panel_get_backlight (dev); dev_priv->backlight.enabled = dev_priv->backlight.level !=0 ; }
Signature · 1 line
1.8.3.1
Jani Nikula
maintainerQuoted 2 lines · Jesse Barnes
Still digging up the actual VBT info for this, but wanted to get this out there for testing, or in case others are also bugged by this.
I had a look at this a few weeks back. The VBT value for max backlight is in Hz (as is the value you get through opregion) and transforming that into the value the registers eat needs some digging. I tried, but none of the real world examples of VBT and PWM freq matched any of that, so I moved on...
Quoted 4 lines
This can happen if you boot with an external display connected. In that case, the attached eDP backlight modulation frequency may not be programmed, so we need to use something (in this case the value my BIOS normally programs with just the internal display enabled).
Something similar is required for non-vlv ChromeOS stuff too AFAIK.
Quoted 10 lines
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/gpu/drm/i915/intel_panel.c +0
-0
drivers/gpu/drm/i915/intel_panel.c static u32 i915_read_blc_pwm_ctl(struct drm_device *dev) · line 377
Quoted 6 lines
drivers/gpu/drm/i915/intel_panel.c +3
-0@@ -372,6 +372,9 @@ static u32 i915_read_blc_pwm_ctl(struct drm_device *dev)I915_WRITE (BLC_PWM_CTL2 , dev_priv->regfile.saveBLC_PWM_CTL2); } + +if (IS_VALLEYVIEW (dev) && !val) + val =0xffffffff ;
Huh, that's a lot... why don't you use the same value here and below?
In fact, it should be sufficient to do the hack right here, as this gets called through intel_panel_setup_backlight(). Then again, this hole function is a kludge... :/
Quoted 5 lines
drivers/gpu/drm/i915/intel_panel.c +0
-0}return val;@@ -629,10 +632,24 @@ set_level:spin_unlock_irqrestore (&dev_priv->backlight.lock, flags);
drivers/gpu/drm/i915/intel_panel.c set_level: · line 642
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +8
-0} +/* FIXME: use VBT vals to init PWM_CTL and PWM_CTL2 correctly */ +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 ;
That should be without the NOT, right?
Quoted 20 lines
drivers/gpu/drm/i915/intel_panel.c +6
-0+I915_WRITE (BLC_PWM_CTL , (0xf42 <<16 ) | cur_val); + } +} +static void intel_panel_init_backlight (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +intel_panel_init_backlight_regs (dev); + dev_priv->backlight.level =intel_panel_get_backlight (dev); dev_priv->backlight.enabled = dev_priv->backlight.level !=0 ; }Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 36 lines · On Wed, 25 Sep 2013 20:18:39 +0300 Jani Nikula <[email protected]>…
Quoted 2 lines · Jesse Barnes
Still digging up the actual VBT info for this, but wanted to get this out there for testing, or in case others are also bugged by this.
I had a look at this a few weeks back. The VBT value for max backlight is in Hz (as is the value you get through opregion) and transforming that into the value the registers eat needs some digging. I tried, but none of the real world examples of VBT and PWM freq matched any of that, so I moved on...
Quoted 4 lines
This can happen if you boot with an external display connected. In that case, the attached eDP backlight modulation frequency may not be programmed, so we need to use something (in this case the value my BIOS normally programs with just the internal display enabled).
Something similar is required for non-vlv ChromeOS stuff too AFAIK.
Quoted 10 lines
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/gpu/drm/i915/intel_panel.c +0
-0drivers/gpu/drm/i915/intel_panel.c static u32 i915_read_blc_pwm_ctl(struct drm_device *dev) · line 377
Quoted 6 lines
drivers/gpu/drm/i915/intel_panel.c +3
-0@@ -372,6 +372,9 @@ static u32 i915_read_blc_pwm_ctl(struct drm_device *dev)I915_WRITE (BLC_PWM_CTL2 , dev_priv->regfile.saveBLC_PWM_CTL2); } + +if (IS_VALLEYVIEW (dev) && !val) + val =0xffffffff ;Huh, that's a lot... why don't you use the same value here and below?
Quoted 3 lines
In fact, it should be sufficient to do the hack right here, as this gets called through
intel_panel_setup_backlight(). Then again, this hole function is a kludge... :/
Simply doing it here isn't enough, because we never actually set the modulation freq bits. But yes, we could use the same magic value in both places. Seems to work either way though.
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_panel.c +0
-0}return val;@@ -629,10 +632,24 @@ set_level:spin_unlock_irqrestore (&dev_priv->backlight.lock, flags); }
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c set_level: · line 642
Quoted 8 lines
drivers/gpu/drm/i915/intel_panel.c +8
-0+/* FIXME: use VBT vals to init PWM_CTL and PWM_CTL2 correctly */ +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 ;That should be without the NOT, right?
No I'm explicitly ignoring the low 16 bits, trying to set the bits for the modulation frequency. Without those, setting a value just gives you a blinking display as the backlight goes on and off about once per 500ms.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 47 lines · On Wed, 25 Sep 2013 20:18:39 +0300 Jani Nikula <[email protected]>…
Quoted 2 lines · Jesse Barnes
Still digging up the actual VBT info for this, but wanted to get this out there for testing, or in case others are also bugged by this.
I had a look at this a few weeks back. The VBT value for max backlight is in Hz (as is the value you get through opregion) and transforming that into the value the registers eat needs some digging. I tried, but none of the real world examples of VBT and PWM freq matched any of that, so I moved on...
Quoted 4 lines
This can happen if you boot with an external display connected. In that case, the attached eDP backlight modulation frequency may not be programmed, so we need to use something (in this case the value my BIOS normally programs with just the internal display enabled).
Something similar is required for non-vlv ChromeOS stuff too AFAIK.
Quoted 10 lines
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/gpu/drm/i915/intel_panel.c +0
-0drivers/gpu/drm/i915/intel_panel.c static u32 i915_read_blc_pwm_ctl(struct drm_device *dev) · line 377
Quoted 6 lines
drivers/gpu/drm/i915/intel_panel.c +3
-0@@ -372,6 +372,9 @@ static u32 i915_read_blc_pwm_ctl(struct drm_device *dev)I915_WRITE (BLC_PWM_CTL2 , dev_priv->regfile.saveBLC_PWM_CTL2); } + +if (IS_VALLEYVIEW (dev) && !val) + val =0xffffffff ;Huh, that's a lot... why don't you use the same value here and below?
In fact, it should be sufficient to do the hack right here, as this gets called through
intel_panel_setup_backlight(). Then again, this hole function is a kludge... :/Quoted 7 lines
drivers/gpu/drm/i915/intel_panel.c +0
-0}return val;@@ -629,10 +632,24 @@ set_level:spin_unlock_irqrestore (&dev_priv->backlight.lock, flags); }
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c set_level: · line 642
Quoted 8 lines
drivers/gpu/drm/i915/intel_panel.c +8
-0+/* FIXME: use VBT vals to init PWM_CTL and PWM_CTL2 correctly */ +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 ;That should be without the NOT, right?
Oops yes, rather than preserving the value I'm about to clobber... :)
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 10 lines · Jani Nikula
Quoted 2 lines · Jesse Barnes
Still digging up the actual VBT info for this, but wanted to get this out there for testing, or in case others are also bugged by this.
I had a look at this a few weeks back. The VBT value for max backlight is in Hz (as is the value you get through opregion) and transforming that into the value the registers eat needs some digging. I tried, but none of the real world examples of VBT and PWM freq matched any of that, so I moved on...
Quoted 6 lines
Quoted 4 lines
This can happen if you boot with an external display connected. In that case, the attached eDP backlight modulation frequency may not be programmed, so we need to use something (in this case the value my BIOS normally programs with just the internal display enabled).
Something similar is required for non-vlv ChromeOS stuff too AFAIK.
Afaik ChromeOS doesn't have a vbt, so I think we need to shovel some failsafe (yeah, failsafe and backlight doesn't compute, I know) default into the regs in case all else fails.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch