drm/i915: Correctly read backlight PWM for pipe B on vlv/chv
Subsystems (2)
PATCH 1/1 drm/i915: Correctly read backlight PWM for pipe B on vlv/chv
From: Rafael Barbalho <[email protected]>
Make the vlv/chv backlight setup more generic by actually looking at which pipe the panel is attached to and read the backlight PWM registers that were setup by the bios from that pipe.
--- drivers/gpu/drm/i915/intel_panel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +10 -14
@@ -1200,32 +1200,28 @@ static int vlv_setup_backlight(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; -enum pipe pipe; +enum pipe pipe =intel_get_pipe_from_connector (connector);u32 ctl, ctl2, val; -for_each_pipe (pipe) { -u32 cur_val =I915_READ (VLV_BLC_PWM_CTL (pipe)); + ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (pipe)); + panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; -/* Skip if the modulation freq is already set */ -if (cur_val & ~BACKLIGHT_DUTY_CYCLE_MASK ) -continue ; + ctl =I915_READ (VLV_BLC_PWM_CTL (pipe)); - cur_val &=BACKLIGHT_DUTY_CYCLE_MASK ; -I915_WRITE (VLV_BLC_PWM_CTL (pipe), (0xf42 <<16 ) | - cur_val); +/* Skip if the modulation freq is already set */ +if ((ctl & ~BACKLIGHT_DUTY_CYCLE_MASK ) ==0 ) { + ctl &=BACKLIGHT_DUTY_CYCLE_MASK ; + ctl |= (0xf42 <<16 ); +I915_WRITE (VLV_BLC_PWM_CTL (pipe), ctl); } - ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (PIPE_A )); - panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; - - ctl =I915_READ (VLV_BLC_PWM_CTL (PIPE_A )); panel->backlight.max = ctl >>16 ;if (!panel->backlight.max)return -ENODEV ; panel->backlight.min =get_backlight_min_vbt (connector); - val =_vlv_get_backlight (dev,PIPE_A ); + val =_vlv_get_backlight (dev, pipe); panel->backlight.level =intel_panel_compute_brightness (connector, val); panel->backlight.enabled = (ctl2 & BLM_PWM_ENABLE) &&
Signature · 6 lines
2.0.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 17 lines · On Tue, Jul 29, 2014 at 01:44:40PM +0100, [email protected] wrote:
From: Rafael Barbalho <[email protected]>
Make the vlv/chv backlight setup more generic by actually looking at which pipe the panel is attached to and read the backlight PWM registers that were setup by the bios from that pipe.
Cc Ville Syrjälä <[email protected]>Signed-off-by Rafael Barbalho <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_panel.c +0
-0
drivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct intel_connector *connector) · line 1203
Quoted 5 lines
drivers/gpu/drm/i915/intel_panel.c +1
-1@@ -1200,32 +1200,28 @@ static int vlv_setup_backlight(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; -enum pipe pipe; +enum pipe pipe =intel_get_pipe_from_connector (connector);
This won't work unless the connector is already enabled.
The power sequencer has a similar problem where we have to somehow deduce the correct pipe. vlv_power_sequencer_pipe() tries to guess the correct pipe there.
We could start with intel_get_pipe_from_connector() and if that fails we'd do something like vlv_power_sequencer_pipe(). Hmm, except the backlight registers don't have the port information, so I guess we'd need to pick the pipe simply based on the DP port control register.
Quoted 39 lines
drivers/gpu/drm/i915/intel_panel.c +9
-13u32 ctl, ctl2, val; -for_each_pipe (pipe) { -u32 cur_val =I915_READ (VLV_BLC_PWM_CTL (pipe)); + ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (pipe)); + panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; -/* Skip if the modulation freq is already set */ -if (cur_val & ~BACKLIGHT_DUTY_CYCLE_MASK ) -continue ; + ctl =I915_READ (VLV_BLC_PWM_CTL (pipe)); - cur_val &=BACKLIGHT_DUTY_CYCLE_MASK ; -I915_WRITE (VLV_BLC_PWM_CTL (pipe), (0xf42 <<16 ) | - cur_val); +/* Skip if the modulation freq is already set */ +if ((ctl & ~BACKLIGHT_DUTY_CYCLE_MASK ) ==0 ) { + ctl &=BACKLIGHT_DUTY_CYCLE_MASK ; + ctl |= (0xf42 <<16 ); +I915_WRITE (VLV_BLC_PWM_CTL (pipe), ctl); } - ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (PIPE_A )); - panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; - - ctl =I915_READ (VLV_BLC_PWM_CTL (PIPE_A )); panel->backlight.max = ctl >>16 ;if (!panel->backlight.max)return -ENODEV ; panel->backlight.min =get_backlight_min_vbt (connector); - val =_vlv_get_backlight (dev,PIPE_A ); + val =_vlv_get_backlight (dev, pipe); panel->backlight.level =intel_panel_compute_brightness (connector, val); panel->backlight.enabled = (ctl2 & BLM_PWM_ENABLE) &&Signature · 1 line
2.0.3
Signature · 2 lines
Ville Syrjälä Intel OTC
Quoted 43 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, July 29, 2014 2:13 PM
To: Barbalho, Rafael
Cc: [email protected]
Subject: Re: [PATCH] drm/i915: Correctly read backlight PWM for pipe B on vlv/chvQuoted 4 lines · On Tue, Jul 29, 2014 at 01:44:40PM +0100, [email protected] wrote:
From: Rafael Barbalho <[email protected]>
Make the vlv/chv backlight setup more generic by actually looking at which pipe the panel is attached to and read the backlight PWM registers that
were
Review
Quoted 9 lines
setup by the bios from that pipe.
Cc Ville Syrjälä <[email protected]>Signed-off-by Rafael Barbalho <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/intel_panel.cdrivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct
Quoted 4 lines
index 59b028f..be75d76 100644
drivers/gpu/drm/i915/intel_panel.c +0
-0@@ -1200,32 +1200,28 @@ static int vlv_setup_backlight(struct
intel_connector*connector)drivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct intel_connector *connector) · line 1203
Quoted 5 lines
drivers/gpu/drm/i915/intel_panel.c +1
-1struct drm_device *dev = connector->base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct intel_panel *panel = &connector->panel; -enum pipe pipe; +enum pipe pipe =intel_get_pipe_from_connector (connector);This won't work unless the connector is already enabled.
The power sequencer has a similar problem where we have to somehow deduce
the correct pipe.vlv_power_sequencer_pipe()tries to guess the correct pipe
there.
Quoted 5 lines
We could start with
intel_get_pipe_from_connector()and if that fails we'd do something likevlv_power_sequencer_pipe(). Hmm, except the backlight registers don't have the port information, so I guess we'd need to pick the pipe simply based on the DP port control register.
Fair point, I didn't realise that intel_get_pipe_from_connector could return INVALID_PIPE.
How about if I add:
+ enum pipe pipe = intel_get_pipe_from_connector(connector);
+
+ if (pipe == INVALID_PIPE)
+ pipe = PIPE_A;
It would return the driver to the current behaviour but still enable pipe B when that is present at start up.
Quoted 44 lines
Quoted 25 lines
drivers/gpu/drm/i915/intel_panel.c +8
-11u32 ctl, ctl2, val; -for_each_pipe (pipe) { -u32 cur_val =I915_READ (VLV_BLC_PWM_CTL (pipe)); + ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (pipe)); + panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; -/* Skip if the modulation freq is already set */ -if (cur_val & ~BACKLIGHT_DUTY_CYCLE_MASK ) -continue ; + ctl =I915_READ (VLV_BLC_PWM_CTL (pipe)); - cur_val &=BACKLIGHT_DUTY_CYCLE_MASK ; -I915_WRITE (VLV_BLC_PWM_CTL (pipe), (0xf42 <<16 ) | - cur_val); +/* Skip if the modulation freq is already set */ +if ((ctl & ~BACKLIGHT_DUTY_CYCLE_MASK ) ==0 ) { + ctl &=BACKLIGHT_DUTY_CYCLE_MASK ; + ctl |= (0xf42 <<16 ); +I915_WRITE (VLV_BLC_PWM_CTL (pipe), ctl); } - ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (PIPE_A )); - panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; -drivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct intel_connector *connector)
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +1
-2- ctl =I915_READ (VLV_BLC_PWM_CTL (PIPE_A )); panel->backlight.max = ctl >>16 ;if (!panel->backlight.max)return -ENODEV ; panel->backlight.min =get_backlight_min_vbt (connector); - val =_vlv_get_backlight (dev,PIPE_A ); + val =_vlv_get_backlight (dev, pipe); panel->backlight.level =
intel_panel_compute_brightness(connector, val);Quoted 4 lines
drivers/gpu/drm/i915/intel_panel.c +0
-1panel->backlight.enabled = (ctl2 & BLM_PWM_ENABLE) && --2.0.3
--
Ville Syrjälä
Intel OTC
Quoted 71 lines
-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Barbalho, Rafael
Sent: Tuesday, July 29, 2014 2:38 PM
To: Ville Syrjälä
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Correctly read backlight PWM for pipe B on vlv/chv
Importance: HighQuoted 9 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, July 29, 2014 2:13 PM
To: Barbalho, Rafael
Cc: [email protected]
Subject: Re: [PATCH] drm/i915: Correctly read backlight PWM for pipe B on vlv/chvOn Tue, Jul 29, 2014 at 01:44:40PM +0100, [email protected]
Quoted 3 lines · wrote:
Quoted 3 lines
From: Rafael Barbalho <[email protected]>
Make the vlv/chv backlight setup more generic by actually looking at
which
Quoted 25 lines
Quoted 1 line
pipe the panel is attached to and read the backlight PWM registers that
were
Review
Quoted 9 lines
setup by the bios from that pipe.
Cc Ville Syrjälä <[email protected]>Signed-off-by Rafael Barbalho <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/intel_panel.cdrivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct
Quoted 4 lines
index 59b028f..be75d76 100644
drivers/gpu/drm/i915/intel_panel.c +0
-0@@ -1200,32 +1200,28 @@ static int vlv_setup_backlight(struct
intel_connector*connector)drivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct intel_connector *connector) · line 1203
Quoted 5 lines
drivers/gpu/drm/i915/intel_panel.c +1
-1struct drm_device *dev = connector->base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct intel_panel *panel = &connector->panel; -enum pipe pipe; +enum pipe pipe =intel_get_pipe_from_connector (connector);This won't work unless the connector is already enabled.
Quoted 8 lines
The power sequencer has a similar problem where we have to somehow deduce
the correct pipe.vlv_power_sequencer_pipe()tries to guess the correct pipe
there.We could start with
intel_get_pipe_from_connector()and if that fails we'd do something likevlv_power_sequencer_pipe(). Hmm, except thebacklight
Quoted 3 lines
registers don't have the port information, so I guess we'd need to pick the pipe simply based on the DP port control register.
Fair point, I didn't realise that
intel_get_pipe_from_connectorcould returnINVALID_PIPE.How about if I add:
(quoted diff) +4
-0+ enum pipe pipe = intel_get_pipe_from_connector(connector); + + if (pipe == INVALID_PIPE) + pipe = PIPE_A;
Quoted 4 lines
It would return the driver to the current behaviour but still enable pipe B when that is present
at start up.
Thinking about it I need to still keep the initial for_each_pipe loop to very subtly initialise both pipe A & B to a known PWM modulation frequency, which would explain why setting the backlight brightness works on pipe B. However, inheriting it from the bios is not working, which is what I am seeing. Let me rejig the patch and I'll send out a new version.
Quoted 48 lines
Quoted 37 lines
Quoted 25 lines
drivers/gpu/drm/i915/intel_panel.c +8
-11u32 ctl, ctl2, val; -for_each_pipe (pipe) { -u32 cur_val =I915_READ (VLV_BLC_PWM_CTL (pipe)); + ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (pipe)); + panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; -/* Skip if the modulation freq is already set */ -if (cur_val & ~BACKLIGHT_DUTY_CYCLE_MASK ) -continue ; + ctl =I915_READ (VLV_BLC_PWM_CTL (pipe)); - cur_val &=BACKLIGHT_DUTY_CYCLE_MASK ; -I915_WRITE (VLV_BLC_PWM_CTL (pipe), (0xf42 <<16 ) | - cur_val); +/* Skip if the modulation freq is already set */ +if ((ctl & ~BACKLIGHT_DUTY_CYCLE_MASK ) ==0 ) { + ctl &=BACKLIGHT_DUTY_CYCLE_MASK ; + ctl |= (0xf42 <<16 ); +I915_WRITE (VLV_BLC_PWM_CTL (pipe), ctl); } - ctl2 =I915_READ (VLV_BLC_PWM_CTL2 (PIPE_A )); - panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; -drivers/gpu/drm/i915/intel_panel.c static int vlv_setup_backlight(struct intel_connector *connector)
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +1
-2- ctl =I915_READ (VLV_BLC_PWM_CTL (PIPE_A )); panel->backlight.max = ctl >>16 ;if (!panel->backlight.max)return -ENODEV ; panel->backlight.min =get_backlight_min_vbt (connector); - val =_vlv_get_backlight (dev,PIPE_A ); + val =_vlv_get_backlight (dev, pipe); panel->backlight.level =
intel_panel_compute_brightness(connector, val);Quoted 1 line
Quoted 7 lines
Quoted 3 lines
panel->backlight.enabled= (ctl2 &BLM_PWM_ENABLE) &&
--
2.0.3--
Ville Syrjälä
Intel OTC_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx