Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.15 commit in: /
Date: Tue, 30 Nov 2021 00:50:05
Message-Id: 1638233348.e9f26ab59b40c1bc915f2d074f3d37b12038af40.mpagano@gentoo
1 commit: e9f26ab59b40c1bc915f2d074f3d37b12038af40
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 30 00:49:08 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 30 00:49:08 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=e9f26ab5
7
8 VESA patch needs fix
9
10 removing in case 5.15.6 comes out before I fix it
11
12 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
13
14 0000_README | 4 -
15 ...15-PWM-support-for-VESA-backlight-helpers.patch | 618 ---------------------
16 2 files changed, 622 deletions(-)
17
18 diff --git a/0000_README b/0000_README
19 index 0923a646..68d0c0db 100644
20 --- a/0000_README
21 +++ b/0000_README
22 @@ -75,10 +75,6 @@ Patch: 2000_BT-Check-key-sizes-only-if-Secure-Simple-Pairing-enabled.patch
23 From: https://lore.kernel.org/linux-bluetooth/20190522070540.48895-1-marcel@××××××××.org/raw
24 Desc: Bluetooth: Check key sizes only when Secure Simple Pairing is enabled. See bug #686758
25
26 -Patch: 2800_drm-i915-PWM-support-for-VESA-backlight-helpers.patch
27 -From: https://patchwork.freedesktop.org/series/95127/
28 -Desc: drm/i915: Add support for panels with VESA backlights with PWM enable/disable
29 -
30 Patch: 2900_tmp513-Fix-build-issue-by-selecting-CONFIG_REG.patch
31 From: https://bugs.gentoo.org/710790
32 Desc: tmp513 requies REGMAP_I2C to build. Select it by default in Kconfig. See bug #710790. Thanks to Phil Stracchino
33
34 diff --git a/2800_drm-i915-PWM-support-for-VESA-backlight-helpers.patch b/2800_drm-i915-PWM-support-for-VESA-backlight-helpers.patch
35 deleted file mode 100644
36 index 45969bce..00000000
37 --- a/2800_drm-i915-PWM-support-for-VESA-backlight-helpers.patch
38 +++ /dev/null
39 @@ -1,618 +0,0 @@
40 -From patchwork Fri Nov 5 18:33:38 2021
41 -Content-Type: text/plain; charset="utf-8"
42 -MIME-Version: 1.0
43 -Content-Transfer-Encoding: 8bit
44 -Subject: [v5,1/5] drm/i915: Add support for panels with VESA backlights with
45 - PWM enable/disable
46 -From: Lyude Paul <lyude@××××××.com>
47 -X-Patchwork-Id: 462369
48 -Message-Id: <20211105183342.130810-2-lyude@××××××.com>
49 -To: dri-devel@×××××××××××××××××.org, nouveau@×××××××××××××××××.org,
50 - intel-gfx@×××××××××××××××××.org
51 -Cc: David Airlie <airlied@×××××.ie>, open list <linux-kernel@×××××××××××.org>,
52 - stable@×××××××××××.org
53 -Date: Fri, 5 Nov 2021 14:33:38 -0400
54 -
55 -This simply adds proper support for panel backlights that can be controlled
56 -via VESA's backlight control protocol, but which also require that we
57 -enable and disable the backlight via PWM instead of via the DPCD interface.
58 -We also enable this by default, in order to fix some people's backlights
59 -that were broken by not having this enabled.
60 -
61 -For reference, backlights that require this and use VESA's backlight
62 -interface tend to be laptops with hybrid GPUs, but this very well may
63 -change in the future.
64 -
65 -v4:
66 -* Make sure that we call intel_backlight_level_to_pwm() in
67 - intel_dp_aux_vesa_enable_backlight() - vsyrjala
68 -
69 -Signed-off-by: Lyude Paul <lyude@××××××.com>
70 -Link: https://gitlab.freedesktop.org/drm/intel/-/issues/3680
71 -Fixes: fe7d52bccab6 ("drm/i915/dp: Don't use DPCD backlights that need PWM enable/disable")
72 -Reviewed-by: Ville Syrjälä <ville.syrjala@×××××××××××.com>
73 -Cc: <stable@×××××××××××.org> # v5.12+
74 ----
75 - .../drm/i915/display/intel_dp_aux_backlight.c | 27 ++++++++++++++-----
76 - 1 file changed, 21 insertions(+), 6 deletions(-)
77 -
78 -diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
79 -index 569d17b4d00f..f05b71c01b8e 100644
80 ---- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
81 -+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
82 -@@ -293,6 +293,13 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,
83 - struct intel_panel *panel = &connector->panel;
84 - struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
85 -
86 -+ if (!panel->backlight.edp.vesa.info.aux_enable) {
87 -+ u32 pwm_level = intel_backlight_invert_pwm_level(connector,
88 -+ panel->backlight.pwm_level_max);
89 -+
90 -+ panel->backlight.pwm_funcs->enable(crtc_state, conn_state, pwm_level);
91 -+ }
92 -+
93 - drm_edp_backlight_enable(&intel_dp->aux, &panel->backlight.edp.vesa.info, level);
94 - }
95 -
96 -@@ -304,6 +311,10 @@ static void intel_dp_aux_vesa_disable_backlight(const struct drm_connector_state
97 - struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
98 -
99 - drm_edp_backlight_disable(&intel_dp->aux, &panel->backlight.edp.vesa.info);
100 -+
101 -+ if (!panel->backlight.edp.vesa.info.aux_enable)
102 -+ panel->backlight.pwm_funcs->disable(old_conn_state,
103 -+ intel_backlight_invert_pwm_level(connector, 0));
104 - }
105 -
106 - static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector, enum pipe pipe)
107 -@@ -321,6 +332,15 @@ static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector,
108 - if (ret < 0)
109 - return ret;
110 -
111 -+ if (!panel->backlight.edp.vesa.info.aux_enable) {
112 -+ ret = panel->backlight.pwm_funcs->setup(connector, pipe);
113 -+ if (ret < 0) {
114 -+ drm_err(&i915->drm,
115 -+ "Failed to setup PWM backlight controls for eDP backlight: %d\n",
116 -+ ret);
117 -+ return ret;
118 -+ }
119 -+ }
120 - panel->backlight.max = panel->backlight.edp.vesa.info.max;
121 - panel->backlight.min = 0;
122 - if (current_mode == DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) {
123 -@@ -340,12 +360,7 @@ intel_dp_aux_supports_vesa_backlight(struct intel_connector *connector)
124 - struct intel_dp *intel_dp = intel_attached_dp(connector);
125 - struct drm_i915_private *i915 = dp_to_i915(intel_dp);
126 -
127 -- /* TODO: We currently only support AUX only backlight configurations, not backlights which
128 -- * require a mix of PWM and AUX controls to work. In the mean time, these machines typically
129 -- * work just fine using normal PWM controls anyway.
130 -- */
131 -- if ((intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP) &&
132 -- drm_edp_backlight_supported(intel_dp->edp_dpcd)) {
133 -+ if (drm_edp_backlight_supported(intel_dp->edp_dpcd)) {
134 - drm_dbg_kms(&i915->drm, "AUX Backlight Control Supported!\n");
135 - return true;
136 - }
137 -
138 -From patchwork Fri Nov 5 18:33:39 2021
139 -Content-Type: text/plain; charset="utf-8"
140 -MIME-Version: 1.0
141 -Content-Transfer-Encoding: 7bit
142 -Subject: [v5,2/5] drm/nouveau/kms/nv50-: Explicitly check DPCD backlights for
143 - aux enable/brightness
144 -From: Lyude Paul <lyude@××××××.com>
145 -X-Patchwork-Id: 462371
146 -Message-Id: <20211105183342.130810-3-lyude@××××××.com>
147 -To: dri-devel@×××××××××××××××××.org, nouveau@×××××××××××××××××.org,
148 - intel-gfx@×××××××××××××××××.org
149 -Cc: David Airlie <airlied@×××××.ie>, Ben Skeggs <bskeggs@××××××.com>,
150 - Karol Herbst <kherbst@××××××.com>, open list <linux-kernel@×××××××××××.org>
151 -Date: Fri, 5 Nov 2021 14:33:39 -0400
152 -
153 -Since we don't support hybrid AUX/PWM backlights in nouveau right now,
154 -let's add some explicit checks so that we don't break nouveau once we
155 -enable support for these backlights in other drivers.
156 -
157 -Reviewed-by: Karol Herbst <kherbst@××××××.com>
158 -Signed-off-by: Lyude Paul <lyude@××××××.com>
159 ----
160 - drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 ++++-
161 - 1 file changed, 4 insertions(+), 1 deletion(-)
162 -
163 -diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
164 -index 1cbd71abc80a..ae2f2abc8f5a 100644
165 ---- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
166 -+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
167 -@@ -308,7 +308,10 @@ nv50_backlight_init(struct nouveau_backlight *bl,
168 - if (ret < 0)
169 - return ret;
170 -
171 -- if (drm_edp_backlight_supported(edp_dpcd)) {
172 -+ /* TODO: Add support for hybrid PWM/DPCD panels */
173 -+ if (drm_edp_backlight_supported(edp_dpcd) &&
174 -+ (edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP) &&
175 -+ (edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)) {
176 - NV_DEBUG(drm, "DPCD backlight controls supported on %s\n",
177 - nv_conn->base.name);
178 -
179 -
180 -From patchwork Fri Nov 5 18:33:40 2021
181 -Content-Type: text/plain; charset="utf-8"
182 -MIME-Version: 1.0
183 -Content-Transfer-Encoding: 7bit
184 -Subject: [v5,3/5] drm/dp: Don't read back backlight mode in
185 - drm_edp_backlight_enable()
186 -From: Lyude Paul <lyude@××××××.com>
187 -X-Patchwork-Id: 462376
188 -Message-Id: <20211105183342.130810-4-lyude@××××××.com>
189 -To: dri-devel@×××××××××××××××××.org, nouveau@×××××××××××××××××.org,
190 - intel-gfx@×××××××××××××××××.org
191 -Cc: Thomas Zimmermann <tzimmermann@××××.de>, David Airlie <airlied@×××××.ie>,
192 - open list <linux-kernel@×××××××××××.org>, Maxime Ripard <mripard@××××××.org>
193 -Date: Fri, 5 Nov 2021 14:33:40 -0400
194 -
195 -As it turns out, apparently some machines will actually leave additional
196 -backlight functionality like dynamic backlight control on before the OS
197 -loads. Currently we don't take care to disable unsupported features when
198 -writing back the backlight mode, which can lead to some rather strange
199 -looking behavior when adjusting the backlight.
200 -
201 -So, let's fix this by just not reading back the current backlight mode on
202 -initial enable. I don't think there should really be any downsides to this,
203 -and this will ensure we don't leave any unsupported functionality enabled.
204 -
205 -This should fix at least one (but not all) of the issues seen with DPCD
206 -backlight support on fi-bdw-samus
207 -
208 -v5:
209 -* Just avoid reading back DPCD register - Doug Anderson
210 -
211 -Signed-off-by: Lyude Paul <lyude@××××××.com>
212 -Fixes: 867cf9cd73c3 ("drm/dp: Extract i915's eDP backlight code into DRM helpers")
213 -Reviewed-by: Douglas Anderson <dianders@××××××××.org>
214 ----
215 - drivers/gpu/drm/drm_dp_helper.c | 40 ++++++++++-----------------------
216 - 1 file changed, 12 insertions(+), 28 deletions(-)
217 -
218 -diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
219 -index ada0a1ff262d..af2aad2f4725 100644
220 ---- a/drivers/gpu/drm/drm_dp_helper.c
221 -+++ b/drivers/gpu/drm/drm_dp_helper.c
222 -@@ -3363,27 +3363,13 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
223 - const u16 level)
224 - {
225 - int ret;
226 -- u8 dpcd_buf, new_dpcd_buf;
227 -+ u8 dpcd_buf = DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
228 -
229 -- ret = drm_dp_dpcd_readb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf);
230 -- if (ret != 1) {
231 -- drm_dbg_kms(aux->drm_dev,
232 -- "%s: Failed to read backlight mode: %d\n", aux->name, ret);
233 -- return ret < 0 ? ret : -EIO;
234 -- }
235 --
236 -- new_dpcd_buf = dpcd_buf;
237 --
238 -- if ((dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) != DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) {
239 -- new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
240 -- new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
241 --
242 -- if (bl->pwmgen_bit_count) {
243 -- ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
244 -- if (ret != 1)
245 -- drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n",
246 -- aux->name, ret);
247 -- }
248 -+ if (bl->pwmgen_bit_count) {
249 -+ ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
250 -+ if (ret != 1)
251 -+ drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n",
252 -+ aux->name, ret);
253 - }
254 -
255 - if (bl->pwm_freq_pre_divider) {
256 -@@ -3393,16 +3379,14 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
257 - "%s: Failed to write aux backlight frequency: %d\n",
258 - aux->name, ret);
259 - else
260 -- new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE;
261 -+ dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE;
262 - }
263 -
264 -- if (new_dpcd_buf != dpcd_buf) {
265 -- ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf);
266 -- if (ret != 1) {
267 -- drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n",
268 -- aux->name, ret);
269 -- return ret < 0 ? ret : -EIO;
270 -- }
271 -+ ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf);
272 -+ if (ret != 1) {
273 -+ drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n",
274 -+ aux->name, ret);
275 -+ return ret < 0 ? ret : -EIO;
276 - }
277 -
278 - ret = drm_edp_backlight_set_level(aux, bl, level);
279 -
280 -From patchwork Fri Nov 5 18:33:41 2021
281 -Content-Type: text/plain; charset="utf-8"
282 -MIME-Version: 1.0
283 -Content-Transfer-Encoding: 7bit
284 -Subject: [v5,4/5] drm/dp,
285 - drm/i915: Add support for VESA backlights using PWM for brightness control
286 -From: Lyude Paul <lyude@××××××.com>
287 -X-Patchwork-Id: 462379
288 -Message-Id: <20211105183342.130810-5-lyude@××××××.com>
289 -To: dri-devel@×××××××××××××××××.org, nouveau@×××××××××××××××××.org,
290 - intel-gfx@×××××××××××××××××.org
291 -Cc: Rajeev Nandan <rajeevny@××××××××××.org>, David Airlie <airlied@×××××.ie>,
292 - Doug Anderson <dianders@××××××××.org>, Maxime Ripard <mripard@××××××.org>,
293 - open list <linux-kernel@×××××××××××.org>,
294 - Thomas Zimmermann <tzimmermann@××××.de>
295 -Date: Fri, 5 Nov 2021 14:33:41 -0400
296 -
297 -Now that we've added support to i915 for controlling panel backlights that
298 -need PWM to be enabled/disabled, let's finalize this and add support for
299 -controlling brightness levels via PWM as well. This should hopefully put us
300 -towards the path of supporting _ALL_ backlights via VESA's DPCD interface
301 -which would allow us to finally start trusting the DPCD again.
302 -
303 -Note however that we still don't enable using this by default on i915 when
304 -it's not needed, primarily because I haven't yet had a chance to confirm if
305 -it's safe to do this on the one machine in Intel's CI that had an issue
306 -with this: samus-fi-bdw. I have done basic testing of this on other
307 -machines though, by manually patching i915 to force it into PWM-only mode
308 -on some of my laptops.
309 -
310 -v2:
311 -* Correct documentation (thanks Doug!)
312 -* Get rid of backlight caps
313 -
314 -Signed-off-by: Lyude Paul <lyude@××××××.com>
315 -Reviewed-by: Doug Anderson <dianders@××××××××.org>
316 -Cc: Rajeev Nandan <rajeevny@××××××××××.org>
317 -Cc: Satadru Pramanik <satadru@×××××.com>
318 ----
319 - drivers/gpu/drm/drm_dp_helper.c | 72 +++++++++++++------
320 - .../drm/i915/display/intel_dp_aux_backlight.c | 44 +++++++++---
321 - include/drm/drm_dp_helper.h | 7 +-
322 - 3 files changed, 89 insertions(+), 34 deletions(-)
323 -
324 -diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
325 -index af2aad2f4725..23f9073bc473 100644
326 ---- a/drivers/gpu/drm/drm_dp_helper.c
327 -+++ b/drivers/gpu/drm/drm_dp_helper.c
328 -@@ -3290,6 +3290,10 @@ int drm_edp_backlight_set_level(struct drm_dp_aux *aux, const struct drm_edp_bac
329 - int ret;
330 - u8 buf[2] = { 0 };
331 -
332 -+ /* The panel uses the PWM for controlling brightness levels */
333 -+ if (!bl->aux_set)
334 -+ return 0;
335 -+
336 - if (bl->lsb_reg_used) {
337 - buf[0] = (level & 0xff00) >> 8;
338 - buf[1] = (level & 0x00ff);
339 -@@ -3316,7 +3320,7 @@ drm_edp_backlight_set_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
340 - int ret;
341 - u8 buf;
342 -
343 -- /* The panel uses something other then DPCD for enabling its backlight */
344 -+ /* This panel uses the EDP_BL_PWR GPIO for enablement */
345 - if (!bl->aux_enable)
346 - return 0;
347 -
348 -@@ -3351,11 +3355,11 @@ drm_edp_backlight_set_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
349 - * restoring any important backlight state such as the given backlight level, the brightness byte
350 - * count, backlight frequency, etc.
351 - *
352 -- * Note that certain panels, while supporting brightness level controls over DPCD, may not support
353 -- * having their backlights enabled via the standard %DP_EDP_DISPLAY_CONTROL_REGISTER. On such panels
354 -- * &drm_edp_backlight_info.aux_enable will be set to %false, this function will skip the step of
355 -- * programming the %DP_EDP_DISPLAY_CONTROL_REGISTER, and the driver must perform the required
356 -- * implementation specific step for enabling the backlight after calling this function.
357 -+ * Note that certain panels do not support being enabled or disabled via DPCD, but instead require
358 -+ * that the driver handle enabling/disabling the panel through implementation-specific means using
359 -+ * the EDP_BL_PWR GPIO. For such panels, &drm_edp_backlight_info.aux_enable will be set to %false,
360 -+ * this function becomes a no-op, and the driver is expected to handle powering the panel on using
361 -+ * the EDP_BL_PWR GPIO.
362 - *
363 - * Returns: %0 on success, negative error code on failure.
364 - */
365 -@@ -3363,7 +3367,12 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
366 - const u16 level)
367 - {
368 - int ret;
369 -- u8 dpcd_buf = DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
370 -+ u8 dpcd_buf;
371 -+
372 -+ if (bl->aux_set)
373 -+ dpcd_buf = DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
374 -+ else
375 -+ dpcd_buf = DP_EDP_BACKLIGHT_CONTROL_MODE_PWM;
376 -
377 - if (bl->pwmgen_bit_count) {
378 - ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
379 -@@ -3405,12 +3414,13 @@ EXPORT_SYMBOL(drm_edp_backlight_enable);
380 - * @aux: The DP AUX channel to use
381 - * @bl: Backlight capability info from drm_edp_backlight_init()
382 - *
383 -- * This function handles disabling DPCD backlight controls on a panel over AUX. Note that some
384 -- * panels have backlights that are enabled/disabled by other means, despite having their brightness
385 -- * values controlled through DPCD. On such panels &drm_edp_backlight_info.aux_enable will be set to
386 -- * %false, this function will become a no-op (and we will skip updating
387 -- * %DP_EDP_DISPLAY_CONTROL_REGISTER), and the driver must take care to perform it's own
388 -- * implementation specific step for disabling the backlight.
389 -+ * This function handles disabling DPCD backlight controls on a panel over AUX.
390 -+ *
391 -+ * Note that certain panels do not support being enabled or disabled via DPCD, but instead require
392 -+ * that the driver handle enabling/disabling the panel through implementation-specific means using
393 -+ * the EDP_BL_PWR GPIO. For such panels, &drm_edp_backlight_info.aux_enable will be set to %false,
394 -+ * this function becomes a no-op, and the driver is expected to handle powering the panel off using
395 -+ * the EDP_BL_PWR GPIO.
396 - *
397 - * Returns: %0 on success or no-op, negative error code on failure.
398 - */
399 -@@ -3434,6 +3444,9 @@ drm_edp_backlight_probe_max(struct drm_dp_aux *aux, struct drm_edp_backlight_inf
400 - int ret;
401 - u8 pn, pn_min, pn_max;
402 -
403 -+ if (!bl->aux_set)
404 -+ return 0;
405 -+
406 - ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT, &pn);
407 - if (ret != 1) {
408 - drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap: %d\n",
409 -@@ -3519,7 +3532,7 @@ drm_edp_backlight_probe_max(struct drm_dp_aux *aux, struct drm_edp_backlight_inf
410 - }
411 -
412 - static inline int
413 --drm_edp_backlight_probe_level(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl,
414 -+drm_edp_backlight_probe_state(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl,
415 - u8 *current_mode)
416 - {
417 - int ret;
418 -@@ -3534,6 +3547,9 @@ drm_edp_backlight_probe_level(struct drm_dp_aux *aux, struct drm_edp_backlight_i
419 - }
420 -
421 - *current_mode = (mode_reg & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK);
422 -+ if (!bl->aux_set)
423 -+ return 0;
424 -+
425 - if (*current_mode == DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) {
426 - int size = 1 + bl->lsb_reg_used;
427 -
428 -@@ -3564,7 +3580,7 @@ drm_edp_backlight_probe_level(struct drm_dp_aux *aux, struct drm_edp_backlight_i
429 - * @bl: The &drm_edp_backlight_info struct to fill out with information on the backlight
430 - * @driver_pwm_freq_hz: Optional PWM frequency from the driver in hz
431 - * @edp_dpcd: A cached copy of the eDP DPCD
432 -- * @current_level: Where to store the probed brightness level
433 -+ * @current_level: Where to store the probed brightness level, if any
434 - * @current_mode: Where to store the currently set backlight control mode
435 - *
436 - * Initializes a &drm_edp_backlight_info struct by probing @aux for it's backlight capabilities,
437 -@@ -3584,24 +3600,38 @@ drm_edp_backlight_init(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl
438 -
439 - if (edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP)
440 - bl->aux_enable = true;
441 -+ if (edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)
442 -+ bl->aux_set = true;
443 - if (edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_BYTE_COUNT)
444 - bl->lsb_reg_used = true;
445 -
446 -+ /* Sanity check caps */
447 -+ if (!bl->aux_set && !(edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP)) {
448 -+ drm_dbg_kms(aux->drm_dev,
449 -+ "%s: Panel supports neither AUX or PWM brightness control? Aborting\n",
450 -+ aux->name);
451 -+ return -EINVAL;
452 -+ }
453 -+
454 - ret = drm_edp_backlight_probe_max(aux, bl, driver_pwm_freq_hz, edp_dpcd);
455 - if (ret < 0)
456 - return ret;
457 -
458 -- ret = drm_edp_backlight_probe_level(aux, bl, current_mode);
459 -+ ret = drm_edp_backlight_probe_state(aux, bl, current_mode);
460 - if (ret < 0)
461 - return ret;
462 - *current_level = ret;
463 -
464 - drm_dbg_kms(aux->drm_dev,
465 -- "%s: Found backlight level=%d/%d pwm_freq_pre_divider=%d mode=%x\n",
466 -- aux->name, *current_level, bl->max, bl->pwm_freq_pre_divider, *current_mode);
467 -- drm_dbg_kms(aux->drm_dev,
468 -- "%s: Backlight caps: pwmgen_bit_count=%d lsb_reg_used=%d aux_enable=%d\n",
469 -- aux->name, bl->pwmgen_bit_count, bl->lsb_reg_used, bl->aux_enable);
470 -+ "%s: Found backlight: aux_set=%d aux_enable=%d mode=%d\n",
471 -+ aux->name, bl->aux_set, bl->aux_enable, *current_mode);
472 -+ if (bl->aux_set) {
473 -+ drm_dbg_kms(aux->drm_dev,
474 -+ "%s: Backlight caps: level=%d/%d pwm_freq_pre_divider=%d lsb_reg_used=%d\n",
475 -+ aux->name, *current_level, bl->max, bl->pwm_freq_pre_divider,
476 -+ bl->lsb_reg_used);
477 -+ }
478 -+
479 - return 0;
480 - }
481 - EXPORT_SYMBOL(drm_edp_backlight_init);
482 -diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
483 -index f05b71c01b8e..96fe3eaba44a 100644
484 ---- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
485 -+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
486 -@@ -282,6 +282,12 @@ intel_dp_aux_vesa_set_backlight(const struct drm_connector_state *conn_state, u3
487 - struct intel_panel *panel = &connector->panel;
488 - struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
489 -
490 -+ if (!panel->backlight.edp.vesa.info.aux_set) {
491 -+ const u32 pwm_level = intel_backlight_level_to_pwm(connector, level);
492 -+
493 -+ intel_backlight_set_pwm_level(conn_state, pwm_level);
494 -+ }
495 -+
496 - drm_edp_backlight_set_level(&intel_dp->aux, &panel->backlight.edp.vesa.info, level);
497 - }
498 -
499 -@@ -294,8 +300,13 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,
500 - struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
501 -
502 - if (!panel->backlight.edp.vesa.info.aux_enable) {
503 -- u32 pwm_level = intel_backlight_invert_pwm_level(connector,
504 -- panel->backlight.pwm_level_max);
505 -+ u32 pwm_level;
506 -+
507 -+ if (!panel->backlight.edp.vesa.info.aux_set)
508 -+ pwm_level = intel_backlight_level_to_pwm(connector, level);
509 -+ else
510 -+ pwm_level = intel_backlight_invert_pwm_level(connector,
511 -+ panel->backlight.pwm_level_max);
512 -
513 - panel->backlight.pwm_funcs->enable(crtc_state, conn_state, pwm_level);
514 - }
515 -@@ -332,7 +343,7 @@ static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector,
516 - if (ret < 0)
517 - return ret;
518 -
519 -- if (!panel->backlight.edp.vesa.info.aux_enable) {
520 -+ if (!panel->backlight.edp.vesa.info.aux_set || !panel->backlight.edp.vesa.info.aux_enable) {
521 - ret = panel->backlight.pwm_funcs->setup(connector, pipe);
522 - if (ret < 0) {
523 - drm_err(&i915->drm,
524 -@@ -341,14 +352,27 @@ static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector,
525 - return ret;
526 - }
527 - }
528 -- panel->backlight.max = panel->backlight.edp.vesa.info.max;
529 -- panel->backlight.min = 0;
530 -- if (current_mode == DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) {
531 -- panel->backlight.level = current_level;
532 -- panel->backlight.enabled = panel->backlight.level != 0;
533 -+
534 -+ if (panel->backlight.edp.vesa.info.aux_set) {
535 -+ panel->backlight.max = panel->backlight.edp.vesa.info.max;
536 -+ panel->backlight.min = 0;
537 -+ if (current_mode == DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) {
538 -+ panel->backlight.level = current_level;
539 -+ panel->backlight.enabled = panel->backlight.level != 0;
540 -+ } else {
541 -+ panel->backlight.level = panel->backlight.max;
542 -+ panel->backlight.enabled = false;
543 -+ }
544 - } else {
545 -- panel->backlight.level = panel->backlight.max;
546 -- panel->backlight.enabled = false;
547 -+ panel->backlight.max = panel->backlight.pwm_level_max;
548 -+ panel->backlight.min = panel->backlight.pwm_level_min;
549 -+ if (current_mode == DP_EDP_BACKLIGHT_CONTROL_MODE_PWM) {
550 -+ panel->backlight.level = panel->backlight.pwm_funcs->get(connector, pipe);
551 -+ panel->backlight.enabled = panel->backlight.pwm_enabled;
552 -+ } else {
553 -+ panel->backlight.level = panel->backlight.max;
554 -+ panel->backlight.enabled = false;
555 -+ }
556 - }
557 -
558 - return 0;
559 -diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
560 -index afdf7f4183f9..8b2ed4199284 100644
561 ---- a/include/drm/drm_dp_helper.h
562 -+++ b/include/drm/drm_dp_helper.h
563 -@@ -1868,7 +1868,7 @@ drm_dp_sink_can_do_video_without_timing_msa(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
564 - *
565 - * Note that currently this function will return %false for panels which support various DPCD
566 - * backlight features but which require the brightness be set through PWM, and don't support setting
567 -- * the brightness level via the DPCD. This is a TODO.
568 -+ * the brightness level via the DPCD.
569 - *
570 - * Returns: %True if @edp_dpcd indicates that VESA backlight controls are supported, %false
571 - * otherwise
572 -@@ -1876,8 +1876,7 @@ drm_dp_sink_can_do_video_without_timing_msa(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
573 - static inline bool
574 - drm_edp_backlight_supported(const u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE])
575 - {
576 -- return (edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP) &&
577 -- (edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP);
578 -+ return !!(edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP);
579 - }
580 -
581 - /*
582 -@@ -2238,6 +2237,7 @@ drm_dp_has_quirk(const struct drm_dp_desc *desc, enum drm_dp_quirk quirk)
583 - * @max: The maximum backlight level that may be set
584 - * @lsb_reg_used: Do we also write values to the DP_EDP_BACKLIGHT_BRIGHTNESS_LSB register?
585 - * @aux_enable: Does the panel support the AUX enable cap?
586 -+ * @aux_set: Does the panel support setting the brightness through AUX?
587 - *
588 - * This structure contains various data about an eDP backlight, which can be populated by using
589 - * drm_edp_backlight_init().
590 -@@ -2249,6 +2249,7 @@ struct drm_edp_backlight_info {
591 -
592 - bool lsb_reg_used : 1;
593 - bool aux_enable : 1;
594 -+ bool aux_set : 1;
595 - };
596 -
597 - int
598 -
599 -From patchwork Fri Nov 5 18:33:42 2021
600 -Content-Type: text/plain; charset="utf-8"
601 -MIME-Version: 1.0
602 -Content-Transfer-Encoding: 8bit
603 -Subject: [v5,5/5] drm/i915: Clarify probing order in
604 - intel_dp_aux_init_backlight_funcs()
605 -From: Lyude Paul <lyude@××××××.com>
606 -X-Patchwork-Id: 462382
607 -Message-Id: <20211105183342.130810-6-lyude@××××××.com>
608 -To: dri-devel@×××××××××××××××××.org, nouveau@×××××××××××××××××.org,
609 - intel-gfx@×××××××××××××××××.org
610 -Cc: David Airlie <airlied@×××××.ie>, open list <linux-kernel@×××××××××××.org>
611 -Date: Fri, 5 Nov 2021 14:33:42 -0400
612 -
613 -Hooray! We've managed to hit enough bugs upstream that I've been able to
614 -come up with a pretty solid explanation for how backlight controls are
615 -actually supposed to be detected and used these days. As well, having the
616 -rest of the PWM bits in VESA's backlight interface implemented seems to
617 -have fixed all of the problematic brightness controls laptop panels that
618 -we've hit so far.
619 -
620 -So, let's actually document this instead of just calling the laptop panels
621 -liars. As well, I would like to formally apologize to all of the laptop
622 -panels I called liars. I'm sorry laptop panels, hopefully you can all
623 -forgive me and we can move past this~
624 -
625 -Signed-off-by: Lyude Paul <lyude@××××××.com>
626 -Acked-by: Ville Syrjälä <ville.syrjala@×××××××××××.com>
627 ----
628 - .../drm/i915/display/intel_dp_aux_backlight.c | 16 +++++++++++-----
629 - 1 file changed, 11 insertions(+), 5 deletions(-)
630 -
631 -diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
632 -index 96fe3eaba44a..8b9c925c4c16 100644
633 ---- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
634 -+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
635 -@@ -456,11 +456,17 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
636 - }
637 -
638 - /*
639 -- * A lot of eDP panels in the wild will report supporting both the
640 -- * Intel proprietary backlight control interface, and the VESA
641 -- * backlight control interface. Many of these panels are liars though,
642 -- * and will only work with the Intel interface. So, always probe for
643 -- * that first.
644 -+ * Since Intel has their own backlight control interface, the majority of machines out there
645 -+ * using DPCD backlight controls with Intel GPUs will be using this interface as opposed to
646 -+ * the VESA interface. However, other GPUs (such as Nvidia's) will always use the VESA
647 -+ * interface. This means that there's quite a number of panels out there that will advertise
648 -+ * support for both interfaces, primarily systems with Intel/Nvidia hybrid GPU setups.
649 -+ *
650 -+ * There's a catch to this though: on many panels that advertise support for both
651 -+ * interfaces, the VESA backlight interface will stop working once we've programmed the
652 -+ * panel with Intel's OUI - which is also required for us to be able to detect Intel's
653 -+ * backlight interface at all. This means that the only sensible way for us to detect both
654 -+ * interfaces is to probe for Intel's first, and VESA's second.
655 - */
656 - if (try_intel_interface && intel_dp_aux_supports_hdr_backlight(connector)) {
657 - drm_dbg_kms(dev, "Using Intel proprietary eDP backlight controls\n");