about summary refs log tree commit diff
path: root/overlays/patches/linux/eve-backlight.patch
blob: 6df8577008c56743752b08b83e0b11f811d3561e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
From 4b5c309e05e3033ebc2dc00c17a1884449cf4e2b Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Thu, 24 Jun 2021 00:46:26 +0000
Subject: [PATCH 1/2] Revert "drm/i915/dp: Don't use DPCD backlights that need
 PWM enable/disable"

This reverts commit fe7d52bccab674a22776a2f31236bf4232e85410.
---
 drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
index c82f8febe730..82d1fcc095f2 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
@@ -345,12 +345,7 @@ intel_dp_aux_supports_vesa_backlight(struct intel_connector *connector)
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
 
-	/* TODO: We currently only support AUX only backlight configurations, not backlights which
-	 * require a mix of PWM and AUX controls to work. In the mean time, these machines typically
-	 * work just fine using normal PWM controls anyway.
-	 */
-	if ((intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP) &&
-	    drm_edp_backlight_supported(intel_dp->edp_dpcd)) {
+	if (drm_edp_backlight_supported(intel_dp->edp_dpcd)) {
 		drm_dbg_kms(&i915->drm, "AUX Backlight Control Supported!\n");
 		return true;
 	}
-- 
2.33.0


From 023170bb983f59dff1f249500262d15705bc4c6f Mon Sep 17 00:00:00 2001
From: Kevin Chowski <chowski@google.com>
Date: Sat, 8 Aug 2020 15:40:51 -0600
Subject: [PATCH 2/2] CHROMIUM: Changes needed for backlight control on Eve-5.4

 #1: Port https://crrev.com/c/439873 to the 5.4 tree
 #2: Port https://crrev.com/c/440445 to the 5.4 tree
 #3: Port https://crrev.com/c/456118 to the 5.4 tree

The first two patches are needed to correctly enable the backlight for
Eve; they were submitted upstream in 2017 but were rolled back.

The third patch was not rolled back upstream, but the code related to it
changed quite a bit between 4.4 and 5.4: the write of
DP_EDP_PWMGEN_BIT_COUNT used to happen on every screen enable via
intel_dp_aux_set_pwm_freq (that's how it works in 4.4), but in 5.4 the
write was refactored into intel_dp_aux_calc_max_backlight and only
called once per screen setup. This patch brings back the old
functionality of intel_dp_aux_set_pwm_freq to ensure we set that
register on each screen enable, but this is at the cost of duplication
between intel_dp_aux_calc_max_backlight. Unfortunately, I don't see a
better way to do this without making the cros code diverge even further
from 4.4 and 5.4.

I'd like to submit this CL into the chromium tree, and use b/163412221
to track its upstreaming and the ultimate revert of this change.

Test:
   * `emerge-eve-kernelnext sys-kernel/chromeos-kernel-5_4`
   * `./update_kernel.sh --remote=192.168.0.22 --remote_bootarg`
   * On DUT, set options `i915.enable_dpcd_backlight=1 i915.enable_dbc=1`
     (using e.g. `/usr/share/vboot/bin/make_dev_ssd.sh`)
   * reboot
   * Change brightness on DUT
   * Allow DUT screen to fall asleep
   * Wake DUT screen, change brightness again

BUG=b:162255390
TEST=See above

Change-Id: I9eafa28226f1c6b8332fcf9730259bea05cf7975
Signed-off-by: Kevin Chowski <chowski@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2344844
Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
Conflicts:
	drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
[rebase510(groeck): Picked code from continuous rebase project to resolve conflicts]
Signed-off-by: Guenter Roeck <groeck@chromium.org>
(cherry picked from commit 37af4b996c1e25b7be4a00e5c5bcf29bc37cd51a)
---
 .../drm/i915/display/intel_dp_aux_backlight.c | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
index 82d1fcc095f2..a139b7e29aa3 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
@@ -352,6 +352,59 @@ intel_dp_aux_supports_vesa_backlight(struct intel_connector *connector)
 	return false;
 }
 
+/*
+ * Heuristic function whether we should use AUX for backlight adjustment or not.
+ *
+ * We should use AUX for backlight brightness adjustment if panel doesn't this
+ * via PWM pin or using AUX is better than using PWM pin.
+ *
+ * The heuristic to determine that using AUX pin is better than using PWM pin is
+ * that the panel support any of the feature list here.
+ * - Regional backlight brightness adjustment
+ * - Backlight PWM frequency set
+ * - More than 8 bits resolution of brightness level
+ * - Backlight enablement via AUX and not by BL_ENABLE pin
+ *
+ * If all above are not true, assume that using PWM pin is better.
+ */
+static bool
+intel_dp_aux_display_control_heuristic(struct intel_connector *connector)
+{
+	struct intel_dp *intel_dp = intel_attached_dp(connector);
+	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
+	uint8_t reg_val;
+
+	/* Panel doesn't support adjusting backlight brightness via PWN pin */
+	if (!(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP))
+		return true;
+
+	/* Panel supports regional backlight brightness adjustment */
+	if (drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_GENERAL_CAP_3,
+			      &reg_val) != 1) {
+		drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n",
+			       DP_EDP_GENERAL_CAP_3);
+		return false;
+	}
+	if (reg_val > 0)
+		return true;
+
+	/* Panel supports backlight PWM frequency set */
+	if (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_FREQ_AUX_SET_CAP)
+		return true;
+
+	/* Panel supports more than 8 bits resolution of brightness level */
+	if (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_BYTE_COUNT)
+		return true;
+
+	/* Panel supports enabling backlight via AUX but not by BL_ENABLE pin */
+	if ((intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP) &&
+	    !(intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_PIN_ENABLE_CAP))
+		return true;
+
+	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,
@@ -429,6 +482,10 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
 		return 0;
 	}
 
+	if (i915_modparams.enable_dpcd_backlight == -1 &&
+	    !intel_dp_aux_display_control_heuristic(connector))
+		return -ENODEV;
+
 	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;
-- 
2.33.0