]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Assume 100% brightness when not in DPCD control mode
authorLyude Paul <lyude@redhat.com>
Thu, 16 Jan 2020 21:16:09 +0000 (16:16 -0500)
committerJani Nikula <jani.nikula@intel.com>
Fri, 17 Jan 2020 11:41:03 +0000 (13:41 +0200)
commitf8af9e66566d1a1d0ff1871df08d4566762f488f
tree2e65017d83ac15fb622d251a7e8f37845cf95504
parentab518b483f9c91ab8c49cc0aa7c55dc12f81b730
drm/i915: Assume 100% brightness when not in DPCD control mode

Currently we always determine the initial panel brightness level by
simply reading the value from DP_EDP_BACKLIGHT_BRIGHTNESS_MSB/LSB. This
seems wrong though, because if the panel is not currently in DPCD
control mode there's not really any reason why there would be any
brightness value programmed in the first place.

This appears to be the case on the Lenovo ThinkPad X1 Extreme 2nd
Generation, where the default value in these registers is always 0 on
boot despite the fact the panel runs at max brightness by default.
Getting the initial brightness value correct here is important as well,
since the panel on this laptop doesn't behave well if it's ever put into
DPCD control mode while the brightness level is programmed to 0.

So, let's fix this by checking what the current backlight control mode
is before reading the brightness level. If it's in DPCD control mode, we
return the programmed brightness level. Otherwise we assume 100%
brightness and return the highest possible brightness level. This also
prevents us from accidentally programming a brightness level of 0.

This is one of the many fixes that gets backlight controls working on
the ThinkPad X1 Extreme 2nd Generation with optional 4K AMOLED screen.

Changes since v1:
* s/DP_EDP_DISPLAY_CONTROL_REGISTER/DP_EDP_BACKLIGHT_MODE_SET_REGISTER/
  - Jani

Tested-by: AceLan Kao <acelan.kao@canonical.com>
Tested-by: Perry Yuan <pyuan@redhat.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200116211623.53799-3-lyude@redhat.com
drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c