drm/i915/backlight: Fix backlight takeover on LPT, v3.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tue, 8 Jan 2019 16:08:39 +0000 (17:08 +0100)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Thu, 24 Jan 2019 12:02:48 +0000 (13:02 +0100)
commit5b1ec9ac7ab5b4520d4db98b7024a8dd5051b000
tree419216376d8b085e69d74c00d2d82d2e75ecdcb5
parent63a23d245b2cb094be99d274204e458eb2810410
drm/i915/backlight: Fix backlight takeover on LPT, v3.

On lynxpoint the bios sometimes sets up the backlight using the CPU
display, but the driver expects using the PWM PCH override register.

Read the value from the CPU register, then convert it to the other
units by converting from the old duty cycle, to freq, to the new units.

This value is then programmed in the override register, after which
we set the override and disable the CPU display control. This allows
us to switch the source without flickering, and make the backlight
controls work in the driver.

Changes since v1:
- Read BLC_PWM_CPU_CTL2 to cpu_ctl2.
- Clean up cpu_mode if slightly.
- Always disable BLM_PWM_ENABLE in cpu_ctl2.
Changes since v2:
- Simplify cpu_mode handling (Jani)

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108225
Cc: Basil Eric Rabi <ericbasil.rabi@gmail.com>
Cc: Hans de Goede <jwrdegoede@fedoraproject.org>
Cc: Tolga Cakir <cevelnet@gmail.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Tolga Cakir <cevelnet@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190108160842.13396-2-maarten.lankhorst@linux.intel.com
drivers/gpu/drm/i915/intel_panel.c