After the recent refactoring of the backlight code the contents of intel_panel_actually_set_backlight() is exactly the same (minus a small wording difference in the drm_dbg_kms() as the contents if the more widely used intel_backlight_set_pwm_level() function.
Drop the duplicate intel_panel_actually_set_backlight() function.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- drivers/gpu/drm/i915/display/intel_backlight.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 9523411cddd8..03cd730c926a 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -268,18 +268,6 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state, pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); }
-static void -intel_panel_actually_set_backlight(const struct drm_connector_state *conn_state, u32 level) -{ - 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 level = %d\n", level); - - panel->backlight.funcs->set(conn_state, level); -} - /* set backlight brightness to level in range [0..max], assuming hw min is * respected. */ @@ -314,7 +302,7 @@ void intel_backlight_set_acpi(const struct drm_connector_state *conn_state, panel->backlight.device->props.max_brightness);
if (panel->backlight.enabled) - intel_panel_actually_set_backlight(conn_state, hw_level); + intel_backlight_set_pwm_level(conn_state, hw_level);
mutex_unlock(&dev_priv->backlight_lock); } @@ -863,7 +851,7 @@ static void intel_panel_set_backlight(const struct drm_connector_state *conn_sta panel->backlight.level = hw_level;
if (panel->backlight.enabled) - intel_panel_actually_set_backlight(conn_state, hw_level); + intel_backlight_set_pwm_level(conn_state, hw_level);
mutex_unlock(&dev_priv->backlight_lock); }
At least the Bay Trail LPSS PWM controller used with DSI panels on many Bay Trail tablets seems to leave the PWM pin in whatever state it was (high or low) ATM that the PWM gets disabled. Combined with some panels not having a separate backlight-enable pin this leads to the backlight sometimes staying on while it should not (when the pin was high during PWM-disabling).
First calling intel_backlight_set_pwm_level() will ensure that the pin is always low (or high for inverted brightness panels) since the passed in duty-cycle is 0% (or 100%) when the PWM gets disabled fixing the backlight sometimes staying on.
With the exception of ext_pwm_disable_backlight() all other foo_disable_backlight() functions call intel_backlight_set_pwm_level() already before disabling the backlight, so this change also aligns ext_pwm_disable_backlight() with all the other disable() functions.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- drivers/gpu/drm/i915/display/intel_backlight.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 03cd730c926a..2758a2f6c093 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -421,6 +421,8 @@ static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn struct intel_connector *connector = to_intel_connector(old_conn_state->connector); struct intel_panel *panel = &connector->panel;
+ intel_backlight_set_pwm_level(old_conn_state, level); + panel->backlight.pwm_state.enabled = false; pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); }
On Sun, 21 Nov 2021, Hans de Goede hdegoede@redhat.com wrote:
At least the Bay Trail LPSS PWM controller used with DSI panels on many Bay Trail tablets seems to leave the PWM pin in whatever state it was (high or low) ATM that the PWM gets disabled. Combined with some panels not having a separate backlight-enable pin this leads to the backlight sometimes staying on while it should not (when the pin was high during PWM-disabling).
First calling intel_backlight_set_pwm_level() will ensure that the pin is always low (or high for inverted brightness panels) since the passed in duty-cycle is 0% (or 100%) when the PWM gets disabled fixing the backlight sometimes staying on.
With the exception of ext_pwm_disable_backlight() all other foo_disable_backlight() functions call intel_backlight_set_pwm_level() already before disabling the backlight, so this change also aligns ext_pwm_disable_backlight() with all the other disable() functions.
Signed-off-by: Hans de Goede hdegoede@redhat.com
I'll take your word for it.
Acked-by: Jani Nikula jani.nikula@intel.com
drivers/gpu/drm/i915/display/intel_backlight.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 03cd730c926a..2758a2f6c093 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -421,6 +421,8 @@ static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn struct intel_connector *connector = to_intel_connector(old_conn_state->connector); struct intel_panel *panel = &connector->panel;
- intel_backlight_set_pwm_level(old_conn_state, level);
- panel->backlight.pwm_state.enabled = false; pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
}
Reviewed-by: Lyude Paul lyude@redhat.com
On Sun, 2021-11-21 at 12:00 +0100, Hans de Goede wrote:
At least the Bay Trail LPSS PWM controller used with DSI panels on many Bay Trail tablets seems to leave the PWM pin in whatever state it was (high or low) ATM that the PWM gets disabled. Combined with some panels not having a separate backlight-enable pin this leads to the backlight sometimes staying on while it should not (when the pin was high during PWM-disabling).
First calling intel_backlight_set_pwm_level() will ensure that the pin is always low (or high for inverted brightness panels) since the passed in duty-cycle is 0% (or 100%) when the PWM gets disabled fixing the backlight sometimes staying on.
With the exception of ext_pwm_disable_backlight() all other foo_disable_backlight() functions call intel_backlight_set_pwm_level() already before disabling the backlight, so this change also aligns ext_pwm_disable_backlight() with all the other disable() functions.
Signed-off-by: Hans de Goede hdegoede@redhat.com
drivers/gpu/drm/i915/display/intel_backlight.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 03cd730c926a..2758a2f6c093 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -421,6 +421,8 @@ static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn struct intel_connector *connector = to_intel_connector(old_conn_state->connector); struct intel_panel *panel = &connector->panel; + intel_backlight_set_pwm_level(old_conn_state, level);
panel->backlight.pwm_state.enabled = false; pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); }
On Sun, 21 Nov 2021, Hans de Goede hdegoede@redhat.com wrote:
After the recent refactoring of the backlight code the contents of intel_panel_actually_set_backlight() is exactly the same (minus a small wording difference in the drm_dbg_kms() as the contents if the more widely used intel_backlight_set_pwm_level() function.
Drop the duplicate intel_panel_actually_set_backlight() function.
Signed-off-by: Hans de Goede hdegoede@redhat.com
Reviewed-by: Jani Nikula jani.nikula@intel.com
drivers/gpu/drm/i915/display/intel_backlight.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 9523411cddd8..03cd730c926a 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -268,18 +268,6 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state, pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); }
-static void -intel_panel_actually_set_backlight(const struct drm_connector_state *conn_state, u32 level) -{
- 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 level = %d\n", level);
- panel->backlight.funcs->set(conn_state, level);
-}
/* set backlight brightness to level in range [0..max], assuming hw min is
- respected.
*/ @@ -314,7 +302,7 @@ void intel_backlight_set_acpi(const struct drm_connector_state *conn_state, panel->backlight.device->props.max_brightness);
if (panel->backlight.enabled)
intel_panel_actually_set_backlight(conn_state, hw_level);
intel_backlight_set_pwm_level(conn_state, hw_level);
mutex_unlock(&dev_priv->backlight_lock);
} @@ -863,7 +851,7 @@ static void intel_panel_set_backlight(const struct drm_connector_state *conn_sta panel->backlight.level = hw_level;
if (panel->backlight.enabled)
intel_panel_actually_set_backlight(conn_state, hw_level);
intel_backlight_set_pwm_level(conn_state, hw_level);
mutex_unlock(&dev_priv->backlight_lock);
}
Hi,
On 11/21/21 12:00, Hans de Goede wrote:
After the recent refactoring of the backlight code the contents of intel_panel_actually_set_backlight() is exactly the same (minus a small wording difference in the drm_dbg_kms() as the contents if the more widely used intel_backlight_set_pwm_level() function.
Drop the duplicate intel_panel_actually_set_backlight() function.
Signed-off-by: Hans de Goede hdegoede@redhat.com
I just realized that I did not push this series to drm-intel-next yet.
Before pushing I double checked my work and I noticed that this patch is wrong there is a subtle but important difference between intel_panel_actually_set_backlight() and intel_backlight_set_pwm_level()
intel_panel_actually_set_backlight() calls:
panel->backlight.funcs->set(conn_state, level);
where as intel_backlight_set_pwm_level() calls:
panel->backlight.pwm_funcs->set(conn_state, level);
I missed the pwm_funcs vs funcs difference, the funcs->set function is normally just a wrapper for pwm_funcs->set, but the dp_aux and dsi_dsc code my overwrite the functions to which backlight.funcs point to so the difference matters.
Tl;DR: self nack for this one.
Patch 2/2 is still valid and I will push that out shortly.
Regards,
Hans
drivers/gpu/drm/i915/display/intel_backlight.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 9523411cddd8..03cd730c926a 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -268,18 +268,6 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state, pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); }
-static void -intel_panel_actually_set_backlight(const struct drm_connector_state *conn_state, u32 level) -{
- 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 level = %d\n", level);
- panel->backlight.funcs->set(conn_state, level);
-}
/* set backlight brightness to level in range [0..max], assuming hw min is
- respected.
*/ @@ -314,7 +302,7 @@ void intel_backlight_set_acpi(const struct drm_connector_state *conn_state, panel->backlight.device->props.max_brightness);
if (panel->backlight.enabled)
intel_panel_actually_set_backlight(conn_state, hw_level);
intel_backlight_set_pwm_level(conn_state, hw_level);
mutex_unlock(&dev_priv->backlight_lock);
} @@ -863,7 +851,7 @@ static void intel_panel_set_backlight(const struct drm_connector_state *conn_sta panel->backlight.level = hw_level;
if (panel->backlight.enabled)
intel_panel_actually_set_backlight(conn_state, hw_level);
intel_backlight_set_pwm_level(conn_state, hw_level);
mutex_unlock(&dev_priv->backlight_lock);
}
dri-devel@lists.freedesktop.org