VLV backlight bits
Subsystems (2)
Updated these to include Jani's review feedback. Ultimately though, we need to expand this to properly handle dual-panel support on BYT, or figure out which is the correct connector in the OpRegion callback code. I still have an open request from the VBIOS team about that.
And Ville is right that these bits need to be pushed into the connector. What I'd like to do is make them virtual functions of the connector, with the VLV, gen4, and PCH bits split out. We can save/restore the state there too from modeset_init_hw, and maybe drop some bits now that we don't reset the display by default.
But all of that is for follow on patches.
Thanks,
Jesse
PATCH 1/2 drm/i915: make backlight functions take a connector v2
On VLV/BYT, backlight controls a per-pipe, so when adjusting the backlight we need to pass the correct info. So make the externally visible backlight functions take a connector argument, which can be used internally to figure out the pipe backlight to adjust.
v2: make connector pipe lookup check for NULL crtc (Jani)
fixup connector check in ASLE code (Jani)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 11 +++++ drivers/gpu/drm/i915/intel_dp.c | 5 +-- drivers/gpu/drm/i915/intel_drv.h | 8 ++-- drivers/gpu/drm/i915/intel_lvds.c | 9 ++-- drivers/gpu/drm/i915/intel_opregion.c | 28 ++++++++++++- drivers/gpu/drm/i915/intel_panel.c | 79 +++++++++++++++++++++++------------ 7 files changed, 105 insertions(+), 36 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -54,6 +54,7 @@#define DRIVER_DATE "20080730"enum pipe { +INVALID_PIPE =-1 ,PIPE_A =0 ,PIPE_B ,PIPE_C ,
drivers/gpu/drm/i915/intel_display.c +11 -0
@@ -9729,6 +9729,17 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)drm_crtc_helper_add (&intel_crtc->base, &intel_helper_funcs); } +enum pipe intel_get_pipe_from_connector (struct intel_connector *connector) +{ +struct intel_encoder *encoder = connector->encoder; +struct intel_crtc *crtc =to_intel_crtc (encoder->base.crtc); + +if (!crtc) +return INVALID_PIPE ; + +return crtc->pipe; +} +int intel_get_pipe_from_crtc_id (struct drm_device *dev,void *data,struct drm_file *file) {
drivers/gpu/drm/i915/intel_dp.c +2 -3
@@ -1257,7 +1257,6 @@ void ironlake_edp_backlight_on(struct intel_dp *intel_dp)struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp);struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private; -int pipe =to_intel_crtc (intel_dig_port->base.base.crtc)->pipe;u32 pp;u32 pp_ctrl_reg;
@@ -1280,7 +1279,7 @@ void ironlake_edp_backlight_on(struct intel_dp *intel_dp)I915_WRITE (pp_ctrl_reg, pp);POSTING_READ (pp_ctrl_reg); -intel_panel_enable_backlight (dev, pipe); +intel_panel_enable_backlight (intel_dp->attached_connector); }void ironlake_edp_backlight_off (struct intel_dp *intel_dp)
@@ -1293,7 +1292,7 @@ void ironlake_edp_backlight_off(struct intel_dp *intel_dp)if (!is_edp (intel_dp))return ; -intel_panel_disable_backlight (dev); +intel_panel_disable_backlight (intel_dp->attached_connector);DRM_DEBUG_KMS ("\n" ); pp =ironlake_get_pp_control (intel_dp);
drivers/gpu/drm/i915/intel_drv.h +5 -3
@@ -619,6 +619,7 @@ void intel_connector_attach_encoder(struct intel_connector *connector,struct drm_encoder *intel_best_encoder (struct drm_connector *connector);struct drm_display_mode *intel_crtc_mode_get (struct drm_device *dev,struct drm_crtc *crtc); +enum pipe intel_get_pipe_from_connector (struct intel_connector *connector);int intel_get_pipe_from_crtc_id (struct drm_device *dev,void *data,struct drm_file *file_priv); enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
@@ -767,10 +768,11 @@ void intel_pch_panel_fitting(struct intel_crtc *crtc,void intel_gmch_panel_fitting (struct intel_crtc *crtc,struct intel_crtc_config *pipe_config,int fitting_mode); -void intel_panel_set_backlight (struct drm_device *dev,u32 level,u32 max); +void intel_panel_set_backlight (struct intel_connector *connector,u32 level, +u32 max);int intel_panel_setup_backlight (struct drm_connector *connector); -void intel_panel_enable_backlight (struct drm_device *dev,enum pipe pipe); -void intel_panel_disable_backlight (struct drm_device *dev); +void intel_panel_enable_backlight (struct intel_connector *connector); +void intel_panel_disable_backlight (struct intel_connector *connector);void intel_panel_destroy_backlight (struct drm_device *dev);enum drm_connector_status intel_panel_detect (struct drm_device *dev);
drivers/gpu/drm/i915/intel_lvds.c +6 -3
@@ -206,7 +206,8 @@ static void intel_enable_lvds(struct intel_encoder *encoder) {struct drm_device *dev = encoder->base.dev;struct intel_lvds_encoder *lvds_encoder =to_lvds_encoder (&encoder->base); -struct intel_crtc *intel_crtc =to_intel_crtc (encoder->base.crtc); +struct intel_connector *intel_connector = + &lvds_encoder->attached_connector->base;struct drm_i915_private *dev_priv = dev->dev_private;u32 ctl_reg, stat_reg;
@@ -225,13 +226,15 @@ static void intel_enable_lvds(struct intel_encoder *encoder)if (wait_for ((I915_READ (stat_reg) &PP_ON ) !=0 ,1000 ))DRM_ERROR ("timed out waiting for panel to power on\n" ); -intel_panel_enable_backlight (dev, intel_crtc->pipe); +intel_panel_enable_backlight (intel_connector); }static void intel_disable_lvds (struct intel_encoder *encoder) {struct drm_device *dev = encoder->base.dev;struct intel_lvds_encoder *lvds_encoder =to_lvds_encoder (&encoder->base); +struct intel_connector *intel_connector = + &lvds_encoder->attached_connector->base;struct drm_i915_private *dev_priv = dev->dev_private;u32 ctl_reg, stat_reg;
@@ -243,7 +246,7 @@ static void intel_disable_lvds(struct intel_encoder *encoder) stat_reg =PP_STATUS ; } -intel_panel_disable_backlight (dev); +intel_panel_disable_backlight (intel_connector);I915_WRITE (ctl_reg,I915_READ (ctl_reg) & ~POWER_TARGET_ON );if (wait_for ((I915_READ (stat_reg) &PP_ON ) ==0 ,1000 ))
drivers/gpu/drm/i915/intel_opregion.c +27 -1
@@ -395,6 +395,11 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) {struct drm_i915_private *dev_priv = dev->dev_private;struct opregion_asle __iomem *asle = dev_priv->opregion.asle; +struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[0 ]; +struct drm_encoder *encoder; +struct drm_connector *connector; +struct intel_connector *intel_connector =NULL ; +bool found = false;DRM_DEBUG_DRIVER ("bclp = 0x%08x\n" , bclp);
@@ -405,7 +410,28 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)if (bclp >255 )return ASLC_BACKLIGHT_FAILED ; -intel_panel_set_backlight (dev, bclp,255 ); +/* +* Could match the OpRegion connector here instead, but we'd +* also need to verify the connector could handle a backlight +* call. +*/ +list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) +if (encoder->crtc == crtc) { + found = true; +break ; + } + +if (!found) +return ASLC_BACKLIGHT_FAILED ; + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) +if (connector->encoder == encoder) + intel_connector =to_intel_connector (connector); + +if (!intel_connector) +return ASLC_BACKLIGHT_FAILED ; + +intel_panel_set_backlight (intel_connector, bclp,255 );iowrite32 (DIV_ROUND_UP (bclp *100 ,255 ) |ASLE_CBLV_VALID , &asle->cblv);return 0 ;
drivers/gpu/drm/i915/intel_panel.c +53 -26
223 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 1/2] drm/i915: make backlight functions take a connector v2
Quoted 9 lines · Jesse Barnes
On VLV/BYT, backlight controls a per-pipe, so when adjusting the backlight we need to pass the correct info. So make the externally visible backlight functions take a connector argument, which can be used internally to figure out the pipe backlight to adjust.
v2: make connector pipe lookup check for NULL crtc (Jani)
fixup connector check in ASLE code (Jani)Signed-off-by Jesse Barnes <[email protected]>
To high-level things that we need to figure out first:
1. You're connector->pipe chasing is buggy. You shouldn't chase intel_connector->encoder since for shared encoders this doesn't reflect whether the connector is actually connected to that encoder. Instead check intel_connector->base.encoder for non-NULL, which guarantees you that you also have a valid crtc. Then getting at the pipe is simple:
pipe = to_intel_crtc(intel_connector->base.encoder->crtc);
so I think we can also ditch your little helper and PIPE_INVALID (which is good, since otherwise I'll volunteer your for a follow-up patch to use PIPE_INVALID at a bunch more places ...).
2. You can only chase the above pointers if you have the big modeset lock locked. Which at least for the functions implementing the backlight sysfs interface seems to not be the case.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 1/2] drm/i915: make backlight functions take a connector v2
Quoted 22 lines · On Sat, 5 Oct 2013 13:04:08 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 9 lines · Jesse Barnes
On VLV/BYT, backlight controls a per-pipe, so when adjusting the backlight we need to pass the correct info. So make the externally visible backlight functions take a connector argument, which can be used internally to figure out the pipe backlight to adjust.
v2: make connector pipe lookup check for NULL crtc (Jani)
fixup connector check in ASLE code (Jani)Signed-off-by Jesse Barnes <[email protected]>To high-level things that we need to figure out first:
1. You're
connector->pipechasing is buggy. You shouldn't chaseintel_connector->encodersince for shared encoders this doesn't reflect whether the connector is actually connected to that encoder. Instead checkintel_connector->base.encoderfor non-NULL, which guarantees you that you also have a valid crtc. Then getting at the pipe is simple:pipe =
to_intel_crtc(intel_connector->base.encoder->crtc);
Quoted 7 lines
so I think we can also ditch your little helper and
PIPE_INVALID(which is good, since otherwise I'll volunteer your for a follow-up patch to usePIPE_INVALIDat a bunch more places ...).2. You can only chase the above pointers if you have the big modeset lock locked. Which at least for the functions implementing the backlight sysfs interface seems to not be the case.
Ah ok thanks. I actually coded it a couple of times and I think I used the base.encoder first, but then lost that somehow in a rebase. I'll go back to that.
Good catch on the locking, I'll see about that too.
As for putting this in the connector, yes it really only applies to LVDS and eDP panels (though it could apply to monitors that support the VESA backlight control extensions too, but I don't think we have code for that yet). Anyway all of that is just icing on the cake after the panel bits handle multiple pipes correctly.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH 2/2 drm/i915/vlv: use per-pipe backlight controls v2
In reply to Jesse BarnesWith the connector and pipe passed around, we can now set the backlight on the right pipe on VLV/BYT.
v2: drop combination mode check for VLV (Jani)
add save/restore code for VLV backlight regs (Jani)
check for existing modulation freq when initializing backlight regs (Jani)
--- drivers/gpu/drm/i915/i915_drv.h | 3 ++ drivers/gpu/drm/i915/i915_reg.h | 15 +++++++++ drivers/gpu/drm/i915/i915_suspend.c | 29 ++++++++++++++++ drivers/gpu/drm/i915/intel_panel.c | 67 ++++++++++++++++++++++++++++++------- 4 files changed, 102 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -718,6 +718,9 @@ struct i915_suspend_saved_registers {u32 saveBLC_HIST_CTL;u32 saveBLC_PWM_CTL;u32 saveBLC_PWM_CTL2; +u32 saveBLC_HIST_CTL_B; +u32 saveBLC_PWM_CTL_B; +u32 saveBLC_PWM_CTL2_B;u32 saveBLC_CPU_PWM_CTL;u32 saveBLC_CPU_PWM_CTL2;u32 saveFPB0;
drivers/gpu/drm/i915/i915_reg.h +15 -0
@@ -2304,6 +2304,21 @@#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) + +#define _VLV_BLC_HIST_CTL_A (dev_priv->info->display_mmio_offset + 0x61260) +#define _VLV_BLC_HIST_CTL_B (dev_priv->info->display_mmio_offset + 0x61360) +#define VLV_BLC_HIST_CTL (pipe) _PIPE(pipe, _VLV_BLC_HIST_CTL_A, \ + _VLV_BLC_HIST_CTL_B) +/* Backlight control */ #define BLC_PWM_CTL2 (dev_priv->info->display_mmio_offset + 0x61250)/* 965+ only */ #define BLM_PWM_ENABLE (1 << 31)
drivers/gpu/drm/i915/i915_suspend.c +29 -0
@@ -214,6 +214,22 @@ static void i915_save_display(struct drm_device *dev) dev_priv->regfile.saveBLC_CPU_PWM_CTL2 =I915_READ (BLC_PWM_CPU_CTL2 );if (HAS_PCH_IBX (dev) ||HAS_PCH_CPT (dev)) dev_priv->regfile.saveLVDS =I915_READ (PCH_LVDS ); + }else if (IS_VALLEYVIEW (dev)) { + dev_priv->regfile.savePP_CONTROL =I915_READ (PP_CONTROL ); + dev_priv->regfile.savePFIT_PGM_RATIOS =I915_READ (PFIT_PGM_RATIOS ); + + dev_priv->regfile.saveBLC_PWM_CTL = +I915_READ (VLV_BLC_PWM_CTL (PIPE_A )); + dev_priv->regfile.saveBLC_HIST_CTL = +I915_READ (VLV_BLC_HIST_CTL (PIPE_A )); + dev_priv->regfile.saveBLC_PWM_CTL2 = +I915_READ (VLV_BLC_PWM_CTL2 (PIPE_A )); + dev_priv->regfile.saveBLC_PWM_CTL_B = +I915_READ (VLV_BLC_PWM_CTL (PIPE_B )); + dev_priv->regfile.saveBLC_HIST_CTL_B = +I915_READ (VLV_BLC_HIST_CTL (PIPE_B )); + dev_priv->regfile.saveBLC_PWM_CTL2_B = +I915_READ (VLV_BLC_PWM_CTL2 (PIPE_B )); }else { dev_priv->regfile.savePP_CONTROL =I915_READ (PP_CONTROL ); dev_priv->regfile.savePFIT_PGM_RATIOS =I915_READ (PFIT_PGM_RATIOS );
@@ -302,6 +318,19 @@ static void i915_restore_display(struct drm_device *dev)I915_WRITE (PCH_PP_CONTROL , dev_priv->regfile.savePP_CONTROL);I915_WRITE (RSTDBYCTL , dev_priv->regfile.saveMCHBAR_RENDER_STANDBY); + }else if (IS_VALLEYVIEW (dev)) { +I915_WRITE (VLV_BLC_PWM_CTL (PIPE_A ), + dev_priv->regfile.saveBLC_PWM_CTL); +I915_WRITE (VLV_BLC_HIST_CTL (PIPE_A ), + dev_priv->regfile.saveBLC_HIST_CTL); +I915_WRITE (VLV_BLC_PWM_CTL2 (PIPE_A ), + dev_priv->regfile.saveBLC_PWM_CTL2); +I915_WRITE (VLV_BLC_PWM_CTL (PIPE_B ), + dev_priv->regfile.saveBLC_PWM_CTL); +I915_WRITE (VLV_BLC_HIST_CTL (PIPE_B ), + dev_priv->regfile.saveBLC_HIST_CTL); +I915_WRITE (VLV_BLC_PWM_CTL2 (PIPE_B ), + dev_priv->regfile.saveBLC_PWM_CTL2); }else {I915_WRITE (PFIT_PGM_RATIOS , dev_priv->regfile.savePFIT_PGM_RATIOS);I915_WRITE (BLC_PWM_CTL , dev_priv->regfile.saveBLC_PWM_CTL);
drivers/gpu/drm/i915/intel_panel.c +55 -12
124 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 5 lines · Jesse Barnes
And Ville is right that these bits need to be pushed into the connector. What I'd like to do is make them virtual functions of the connector, with the VLV, gen4, and PCH bits split out. We can save/restore the state there too from
modeset_init_hw, and maybe drop some bits now that we don't reset the display by default.
We already have a struct intel_panel, imo it would make more sense to shove it in there. After all vga, hdmi, sdvo, ... don't really care about the backlight at all.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch