drm/i915: Add support for Intel's eDP backlight controls
v5 cover drm/i915: Add support for Intel's eDP backlight controls
A while ago we ran into issues while trying to enable the eDP backlight control interface as defined by VESA, in order to make the DPCD backlight controls on newer laptop panels work. The issue ended up being much more complicated however, as we also apparently needed to add support for an Intel-specific DPCD backlight control interface as the VESA interface is broken on many laptop panels. For lack of a better name, we just call this the Intel HDR backlight interface.
While this only adds support for the SDR backlight mode (I think), this will fix a lot of user's laptop panels that we weren't able to properly automatically detect DPCD backlight controls on previously.
Series-wide changes in v3:
* Pass down brightness values to enable/disable backlight callbacks in a separate patch
* Rebase
Lyude Paul (4):
drm/i915: Keep track of pwm-related backlight hooks separately drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now) drm/i915/dp: Allow forcing specific interfaces through
enable_dpcd_backlight
drm/dp: Revert "drm/dp: Introduce EDID-based quirks"
drivers/gpu/drm/drm_dp_helper.c | 83 +--- drivers/gpu/drm/drm_dp_mst_topology.c | 3 +- .../drm/i915/display/intel_display_types.h | 14 +- drivers/gpu/drm/i915/display/intel_dp.c | 9 +- .../drm/i915/display/intel_dp_aux_backlight.c | 287 ++++++++++++-- drivers/gpu/drm/i915/display/intel_dp_mst.c | 3 +- drivers/gpu/drm/i915/display/intel_panel.c | 371 ++++++++++-------- drivers/gpu/drm/i915/display/intel_panel.h | 4 + drivers/gpu/drm/i915/display/intel_psr.c | 2 +- drivers/gpu/drm/i915/i915_params.c | 2 +- include/drm/drm_dp_helper.h | 21 +- 11 files changed, 505 insertions(+), 294 deletions(-)
Signature · 6 lines
2.29.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v5 1/4 drm/i915: Keep track of pwm-related backlight hooks separately
Currently, every different type of backlight hook that i915 supports is pretty straight forward - you have a backlight, probably through PWM (but maybe DPCD), with a single set of platform-specific hooks that are used for controlling it.
HDR backlights, in particular VESA and Intel's HDR backlight implementations, can end up being more complicated. With Intel's proprietary interface, HDR backlight controls always run through the DPCD. When the backlight is in SDR backlight mode however, the driver may need to bypass the TCON and control the backlight directly through PWM.
So, in order to support this we'll need to split our backlight callbacks into two groups: a set of high-level backlight control callbacks in intel_panel, and an additional set of pwm-specific backlight control callbacks. This also implies a functional changes for how these callbacks are used:
* We now keep track of two separate backlight level ranges, one for the high-level backlight, and one for the pwm backlight range
* We also keep track of backlight enablement and PWM backlight enablement separately
* Since the currently set backlight level might not be the same as the currently programmed PWM backlight level, we stop setting panel->backlight.level with the currently programmed PWM backlight level in panel->backlight.pwm_funcs->setup(). Instead, we rely on the higher level backlight control functions to retrieve the current PWM backlight level (in this case, intel_pwm_get_backlight()). Note that there are still a few PWM backlight setup callbacks that do actually need to retrieve the current PWM backlight level, although we no longer save this value in panel->backlight.level like before.
Additionally, we drop the call to lpt_get_backlight() in lpt_setup_backlight(), and avoid unconditionally writing the PWM value that we get from it and only write it back if we're in CPU mode, and switching to PCH mode. The reason for this is because in the original codepath for this, it was expected that the intel_panel_bl_funcs->setup() hook would be responsible for fetching the initial backlight level. On lpt systems, the only time we could ever be in PCH backlight mode is during the initial driver load - meaning that outside of the setup() hook, lpt_get_backlight() will always be the callback used for retrieving the current backlight level. After this patch we still need to fetch and write-back the PCH backlight value if we're switching from CPU mode to PCH, but because intel_pwm_setup_backlight() will retrieve the backlight level after setup() using the get() hook, which always ends up being lpt_get_backlight(). Thus
- an additional call to lpt_get_backlight() in lpt_setup_backlight() is made redundant.
v5:
* Fix indenting warnings from checkpatch
v4:
* Fix commit message
* Remove outdated comment in intel_panel.c
* Rename pwm_(min|max) to pwm_level_(min|max)
* Use intel_pwm_get_backlight() in intel_pwm_setup_backlight() instead of indirection
* Don't move intel_dp_aux_init_bcklight_funcs() call to bottom of intel_panel_init_backlight_funcs() quite yet
v3:
* Reuse intel_panel_bl_funcs() for pwm_funcs
* Explain why we drop lpt_get_backlight()
--- .../drm/i915/display/intel_display_types.h | 4 + drivers/gpu/drm/i915/display/intel_panel.c | 333 ++++++++++-------- 2 files changed, 187 insertions(+), 150 deletions(-)
drivers/gpu/drm/i915/display/intel_display_types.h +4 -0
@@ -252,6 +252,9 @@ struct intel_panel {bool alternate_pwm_increment;/* lpt+ */ /* PWM chip */ +u32 pwm_level_min; +u32 pwm_level_max; +bool pwm_enabled;bool util_pin_active_low;/* bxt+ */ u8 controller;/* bxt+ only */ struct pwm_device *pwm;
@@ -263,6 +266,7 @@ struct intel_panel {struct backlight_device *device;const struct intel_panel_bl_funcs *funcs; +const struct intel_panel_bl_funcs *pwm_funcs;void (*power)(struct intel_connector *,bool enable); } backlight; };
drivers/gpu/drm/i915/display/intel_panel.c +183 -150
724 lines not on this page · raw message
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Jani Nikula
maintainerRe: [PATCH v5 1/4] drm/i915: Keep track of pwm-related backlight hooks separately
Quoted 29 lines · Lyude Paul
drivers/gpu/drm/i915/display/intel_panel.c +7
-8@@ -1628,37 +1633,32 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus panel->backlight.active_low_pwm = pch_ctl1 &BLM_PCH_POLARITY ; pch_ctl2 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL2 ); - panel->backlight.max = pch_ctl2 >>16 ; + panel->backlight.pwm_level_max = pch_ctl2 >>16 ; cpu_ctl2 =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 ); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = pch_ctl1 &BLM_PCH_PWM_ENABLE ; + panel->backlight.pwm_enabled = pch_ctl1 &BLM_PCH_PWM_ENABLE ; - cpu_mode = panel->backlight.enabled &&HAS_PCH_LPT (dev_priv) && + cpu_mode = panel->backlight.pwm_enabled &&HAS_PCH_LPT (dev_priv) && !(pch_ctl1 &BLM_PCH_OVERRIDE_ENABLE ) && (cpu_ctl2 &BLM_PWM_ENABLE ); -if (cpu_mode)
drivers/gpu/drm/i915/display/intel_panel.c static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus · line 1656
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_panel.c +2
-6- val =pch_get_backlight (connector); - else - val =lpt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max);if (cpu_mode) { + val =intel_panel_sanitize_pwm_level (connector,pch_get_backlight (connector)); +
(This really is a PITA to review, not because of how you do it but because of the hardware and the code itself. I'm just pointing out one thing here, but I'm not finished yet.)
I think this sanitize call is wrong here. It should be called only when converting to and from the hw register. Here, we read directly from one hw register and write back to another hw register.
Now, looking at the history, I think it's been wrong all the way since commit 5b1ec9ac7ab5 ("drm/i915/backlight: Fix backlight takeover on LPT, v3."). Probably nobody noticed, because AFAIK inverted brightness control has only ever been an issue on some gen4 platforms...
*facepalm*
BR,
Jani.
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_panel.c +1
-1drm_dbg_kms (&dev_priv->drm,"CPU backlight register was enabled, switching to PCH override\n" );/* Write converted CPU PWM value to PCH override register */ -lpt_set_backlight (connector->base.state, panel->backlight.level); +lpt_set_backlight (connector->base.state, val);intel_de_write (dev_priv,BLC_PWM_PCH_CTL1 , pch_ctl1 |BLM_PCH_OVERRIDE_ENABLE );
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v5 1/4] drm/i915: Keep track of pwm-related backlight hooks separately
In reply to Lyude PaulQuoted 97 lines · Lyude Paul
Currently, every different type of backlight hook that i915 supports is pretty straight forward - you have a backlight, probably through PWM (but maybe DPCD), with a single set of platform-specific hooks that are used for controlling it.
HDR backlights, in particular VESA and Intel's HDR backlight implementations, can end up being more complicated. With Intel's proprietary interface, HDR backlight controls always run through the DPCD. When the backlight is in SDR backlight mode however, the driver may need to bypass the TCON and control the backlight directly through PWM.
So, in order to support this we'll need to split our backlight callbacks into two groups: a set of high-level backlight control callbacks in
intel_panel, and an additional set of pwm-specific backlight control callbacks. This also implies a functional changes for how these callbacks are used:* We now keep track of two separate backlight level ranges, one for the high-level backlight, and one for the pwm backlight range
* We also keep track of backlight enablement and PWM backlight enablement separately
* Since the currently set backlight level might not be the same as the currently programmed PWM backlight level, we stop settingpanel->backlight.levelwith the currently programmed PWM backlight level inpanel->backlight.pwm_funcs->setup(). Instead, we rely on the higher level backlight control functions to retrieve the current PWM backlight level (in this case,intel_pwm_get_backlight()). Note that there are still a few PWM backlight setup callbacks that do actually need to retrieve the current PWM backlight level, although we no longer save this value inpanel->backlight.levellike before.Additionally, we drop the call to
lpt_get_backlight()inlpt_setup_backlight(), and avoid unconditionally writing the PWM value that we get from it and only write it back if we're in CPU mode, and switching to PCH mode. The reason for this is because in the original codepath for this, it was expected that theintel_panel_bl_funcs->setup()hook would be responsible for fetching the initial backlight level. On lpt systems, the only time we could ever be in PCH backlight mode is during the initial driver load - meaning that outside of thesetup()hook,lpt_get_backlight()will always be the callback used for retrieving the current backlight level. After this patch we still need to fetch and write-back the PCH backlight value if we're switching from CPU mode to PCH, but becauseintel_pwm_setup_backlight()will retrieve the backlight level aftersetup()using theget()hook, which always ends up beinglpt_get_backlight(). Thus
- an additional call tolpt_get_backlight()inlpt_setup_backlight()is made redundant.v5:
* Fix indenting warnings from checkpatch
v4:
* Fix commit message
* Remove outdated comment inintel_panel.c
* Renamepwm_(min|max)topwm_level_(min|max)
* Useintel_pwm_get_backlight()inintel_pwm_setup_backlight()instead of indirection
* Don't moveintel_dp_aux_init_bcklight_funcs()call to bottom ofintel_panel_init_backlight_funcs()quite yet
v3:
* Reuseintel_panel_bl_funcs()forpwm_funcs
* Explain why we droplpt_get_backlight()Signed-off-by Lyude Paul <[email protected]>Cc Vasily Khoruzhick <[email protected]>--- .../drm/i915/display/intel_display_types.h | 4 + drivers/gpu/drm/i915/display/intel_panel.c | 333 ++++++++++-------- 2 files changed, 187 insertions(+), 150 deletions(-)drivers/gpu/drm/i915/display/intel_display_types.h +4
-0@@ -252,6 +252,9 @@ struct intel_panel {bool alternate_pwm_increment;/* lpt+ */ /* PWM chip */ +u32 pwm_level_min; +u32 pwm_level_max; +bool pwm_enabled;bool util_pin_active_low;/* bxt+ */ u8 controller;/* bxt+ only */ struct pwm_device *pwm;@@ -263,6 +266,7 @@ struct intel_panel {struct backlight_device *device;const struct intel_panel_bl_funcs *funcs; +const struct intel_panel_bl_funcs *pwm_funcs;void (*power)(struct intel_connector *,bool enable); } backlight; };drivers/gpu/drm/i915/display/intel_panel.c +0
-0
drivers/gpu/drm/i915/display/intel_panel.c static u32 scale_hw_to_user(struct intel_connector *connector, · line 514
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_panel.c +1
-2@@ -511,25 +511,34 @@ static u32 scale_hw_to_user(struct intel_connector *connector, 0, user_max); } -static u32 intel_panel_compute_brightness (struct intel_connector *connector, -u32 val) +static u32 intel_panel_sanitize_pwm_level (struct intel_connector *connector,u32 val)
Should we call this intel_panel_invert_pwm_level() or something, because that's what the function does, and only that?
Up to you.
Quoted 764 lines
drivers/gpu/drm/i915/display/intel_panel.c +182
-148{struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -drm_WARN_ON (&dev_priv->drm, panel->backlight.max ==0 ); +drm_WARN_ON (&dev_priv->drm, panel->backlight.pwm_level_max ==0 );if (dev_priv->params.invert_brightness <0 )return val;if (dev_priv->params.invert_brightness >0 || dev_priv->quirks &QUIRK_INVERT_BRIGHTNESS ) { -return panel->backlight.max - val + panel->backlight.min; +return panel->backlight.pwm_level_max - val + panel->backlight.pwm_level_min; }return val; } +static void intel_panel_set_pwm_level (const struct drm_connector_state *conn_state,u32 val) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct drm_i915_private *i915 =to_i915 (connector->base.dev); +struct intel_panel *panel = &connector->panel; + +drm_dbg_kms (&i915->drm,"set backlight PWM = %d\n" , val); + panel->backlight.pwm_funcs->set (conn_state, val); +} +static u32 lpt_get_backlight (struct intel_connector *connector) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);@@ -624,12 +633,12 @@ static void i9xx_set_backlight(const struct drm_connector_state *conn_state, u32struct intel_panel *panel = &connector->panel;u32 tmp, mask; -drm_WARN_ON (&dev_priv->drm, panel->backlight.max ==0 ); +drm_WARN_ON (&dev_priv->drm, panel->backlight.pwm_level_max ==0 );if (panel->backlight.combination_mode) {u8 lbpc; - lbpc = level *0xfe / panel->backlight.max +1 ; + lbpc = level *0xfe / panel->backlight.pwm_level_max +1 ; level /= lbpc;pci_write_config_byte (dev_priv->drm.pdev,LBPC , lbpc); }@@ -681,9 +690,8 @@ intel_panel_actually_set_backlight(const struct drm_connector_state *conn_state,struct drm_i915_private *i915 =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -drm_dbg_kms (&i915->drm,"set backlight PWM = %d\n" , level); +drm_dbg_kms (&i915->drm,"set backlight level = %d\n" , level); - level =intel_panel_compute_brightness (connector, level); panel->backlight.funcs->set (conn_state, level); }@@ -732,7 +740,7 @@ static void lpt_disable_backlight(const struct drm_connector_state *old_conn_stastruct drm_i915_private *dev_priv =to_i915 (connector->base.dev);u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, level); +intel_panel_set_pwm_level (old_conn_state, level);/* * Although we don't support or enable CPU PWM with LPT/SPT based @@ -760,7 +768,7 @@ static void pch_disable_backlight(const struct drm_connector_state *old_conn_stastruct drm_i915_private *dev_priv =to_i915 (connector->base.dev);u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 );intel_de_write (dev_priv,BLC_PWM_CPU_CTL2 , tmp & ~BLM_PWM_ENABLE );@@ -771,7 +779,7 @@ static void pch_disable_backlight(const struct drm_connector_state *old_conn_stastatic void i9xx_disable_backlight (const struct drm_connector_state *old_conn_state,u32 val) { -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); }static void i965_disable_backlight (const struct drm_connector_state *old_conn_state,u32 val)@@ -779,7 +787,7 @@ static void i965_disable_backlight(const struct drm_connector_state *old_conn_ststruct drm_i915_private *dev_priv =to_i915 (old_conn_state->connector->dev);u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BLC_PWM_CTL2 );intel_de_write (dev_priv,BLC_PWM_CTL2 , tmp & ~BLM_PWM_ENABLE );@@ -792,7 +800,7 @@ static void vlv_disable_backlight(const struct drm_connector_state *old_conn_staenum pipe pipe =to_intel_crtc (old_conn_state->crtc)->pipe;u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,VLV_BLC_PWM_CTL2 (pipe)); intel_de_write(dev_priv, VLV_BLC_PWM_CTL2(pipe),@@ -806,7 +814,7 @@ static void bxt_disable_backlight(const struct drm_connector_state *old_conn_stastruct intel_panel *panel = &connector->panel;u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BXT_BLC_PWM_CTL (panel->backlight.controller));@@ -827,7 +835,7 @@ static void cnp_disable_backlight(const struct drm_connector_state *old_conn_stastruct intel_panel *panel = &connector->panel;u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BXT_BLC_PWM_CTL (panel->backlight.controller));@@ -906,7 +914,7 @@ static void lpt_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,SOUTH_CHICKEN1 , schicken); } - pch_ctl2 = panel->backlight.max <<16 ; + pch_ctl2 = panel->backlight.pwm_level_max <<16 ;intel_de_write (dev_priv,BLC_PWM_PCH_CTL2 , pch_ctl2); pch_ctl1 =0 ;@@ -923,7 +931,7 @@ static void lpt_enable_backlight(const struct intel_crtc_state *crtc_state, pch_ctl1 | BLM_PCH_PWM_ENABLE);/* This won't stick until the above enable. */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); } static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,@@ -958,9 +966,9 @@ static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BLC_PWM_CPU_CTL2 , cpu_ctl2 |BLM_PWM_ENABLE );/* This won't stick until the above enable. */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); - pch_ctl2 = panel->backlight.max <<16 ; + pch_ctl2 = panel->backlight.pwm_level_max <<16 ;intel_de_write (dev_priv,BLC_PWM_PCH_CTL2 , pch_ctl2); pch_ctl1 =0 ;@@ -987,7 +995,7 @@ static void i9xx_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BLC_PWM_CTL ,0 ); } - freq = panel->backlight.max; + freq = panel->backlight.pwm_level_max;if (panel->backlight.combination_mode) freq /=0xff ;@@ -1001,7 +1009,7 @@ static void i9xx_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_posting_read (dev_priv,BLC_PWM_CTL );/* XXX: combine this into above write? */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level);/* * Needed to enable backlight on some 855gm models. BLC_HIST_CTL is @@ -1028,7 +1036,7 @@ static void i965_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BLC_PWM_CTL2 , ctl2); } - freq = panel->backlight.max; + freq = panel->backlight.pwm_level_max;if (panel->backlight.combination_mode) freq /=0xff ;@@ -1044,7 +1052,7 @@ static void i965_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_posting_read (dev_priv,BLC_PWM_CTL2 );intel_de_write (dev_priv,BLC_PWM_CTL2 , ctl2 |BLM_PWM_ENABLE ); -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); } static void vlv_enable_backlight(const struct intel_crtc_state *crtc_state,@@ -1063,11 +1071,11 @@ static void vlv_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,VLV_BLC_PWM_CTL2 (pipe), ctl2); } - ctl = panel->backlight.max <<16 ; + ctl = panel->backlight.pwm_level_max <<16 ;intel_de_write (dev_priv,VLV_BLC_PWM_CTL (pipe), ctl);/* XXX: combine this into above write? */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); ctl2 =0 ;if (panel->backlight.active_low_pwm)@@ -1116,9 +1124,9 @@ static void bxt_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller), - panel->backlight.max); + panel->backlight.pwm_level_max); -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); pwm_ctl =0 ;if (panel->backlight.active_low_pwm)@@ -1152,9 +1160,9 @@ static void cnp_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller), - panel->backlight.max); + panel->backlight.pwm_level_max); -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); pwm_ctl =0 ;if (panel->backlight.active_low_pwm)@@ -1174,7 +1182,6 @@ static void ext_pwm_enable_backlight(const struct intel_crtc_state *crtc_state,struct intel_connector *connector =to_intel_connector (conn_state->connector);struct intel_panel *panel = &connector->panel; - level =intel_panel_compute_brightness (connector, level);pwm_set_relative_duty_cycle (&panel->backlight.pwm_state, level,100 ); panel->backlight.pwm_state.enabled = true;pwm_apply_state (panel->backlight.pwm, &panel->backlight.pwm_state);@@ -1232,10 +1239,8 @@ static u32 intel_panel_get_backlight(struct intel_connector *connector)mutex_lock (&dev_priv->backlight_lock); -if (panel->backlight.enabled) { +if (panel->backlight.enabled) val = panel->backlight.funcs->get (connector); - val =intel_panel_compute_brightness (connector, val); - }mutex_unlock (&dev_priv->backlight_lock);@@ -1566,13 +1571,13 @@ static u32 get_backlight_max_vbt(struct intel_connector *connector)u16 pwm_freq_hz =get_vbt_pwm_freq (dev_priv);u32 pwm; -if (!panel->backlight.funcs->hz_to_pwm) { +if (!panel->backlight.pwm_funcs->hz_to_pwm) {drm_dbg_kms (&dev_priv->drm,"backlight frequency conversion not supported\n" );return 0 ; } - pwm = panel->backlight.funcs->hz_to_pwm (connector, pwm_freq_hz); + pwm = panel->backlight.pwm_funcs->hz_to_pwm (connector, pwm_freq_hz);if (!pwm) {drm_dbg_kms (&dev_priv->drm,"backlight frequency conversion failed\n" );@@ -1591,7 +1596,7 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)struct intel_panel *panel = &connector->panel;int min; -drm_WARN_ON (&dev_priv->drm, panel->backlight.max ==0 ); +drm_WARN_ON (&dev_priv->drm, panel->backlight.pwm_level_max ==0 );/* * XXX: If the vbt value is 255, it makes min equal to max, which leads @@ -1608,7 +1613,7 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector) }/* vbt value is a coefficient in range [0..255] */ -return scale (min,0 ,255 ,0 , panel->backlight.max); +return scale (min,0 ,255 ,0 , panel->backlight.pwm_level_max); }static int lpt_setup_backlight (struct intel_connector *connector,enum pipe unused)@@ -1628,37 +1633,32 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus panel->backlight.active_low_pwm = pch_ctl1 &BLM_PCH_POLARITY ; pch_ctl2 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL2 ); - panel->backlight.max = pch_ctl2 >>16 ; + panel->backlight.pwm_level_max = pch_ctl2 >>16 ; cpu_ctl2 =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 ); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = pch_ctl1 &BLM_PCH_PWM_ENABLE ; + panel->backlight.pwm_enabled = pch_ctl1 &BLM_PCH_PWM_ENABLE ; - cpu_mode = panel->backlight.enabled &&HAS_PCH_LPT (dev_priv) && + cpu_mode = panel->backlight.pwm_enabled &&HAS_PCH_LPT (dev_priv) && !(pch_ctl1 &BLM_PCH_OVERRIDE_ENABLE ) && (cpu_ctl2 &BLM_PWM_ENABLE ); -if (cpu_mode) - val =pch_get_backlight (connector); -else - val =lpt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max);if (cpu_mode) { + val =intel_panel_sanitize_pwm_level (connector,pch_get_backlight (connector)); +drm_dbg_kms (&dev_priv->drm,"CPU backlight register was enabled, switching to PCH override\n" );/* Write converted CPU PWM value to PCH override register */ -lpt_set_backlight (connector->base.state, panel->backlight.level); +lpt_set_backlight (connector->base.state, val);intel_de_write (dev_priv,BLC_PWM_PCH_CTL1 , pch_ctl1 |BLM_PCH_OVERRIDE_ENABLE );@@ -1673,29 +1673,24 @@ static int pch_setup_backlight(struct intel_connector *connector, enum pipe unus {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 cpu_ctl2, pch_ctl1, pch_ctl2, val; +u32 cpu_ctl2, pch_ctl1, pch_ctl2; pch_ctl1 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL1 ); panel->backlight.active_low_pwm = pch_ctl1 &BLM_PCH_POLARITY ; pch_ctl2 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL2 ); - panel->backlight.max = pch_ctl2 >>16 ; + panel->backlight.pwm_level_max = pch_ctl2 >>16 ; -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); - - val =pch_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); cpu_ctl2 =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 ); - panel->backlight.enabled = (cpu_ctl2 &BLM_PWM_ENABLE ) && + panel->backlight.pwm_enabled = (cpu_ctl2 &BLM_PWM_ENABLE ) && (pch_ctl1 &BLM_PCH_PWM_ENABLE );return 0 ;@@ -1715,27 +1710,26 @@ static int i9xx_setup_backlight(struct intel_connector *connector, enum pipe unuif (IS_PINEVIEW (dev_priv)) panel->backlight.active_low_pwm = ctl &BLM_POLARITY_PNV ; - panel->backlight.max = ctl >>17 ; + panel->backlight.pwm_level_max = ctl >>17 ; -if (!panel->backlight.max) { - panel->backlight.max =get_backlight_max_vbt (connector); - panel->backlight.max >>=1 ; +if (!panel->backlight.pwm_level_max) { + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); + panel->backlight.pwm_level_max >>=1 ; } -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ;if (panel->backlight.combination_mode) - panel->backlight.max *=0xff ; + panel->backlight.pwm_level_max *=0xff ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); val =i9xx_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + val =intel_panel_sanitize_pwm_level (connector, val); + val =clamp (val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max); - panel->backlight.enabled = val !=0 ; + panel->backlight.pwm_enabled = val !=0 ;return 0 ; }@@ -1744,32 +1738,27 @@ static int i965_setup_backlight(struct intel_connector *connector, enum pipe unu {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 ctl, ctl2, val; +u32 ctl, ctl2; ctl2 =intel_de_read (dev_priv,BLC_PWM_CTL2 ); panel->backlight.combination_mode = ctl2 &BLM_COMBINATION_MODE ; panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; ctl =intel_de_read (dev_priv,BLC_PWM_CTL ); - panel->backlight.max = ctl >>16 ; + panel->backlight.pwm_level_max = ctl >>16 ; -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ;if (panel->backlight.combination_mode) - panel->backlight.max *=0xff ; - - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_max *=0xff ; - val =i9xx_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = ctl2 &BLM_PWM_ENABLE ; + panel->backlight.pwm_enabled = ctl2 &BLM_PWM_ENABLE ;return 0 ; }@@ -1778,7 +1767,7 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 ctl, ctl2, val; +u32 ctl, ctl2;if (drm_WARN_ON (&dev_priv->drm, pipe !=PIPE_A && pipe !=PIPE_B ))return -ENODEV ;@@ -1787,22 +1776,17 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; ctl =intel_de_read (dev_priv,VLV_BLC_PWM_CTL (pipe)); - panel->backlight.max = ctl >>16 ; + panel->backlight.pwm_level_max = ctl >>16 ; -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - val =_vlv_get_backlight (dev_priv, pipe); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); - - panel->backlight.enabled = ctl2 &BLM_PWM_ENABLE ; + panel->backlight.pwm_enabled = ctl2 &BLM_PWM_ENABLE ;return 0 ; }@@ -1827,24 +1811,18 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused) } panel->backlight.active_low_pwm = pwm_ctl &BXT_BLC_PWM_POLARITY ; - panel->backlight.max = -intel_de_read (dev_priv, -BXT_BLC_PWM_FREQ (panel->backlight.controller)); + panel->backlight.pwm_level_max = +intel_de_read (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller)); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); - - val =bxt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ; + panel->backlight.pwm_enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ;return 0 ; }@@ -1854,7 +1832,7 @@ cnp_setup_backlight(struct intel_connector *connector, enum pipe unused) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 pwm_ctl, val; +u32 pwm_ctl;/* * CNP has the BXT implementation of backlight, but with only one @@ -1867,24 +1845,18 @@ cnp_setup_backlight(struct intel_connector *connector, enum pipe unused) BXT_BLC_PWM_CTL(panel->backlight.controller)); panel->backlight.active_low_pwm = pwm_ctl &BXT_BLC_PWM_POLARITY ; - panel->backlight.max = -intel_de_read (dev_priv, -BXT_BLC_PWM_FREQ (panel->backlight.controller)); + panel->backlight.pwm_level_max = +intel_de_read (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller)); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - val =bxt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); - - panel->backlight.enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ; + panel->backlight.pwm_enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ;return 0 ; }@@ -1914,8 +1886,8 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector,return -ENODEV ; } - panel->backlight.max =100 ;/* 100% */ - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_max =100 ;/* 100% */ + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector);if (pwm_is_enabled (panel->backlight.pwm)) {/* PWM is already enabled, use existing settings */ @@ -1923,10 +1895,8 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector, level =pwm_get_relative_duty_cycle (&panel->backlight.pwm_state,100 ); - level =intel_panel_compute_brightness (connector, level); - panel->backlight.level =clamp (level, panel->backlight.min, - panel->backlight.max); - panel->backlight.enabled = true; + level =intel_panel_sanitize_pwm_level (connector, level); + panel->backlight.pwm_enabled = true; drm_dbg_kms(&dev_priv->drm, "PWM already enabled at freq %ld, VBT freq %d, level %d\n", NSEC_PER_SEC / (unsigned long)panel->backlight.pwm_state.period,@@ -1942,6 +1912,58 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector,return 0 ; } +static void intel_pwm_set_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + + panel->backlight.pwm_funcs->set (conn_state, +intel_panel_sanitize_pwm_level (connector, level)); +} + +static u32 intel_pwm_get_backlight (struct intel_connector *connector) +{ +struct intel_panel *panel = &connector->panel; + +return intel_panel_sanitize_pwm_level (connector, + panel->backlight.pwm_funcs->get (connector)); +} + +static void intel_pwm_enable_backlight (const struct intel_crtc_state *crtc_state, +const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + + panel->backlight.pwm_funcs->enable (crtc_state, conn_state, +intel_panel_sanitize_pwm_level (connector, level)); +} + +static void intel_pwm_disable_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + + panel->backlight.pwm_funcs->disable (conn_state, +intel_panel_sanitize_pwm_level (connector, level)); +} + +static int intel_pwm_setup_backlight (struct intel_connector *connector,enum pipe pipe) +{ +struct intel_panel *panel = &connector->panel; +int ret = panel->backlight.pwm_funcs->setup (connector, pipe); + +if (ret <0 ) +return ret; + + panel->backlight.min = panel->backlight.pwm_level_min; + panel->backlight.max = panel->backlight.pwm_level_max; + panel->backlight.level =intel_pwm_get_backlight (connector); + panel->backlight.enabled = panel->backlight.pwm_enabled; + +return 0 ; +} + void intel_panel_update_backlight(struct intel_atomic_state *state, struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state,@@ -2015,7 +2037,7 @@ static void intel_panel_destroy_backlight(struct intel_panel *panel) panel->backlight.present = false; } -static const struct intel_panel_bl_funcs bxt_funcs = { +static const struct intel_panel_bl_funcs bxt_pwm_funcs = { .setup = bxt_setup_backlight, .enable = bxt_enable_backlight, .disable = bxt_disable_backlight,@@ -2024,7 +2046,7 @@ static const struct intel_panel_bl_funcs bxt_funcs = { .hz_to_pwm = bxt_hz_to_pwm, }; -static const struct intel_panel_bl_funcs cnp_funcs = { +static const struct intel_panel_bl_funcs cnp_pwm_funcs = { .setup = cnp_setup_backlight, .enable = cnp_enable_backlight, .disable = cnp_disable_backlight,@@ -2033,7 +2055,7 @@ static const struct intel_panel_bl_funcs cnp_funcs = { .hz_to_pwm = cnp_hz_to_pwm, }; -static const struct intel_panel_bl_funcs lpt_funcs = { +static const struct intel_panel_bl_funcs lpt_pwm_funcs = { .setup = lpt_setup_backlight, .enable = lpt_enable_backlight, .disable = lpt_disable_backlight,@@ -2042,7 +2064,7 @@ static const struct intel_panel_bl_funcs lpt_funcs = { .hz_to_pwm = lpt_hz_to_pwm, }; -static const struct intel_panel_bl_funcs spt_funcs = { +static const struct intel_panel_bl_funcs spt_pwm_funcs = { .setup = lpt_setup_backlight, .enable = lpt_enable_backlight, .disable = lpt_disable_backlight,@@ -2051,7 +2073,7 @@ static const struct intel_panel_bl_funcs spt_funcs = { .hz_to_pwm = spt_hz_to_pwm, }; -static const struct intel_panel_bl_funcs pch_funcs = { +static const struct intel_panel_bl_funcs pch_pwm_funcs = { .setup = pch_setup_backlight, .enable = pch_enable_backlight, .disable = pch_disable_backlight,@@ -2068,7 +2090,7 @@ static const struct intel_panel_bl_funcs ext_pwm_funcs = { .get = ext_pwm_get_backlight, }; -static const struct intel_panel_bl_funcs vlv_funcs = { +static const struct intel_panel_bl_funcs vlv_pwm_funcs = { .setup = vlv_setup_backlight, .enable = vlv_enable_backlight, .disable = vlv_disable_backlight,@@ -2077,7 +2099,7 @@ static const struct intel_panel_bl_funcs vlv_funcs = { .hz_to_pwm = vlv_hz_to_pwm, }; -static const struct intel_panel_bl_funcs i965_funcs = { +static const struct intel_panel_bl_funcs i965_pwm_funcs = { .setup = i965_setup_backlight, .enable = i965_enable_backlight, .disable = i965_disable_backlight,@@ -2086,7 +2108,7 @@ static const struct intel_panel_bl_funcs i965_funcs = { .hz_to_pwm = i965_hz_to_pwm, }; -static const struct intel_panel_bl_funcs i9xx_funcs = { +static const struct intel_panel_bl_funcs i9xx_pwm_funcs = { .setup = i9xx_setup_backlight, .enable = i9xx_enable_backlight, .disable = i9xx_disable_backlight,@@ -2095,6 +2117,14 @@ static const struct intel_panel_bl_funcs i9xx_funcs = { .hz_to_pwm = i9xx_hz_to_pwm, }; +static const struct intel_panel_bl_funcs pwm_bl_funcs = { + .setup = intel_pwm_setup_backlight, + .enable = intel_pwm_enable_backlight, + .disable = intel_pwm_disable_backlight, + .set = intel_pwm_set_backlight, + .get = intel_pwm_get_backlight, +}; +/* Set up chip specific backlight functions */ static void intel_panel_init_backlight_funcs (struct intel_panel *panel)@@ -2112,27 +2142,30 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel)return ;if (IS_GEN9_LP (dev_priv)) { - panel->backlight.funcs = &bxt_funcs; + panel->backlight.pwm_funcs = &bxt_pwm_funcs; }else if (INTEL_PCH_TYPE (dev_priv) >=PCH_CNP ) { - panel->backlight.funcs = &cnp_funcs; + panel->backlight.pwm_funcs = &cnp_pwm_funcs; }else if (INTEL_PCH_TYPE (dev_priv) >=PCH_LPT ) {if (HAS_PCH_LPT (dev_priv)) - panel->backlight.funcs = &lpt_funcs; + panel->backlight.pwm_funcs = &lpt_pwm_funcs;else - panel->backlight.funcs = &spt_funcs; + panel->backlight.pwm_funcs = &spt_pwm_funcs; }else if (HAS_PCH_SPLIT (dev_priv)) { - panel->backlight.funcs = &pch_funcs; + panel->backlight.pwm_funcs = &pch_pwm_funcs; }else if (IS_VALLEYVIEW (dev_priv) ||IS_CHERRYVIEW (dev_priv)) {if (connector->base.connector_type ==DRM_MODE_CONNECTOR_DSI ) { - panel->backlight.funcs = &ext_pwm_funcs; + panel->backlight.pwm_funcs = &ext_pwm_funcs; }else { - panel->backlight.funcs = &vlv_funcs; + panel->backlight.pwm_funcs = &vlv_pwm_funcs; } }else if (IS_GEN (dev_priv,4 )) { - panel->backlight.funcs = &i965_funcs; + panel->backlight.pwm_funcs = &i965_pwm_funcs; }else { - panel->backlight.funcs = &i9xx_funcs; + panel->backlight.pwm_funcs = &i9xx_pwm_funcs; } + +/* We're using a standard PWM backlight interface */ + panel->backlight.funcs = &pwm_bl_funcs; }enum drm_connector_status
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 1/4] drm/i915: Keep track of pwm-related backlight hooks separately
In reply to Lyude PaulQuoted 63 lines · Lyude Paul
Currently, every different type of backlight hook that i915 supports is pretty straight forward - you have a backlight, probably through PWM (but maybe DPCD), with a single set of platform-specific hooks that are used for controlling it.
HDR backlights, in particular VESA and Intel's HDR backlight implementations, can end up being more complicated. With Intel's proprietary interface, HDR backlight controls always run through the DPCD. When the backlight is in SDR backlight mode however, the driver may need to bypass the TCON and control the backlight directly through PWM.
So, in order to support this we'll need to split our backlight callbacks into two groups: a set of high-level backlight control callbacks in
intel_panel, and an additional set of pwm-specific backlight control callbacks. This also implies a functional changes for how these callbacks are used:* We now keep track of two separate backlight level ranges, one for the high-level backlight, and one for the pwm backlight range
* We also keep track of backlight enablement and PWM backlight enablement separately
* Since the currently set backlight level might not be the same as the currently programmed PWM backlight level, we stop settingpanel->backlight.levelwith the currently programmed PWM backlight level inpanel->backlight.pwm_funcs->setup(). Instead, we rely on the higher level backlight control functions to retrieve the current PWM backlight level (in this case,intel_pwm_get_backlight()). Note that there are still a few PWM backlight setup callbacks that do actually need to retrieve the current PWM backlight level, although we no longer save this value inpanel->backlight.levellike before.Additionally, we drop the call to
lpt_get_backlight()inlpt_setup_backlight(), and avoid unconditionally writing the PWM value that we get from it and only write it back if we're in CPU mode, and switching to PCH mode. The reason for this is because in the original codepath for this, it was expected that theintel_panel_bl_funcs->setup()hook would be responsible for fetching the initial backlight level. On lpt systems, the only time we could ever be in PCH backlight mode is during the initial driver load - meaning that outside of thesetup()hook,lpt_get_backlight()will always be the callback used for retrieving the current backlight level. After this patch we still need to fetch and write-back the PCH backlight value if we're switching from CPU mode to PCH, but becauseintel_pwm_setup_backlight()will retrieve the backlight level aftersetup()using theget()hook, which always ends up beinglpt_get_backlight(). Thus
- an additional call tolpt_get_backlight()inlpt_setup_backlight()is made redundant.v5:
* Fix indenting warnings from checkpatch
v4:
* Fix commit message
* Remove outdated comment inintel_panel.c
* Renamepwm_(min|max)topwm_level_(min|max)
* Useintel_pwm_get_backlight()inintel_pwm_setup_backlight()instead of indirection
* Don't moveintel_dp_aux_init_bcklight_funcs()call to bottom ofintel_panel_init_backlight_funcs()quite yet
v3:
* Reuseintel_panel_bl_funcs()forpwm_funcs
* Explain why we droplpt_get_backlight()
Quoted 3 lines
Signed-off-by Lyude Paul <[email protected]>Cc Vasily Khoruzhick <[email protected]>
Whole series is:
Quoted 803 lines
--- .../drm/i915/display/intel_display_types.h | 4 + drivers/gpu/drm/i915/display/intel_panel.c | 333 ++++++++++-------- 2 files changed, 187 insertions(+), 150 deletions(-)drivers/gpu/drm/i915/display/intel_display_types.h +4
-0@@ -252,6 +252,9 @@ struct intel_panel {bool alternate_pwm_increment;/* lpt+ */ /* PWM chip */ +u32 pwm_level_min; +u32 pwm_level_max; +bool pwm_enabled;bool util_pin_active_low;/* bxt+ */ u8 controller;/* bxt+ only */ struct pwm_device *pwm;@@ -263,6 +266,7 @@ struct intel_panel {struct backlight_device *device;const struct intel_panel_bl_funcs *funcs; +const struct intel_panel_bl_funcs *pwm_funcs;void (*power)(struct intel_connector *,bool enable); } backlight; };drivers/gpu/drm/i915/display/intel_panel.c +183
-151@@ -511,25 +511,34 @@ static u32 scale_hw_to_user(struct intel_connector *connector, 0, user_max); } -static u32 intel_panel_compute_brightness (struct intel_connector *connector, -u32 val) +static u32 intel_panel_sanitize_pwm_level (struct intel_connector *connector,u32 val) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -drm_WARN_ON (&dev_priv->drm, panel->backlight.max ==0 ); +drm_WARN_ON (&dev_priv->drm, panel->backlight.pwm_level_max ==0 );if (dev_priv->params.invert_brightness <0 )return val;if (dev_priv->params.invert_brightness >0 || dev_priv->quirks &QUIRK_INVERT_BRIGHTNESS ) { -return panel->backlight.max - val + panel->backlight.min; +return panel->backlight.pwm_level_max - val + panel->backlight.pwm_level_min; }return val; } +static void intel_panel_set_pwm_level (const struct drm_connector_state *conn_state,u32 val) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct drm_i915_private *i915 =to_i915 (connector->base.dev); +struct intel_panel *panel = &connector->panel; + +drm_dbg_kms (&i915->drm,"set backlight PWM = %d\n" , val); + panel->backlight.pwm_funcs->set (conn_state, val); +} +static u32 lpt_get_backlight (struct intel_connector *connector) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);@@ -624,12 +633,12 @@ static void i9xx_set_backlight(const struct drm_connector_state *conn_state, u32struct intel_panel *panel = &connector->panel;u32 tmp, mask; -drm_WARN_ON (&dev_priv->drm, panel->backlight.max ==0 ); +drm_WARN_ON (&dev_priv->drm, panel->backlight.pwm_level_max ==0 );if (panel->backlight.combination_mode) {u8 lbpc; - lbpc = level *0xfe / panel->backlight.max +1 ; + lbpc = level *0xfe / panel->backlight.pwm_level_max +1 ; level /= lbpc;pci_write_config_byte (dev_priv->drm.pdev,LBPC , lbpc); }@@ -681,9 +690,8 @@ intel_panel_actually_set_backlight(const struct drm_connector_state *conn_state,struct drm_i915_private *i915 =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -drm_dbg_kms (&i915->drm,"set backlight PWM = %d\n" , level); +drm_dbg_kms (&i915->drm,"set backlight level = %d\n" , level); - level =intel_panel_compute_brightness (connector, level); panel->backlight.funcs->set (conn_state, level); }@@ -732,7 +740,7 @@ static void lpt_disable_backlight(const struct drm_connector_state *old_conn_stastruct drm_i915_private *dev_priv =to_i915 (connector->base.dev);u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, level); +intel_panel_set_pwm_level (old_conn_state, level);/* * Although we don't support or enable CPU PWM with LPT/SPT based @@ -760,7 +768,7 @@ static void pch_disable_backlight(const struct drm_connector_state *old_conn_stastruct drm_i915_private *dev_priv =to_i915 (connector->base.dev);u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 );intel_de_write (dev_priv,BLC_PWM_CPU_CTL2 , tmp & ~BLM_PWM_ENABLE );@@ -771,7 +779,7 @@ static void pch_disable_backlight(const struct drm_connector_state *old_conn_stastatic void i9xx_disable_backlight (const struct drm_connector_state *old_conn_state,u32 val) { -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); }static void i965_disable_backlight (const struct drm_connector_state *old_conn_state,u32 val)@@ -779,7 +787,7 @@ static void i965_disable_backlight(const struct drm_connector_state *old_conn_ststruct drm_i915_private *dev_priv =to_i915 (old_conn_state->connector->dev);u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BLC_PWM_CTL2 );intel_de_write (dev_priv,BLC_PWM_CTL2 , tmp & ~BLM_PWM_ENABLE );@@ -792,7 +800,7 @@ static void vlv_disable_backlight(const struct drm_connector_state *old_conn_staenum pipe pipe =to_intel_crtc (old_conn_state->crtc)->pipe;u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,VLV_BLC_PWM_CTL2 (pipe)); intel_de_write(dev_priv, VLV_BLC_PWM_CTL2(pipe),@@ -806,7 +814,7 @@ static void bxt_disable_backlight(const struct drm_connector_state *old_conn_stastruct intel_panel *panel = &connector->panel;u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BXT_BLC_PWM_CTL (panel->backlight.controller));@@ -827,7 +835,7 @@ static void cnp_disable_backlight(const struct drm_connector_state *old_conn_stastruct intel_panel *panel = &connector->panel;u32 tmp; -intel_panel_actually_set_backlight (old_conn_state, val); +intel_panel_set_pwm_level (old_conn_state, val); tmp =intel_de_read (dev_priv,BXT_BLC_PWM_CTL (panel->backlight.controller));@@ -906,7 +914,7 @@ static void lpt_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,SOUTH_CHICKEN1 , schicken); } - pch_ctl2 = panel->backlight.max <<16 ; + pch_ctl2 = panel->backlight.pwm_level_max <<16 ;intel_de_write (dev_priv,BLC_PWM_PCH_CTL2 , pch_ctl2); pch_ctl1 =0 ;@@ -923,7 +931,7 @@ static void lpt_enable_backlight(const struct intel_crtc_state *crtc_state, pch_ctl1 | BLM_PCH_PWM_ENABLE);/* This won't stick until the above enable. */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); } static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,@@ -958,9 +966,9 @@ static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BLC_PWM_CPU_CTL2 , cpu_ctl2 |BLM_PWM_ENABLE );/* This won't stick until the above enable. */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); - pch_ctl2 = panel->backlight.max <<16 ; + pch_ctl2 = panel->backlight.pwm_level_max <<16 ;intel_de_write (dev_priv,BLC_PWM_PCH_CTL2 , pch_ctl2); pch_ctl1 =0 ;@@ -987,7 +995,7 @@ static void i9xx_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BLC_PWM_CTL ,0 ); } - freq = panel->backlight.max; + freq = panel->backlight.pwm_level_max;if (panel->backlight.combination_mode) freq /=0xff ;@@ -1001,7 +1009,7 @@ static void i9xx_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_posting_read (dev_priv,BLC_PWM_CTL );/* XXX: combine this into above write? */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level);/* * Needed to enable backlight on some 855gm models. BLC_HIST_CTL is @@ -1028,7 +1036,7 @@ static void i965_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BLC_PWM_CTL2 , ctl2); } - freq = panel->backlight.max; + freq = panel->backlight.pwm_level_max;if (panel->backlight.combination_mode) freq /=0xff ;@@ -1044,7 +1052,7 @@ static void i965_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_posting_read (dev_priv,BLC_PWM_CTL2 );intel_de_write (dev_priv,BLC_PWM_CTL2 , ctl2 |BLM_PWM_ENABLE ); -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); } static void vlv_enable_backlight(const struct intel_crtc_state *crtc_state,@@ -1063,11 +1071,11 @@ static void vlv_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,VLV_BLC_PWM_CTL2 (pipe), ctl2); } - ctl = panel->backlight.max <<16 ; + ctl = panel->backlight.pwm_level_max <<16 ;intel_de_write (dev_priv,VLV_BLC_PWM_CTL (pipe), ctl);/* XXX: combine this into above write? */ -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); ctl2 =0 ;if (panel->backlight.active_low_pwm)@@ -1116,9 +1124,9 @@ static void bxt_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller), - panel->backlight.max); + panel->backlight.pwm_level_max); -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); pwm_ctl =0 ;if (panel->backlight.active_low_pwm)@@ -1152,9 +1160,9 @@ static void cnp_enable_backlight(const struct intel_crtc_state *crtc_state,intel_de_write (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller), - panel->backlight.max); + panel->backlight.pwm_level_max); -intel_panel_actually_set_backlight (conn_state, level); +intel_panel_set_pwm_level (conn_state, level); pwm_ctl =0 ;if (panel->backlight.active_low_pwm)@@ -1174,7 +1182,6 @@ static void ext_pwm_enable_backlight(const struct intel_crtc_state *crtc_state,struct intel_connector *connector =to_intel_connector (conn_state->connector);struct intel_panel *panel = &connector->panel; - level =intel_panel_compute_brightness (connector, level);pwm_set_relative_duty_cycle (&panel->backlight.pwm_state, level,100 ); panel->backlight.pwm_state.enabled = true;pwm_apply_state (panel->backlight.pwm, &panel->backlight.pwm_state);@@ -1232,10 +1239,8 @@ static u32 intel_panel_get_backlight(struct intel_connector *connector)mutex_lock (&dev_priv->backlight_lock); -if (panel->backlight.enabled) { +if (panel->backlight.enabled) val = panel->backlight.funcs->get (connector); - val =intel_panel_compute_brightness (connector, val); - }mutex_unlock (&dev_priv->backlight_lock);@@ -1566,13 +1571,13 @@ static u32 get_backlight_max_vbt(struct intel_connector *connector)u16 pwm_freq_hz =get_vbt_pwm_freq (dev_priv);u32 pwm; -if (!panel->backlight.funcs->hz_to_pwm) { +if (!panel->backlight.pwm_funcs->hz_to_pwm) {drm_dbg_kms (&dev_priv->drm,"backlight frequency conversion not supported\n" );return 0 ; } - pwm = panel->backlight.funcs->hz_to_pwm (connector, pwm_freq_hz); + pwm = panel->backlight.pwm_funcs->hz_to_pwm (connector, pwm_freq_hz);if (!pwm) {drm_dbg_kms (&dev_priv->drm,"backlight frequency conversion failed\n" );@@ -1591,7 +1596,7 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)struct intel_panel *panel = &connector->panel;int min; -drm_WARN_ON (&dev_priv->drm, panel->backlight.max ==0 ); +drm_WARN_ON (&dev_priv->drm, panel->backlight.pwm_level_max ==0 );/* * XXX: If the vbt value is 255, it makes min equal to max, which leads @@ -1608,7 +1613,7 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector) }/* vbt value is a coefficient in range [0..255] */ -return scale (min,0 ,255 ,0 , panel->backlight.max); +return scale (min,0 ,255 ,0 , panel->backlight.pwm_level_max); }static int lpt_setup_backlight (struct intel_connector *connector,enum pipe unused)@@ -1628,37 +1633,32 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus panel->backlight.active_low_pwm = pch_ctl1 &BLM_PCH_POLARITY ; pch_ctl2 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL2 ); - panel->backlight.max = pch_ctl2 >>16 ; + panel->backlight.pwm_level_max = pch_ctl2 >>16 ; cpu_ctl2 =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 ); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = pch_ctl1 &BLM_PCH_PWM_ENABLE ; + panel->backlight.pwm_enabled = pch_ctl1 &BLM_PCH_PWM_ENABLE ; - cpu_mode = panel->backlight.enabled &&HAS_PCH_LPT (dev_priv) && + cpu_mode = panel->backlight.pwm_enabled &&HAS_PCH_LPT (dev_priv) && !(pch_ctl1 &BLM_PCH_OVERRIDE_ENABLE ) && (cpu_ctl2 &BLM_PWM_ENABLE ); -if (cpu_mode) - val =pch_get_backlight (connector); -else - val =lpt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max);if (cpu_mode) { + val =intel_panel_sanitize_pwm_level (connector,pch_get_backlight (connector)); +drm_dbg_kms (&dev_priv->drm,"CPU backlight register was enabled, switching to PCH override\n" );/* Write converted CPU PWM value to PCH override register */ -lpt_set_backlight (connector->base.state, panel->backlight.level); +lpt_set_backlight (connector->base.state, val);intel_de_write (dev_priv,BLC_PWM_PCH_CTL1 , pch_ctl1 |BLM_PCH_OVERRIDE_ENABLE );@@ -1673,29 +1673,24 @@ static int pch_setup_backlight(struct intel_connector *connector, enum pipe unus {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 cpu_ctl2, pch_ctl1, pch_ctl2, val; +u32 cpu_ctl2, pch_ctl1, pch_ctl2; pch_ctl1 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL1 ); panel->backlight.active_low_pwm = pch_ctl1 &BLM_PCH_POLARITY ; pch_ctl2 =intel_de_read (dev_priv,BLC_PWM_PCH_CTL2 ); - panel->backlight.max = pch_ctl2 >>16 ; + panel->backlight.pwm_level_max = pch_ctl2 >>16 ; -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); - - val =pch_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); cpu_ctl2 =intel_de_read (dev_priv,BLC_PWM_CPU_CTL2 ); - panel->backlight.enabled = (cpu_ctl2 &BLM_PWM_ENABLE ) && + panel->backlight.pwm_enabled = (cpu_ctl2 &BLM_PWM_ENABLE ) && (pch_ctl1 &BLM_PCH_PWM_ENABLE );return 0 ;@@ -1715,27 +1710,26 @@ static int i9xx_setup_backlight(struct intel_connector *connector, enum pipe unuif (IS_PINEVIEW (dev_priv)) panel->backlight.active_low_pwm = ctl &BLM_POLARITY_PNV ; - panel->backlight.max = ctl >>17 ; + panel->backlight.pwm_level_max = ctl >>17 ; -if (!panel->backlight.max) { - panel->backlight.max =get_backlight_max_vbt (connector); - panel->backlight.max >>=1 ; +if (!panel->backlight.pwm_level_max) { + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); + panel->backlight.pwm_level_max >>=1 ; } -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ;if (panel->backlight.combination_mode) - panel->backlight.max *=0xff ; + panel->backlight.pwm_level_max *=0xff ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); val =i9xx_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + val =intel_panel_sanitize_pwm_level (connector, val); + val =clamp (val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max); - panel->backlight.enabled = val !=0 ; + panel->backlight.pwm_enabled = val !=0 ;return 0 ; }@@ -1744,32 +1738,27 @@ static int i965_setup_backlight(struct intel_connector *connector, enum pipe unu {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 ctl, ctl2, val; +u32 ctl, ctl2; ctl2 =intel_de_read (dev_priv,BLC_PWM_CTL2 ); panel->backlight.combination_mode = ctl2 &BLM_COMBINATION_MODE ; panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; ctl =intel_de_read (dev_priv,BLC_PWM_CTL ); - panel->backlight.max = ctl >>16 ; + panel->backlight.pwm_level_max = ctl >>16 ; -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ;if (panel->backlight.combination_mode) - panel->backlight.max *=0xff ; - - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_max *=0xff ; - val =i9xx_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = ctl2 &BLM_PWM_ENABLE ; + panel->backlight.pwm_enabled = ctl2 &BLM_PWM_ENABLE ;return 0 ; }@@ -1778,7 +1767,7 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 ctl, ctl2, val; +u32 ctl, ctl2;if (drm_WARN_ON (&dev_priv->drm, pipe !=PIPE_A && pipe !=PIPE_B ))return -ENODEV ;@@ -1787,22 +1776,17 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe panel->backlight.active_low_pwm = ctl2 &BLM_POLARITY_I965 ; ctl =intel_de_read (dev_priv,VLV_BLC_PWM_CTL (pipe)); - panel->backlight.max = ctl >>16 ; + panel->backlight.pwm_level_max = ctl >>16 ; -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - val =_vlv_get_backlight (dev_priv, pipe); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); - - panel->backlight.enabled = ctl2 &BLM_PWM_ENABLE ; + panel->backlight.pwm_enabled = ctl2 &BLM_PWM_ENABLE ;return 0 ; }@@ -1827,24 +1811,18 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused) } panel->backlight.active_low_pwm = pwm_ctl &BXT_BLC_PWM_POLARITY ; - panel->backlight.max = -intel_de_read (dev_priv, -BXT_BLC_PWM_FREQ (panel->backlight.controller)); + panel->backlight.pwm_level_max = +intel_de_read (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller)); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); - - val =bxt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - panel->backlight.enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ; + panel->backlight.pwm_enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ;return 0 ; }@@ -1854,7 +1832,7 @@ cnp_setup_backlight(struct intel_connector *connector, enum pipe unused) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel; -u32 pwm_ctl, val; +u32 pwm_ctl;/* * CNP has the BXT implementation of backlight, but with only one @@ -1867,24 +1845,18 @@ cnp_setup_backlight(struct intel_connector *connector, enum pipe unused) BXT_BLC_PWM_CTL(panel->backlight.controller)); panel->backlight.active_low_pwm = pwm_ctl &BXT_BLC_PWM_POLARITY ; - panel->backlight.max = -intel_de_read (dev_priv, -BXT_BLC_PWM_FREQ (panel->backlight.controller)); + panel->backlight.pwm_level_max = +intel_de_read (dev_priv,BXT_BLC_PWM_FREQ (panel->backlight.controller)); -if (!panel->backlight.max) - panel->backlight.max =get_backlight_max_vbt (connector); +if (!panel->backlight.pwm_level_max) + panel->backlight.pwm_level_max =get_backlight_max_vbt (connector); -if (!panel->backlight.max) +if (!panel->backlight.pwm_level_max)return -ENODEV ; - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector); - val =bxt_get_backlight (connector); - val =intel_panel_compute_brightness (connector, val); - panel->backlight.level =clamp (val, panel->backlight.min, - panel->backlight.max); - - panel->backlight.enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ; + panel->backlight.pwm_enabled = pwm_ctl &BXT_BLC_PWM_ENABLE ;return 0 ; }@@ -1914,8 +1886,8 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector,return -ENODEV ; } - panel->backlight.max =100 ;/* 100% */ - panel->backlight.min =get_backlight_min_vbt (connector); + panel->backlight.pwm_level_max =100 ;/* 100% */ + panel->backlight.pwm_level_min =get_backlight_min_vbt (connector);if (pwm_is_enabled (panel->backlight.pwm)) {/* PWM is already enabled, use existing settings */ @@ -1923,10 +1895,8 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector, level =pwm_get_relative_duty_cycle (&panel->backlight.pwm_state,100 ); - level =intel_panel_compute_brightness (connector, level); - panel->backlight.level =clamp (level, panel->backlight.min, - panel->backlight.max); - panel->backlight.enabled = true; + level =intel_panel_sanitize_pwm_level (connector, level); + panel->backlight.pwm_enabled = true; drm_dbg_kms(&dev_priv->drm, "PWM already enabled at freq %ld, VBT freq %d, level %d\n", NSEC_PER_SEC / (unsigned long)panel->backlight.pwm_state.period,@@ -1942,6 +1912,58 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector,return 0 ; } +static void intel_pwm_set_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + + panel->backlight.pwm_funcs->set (conn_state, +intel_panel_sanitize_pwm_level (connector, level)); +} + +static u32 intel_pwm_get_backlight (struct intel_connector *connector) +{ +struct intel_panel *panel = &connector->panel; + +return intel_panel_sanitize_pwm_level (connector, + panel->backlight.pwm_funcs->get (connector)); +} + +static void intel_pwm_enable_backlight (const struct intel_crtc_state *crtc_state, +const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + + panel->backlight.pwm_funcs->enable (crtc_state, conn_state, +intel_panel_sanitize_pwm_level (connector, level)); +} + +static void intel_pwm_disable_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + + panel->backlight.pwm_funcs->disable (conn_state, +intel_panel_sanitize_pwm_level (connector, level)); +} + +static int intel_pwm_setup_backlight (struct intel_connector *connector,enum pipe pipe) +{ +struct intel_panel *panel = &connector->panel; +int ret = panel->backlight.pwm_funcs->setup (connector, pipe); + +if (ret <0 ) +return ret; + + panel->backlight.min = panel->backlight.pwm_level_min; + panel->backlight.max = panel->backlight.pwm_level_max; + panel->backlight.level =intel_pwm_get_backlight (connector); + panel->backlight.enabled = panel->backlight.pwm_enabled; + +return 0 ; +} + void intel_panel_update_backlight(struct intel_atomic_state *state, struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state,@@ -2015,7 +2037,7 @@ static void intel_panel_destroy_backlight(struct intel_panel *panel) panel->backlight.present = false; } -static const struct intel_panel_bl_funcs bxt_funcs = { +static const struct intel_panel_bl_funcs bxt_pwm_funcs = { .setup = bxt_setup_backlight, .enable = bxt_enable_backlight, .disable = bxt_disable_backlight,@@ -2024,7 +2046,7 @@ static const struct intel_panel_bl_funcs bxt_funcs = { .hz_to_pwm = bxt_hz_to_pwm, }; -static const struct intel_panel_bl_funcs cnp_funcs = { +static const struct intel_panel_bl_funcs cnp_pwm_funcs = { .setup = cnp_setup_backlight, .enable = cnp_enable_backlight, .disable = cnp_disable_backlight,@@ -2033,7 +2055,7 @@ static const struct intel_panel_bl_funcs cnp_funcs = { .hz_to_pwm = cnp_hz_to_pwm, }; -static const struct intel_panel_bl_funcs lpt_funcs = { +static const struct intel_panel_bl_funcs lpt_pwm_funcs = { .setup = lpt_setup_backlight, .enable = lpt_enable_backlight, .disable = lpt_disable_backlight,@@ -2042,7 +2064,7 @@ static const struct intel_panel_bl_funcs lpt_funcs = { .hz_to_pwm = lpt_hz_to_pwm, }; -static const struct intel_panel_bl_funcs spt_funcs = { +static const struct intel_panel_bl_funcs spt_pwm_funcs = { .setup = lpt_setup_backlight, .enable = lpt_enable_backlight, .disable = lpt_disable_backlight,@@ -2051,7 +2073,7 @@ static const struct intel_panel_bl_funcs spt_funcs = { .hz_to_pwm = spt_hz_to_pwm, }; -static const struct intel_panel_bl_funcs pch_funcs = { +static const struct intel_panel_bl_funcs pch_pwm_funcs = { .setup = pch_setup_backlight, .enable = pch_enable_backlight, .disable = pch_disable_backlight,@@ -2068,7 +2090,7 @@ static const struct intel_panel_bl_funcs ext_pwm_funcs = { .get = ext_pwm_get_backlight, }; -static const struct intel_panel_bl_funcs vlv_funcs = { +static const struct intel_panel_bl_funcs vlv_pwm_funcs = { .setup = vlv_setup_backlight, .enable = vlv_enable_backlight, .disable = vlv_disable_backlight,@@ -2077,7 +2099,7 @@ static const struct intel_panel_bl_funcs vlv_funcs = { .hz_to_pwm = vlv_hz_to_pwm, }; -static const struct intel_panel_bl_funcs i965_funcs = { +static const struct intel_panel_bl_funcs i965_pwm_funcs = { .setup = i965_setup_backlight, .enable = i965_enable_backlight, .disable = i965_disable_backlight,@@ -2086,7 +2108,7 @@ static const struct intel_panel_bl_funcs i965_funcs = { .hz_to_pwm = i965_hz_to_pwm, }; -static const struct intel_panel_bl_funcs i9xx_funcs = { +static const struct intel_panel_bl_funcs i9xx_pwm_funcs = { .setup = i9xx_setup_backlight, .enable = i9xx_enable_backlight, .disable = i9xx_disable_backlight,@@ -2095,6 +2117,14 @@ static const struct intel_panel_bl_funcs i9xx_funcs = { .hz_to_pwm = i9xx_hz_to_pwm, }; +static const struct intel_panel_bl_funcs pwm_bl_funcs = { + .setup = intel_pwm_setup_backlight, + .enable = intel_pwm_enable_backlight, + .disable = intel_pwm_disable_backlight, + .set = intel_pwm_set_backlight, + .get = intel_pwm_get_backlight, +}; +/* Set up chip specific backlight functions */ static void intel_panel_init_backlight_funcs (struct intel_panel *panel)@@ -2112,27 +2142,30 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel)return ;if (IS_GEN9_LP (dev_priv)) { - panel->backlight.funcs = &bxt_funcs; + panel->backlight.pwm_funcs = &bxt_pwm_funcs; }else if (INTEL_PCH_TYPE (dev_priv) >=PCH_CNP ) { - panel->backlight.funcs = &cnp_funcs; + panel->backlight.pwm_funcs = &cnp_pwm_funcs; }else if (INTEL_PCH_TYPE (dev_priv) >=PCH_LPT ) {if (HAS_PCH_LPT (dev_priv)) - panel->backlight.funcs = &lpt_funcs; + panel->backlight.pwm_funcs = &lpt_pwm_funcs;else - panel->backlight.funcs = &spt_funcs; + panel->backlight.pwm_funcs = &spt_pwm_funcs; }else if (HAS_PCH_SPLIT (dev_priv)) { - panel->backlight.funcs = &pch_funcs; + panel->backlight.pwm_funcs = &pch_pwm_funcs; }else if (IS_VALLEYVIEW (dev_priv) ||IS_CHERRYVIEW (dev_priv)) {if (connector->base.connector_type ==DRM_MODE_CONNECTOR_DSI ) { - panel->backlight.funcs = &ext_pwm_funcs; + panel->backlight.pwm_funcs = &ext_pwm_funcs; }else { - panel->backlight.funcs = &vlv_funcs; + panel->backlight.pwm_funcs = &vlv_pwm_funcs; } }else if (IS_GEN (dev_priv,4 )) { - panel->backlight.funcs = &i965_funcs; + panel->backlight.pwm_funcs = &i965_pwm_funcs; }else { - panel->backlight.funcs = &i9xx_funcs; + panel->backlight.pwm_funcs = &i9xx_pwm_funcs; } + +/* We're using a standard PWM backlight interface */ + panel->backlight.funcs = &pwm_bl_funcs; }enum drm_connector_status --
Quoted 2 lines
2.29.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 2/4 drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
In reply to Lyude PaulSo-recently a bunch of laptops on the market have started using DPCD backlight controls instead of the traditional DDI backlight controls. Originally we thought we had this handled by adding VESA backlight control support to i915, but the story ended up being a lot more complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the wild. Intel's proprietary HDR backlight interface, and the standard VESA backlight interface. Note that many panels have been observed to report support for both backlight interfaces, but testing has shown far more panels work with the Intel HDR backlight interface at the moment. Additionally, the VBT appears to be capable of reporting support for the VESA backlight interface but not the Intel HDR interface which needs to be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of the Intel HDR backlight interface. The first uses the AUX channel for controlling the brightness of the screen in both SDR and HDR mode, and the second only uses the AUX channel for setting the brightness level in HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks for panels that safely do support the VESA backlight interface. Adding support for Intel's HDR backlight interface in addition however, should finally allow us to auto-detect eDP backlight controls properly so long as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
--- .../drm/i915/display/intel_display_types.h | 9 +- .../drm/i915/display/intel_dp_aux_backlight.c | 248 ++++++++++++++++-- drivers/gpu/drm/i915/display/intel_panel.c | 42 ++- drivers/gpu/drm/i915/display/intel_panel.h | 4 + 4 files changed, 271 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/display/intel_display_types.h +8 -1
@@ -261,7 +261,14 @@ struct intel_panel {struct pwm_state pwm_state;/* DPCD backlight */ -u8 pwmgen_bit_count; +union { +struct { +u8 pwmgen_bit_count; + } vesa; +struct { +bool sdr_uses_aux; + } intel; + } edp;struct backlight_device *device;
drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +223 -25
306 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_panel.c +36 -6
72 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_panel.h +4 -0
@@ -49,6 +49,10 @@ struct drm_display_mode * intel_panel_edid_fixed_mode(struct intel_connector *connector);struct drm_display_mode *intel_panel_vbt_fixed_mode (struct intel_connector *connector); +void intel_panel_set_pwm_level (const struct drm_connector_state *conn_state,u32 level); +u32 intel_panel_sanitize_pwm_level (struct intel_connector *connector,u32 level); +u32 intel_panel_backlight_level_to_pwm (struct intel_connector *connector,u32 level); +u32 intel_panel_backlight_level_from_pwm (struct intel_connector *connector,u32 val);#if IS_ENABLED (CONFIG_BACKLIGHT_CLASS_DEVICE )int intel_backlight_device_register (struct intel_connector *connector);
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 2/4] drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
Quoted 400 lines · Lyude Paul
So-recently a bunch of laptops on the market have started using DPCD backlight controls instead of the traditional DDI backlight controls. Originally we thought we had this handled by adding VESA backlight control support to i915, but the story ended up being a lot more complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the wild. Intel's proprietary HDR backlight interface, and the standard VESA backlight interface. Note that many panels have been observed to report support for both backlight interfaces, but testing has shown far more panels work with the Intel HDR backlight interface at the moment. Additionally, the VBT appears to be capable of reporting support for the VESA backlight interface but not the Intel HDR interface which needs to be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of the Intel HDR backlight interface. The first uses the AUX channel for controlling the brightness of the screen in both SDR and HDR mode, and the second only uses the AUX channel for setting the brightness level in HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks for panels that safely do support the VESA backlight interface. Adding support for Intel's HDR backlight interface in addition however, should finally allow us to auto-detect eDP backlight controls properly so long as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it doesn't have DPCD backlight controlsChanges since v4:
* Fix checkpatch issues
Changes since v3:
* Stop usingdrm_deviceand usedrm_i915_privateinstead
* Don't forget to return fromintel_dp_aux_hdr_get_backlight()if we fail to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis inintel_dp_aux_hdr_enable_backlight()
* Usedrm_dbg_kms()inintel_dp_aux_init_backlight_funcs()Signed-off-by Lyude Paul <[email protected]>Acked-by Jani Nikula <[email protected]>Cc Vasily Khoruzhick <[email protected]>--- .../drm/i915/display/intel_display_types.h | 9 +- .../drm/i915/display/intel_dp_aux_backlight.c | 248 ++++++++++++++++-- drivers/gpu/drm/i915/display/intel_panel.c | 42 ++- drivers/gpu/drm/i915/display/intel_panel.h | 4 + 4 files changed, 271 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/display/intel_display_types.h +8
-1@@ -261,7 +261,14 @@ struct intel_panel {struct pwm_state pwm_state;/* DPCD backlight */ -u8 pwmgen_bit_count; +union { +struct { +u8 pwmgen_bit_count; + } vesa; +struct { +bool sdr_uses_aux; + } intel; + } edp;struct backlight_device *device;drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +223
-25@@ -22,8 +22,26 @@* */ +/* +* Laptops with Intel GPUs which have panels that support controlling the +* backlight through DP AUX can actually use two different interfaces: Intel's +* proprietary DP AUX backlight interface, and the standard VESA backlight +* interface. Unfortunately, at the time of writing this a lot of laptops will +* advertise support for the standard VESA backlight interface when they +* don't properly support it. However, on these systems the Intel backlight +* interface generally does work properly. Additionally, these systems will +* usually just indicate that they use PWM backlight controls in their VBIOS +* for some reason. +*/ +#include "intel_display_types.h" #include "intel_dp_aux_backlight.h" +#include "intel_panel.h" + +/* TODO: +* Implement HDR, right now we just implement the bare minimum to bring us back into SDR mode so we +* can make people's backlights work in the mean time +*/ /* * DP AUX registers for Intel's proprietary HDR backlight interface. We define @@ -77,6 +95,179 @@#define INTEL_EDP_BRIGHTNESS_OPTIMIZATION_1 0x359 +/* Intel EDP backlight callbacks */ +static bool +intel_dp_aux_supports_hdr_backlight (struct intel_connector *connector) +{ +struct drm_i915_private *i915 =to_i915 (connector->base.dev); +struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder); +struct drm_dp_aux *aux = &intel_dp->aux; +struct intel_panel *panel = &connector->panel; +int ret; +u8 tcon_cap[4 ]; + + ret =drm_dp_dpcd_read (aux,INTEL_EDP_HDR_TCON_CAP0 , tcon_cap,sizeof (tcon_cap)); +if (ret <0 ) +return false; + +if (!(tcon_cap[1 ] &INTEL_EDP_HDR_TCON_BRIGHTNESS_NITS_CAP )) +return false; + +if (tcon_cap[0 ] >=1 ) { +drm_dbg_kms (&i915->drm,"Detected Intel HDR backlight interface version %d\n" , + tcon_cap[0 ]); + }else { +drm_dbg_kms (&i915->drm,"Detected unsupported HDR backlight interface version %d\n" , + tcon_cap[0 ]); +return false; + } + + panel->backlight.edp.intel.sdr_uses_aux = + tcon_cap[2 ] &INTEL_EDP_SDR_TCON_BRIGHTNESS_AUX_CAP ; + +return true; +} + +static u32 +intel_dp_aux_hdr_get_backlight (struct intel_connector *connector) +{ +struct drm_i915_private *i915 =to_i915 (connector->base.dev); +struct intel_panel *panel = &connector->panel; +struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder); +u8 tmp; +u8 buf[2 ] = {0 }; + +if (drm_dp_dpcd_readb (&intel_dp->aux,INTEL_EDP_HDR_GETSET_CTRL_PARAMS , &tmp) <0 ) { +drm_err (&i915->drm,"Failed to read current backlight mode from DPCD\n" ); +return 0 ; + } + +if (!(tmp &INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE )) { +if (!panel->backlight.edp.intel.sdr_uses_aux) { +u32 pwm_level = panel->backlight.pwm_funcs->get (connector); + +return intel_panel_backlight_level_from_pwm (connector, pwm_level); + } + +/* Assume 100% brightness if backlight controls aren't enabled yet */ +return panel->backlight.max; + } + +if (drm_dp_dpcd_read (&intel_dp->aux,INTEL_EDP_BRIGHTNESS_NITS_LSB , buf,sizeof (buf)) <0 ) { +drm_err (&i915->drm,"Failed to read brightness from DPCD\n" ); +return 0 ; + } + +return (buf[1 ] <<8 | buf[0 ]); +} + +static void +intel_dp_aux_hdr_set_aux_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct drm_device *dev = connector->base.dev; +struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder); +u8 buf[4 ] = {0 }; + + buf[0 ] = level &0xFF ; + buf[1 ] = (level &0xFF00 ) >>8 ; + +if (drm_dp_dpcd_write (&intel_dp->aux,INTEL_EDP_BRIGHTNESS_NITS_LSB , buf,4 ) <0 ) +drm_err (dev,"Failed to write brightness level to DPCD\n" ); +} + +static void +intel_dp_aux_hdr_set_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + +if (panel->backlight.edp.intel.sdr_uses_aux) { +intel_dp_aux_hdr_set_aux_backlight (conn_state, level); + }else { +const u32 pwm_level =intel_panel_backlight_level_to_pwm (connector, level); + +intel_panel_set_pwm_level (conn_state, pwm_level); + } +} + +static void +intel_dp_aux_hdr_enable_backlight (const struct intel_crtc_state *crtc_state, +const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; +struct drm_i915_private *i915 =to_i915 (connector->base.dev); +struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder); +int ret; +u8 old_ctrl, ctrl; + + ret =drm_dp_dpcd_readb (&intel_dp->aux,INTEL_EDP_HDR_GETSET_CTRL_PARAMS , &old_ctrl); +if (ret <0 ) { +drm_err (&i915->drm,"Failed to read current backlight control mode: %d\n" , ret); +return ; + } + + ctrl = old_ctrl; +if (panel->backlight.edp.intel.sdr_uses_aux) { + ctrl |=INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE ; +intel_dp_aux_hdr_set_aux_backlight (conn_state, level); + }else { +u32 pwm_level =intel_panel_backlight_level_to_pwm (connector, level); + + panel->backlight.pwm_funcs->enable (crtc_state, conn_state, pwm_level); + + ctrl &= ~INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE ; + } + +if (ctrl != old_ctrl) +if (drm_dp_dpcd_writeb (&intel_dp->aux,INTEL_EDP_HDR_GETSET_CTRL_PARAMS , ctrl) <0 ) +drm_err (&i915->drm,"Failed to configure DPCD brightness controls\n" ); +} + +static void +intel_dp_aux_hdr_disable_backlight (const struct drm_connector_state *conn_state,u32 level) +{ +struct intel_connector *connector =to_intel_connector (conn_state->connector); +struct intel_panel *panel = &connector->panel; + +/* Nothing to do for AUX based backlight controls */ +if (panel->backlight.edp.intel.sdr_uses_aux) +return ; + +/* Note we want the actual pwm_level to be 0, regardless of pwm_min */ + panel->backlight.pwm_funcs->disable (conn_state, +intel_panel_sanitize_pwm_level (connector,0 )); +} + +static int +intel_dp_aux_hdr_setup_backlight (struct intel_connector *connector,enum pipe pipe) +{ +struct drm_i915_private *i915 =to_i915 (connector->base.dev); +struct intel_panel *panel = &connector->panel; +int ret; + +if (panel->backlight.edp.intel.sdr_uses_aux) { +drm_dbg_kms (&i915->drm,"SDR backlight is controlled through DPCD\n" ); + }else { +drm_dbg_kms (&i915->drm,"SDR backlight is controlled through PWM\n" ); + + ret = panel->backlight.pwm_funcs->setup (connector, pipe); +if (ret <0 ) { +drm_err (&i915->drm, +"Failed to setup SDR backlight controls through PWM: %d\n" , ret); +return ret; + } + } + + panel->backlight.max =512 ; + panel->backlight.min =0 ; + panel->backlight.level =intel_dp_aux_hdr_get_backlight (connector); + panel->backlight.enabled = panel->backlight.level !=0 ; + +return 0 ; +} +/* VESA backlight callbacks */ static void set_vesa_backlight_enable (struct intel_dp *intel_dp,bool enable) {@@ -195,7 +386,7 @@ static bool intel_dp_aux_vesa_set_pwm_freq(struct intel_connector *connector) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_dp *intel_dp =intel_attached_dp (connector); -const u8 pn = connector->panel.backlight.pwmgen_bit_count; +const u8 pn = connector->panel.backlight.edp.vesa.pwmgen_bit_count;int freq, fxp, f, fxp_actual, fxp_min, fxp_max; freq = dev_priv->vbt.backlight.pwm_freq_hz;@@ -236,6 +427,7 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,struct drm_i915_private *i915 =dp_to_i915 (intel_dp);struct intel_panel *panel = &connector->panel;u8 dpcd_buf, new_dpcd_buf, edp_backlight_mode; +u8 pwmgen_bit_count = panel->backlight.edp.vesa.pwmgen_bit_count;if (drm_dp_dpcd_readb (&intel_dp->aux,DP_EDP_BACKLIGHT_MODE_SET_REGISTER , &dpcd_buf) !=1 ) {@@ -256,7 +448,7 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,if (drm_dp_dpcd_writeb (&intel_dp->aux,DP_EDP_PWMGEN_BIT_COUNT , - panel->backlight.pwmgen_bit_count) <0 ) + pwmgen_bit_count) <0 )drm_dbg_kms (&i915->drm,"Failed to write aux pwmgen bit count\n" );@@ -364,7 +556,7 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto "Failed to write aux pwmgen bit count\n");return max_backlight; } - panel->backlight.pwmgen_bit_count = pn; + panel->backlight.edp.vesa.pwmgen_bit_count = pn; max_backlight = (1 << pn) -1 ;@@ -405,6 +597,14 @@ intel_dp_aux_supports_vesa_backlight(struct intel_connector *connector)return false; } +static const struct intel_panel_bl_funcs intel_dp_hdr_bl_funcs = { + .setup = intel_dp_aux_hdr_setup_backlight, + .enable = intel_dp_aux_hdr_enable_backlight, + .disable = intel_dp_aux_hdr_disable_backlight, + .set = intel_dp_aux_hdr_set_backlight, + .get = intel_dp_aux_hdr_get_backlight, +}; +static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = { .setup = intel_dp_aux_vesa_setup_backlight, .enable = intel_dp_aux_vesa_enable_backlight,@@ -413,36 +613,34 @@ static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = { .get = intel_dp_aux_vesa_get_backlight, }; -int intel_dp_aux_init_backlight_funcs (struct intel_connector *intel_connector) +int intel_dp_aux_init_backlight_funcs (struct intel_connector *connector) { -struct intel_panel *panel = &intel_connector->panel; -struct intel_dp *intel_dp =enc_to_intel_dp (intel_connector->encoder); +struct drm_device *dev = connector->base.dev; +struct intel_panel *panel = &connector->panel; +struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder);struct drm_i915_private *i915 =dp_to_i915 (intel_dp); -if (i915->params.enable_dpcd_backlight ==0 || - !intel_dp_aux_supports_vesa_backlight (intel_connector)) +if (i915->params.enable_dpcd_backlight ==0 )return -ENODEV ;/* -* There are a lot of machines that don't advertise the backlight -* control interface to use properly in their VBIOS, :\ +* A lot of eDP panels in the wild will report supporting both the +* Intel proprietary backlight control interface, and the VESA +* backlight control interface. Many of these panels are liars though, +* and will only work with the Intel interface. So, always probe for +* that first. */ -if (i915->vbt.backlight.type != -INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE && - i915->params.enable_dpcd_backlight !=1 && - !drm_dp_has_quirk (&intel_dp->desc, intel_dp->edid_quirks, -DP_QUIRK_FORCE_DPCD_BACKLIGHT )) { -drm_info (&i915->drm, -"Panel advertises DPCD backlight support, but " -"VBT disagrees. If your backlight controls " -"don't work try booting with " -"i915.enable_dpcd_backlight=1. If your machine " -"needs this, please file a _new_ bug report on " -"drm/i915, see " FDO_BUG_URL " for details.\n" ); -return -ENODEV ; +if (intel_dp_aux_supports_hdr_backlight (connector)) { +drm_dbg_kms (dev,"Using Intel proprietary eDP backlight controls\n" ); + panel->backlight.funcs = &intel_dp_hdr_bl_funcs; +return 0 ; } - panel->backlight.funcs = &intel_dp_vesa_bl_funcs; +if (intel_dp_aux_supports_vesa_backlight (connector)) { +drm_dbg_kms (dev,"Using VESA eDP backlight controls\n" ); + panel->backlight.funcs = &intel_dp_vesa_bl_funcs; +return 0 ; + } -return 0 ; +return -ENODEV ; }drivers/gpu/drm/i915/display/intel_panel.c +0
-0
drivers/gpu/drm/i915/display/intel_panel.c static u32 scale_hw_to_user(struct intel_connector *connector, · line 514
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_panel.c +1
-1@@ -511,7 +511,7 @@ static u32 scale_hw_to_user(struct intel_connector *connector, 0, user_max); } -static u32 intel_panel_sanitize_pwm_level (struct intel_connector *connector,u32 val) +u32 intel_panel_sanitize_pwm_level (struct intel_connector *connector,u32 val)
I'm frankly thinking we shouldn't expose this, and instead limit this to fewer platforms. Maybe it could be baked into the platform specific functions for the affected GM45 platforms. I'd love to just nuke the module parameter.
Again, up to you, and this can be done later since you have the code already.
Quoted 86 lines
drivers/gpu/drm/i915/display/intel_panel.c +35
-5{struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);struct intel_panel *panel = &connector->panel;@@ -529,7 +529,7 @@ static u32 intel_panel_sanitize_pwm_level(struct intel_connector *connector, u32return val; } -static void intel_panel_set_pwm_level (const struct drm_connector_state *conn_state,u32 val) +void intel_panel_set_pwm_level (const struct drm_connector_state *conn_state,u32 val) {struct intel_connector *connector =to_intel_connector (conn_state->connector);struct drm_i915_private *i915 =to_i915 (connector->base.dev);@@ -539,6 +539,36 @@ static void intel_panel_set_pwm_level(const struct drm_connector_state *conn_sta panel->backlight.pwm_funcs->set (conn_state, val); } +u32 intel_panel_backlight_level_to_pwm (struct intel_connector *connector,u32 val) +{ +struct drm_i915_private *dev_priv =to_i915 (connector->base.dev); +struct intel_panel *panel = &connector->panel; + +drm_WARN_ON_ONCE (&dev_priv->drm, + panel->backlight.max ==0 || panel->backlight.pwm_level_max ==0 ); + + val =scale (val, panel->backlight.min, panel->backlight.max, + panel->backlight.pwm_level_min, panel->backlight.pwm_level_max); + +return intel_panel_sanitize_pwm_level (connector, val); +} + +u32 intel_panel_backlight_level_from_pwm (struct intel_connector *connector,u32 val) +{ +struct drm_i915_private *dev_priv =to_i915 (connector->base.dev); +struct intel_panel *panel = &connector->panel; + +drm_WARN_ON_ONCE (&dev_priv->drm, + panel->backlight.max ==0 || panel->backlight.pwm_level_max ==0 ); + +if (dev_priv->params.invert_brightness >0 || + (dev_priv->params.invert_brightness ==0 && dev_priv->quirks &QUIRK_INVERT_BRIGHTNESS )) + val = panel->backlight.pwm_level_max - (val - panel->backlight.pwm_level_min); + +return scale (val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max, + panel->backlight.min, panel->backlight.max); +} +static u32 lpt_get_backlight (struct intel_connector *connector) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev);@@ -2133,10 +2163,6 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel) container_of(panel, struct intel_connector, panel);struct drm_i915_private *dev_priv =to_i915 (connector->base.dev); -if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP && -intel_dp_aux_init_backlight_funcs (connector) ==0 ) -return ; -if (connector->base.connector_type ==DRM_MODE_CONNECTOR_DSI &&intel_dsi_dcs_init_backlight_funcs (connector) ==0 )return ;@@ -2164,6 +2190,10 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel) panel->backlight.pwm_funcs = &i9xx_pwm_funcs; } +if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP && +intel_dp_aux_init_backlight_funcs (connector) ==0 ) +return ; +/* We're using a standard PWM backlight interface */ panel->backlight.funcs = &pwm_bl_funcs; }drivers/gpu/drm/i915/display/intel_panel.h +4
-0@@ -49,6 +49,10 @@ struct drm_display_mode * intel_panel_edid_fixed_mode(struct intel_connector *connector);struct drm_display_mode *intel_panel_vbt_fixed_mode (struct intel_connector *connector); +void intel_panel_set_pwm_level (const struct drm_connector_state *conn_state,u32 level); +u32 intel_panel_sanitize_pwm_level (struct intel_connector *connector,u32 level); +u32 intel_panel_backlight_level_to_pwm (struct intel_connector *connector,u32 level); +u32 intel_panel_backlight_level_from_pwm (struct intel_connector *connector,u32 val);#if IS_ENABLED (CONFIG_BACKLIGHT_CLASS_DEVICE )int intel_backlight_device_register (struct intel_connector *connector);
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 3/4 drm/i915/dp: Allow forcing specific interfaces through enable_dpcd_backlight
In reply to Lyude PaulSince we now support controlling panel backlights through DPCD using both the standard VESA interface, and Intel's proprietary HDR backlight interface, we should allow the user to be able to explicitly choose between one or the other in the event that we're wrong about panels reliably reporting support for the Intel HDR interface.
So, this commit adds support for this by introducing two new enable_dpcd_backlight options: 2 which forces i915 to only probe for the VESA interface, and 3 which forces i915 to only probe for the Intel backlight interface (might be useful if we find panels in the wild that report the VESA interface in their VBT, but actually only support the Intel backlight interface).
v3:
* Rebase
--- .../drm/i915/display/intel_dp_aux_backlight.c | 45 +++++++++++++++++-- drivers/gpu/drm/i915/i915_params.c | 2 +- 2 files changed, 43 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +42 -3
@@ -613,15 +613,54 @@ static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = { .get = intel_dp_aux_vesa_get_backlight, }; +enum intel_dp_aux_backlight_modparam { +INTEL_DP_AUX_BACKLIGHT_AUTO =-1 , +INTEL_DP_AUX_BACKLIGHT_OFF =0 , +INTEL_DP_AUX_BACKLIGHT_ON =1 , +INTEL_DP_AUX_BACKLIGHT_FORCE_VESA =2 , +INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL =3 , +}; +int intel_dp_aux_init_backlight_funcs (struct intel_connector *connector) {struct drm_device *dev = connector->base.dev;struct intel_panel *panel = &connector->panel;struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder);struct drm_i915_private *i915 =dp_to_i915 (intel_dp); +bool try_intel_interface = false, try_vesa_interface = false; -if (i915->params.enable_dpcd_backlight ==0 ) +/* Check the VBT and user's module parameters to figure out which +* interfaces to probe +*/ +switch (i915->params.enable_dpcd_backlight) { +case INTEL_DP_AUX_BACKLIGHT_OFF :return -ENODEV ; +case INTEL_DP_AUX_BACKLIGHT_AUTO : +switch (i915->vbt.backlight.type) { +case INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE : + try_vesa_interface = true; +break ; +case INTEL_BACKLIGHT_DISPLAY_DDI : + try_intel_interface = true; + try_vesa_interface = true; +break ; +default : +return -ENODEV ; + } +break ; +case INTEL_DP_AUX_BACKLIGHT_ON : +if (i915->vbt.backlight.type !=INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE ) + try_intel_interface = true; + + try_vesa_interface = true; +break ; +case INTEL_DP_AUX_BACKLIGHT_FORCE_VESA : + try_vesa_interface = true; +break ; +case INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL : + try_intel_interface = true; +break ; + }/* * A lot of eDP panels in the wild will report supporting both the
@@ -630,13 +669,13 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)* and will only work with the Intel interface. So, always probe for * that first. */ -if (intel_dp_aux_supports_hdr_backlight (connector)) { +if (try_intel_interface &&intel_dp_aux_supports_hdr_backlight (connector)) {drm_dbg_kms (dev,"Using Intel proprietary eDP backlight controls\n" ); panel->backlight.funcs = &intel_dp_hdr_bl_funcs;return 0 ; } -if (intel_dp_aux_supports_vesa_backlight (connector)) { +if (try_vesa_interface &&intel_dp_aux_supports_vesa_backlight (connector)) {drm_dbg_kms (dev,"Using VESA eDP backlight controls\n" ); panel->backlight.funcs = &intel_dp_vesa_bl_funcs;return 0 ;
drivers/gpu/drm/i915/i915_params.c +1 -1
@@ -185,7 +185,7 @@ i915_param_named_unsafe(inject_probe_failure, uint, 0400,i915_param_named (enable_dpcd_backlight, int,0400 ,"Enable support for DPCD backlight control" -"(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enabled)" ); +"(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enable, 2=force VESA interface, 3=force Intel interface)" );#if IS_ENABLED (CONFIG_DRM_I915_GVT ) i915_param_named(enable_gvt, bool, 0400,
Signature · 6 lines
2.29.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v5 3/4] drm/i915/dp: Allow forcing specific interfaces through enable_dpcd_backlight
Quoted 13 lines · Lyude Paul
Since we now support controlling panel backlights through DPCD using both the standard VESA interface, and Intel's proprietary HDR backlight interface, we should allow the user to be able to explicitly choose between one or the other in the event that we're wrong about panels reliably reporting support for the Intel HDR interface.
So, this commit adds support for this by introducing two new
enable_dpcd_backlightoptions: 2 which forces i915 to only probe for the VESA interface, and 3 which forces i915 to only probe for the Intel backlight interface (might be useful if we find panels in the wild that report the VESA interface in their VBT, but actually only support the Intel backlight interface).
Quoted 5 lines
v3:
* RebaseSigned-off-by Lyude Paul <[email protected]>Reviewed-by Jani Nikula <[email protected]>
Yup. Feels maybe a bit convoluted, but I'll trust your judgement as you've been playing with these.
BR,
Jani.
Quoted 96 lines
Cc Vasily Khoruzhick <[email protected]>--- .../drm/i915/display/intel_dp_aux_backlight.c | 45 +++++++++++++++++-- drivers/gpu/drm/i915/i915_params.c | 2 +- 2 files changed, 43 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +42
-3@@ -613,15 +613,54 @@ static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = { .get = intel_dp_aux_vesa_get_backlight, }; +enum intel_dp_aux_backlight_modparam { +INTEL_DP_AUX_BACKLIGHT_AUTO =-1 , +INTEL_DP_AUX_BACKLIGHT_OFF =0 , +INTEL_DP_AUX_BACKLIGHT_ON =1 , +INTEL_DP_AUX_BACKLIGHT_FORCE_VESA =2 , +INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL =3 , +}; +int intel_dp_aux_init_backlight_funcs (struct intel_connector *connector) {struct drm_device *dev = connector->base.dev;struct intel_panel *panel = &connector->panel;struct intel_dp *intel_dp =enc_to_intel_dp (connector->encoder);struct drm_i915_private *i915 =dp_to_i915 (intel_dp); +bool try_intel_interface = false, try_vesa_interface = false; -if (i915->params.enable_dpcd_backlight ==0 ) +/* Check the VBT and user's module parameters to figure out which +* interfaces to probe +*/ +switch (i915->params.enable_dpcd_backlight) { +case INTEL_DP_AUX_BACKLIGHT_OFF :return -ENODEV ; +case INTEL_DP_AUX_BACKLIGHT_AUTO : +switch (i915->vbt.backlight.type) { +case INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE : + try_vesa_interface = true; +break ; +case INTEL_BACKLIGHT_DISPLAY_DDI : + try_intel_interface = true; + try_vesa_interface = true; +break ; +default : +return -ENODEV ; + } +break ; +case INTEL_DP_AUX_BACKLIGHT_ON : +if (i915->vbt.backlight.type !=INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE ) + try_intel_interface = true; + + try_vesa_interface = true; +break ; +case INTEL_DP_AUX_BACKLIGHT_FORCE_VESA : + try_vesa_interface = true; +break ; +case INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL : + try_intel_interface = true; +break ; + }/* * A lot of eDP panels in the wild will report supporting both the @@ -630,13 +669,13 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)* and will only work with the Intel interface. So, always probe for * that first. */ -if (intel_dp_aux_supports_hdr_backlight (connector)) { +if (try_intel_interface &&intel_dp_aux_supports_hdr_backlight (connector)) {drm_dbg_kms (dev,"Using Intel proprietary eDP backlight controls\n" ); panel->backlight.funcs = &intel_dp_hdr_bl_funcs;return 0 ; } -if (intel_dp_aux_supports_vesa_backlight (connector)) { +if (try_vesa_interface &&intel_dp_aux_supports_vesa_backlight (connector)) {drm_dbg_kms (dev,"Using VESA eDP backlight controls\n" ); panel->backlight.funcs = &intel_dp_vesa_bl_funcs;return 0 ;drivers/gpu/drm/i915/i915_params.c +1
-1@@ -185,7 +185,7 @@ i915_param_named_unsafe(inject_probe_failure, uint, 0400,i915_param_named (enable_dpcd_backlight, int,0400 ,"Enable support for DPCD backlight control" -"(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enabled)" ); +"(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enable, 2=force VESA interface, 3=force Intel interface)" );#if IS_ENABLED (CONFIG_DRM_I915_GVT ) i915_param_named(enable_gvt, bool, 0400,
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v5 4/4 drm/dp: Revert "drm/dp: Introduce EDID-based quirks"
In reply to Lyude PaulThis reverts commit 0883ce8146ed6074c76399f4e70dbed788582e12. Originally these quirks were added because of the issues with using the eDP backlight interfaces on certain laptop panels, which made it impossible to properly probe for DPCD backlight support without having a whitelist for panels that we know have working VESA backlight control interfaces over DPCD. As well, it should be noted it was impossible to use the normal sink OUI for recognizing these panels as none of them actually filled out their OUIs, hence needing to resort to checking EDIDs.
At the time we weren't really sure why certain panels had issues with DPCD backlight controls, but we eventually figured out that there was a second interface that these problematic laptop panels actually did work with and advertise properly: Intel's proprietary backlight interface for HDR panels. So far the testing we've done hasn't brought any panels to light that advertise this interface and don't support it properly, which means we finally have a real solution to this problem.
As a result, we now have no need for the force DPCD backlight quirk, and furthermore this also removes the need for any kind of EDID quirk checking in DRM. So, let's just revert it for now since we were the only driver using this.
v3:
* Rebase
v2:
* Fix indenting error picked up by checkpatch in
intel_edp_init_connector()
--- drivers/gpu/drm/drm_dp_helper.c | 83 +------------------ drivers/gpu/drm/drm_dp_mst_topology.c | 3 +- .../drm/i915/display/intel_display_types.h | 1 - drivers/gpu/drm/i915/display/intel_dp.c | 9 +- drivers/gpu/drm/i915/display/intel_dp_mst.c | 3 +- drivers/gpu/drm/i915/display/intel_psr.c | 2 +- include/drm/drm_dp_helper.h | 21 +---- 7 files changed, 9 insertions(+), 113 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +1 -82
@@ -1236,7 +1236,7 @@ bool drm_dp_read_sink_count_cap(struct drm_connector *connector,return connector->connector_type != DRM_MODE_CONNECTOR_eDP && dpcd[DP_DPCD_REV ] >=DP_DPCD_REV_11 && dpcd[DP_DOWNSTREAMPORT_PRESENT ] &DP_DWN_STRM_PORT_PRESENT && - !drm_dp_has_quirk (desc,0 ,DP_DPCD_QUIRK_NO_SINK_COUNT ); + !drm_dp_has_quirk (desc,DP_DPCD_QUIRK_NO_SINK_COUNT ); }EXPORT_SYMBOL (drm_dp_read_sink_count_cap);
@@ -1957,87 +1957,6 @@ drm_dp_get_quirks(const struct drm_dp_dpcd_ident *ident, bool is_branch)#undef DEVICE_ID_ANY#undef DEVICE_ID -struct edid_quirk { -u8 mfg_id[2 ]; -u8 prod_id[2 ]; -u32 quirks; -}; - -#define MFG (first, second) { (first), (second) } -#define PROD_ID (first, second) { (first), (second) } - -/* -* Some devices have unreliable OUIDs where they don't set the device ID -* correctly, and as a result we need to use the EDID for finding additional -* DP quirks in such cases. -*/ -static const struct edid_quirk edid_quirk_list[] = { -/* Optional 4K AMOLED panel in the ThinkPad X1 Extreme 2nd Generation -* only supports DPCD backlight controls -*/ - {MFG (0x4c ,0x83 ),PROD_ID (0x41 ,0x41 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, -/* -* Some Dell CML 2020 systems have panels support both AUX and PWM -* backlight control, and some only support AUX backlight control. All -* said panels start up in AUX mode by default, and we don't have any -* support for disabling HDR mode on these panels which would be -* required to switch to PWM backlight control mode (plus, I'm not -* even sure we want PWM backlight controls over DPCD backlight -* controls anyway...). Until we have a better way of detecting these, -* force DPCD backlight mode on all of them. -*/ - {MFG (0x06 ,0xaf ),PROD_ID (0x9b ,0x32 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x06 ,0xaf ),PROD_ID (0xeb ,0x41 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x4d ,0x10 ),PROD_ID (0xc7 ,0x14 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x4d ,0x10 ),PROD_ID (0xe6 ,0x14 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x4c ,0x83 ),PROD_ID (0x47 ,0x41 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x09 ,0xe5 ),PROD_ID (0xde ,0x08 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, -}; - -#undef MFG -#undef PROD_ID - -/** -* drm_dp_get_edid_quirks() - Check the EDID of a DP device to find additional -* DP-specific quirks -* @edid: The EDID to check -* -* While OUIDs are meant to be used to recognize a DisplayPort device, a lot -* of manufacturers don't seem to like following standards and neglect to fill -* the dev-ID in, making it impossible to only use OUIDs for determining -* quirks in some cases. This function can be used to check the EDID and look -* up any additional DP quirks. The bits returned by this function correspond -* to the quirk bits in &drm_dp_quirk. -* -* Returns: a bitmask of quirks, if any. The driver can check this using -* drm_dp_has_quirk(). -*/ -u32 drm_dp_get_edid_quirks (const struct edid *edid) -{ -const struct edid_quirk *quirk; -u32 quirks =0 ; -int i; - -if (!edid) -return 0 ; - -for (i =0 ; i <ARRAY_SIZE (edid_quirk_list); i++) { - quirk = &edid_quirk_list[i]; -if (memcmp (quirk->mfg_id, edid->mfg_id, -sizeof (edid->mfg_id)) ==0 && -memcmp (quirk->prod_id, edid->prod_code, -sizeof (edid->prod_code)) ==0 ) - quirks |= quirk->quirks; - } - -DRM_DEBUG_KMS ("DP sink: EDID mfg %*phD prod-ID %*phD quirks: 0x%04x\n" , - (int )sizeof (edid->mfg_id), edid->mfg_id, - (int )sizeof (edid->prod_code), edid->prod_code, quirks); - -return quirks; -} -EXPORT_SYMBOL (drm_dp_get_edid_quirks); -/** * drm_dp_read_desc - read sink/branch descriptor from DPCD * @aux: DisplayPort AUX channel
drivers/gpu/drm/drm_dp_mst_topology.c +1 -2
@@ -5824,8 +5824,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)if (drm_dp_read_desc (port->mgr->aux, &desc, true))return NULL ; -if (drm_dp_has_quirk (&desc,0 , -DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD ) && +if (drm_dp_has_quirk (&desc,DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD ) && port->mgr->dpcd[DP_DPCD_REV ] >=DP_DPCD_REV_14 && port->parent == port->mgr->mst_primary) {u8 downstreamport;
drivers/gpu/drm/i915/display/intel_display_types.h +0 -1
@@ -1390,7 +1390,6 @@ struct intel_dp {int max_link_rate;/* sink or branch descriptor */ struct drm_dp_desc desc; -u32 edid_quirks;struct drm_dp_aux aux;u32 aux_busy_last_status;u8 train_set[4 ];
drivers/gpu/drm/i915/display/intel_dp.c +2 -7
@@ -162,8 +162,7 @@ static void intel_dp_set_sink_rates(struct intel_dp *intel_dp)int i, max_rate;int max_lttpr_rate; -if (drm_dp_has_quirk (&intel_dp->desc,0 , -DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS )) { +if (drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS )) {/* Needed, e.g., for Apple MBP 2017, 15 inch eDP Retina panel */ static const int quirk_rates[] = {162000 ,270000 ,324000 };
@@ -2823,8 +2822,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,struct intel_connector *intel_connector = intel_dp->attached_connector;struct intel_digital_connector_state *intel_conn_state =to_intel_digital_connector_state (conn_state); -bool constant_n =drm_dp_has_quirk (&intel_dp->desc,0 , -DP_DPCD_QUIRK_CONSTANT_N ); +bool constant_n =drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_CONSTANT_N );int ret =0 , output_bpp;if (HAS_PCH_SPLIT (dev_priv) && !HAS_DDI (dev_priv) && port !=PORT_A )
@@ -7007,7 +7005,6 @@ intel_dp_set_edid(struct intel_dp *intel_dp) }drm_dp_cec_set_edid (&intel_dp->aux, edid); - intel_dp->edid_quirks =drm_dp_get_edid_quirks (edid); } static void
@@ -7021,7 +7018,6 @@ intel_dp_unset_edid(struct intel_dp *intel_dp) intel_dp->has_hdmi_sink = false; intel_dp->has_audio = false; - intel_dp->edid_quirks =0 ; intel_dp->dfp.max_bpc =0 ; intel_dp->dfp.max_dotclock =0 ;
@@ -8425,7 +8421,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,if (edid) {if (drm_add_edid_modes (connector, edid)) {drm_connector_update_edid_property (connector, edid); - intel_dp->edid_quirks =drm_dp_get_edid_quirks (edid); }else {kfree (edid); edid =ERR_PTR (-EINVAL );
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -2
@@ -53,8 +53,7 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,struct drm_i915_private *i915 =to_i915 (connector->base.dev);const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; -bool constant_n =drm_dp_has_quirk (&intel_dp->desc,0 , -DP_DPCD_QUIRK_CONSTANT_N ); +bool constant_n =drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_CONSTANT_N );int bpp, slots = -EINVAL ; crtc_state->lane_count = limits->max_lane_count;
drivers/gpu/drm/i915/display/intel_psr.c +1 -1
@@ -305,7 +305,7 @@ void intel_psr_init_dpcd(struct intel_dp *intel_dp)drm_dbg_kms (&dev_priv->drm,"eDP panel supports PSR version %x\n" , intel_dp->psr_dpcd[0 ]); -if (drm_dp_has_quirk (&intel_dp->desc,0 ,DP_DPCD_QUIRK_NO_PSR )) { +if (drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_NO_PSR )) {drm_dbg_kms (&dev_priv->drm,"PSR support not currently available for this panel\n" );return ;
include/drm/drm_dp_helper.h +3 -18
@@ -2029,16 +2029,13 @@ struct drm_dp_desc {int drm_dp_read_desc (struct drm_dp_aux *aux,struct drm_dp_desc *desc,bool is_branch); -u32 drm_dp_get_edid_quirks (const struct edid *edid);/** * enum drm_dp_quirk - Display Port sink/branch device specific quirks * * Display Port sink and branch devices in the wild have a variety of bugs, try * to collect them here. The quirks are shared, but it's up to the drivers to -* implement workarounds for them. Note that because some devices have -* unreliable OUIDs, the EDID of sinks should also be checked for quirks using -* drm_dp_get_edid_quirks(). +* implement workarounds for them. */ enum drm_dp_quirk {/**
@@ -2070,16 +2067,6 @@ enum drm_dp_quirk {* The DSC caps can be read from the physical aux instead. */ DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD, -/** -* @DP_QUIRK_FORCE_DPCD_BACKLIGHT: -* -* The device is telling the truth when it says that it uses DPCD -* backlight controls, even if the system's firmware disagrees. This -* quirk should be checked against both the ident and panel EDID. -* When present, the driver should honor the DPCD backlight -* capabilities advertised. -*/ - DP_QUIRK_FORCE_DPCD_BACKLIGHT,/** * @DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS: *
@@ -2092,16 +2079,14 @@ enum drm_dp_quirk {/** * drm_dp_has_quirk() - does the DP device have a specific quirk * @desc: Device descriptor filled by drm_dp_read_desc() -* @edid_quirks: Optional quirk bitmask filled by drm_dp_get_edid_quirks() * @quirk: Quirk to query for * * Return true if DP device identified by @desc has @quirk. */ static inline bool -drm_dp_has_quirk (const struct drm_dp_desc *desc,u32 edid_quirks, -enum drm_dp_quirk quirk) +drm_dp_has_quirk (const struct drm_dp_desc *desc,enum drm_dp_quirk quirk) { -return (desc->quirks | edid_quirks) &BIT (quirk); +return desc->quirks &BIT (quirk); }#ifdef CONFIG_DRM_DP_CEC
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 4/4] drm/dp: Revert "drm/dp: Introduce EDID-based quirks"
Quoted 22 lines · Lyude Paul
This reverts commit
0883ce8146ed6074c76399f4e70dbed788582e12. Originally these quirks were added because of the issues with using the eDP backlight interfaces on certain laptop panels, which made it impossible to properly probe for DPCD backlight support without having a whitelist for panels that we know have working VESA backlight control interfaces over DPCD. As well, it should be noted it was impossible to use the normal sink OUI for recognizing these panels as none of them actually filled out their OUIs, hence needing to resort to checking EDIDs.At the time we weren't really sure why certain panels had issues with DPCD backlight controls, but we eventually figured out that there was a second interface that these problematic laptop panels actually did work with and advertise properly: Intel's proprietary backlight interface for HDR panels. So far the testing we've done hasn't brought any panels to light that advertise this interface and don't support it properly, which means we finally have a real solution to this problem.
As a result, we now have no need for the force DPCD backlight quirk, and furthermore this also removes the need for any kind of EDID quirk checking in DRM. So, let's just revert it for now since we were the only driver using this.
Quoted 8 lines
v3:
* Rebase
v2:
* Fix indenting error picked up by checkpatch in
intel_edp_init_connector()Signed-off-by Lyude Paul <[email protected]>Acked-by Jani Nikula <[email protected]>
Still stands.
BR,
Jani.
Quoted 272 lines
Cc Vasily Khoruzhick <[email protected]>--- drivers/gpu/drm/drm_dp_helper.c | 83 +------------------ drivers/gpu/drm/drm_dp_mst_topology.c | 3 +- .../drm/i915/display/intel_display_types.h | 1 - drivers/gpu/drm/i915/display/intel_dp.c | 9 +- drivers/gpu/drm/i915/display/intel_dp_mst.c | 3 +- drivers/gpu/drm/i915/display/intel_psr.c | 2 +- include/drm/drm_dp_helper.h | 21 +---- 7 files changed, 9 insertions(+), 113 deletions(-)drivers/gpu/drm/drm_dp_helper.c +1
-82@@ -1236,7 +1236,7 @@ bool drm_dp_read_sink_count_cap(struct drm_connector *connector,return connector->connector_type != DRM_MODE_CONNECTOR_eDP && dpcd[DP_DPCD_REV ] >=DP_DPCD_REV_11 && dpcd[DP_DOWNSTREAMPORT_PRESENT ] &DP_DWN_STRM_PORT_PRESENT && - !drm_dp_has_quirk (desc,0 ,DP_DPCD_QUIRK_NO_SINK_COUNT ); + !drm_dp_has_quirk (desc,DP_DPCD_QUIRK_NO_SINK_COUNT ); }EXPORT_SYMBOL (drm_dp_read_sink_count_cap);@@ -1957,87 +1957,6 @@ drm_dp_get_quirks(const struct drm_dp_dpcd_ident *ident, bool is_branch)#undef DEVICE_ID_ANY#undef DEVICE_ID -struct edid_quirk { -u8 mfg_id[2 ]; -u8 prod_id[2 ]; -u32 quirks; -}; - -#define MFG (first, second) { (first), (second) } -#define PROD_ID (first, second) { (first), (second) } - -/* -* Some devices have unreliable OUIDs where they don't set the device ID -* correctly, and as a result we need to use the EDID for finding additional -* DP quirks in such cases. -*/ -static const struct edid_quirk edid_quirk_list[] = { -/* Optional 4K AMOLED panel in the ThinkPad X1 Extreme 2nd Generation -* only supports DPCD backlight controls -*/ - {MFG (0x4c ,0x83 ),PROD_ID (0x41 ,0x41 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, -/* -* Some Dell CML 2020 systems have panels support both AUX and PWM -* backlight control, and some only support AUX backlight control. All -* said panels start up in AUX mode by default, and we don't have any -* support for disabling HDR mode on these panels which would be -* required to switch to PWM backlight control mode (plus, I'm not -* even sure we want PWM backlight controls over DPCD backlight -* controls anyway...). Until we have a better way of detecting these, -* force DPCD backlight mode on all of them. -*/ - {MFG (0x06 ,0xaf ),PROD_ID (0x9b ,0x32 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x06 ,0xaf ),PROD_ID (0xeb ,0x41 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x4d ,0x10 ),PROD_ID (0xc7 ,0x14 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x4d ,0x10 ),PROD_ID (0xe6 ,0x14 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x4c ,0x83 ),PROD_ID (0x47 ,0x41 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, - {MFG (0x09 ,0xe5 ),PROD_ID (0xde ,0x08 ),BIT (DP_QUIRK_FORCE_DPCD_BACKLIGHT ) }, -}; - -#undef MFG -#undef PROD_ID - -/** -* drm_dp_get_edid_quirks() - Check the EDID of a DP device to find additional -* DP-specific quirks -* @edid: The EDID to check -* -* While OUIDs are meant to be used to recognize a DisplayPort device, a lot -* of manufacturers don't seem to like following standards and neglect to fill -* the dev-ID in, making it impossible to only use OUIDs for determining -* quirks in some cases. This function can be used to check the EDID and look -* up any additional DP quirks. The bits returned by this function correspond -* to the quirk bits in &drm_dp_quirk. -* -* Returns: a bitmask of quirks, if any. The driver can check this using -* drm_dp_has_quirk(). -*/ -u32 drm_dp_get_edid_quirks (const struct edid *edid) -{ -const struct edid_quirk *quirk; -u32 quirks =0 ; -int i; - -if (!edid) -return 0 ; - -for (i =0 ; i <ARRAY_SIZE (edid_quirk_list); i++) { - quirk = &edid_quirk_list[i]; -if (memcmp (quirk->mfg_id, edid->mfg_id, -sizeof (edid->mfg_id)) ==0 && -memcmp (quirk->prod_id, edid->prod_code, -sizeof (edid->prod_code)) ==0 ) - quirks |= quirk->quirks; - } - -DRM_DEBUG_KMS ("DP sink: EDID mfg %*phD prod-ID %*phD quirks: 0x%04x\n" , - (int )sizeof (edid->mfg_id), edid->mfg_id, - (int )sizeof (edid->prod_code), edid->prod_code, quirks); - -return quirks; -} -EXPORT_SYMBOL (drm_dp_get_edid_quirks); -/** * drm_dp_read_desc - read sink/branch descriptor from DPCD * @aux: DisplayPort AUX channel drivers/gpu/drm/drm_dp_mst_topology.c +1
-2@@ -5824,8 +5824,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)if (drm_dp_read_desc (port->mgr->aux, &desc, true))return NULL ; -if (drm_dp_has_quirk (&desc,0 , -DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD ) && +if (drm_dp_has_quirk (&desc,DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD ) && port->mgr->dpcd[DP_DPCD_REV ] >=DP_DPCD_REV_14 && port->parent == port->mgr->mst_primary) {u8 downstreamport;drivers/gpu/drm/i915/display/intel_display_types.h +0
-1@@ -1390,7 +1390,6 @@ struct intel_dp {int max_link_rate;/* sink or branch descriptor */ struct drm_dp_desc desc; -u32 edid_quirks;struct drm_dp_aux aux;u32 aux_busy_last_status;u8 train_set[4 ];drivers/gpu/drm/i915/display/intel_dp.c +2
-7@@ -162,8 +162,7 @@ static void intel_dp_set_sink_rates(struct intel_dp *intel_dp)int i, max_rate;int max_lttpr_rate; -if (drm_dp_has_quirk (&intel_dp->desc,0 , -DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS )) { +if (drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS )) {/* Needed, e.g., for Apple MBP 2017, 15 inch eDP Retina panel */ static const int quirk_rates[] = {162000 ,270000 ,324000 };@@ -2823,8 +2822,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,struct intel_connector *intel_connector = intel_dp->attached_connector;struct intel_digital_connector_state *intel_conn_state =to_intel_digital_connector_state (conn_state); -bool constant_n =drm_dp_has_quirk (&intel_dp->desc,0 , -DP_DPCD_QUIRK_CONSTANT_N ); +bool constant_n =drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_CONSTANT_N );int ret =0 , output_bpp;if (HAS_PCH_SPLIT (dev_priv) && !HAS_DDI (dev_priv) && port !=PORT_A )@@ -7007,7 +7005,6 @@ intel_dp_set_edid(struct intel_dp *intel_dp) }drm_dp_cec_set_edid (&intel_dp->aux, edid); - intel_dp->edid_quirks =drm_dp_get_edid_quirks (edid); } static void@@ -7021,7 +7018,6 @@ intel_dp_unset_edid(struct intel_dp *intel_dp) intel_dp->has_hdmi_sink = false; intel_dp->has_audio = false; - intel_dp->edid_quirks =0 ; intel_dp->dfp.max_bpc =0 ; intel_dp->dfp.max_dotclock =0 ;@@ -8425,7 +8421,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,if (edid) {if (drm_add_edid_modes (connector, edid)) {drm_connector_update_edid_property (connector, edid); - intel_dp->edid_quirks =drm_dp_get_edid_quirks (edid); }else {kfree (edid); edid =ERR_PTR (-EINVAL );drivers/gpu/drm/i915/display/intel_dp_mst.c +1
-2@@ -53,8 +53,7 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,struct drm_i915_private *i915 =to_i915 (connector->base.dev);const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; -bool constant_n =drm_dp_has_quirk (&intel_dp->desc,0 , -DP_DPCD_QUIRK_CONSTANT_N ); +bool constant_n =drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_CONSTANT_N );int bpp, slots = -EINVAL ; crtc_state->lane_count = limits->max_lane_count;drivers/gpu/drm/i915/display/intel_psr.c +1
-1@@ -305,7 +305,7 @@ void intel_psr_init_dpcd(struct intel_dp *intel_dp)drm_dbg_kms (&dev_priv->drm,"eDP panel supports PSR version %x\n" , intel_dp->psr_dpcd[0 ]); -if (drm_dp_has_quirk (&intel_dp->desc,0 ,DP_DPCD_QUIRK_NO_PSR )) { +if (drm_dp_has_quirk (&intel_dp->desc,DP_DPCD_QUIRK_NO_PSR )) {drm_dbg_kms (&dev_priv->drm,"PSR support not currently available for this panel\n" );return ;include/drm/drm_dp_helper.h +3
-18@@ -2029,16 +2029,13 @@ struct drm_dp_desc {int drm_dp_read_desc (struct drm_dp_aux *aux,struct drm_dp_desc *desc,bool is_branch); -u32 drm_dp_get_edid_quirks (const struct edid *edid);/** * enum drm_dp_quirk - Display Port sink/branch device specific quirks * * Display Port sink and branch devices in the wild have a variety of bugs, try * to collect them here. The quirks are shared, but it's up to the drivers to -* implement workarounds for them. Note that because some devices have -* unreliable OUIDs, the EDID of sinks should also be checked for quirks using -* drm_dp_get_edid_quirks(). +* implement workarounds for them. */ enum drm_dp_quirk {/** @@ -2070,16 +2067,6 @@ enum drm_dp_quirk {* The DSC caps can be read from the physical aux instead. */ DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD, -/** -* @DP_QUIRK_FORCE_DPCD_BACKLIGHT: -* -* The device is telling the truth when it says that it uses DPCD -* backlight controls, even if the system's firmware disagrees. This -* quirk should be checked against both the ident and panel EDID. -* When present, the driver should honor the DPCD backlight -* capabilities advertised. -*/ - DP_QUIRK_FORCE_DPCD_BACKLIGHT,/** * @DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS: * @@ -2092,16 +2079,14 @@ enum drm_dp_quirk {/** * drm_dp_has_quirk() - does the DP device have a specific quirk * @desc: Device descriptor filled by drm_dp_read_desc() -* @edid_quirks: Optional quirk bitmask filled by drm_dp_get_edid_quirks() * @quirk: Quirk to query for * * Return true if DP device identified by @desc has @quirk. */ static inline bool -drm_dp_has_quirk (const struct drm_dp_desc *desc,u32 edid_quirks, -enum drm_dp_quirk quirk) +drm_dp_has_quirk (const struct drm_dp_desc *desc,enum drm_dp_quirk quirk) { -return (desc->quirks | edid_quirks) &BIT (quirk); +return desc->quirks &BIT (quirk); }#ifdef CONFIG_DRM_DP_CEC
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 4/4] drm/dp: Revert "drm/dp: Introduce EDID-based quirks"
Quoted 29 lines · Jani Nikula
Quoted 28 lines · Lyude Paul
This reverts commit
0883ce8146ed6074c76399f4e70dbed788582e12. Originally these quirks were added because of the issues with using the eDP backlight interfaces on certain laptop panels, which made it impossible to properly probe for DPCD backlight support without having a whitelist for panels that we know have working VESA backlight control interfaces over DPCD. As well, it should be noted it was impossible to use the normal sink OUI for recognizing these panels as none of them actually filled out their OUIs, hence needing to resort to checking EDIDs.At the time we weren't really sure why certain panels had issues with DPCD backlight controls, but we eventually figured out that there was a second interface that these problematic laptop panels actually did work with and advertise properly: Intel's proprietary backlight interface for HDR panels. So far the testing we've done hasn't brought any panels to light that advertise this interface and don't support it properly, which means we finally have a real solution to this problem.
As a result, we now have no need for the force DPCD backlight quirk, and furthermore this also removes the need for any kind of EDID quirk checking in DRM. So, let's just revert it for now since we were the only driver using this.
v3:
* Rebase
v2:
* Fix indenting error picked up by checkpatch in
intel_edp_init_connector()
Quoted 4 lines
Quoted 2 lines
Signed-off-by Lyude Paul <[email protected]>Acked-by Jani Nikula <[email protected]>Still stands.
PS. You'll still need drm or drm-misc maintainer ack if you want to merge this through drm-intel-next.
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Add support for Intel's eDP backlight controls (rev8)
In reply to Lyude Paul== Series Details ==
== Series Details ==
Series: drm/i915: Add support for Intel's eDP backlight controls (rev8)
URL : https://patchwork.freedesktop.org/series/81702/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_9563 -> Patchwork_19286
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_19286 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_19286, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_19286:
### IGT changes ###
#### Possible regressions ####
* igt@runner@aborted:
- fi-bsw-kefka: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-bsw-kefka/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_19286 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@cs-gfx:
- fi-kbl-soraka: NOTRUN -> [SKIP][2] ([fdo#109271]) +17 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-kbl-soraka/igt@amdgpu/[email protected]
* igt@gem_linear_blits@basic:
- fi-tgl-y: [PASS][3] -> [DMESG-WARN][4] ([i915#402])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9563/fi-tgl-y/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-tgl-y/igt@[email protected]
* igt@kms_chamelium@hdmi-crc-fast:
- fi-kbl-7500u: [PASS][5] -> [DMESG-WARN][6] ([i915#2868])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9563/fi-kbl-7500u/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-kbl-7500u/igt@[email protected]
#### Possible fixes ####
* igt@i915_getparams_basic@basic-subslice-total:
- fi-tgl-y: [DMESG-WARN][7] ([i915#402]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9563/fi-tgl-y/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-tgl-y/igt@[email protected]
* igt@i915_module_load@reload:
- fi-kbl-soraka: [DMESG-WARN][9] ([i915#1982]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9563/fi-kbl-soraka/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-kbl-soraka/igt@[email protected]
* igt@i915_selftest@live@evict:
- fi-kbl-soraka: [INCOMPLETE][11] ([i915#2782]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9563/fi-kbl-soraka/igt@i915_selftest@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-kbl-soraka/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@gem:
- fi-kbl-soraka: [DMESG-WARN][13] ([i915#2826]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9563/fi-kbl-soraka/igt@i915_selftest@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/fi-kbl-soraka/igt@i915_selftest@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2268]: https://gitlab.freedesktop.org/drm/intel/issues/2268
[i915#2782]: https://gitlab.freedesktop.org/drm/intel/issues/2782
[i915#2826]: https://gitlab.freedesktop.org/drm/intel/issues/2826
[i915#2868]: https://gitlab.freedesktop.org/drm/intel/issues/2868
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
Participating hosts (43 -> 38)
------------------------------
Missing (5): fi-ilk-m540 fi-hsw-4200u fi-bsw-cyan fi-ctg-p8600 fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_9563 -> Patchwork_19286
CI-20190529: 20190529
CI_DRM_9563: 2b85e51a060e954506ab2dce0778411482fb4625 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5946: 641e5545213dd9a82d80a4e065013a138afb58ff @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_19286: 827c0eb2c2a4e03612eca0754b3010db29da4820 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
827c0eb2c2a4 drm/dp: Revert "drm/dp: Introduce EDID-based quirks" b844d631c301 drm/i915/dp: Allow forcing specific interfaces through enable_dpcd_backlight cf64269a8e16 drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now) bb95b7b53def drm/i915: Keep track of pwm-related backlight hooks separately
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19286/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx