]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: panel: Add get_vbt_pwm_freq() helper
authorHans de Goede <hdegoede@redhat.com>
Thu, 3 Sep 2020 11:23:34 +0000 (13:23 +0200)
committerHans de Goede <hdegoede@redhat.com>
Sun, 6 Sep 2020 13:38:05 +0000 (15:38 +0200)
Factor the code which checks and drm_dbg_kms-s the VBT PWM frequency
out of get_backlight_max_vbt().

This is a preparation patch for honering the VBT PWM frequency for
devices which use an external PWM controller (devices using
pwm_setup_backlight()).

Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200903112337.4113-15-hdegoede@redhat.com
drivers/gpu/drm/i915/display/intel_panel.c

index aaed9eb3b56cec206ef05cead5cdd2eb58eb718d..0cbb73baabf12bcdb1e7db151612db937e0d4298 100644 (file)
@@ -1543,18 +1543,9 @@ static u32 vlv_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
        return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
 }
 
-static u32 get_backlight_max_vbt(struct intel_connector *connector)
+static u16 get_vbt_pwm_freq(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
-       struct intel_panel *panel = &connector->panel;
        u16 pwm_freq_hz = dev_priv->vbt.backlight.pwm_freq_hz;
-       u32 pwm;
-
-       if (!panel->backlight.hz_to_pwm) {
-               drm_dbg_kms(&dev_priv->drm,
-                           "backlight frequency conversion not supported\n");
-               return 0;
-       }
 
        if (pwm_freq_hz) {
                drm_dbg_kms(&dev_priv->drm,
@@ -1567,6 +1558,22 @@ static u32 get_backlight_max_vbt(struct intel_connector *connector)
                            pwm_freq_hz);
        }
 
+       return pwm_freq_hz;
+}
+
+static u32 get_backlight_max_vbt(struct intel_connector *connector)
+{
+       struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+       struct intel_panel *panel = &connector->panel;
+       u16 pwm_freq_hz = get_vbt_pwm_freq(dev_priv);
+       u32 pwm;
+
+       if (!panel->backlight.hz_to_pwm) {
+               drm_dbg_kms(&dev_priv->drm,
+                           "backlight frequency conversion not supported\n");
+               return 0;
+       }
+
        pwm = panel->backlight.hz_to_pwm(connector, pwm_freq_hz);
        if (!pwm) {
                drm_dbg_kms(&dev_priv->drm,