drm/i915: make backlight functions take a connector v3
Subsystems (2)
PATCH 1/2 drm/i915: make backlight functions take a connector v3
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)
v3: make sure we take the mode config lock around lookups (Daniel)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 12 +++++ 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 | 38 +++++++++++++- drivers/gpu/drm/i915/intel_panel.c | 93 +++++++++++++++++++++++++---------- 7 files changed, 129 insertions(+), 37 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 +12 -0
@@ -9729,6 +9729,18 @@ 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 drm_encoder *encoder = connector->base.encoder; + +WARN_ON (!mutex_is_locked (&connector->base.dev->mode_config.mutex)); + +if (!encoder) +return INVALID_PIPE ; + +return to_intel_crtc (encoder->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 +36 -2
@@ -395,6 +395,12 @@ 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; +int ret =0 ;DRM_DEBUG_DRIVER ("bclp = 0x%08x\n" , bclp);
@@ -405,10 +411,38 @@ 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 ); +mutex_lock (&dev->mode_config.mutex); +/* +* 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) { + ret =ASLC_BACKLIGHT_FAILED ; + goto out_unlock; + } + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) +if (connector->encoder == encoder) + intel_connector =to_intel_connector (connector); + +if (!intel_connector) { + ret =ASLC_BACKLIGHT_FAILED ; + goto out_unlock; + } + +intel_panel_set_backlight (intel_connector, bclp,255 );iowrite32 (DIV_ROUND_UP (bclp *100 ,255 ) |ASLE_CBLV_VALID , &asle->cblv); -return 0 ; +out_unlock: +mutex_unlock (&dev->mode_config.mutex); +return ret; }static u32 asle_set_als_illum (struct drm_device *dev,u32 alsi)
drivers/gpu/drm/i915/intel_panel.c +67 -26
237 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/2 drm/i915/vlv: use per-pipe backlight controls v2
With 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
On Fri, Oct 11, 2013 at 11:31:53AM -0700, Jesse Barnes wrote:
[snip]
Quoted 10 lines
static int
intel_panel_get_brightness(struct backlight_device *bd){drivers/gpu/drm/i915/intel_panel.c +6
-2-struct drm_device *dev =bl_get_data (bd); -return intel_panel_get_backlight (dev); +struct intel_connector *connector =bl_get_data (bd); +struct drm_device *dev = connector->base.dev; +enum pipe pipe; +int ret =0 ; + +mutex_lock (&dev->mode_config.mutex);
drivers/gpu/drm/i915/intel_panel.c intel_panel_detect(struct drm_device *dev) · line 729
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +10
-0+ pipe =intel_get_pipe_from_connector (connector); +mutex_unlock (&dev->mode_config.mutex); +if (pipe ==INVALID_PIPE ) { + ret =0 ; + goto out_unlock; + } + + ret =intel_panel_get_backlight (connector->base.dev, pipe); +out_unlock: +mutex_unlock (&dev->mode_config.mutex);
I see mutex_unlock(&dev->mode_config.mutex) twice here. I think you've just volunteered yourselve for some testcases ;-)
Ideas:
- Make sure all lvds/edp connectors are enabled and bash on all backlight interfaces (with igt_fork it's easy to do that concurrently).
- Race the above with output changes: dpms on/off and changing the crtc around.
- Race the above with system suspend for bonus points (can be completely stitched together from igt helpers).
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 28 lines · On Fri, 11 Oct 2013 23:31:10 +0200 Daniel Vetter <[email protected]> wrote:
On Fri, Oct 11, 2013 at 11:31:53AM -0700, Jesse Barnes wrote:
[snip]
Quoted 10 lines
static int
intel_panel_get_brightness(struct backlight_device *bd){drivers/gpu/drm/i915/intel_panel.c +6
-2-struct drm_device *dev =bl_get_data (bd); -return intel_panel_get_backlight (dev); +struct intel_connector *connector =bl_get_data (bd); +struct drm_device *dev = connector->base.dev; +enum pipe pipe; +int ret =0 ; + +mutex_lock (&dev->mode_config.mutex);drivers/gpu/drm/i915/intel_panel.c intel_panel_detect(struct drm_device *dev) · line 729
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +10
-0+ pipe =intel_get_pipe_from_connector (connector); +mutex_unlock (&dev->mode_config.mutex); +if (pipe ==INVALID_PIPE ) { + ret =0 ; + goto out_unlock; + } + + ret =intel_panel_get_backlight (connector->base.dev, pipe); +out_unlock: +mutex_unlock (&dev->mode_config.mutex);I see
mutex_unlock(&dev->mode_config.mutex)twice here. I think you've just volunteered yourselve for some testcases ;-)
Quoted 7 lines
Ideas:
- Make sure all lvds/edp connectors are enabled and bash on all backlight interfaces (withigt_forkit's easy to do that concurrently).
- Race the above with output changes: dpms on/off and changing the crtc around.
- Race the above with system suspend for bonus points (can be completely stitched together from igt helpers).
Sorry can't volunteer for that now, but those sound like good tests to write.
I'll fix up the patch, we don't need to make double sure the lock is unlocked do we? and test locally and re-send.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 10 lines · On Fri, 11 Oct 2013 14:34:35 -0700 Jesse Barnes <[email protected]>…
Quoted 7 lines
Ideas:
- Make sure all lvds/edp connectors are enabled and bash on all backlight interfaces (withigt_forkit's easy to do that concurrently).
- Race the above with output changes: dpms on/off and changing the crtc around.
- Race the above with system suspend for bonus points (can be completely stitched together from igt helpers).Sorry can't volunteer for that now, but those sound like good tests to write.
To clarify per our discussion on IRC. I'll try to make some time next week to add some tests for this. We'll need them for the further intel_panel.c work (getting rid of all the bogus save/restore of the bits sprinkled about now that we don't do display reset).
But I don't want this fix (once I fix the locking) blocked on those tests, since they'll probably take me a few days and people are already using the original version, which is missing the locks for the backlight class and ASLE call sites.
Thanks,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 19 lines · Jesse Barnes
Quoted 10 lines · On Fri, 11 Oct 2013 14:34:35 -0700 Jesse Barnes <[email protected]>…
Quoted 7 lines
Ideas:
- Make sure all lvds/edp connectors are enabled and bash on all backlight interfaces (withigt_forkit's easy to do that concurrently).
- Race the above with output changes: dpms on/off and changing the crtc around.
- Race the above with system suspend for bonus points (can be completely stitched together from igt helpers).Sorry can't volunteer for that now, but those sound like good tests to write.
To clarify per our discussion on IRC. I'll try to make some time next week to add some tests for this. We'll need them for the further
intel_panel.cwork (getting rid of all the bogus save/restore of the bits sprinkled about now that we don't do display reset).
Quoted 4 lines
But I don't want this fix (once I fix the locking) blocked on those tests, since they'll probably take me a few days and people are already using the original version, which is missing the locks for the backlight class and ASLE call sites.
Yeah, I'm happy with this plan. Unfortunately it looks like this is another hornet's nest. So having a bit (and even if it's just a tiny little bit) of automated sanity checking and stress-testing of the locking should help to avoid the "two steps left, one back" dance we so often fall into. So if you have ideas for more effective tests than my quick list just do those, after all you'll know better how to blow this up after a few days of banging your head against the problem than me ;-)
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 25 lines · Daniel Vetter
Quoted 19 lines · Jesse Barnes
Quoted 10 lines · On Fri, 11 Oct 2013 14:34:35 -0700 Jesse Barnes <[email protected]>…
Quoted 7 lines
Ideas:
- Make sure all lvds/edp connectors are enabled and bash on all backlight interfaces (withigt_forkit's easy to do that concurrently).
- Race the above with output changes: dpms on/off and changing the crtc around.
- Race the above with system suspend for bonus points (can be completely stitched together from igt helpers).Sorry can't volunteer for that now, but those sound like good tests to write.
To clarify per our discussion on IRC. I'll try to make some time next week to add some tests for this. We'll need them for the further
intel_panel.cwork (getting rid of all the bogus save/restore of the bits sprinkled about now that we don't do display reset).Quoted 4 lines
But I don't want this fix (once I fix the locking) blocked on those tests, since they'll probably take me a few days and people are already using the original version, which is missing the locks for the backlight class and ASLE call sites.
Quoted 8 lines
Yeah, I'm happy with this plan. Unfortunately it looks like this is another hornet's nest. So having a bit (and even if it's just a tiny little bit) of automated sanity checking and stress-testing of the locking should help to avoid the "two steps left, one back" dance we so often fall into. So if you have ideas for more effective tests than my quick list just do those, after all you'll know better how to blow this up after a few days of banging your head against the problem than me ;-)
Aside: For patch that fix existing bugs where we can directly reproduce the issue in upstream with a test (e.g. tiling after resume broken) I prefer to first commit the testcase to igt and then wait 2-3 days. If the testcase is ready with the patch this can nicely overlap with the patch review and allows us to check the robustness of the
testcase: If QA doesn't file a new bug, something isn't quite working (either in the test or with QA), and we need to figure out what's wrong.
At least for gem issues this has been SOP.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
A message that is not in the archive (sent off-list or not yet received): 22791_1381536398_5258928E_22791_19022_1_CAKMK7uGtNCujq7PEoyJzke6w=y2qcsopa4mvSCLsiWtf72z7AA@mail.gmail.com
intel-drm-nightly broken on 835GM
Hi Daniel,
finally had access again to the Fujitsu laptop with the 835GM chipset. This time, I checked up the nightly-built branch based on the 3.12.rc4 kernel. Similar to the 3.11 kernel, I get a blank screen during login, i.e. gdm does not render its graphics. The boot console, even after loading the i915 module, does appear, is however vertically misaligned. The first line(s) of the console do not show.
When booting with an external monitor connected, the internal DVO locks up, and the signal on the external monitor is flickering left and right, as already described. gdm does not render on the internal panel, and the external panel remains black.
Thus, 3.12rc4 drm-nightly works (unfortunately) as bad as the 3.11 and is not usable.
Greetings,
Thomas
Quoted 4 lines · Jesse Barnes
But I don't want this fix (once I fix the locking) blocked on those tests, since they'll probably take me a few days and people are already using the original version, which is missing the locks for the backlight class and ASLE call sites.
btw for fixing the asle mutex_lock-in-irq-context issue we might want to simply use a trylock - Iirc the opregion spec explicitly allows us to abort the request as "driver busy with modeset ops". Imo both approaches of either delaying the request to a workqueue or using the asle return value feel equally risky wrt funky bioses doing stupid things. In both cases we need to get real-world testing, but using the trylock + abort is simpler in our own code ;-)
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm/i915: make backlight functions take a connector v4
In reply to Jesse BarnesOn 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)
v3: make sure we take the mode config lock around lookups (Daniel)
v4: fix double unlock in panel_get_brightness (Daniel)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 12 +++++ 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 | 38 ++++++++++++++- drivers/gpu/drm/i915/intel_panel.c | 92 +++++++++++++++++++++++++---------- 7 files changed, 128 insertions(+), 37 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 +12 -0
@@ -9729,6 +9729,18 @@ 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 drm_encoder *encoder = connector->base.encoder; + +WARN_ON (!mutex_is_locked (&connector->base.dev->mode_config.mutex)); + +if (!encoder) +return INVALID_PIPE ; + +return to_intel_crtc (encoder->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 +36 -2
@@ -395,6 +395,12 @@ 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; +int ret =0 ;DRM_DEBUG_DRIVER ("bclp = 0x%08x\n" , bclp);
@@ -405,10 +411,38 @@ 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 ); +mutex_lock (&dev->mode_config.mutex); +/* +* 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) { + ret =ASLC_BACKLIGHT_FAILED ; + goto out_unlock; + } + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) +if (connector->encoder == encoder) + intel_connector =to_intel_connector (connector); + +if (!intel_connector) { + ret =ASLC_BACKLIGHT_FAILED ; + goto out_unlock; + } + +intel_panel_set_backlight (intel_connector, bclp,255 );iowrite32 (DIV_ROUND_UP (bclp *100 ,255 ) |ASLE_CBLV_VALID , &asle->cblv); -return 0 ; +out_unlock: +mutex_unlock (&dev->mode_config.mutex); +return ret; }static u32 asle_set_als_illum (struct drm_device *dev,u32 alsi)
drivers/gpu/drm/i915/intel_panel.c +66 -26
236 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH] drm/i915: make backlight functions take a connector v4
Quoted 9 lines · On Fri, 11 Oct 2013 14:46:36 -0700 Jesse Barnes <[email protected]>…
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)
v3: make sure we take the mode config lock around lookups (Daniel)
v4: fix double unlock inpanel_get_brightness(Daniel)
Ok ok you caught me. I didn't test v3... I did test this version but w/o lockdep and apparently w/o any ASLE events or I would have seen the sleeping while atomic messages.
Guess we'll have to factor out the ASLE callback into a work queue (I don't *think* the BIOS will care, we'll have to see).
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH 1/1 drm/i915: make backlight functions take a connector v5
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)
v3: make sure we take the mode config lock around lookups (Daniel)
v4: fix double unlock in panel_get_brightness (Daniel)
v5: push ASLE work into a work queue (Daniel)
--- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/intel_display.c | 12 +++++ 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 | 67 +++++++++++++++++++++---- drivers/gpu/drm/i915/intel_panel.c | 92 +++++++++++++++++++++++++---------- 7 files changed, 151 insertions(+), 44 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -54,6 +54,7 @@#define DRIVER_DATE "20080730"enum pipe { +INVALID_PIPE =-1 ,PIPE_A =0 ,PIPE_B ,PIPE_C ,
@@ -231,6 +232,7 @@ struct intel_opregion {struct opregion_asle __iomem *asle;void __iomem *vbt;u32 __iomem *lid_state; +struct work_struct asle_work; };#define OPREGION_SIZE (8*1024)
drivers/gpu/drm/i915/intel_display.c +12 -0
@@ -9729,6 +9729,18 @@ 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 drm_encoder *encoder = connector->base.encoder; + +WARN_ON (!mutex_is_locked (&connector->base.dev->mode_config.mutex)); + +if (!encoder) +return INVALID_PIPE ; + +return to_intel_crtc (encoder->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 +58 -9
95 lines not on this page · raw message
drivers/gpu/drm/i915/intel_panel.c +66 -26
236 lines not on this page · raw message
Signature · 1 line
1.8.3.1