projects/linux·blob master · refs

1090 lines · 29.4 KiB

1/*
2 * Copyright (C) 2015 Red Hat Inc.
3 * Hans de Goede <[email protected]>
4 * Copyright (C) 2008 SuSE Linux Products GmbH
5 * Thomas Renninger <[email protected]>
6 *
7 * May be copied or modified under the terms of the GNU General Public License
8 *
9 * video_detect.c:
10 * After PCI devices are glued with ACPI devices
11 * acpi_get_pci_dev() can be called to identify ACPI graphics
12 * devices for which a real graphics card is plugged in
13 *
14 * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B)
15 * are available, video.ko should be used to handle the device.
16 *
17 * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop,
18 * sony_acpi,... can take care about backlight brightness.
19 *
20 * Backlight drivers can use acpi_video_get_backlight_type() to determine which
21 * driver should handle the backlight. RAW/GPU-driver backlight drivers must
22 * use the acpi_video_backlight_use_native() helper for this.
23 *
24 * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m)
25 * this file will not be compiled and acpi_video_get_backlight_type() will
26 * always return acpi_backlight_vendor.
27 */
28
29#include <linux/export.h>
30#include <linux/acpi.h>
31#include <linux/apple-gmux.h>
32#include <linux/backlight.h>
33#include <linux/dmi.h>
34#include <linux/module.h>
35#include <linux/pci.h>
36#include <linux/platform_data/x86/nvidia-wmi-ec-backlight.h>
37#include <linux/pnp.h>
38#include <linux/types.h>
39#include <linux/workqueue.h>
40#include <acpi/video.h>
41
42static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef;
43static enum acpi_backlight_type acpi_backlight_dmi = acpi_backlight_undef;
44
45static void acpi_video_parse_cmdline(void)
46{
47 if (!strcmp("vendor", acpi_video_backlight_string))
48 acpi_backlight_cmdline = acpi_backlight_vendor;
49 if (!strcmp("video", acpi_video_backlight_string))
50 acpi_backlight_cmdline = acpi_backlight_video;
51 if (!strcmp("native", acpi_video_backlight_string))
52 acpi_backlight_cmdline = acpi_backlight_native;
53 if (!strcmp("nvidia_wmi_ec", acpi_video_backlight_string))
54 acpi_backlight_cmdline = acpi_backlight_nvidia_wmi_ec;
55 if (!strcmp("apple_gmux", acpi_video_backlight_string))
56 acpi_backlight_cmdline = acpi_backlight_apple_gmux;
57 if (!strcmp("dell_uart", acpi_video_backlight_string))
58 acpi_backlight_cmdline = acpi_backlight_dell_uart;
59 if (!strcmp("none", acpi_video_backlight_string))
60 acpi_backlight_cmdline = acpi_backlight_none;
61}
62
63static acpi_status
64find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
65{
66 struct acpi_device *acpi_dev = acpi_fetch_acpi_dev(handle);
67 long *cap = context;
68 struct pci_dev *dev;
69
70 if (acpi_dev_is_video_device(acpi_dev)) {
71 dev = acpi_dev_get_pci_dev(acpi_dev);
72 if (!dev)
73 return AE_OK;
74 pci_dev_put(dev);
75 *cap |= acpi_is_video_device(handle);
76 }
77 return AE_OK;
78}
79
80/* This depends on ACPI_WMI which is X86 only */
81#ifdef CONFIG_X86
82static bool nvidia_wmi_ec_supported(void)
83{
84 struct wmi_brightness_args args = {
85 .mode = WMI_BRIGHTNESS_MODE_GET,
86 .val = 0,
87 .ret = 0,
88 };
89 struct acpi_buffer buf = { (acpi_size)sizeof(args), &args };
90 acpi_status status;
91
92 status = wmi_evaluate_method(WMI_BRIGHTNESS_GUID, 0,
93 WMI_BRIGHTNESS_METHOD_SOURCE, &buf, &buf);
94 if (ACPI_FAILURE(status))
95 return false;
96
97 /*
98 * If brightness is handled by the EC then nvidia-wmi-ec-backlight
99 * should be used, else the GPU driver(s) should be used.
100 */
101 return args.ret == WMI_BRIGHTNESS_SOURCE_EC;
102}
103#else
104static bool nvidia_wmi_ec_supported(void)
105{
106 return false;
107}
108#endif
109
110/* Force to use vendor driver when the ACPI device is known to be
111 * buggy */
112static int video_detect_force_vendor(const struct dmi_system_id *d)
113{
114 acpi_backlight_dmi = acpi_backlight_vendor;
115 return 0;
116}
117
118static int video_detect_force_video(const struct dmi_system_id *d)
119{
120 acpi_backlight_dmi = acpi_backlight_video;
121 return 0;
122}
123
124static int video_detect_force_native(const struct dmi_system_id *d)
125{
126 acpi_backlight_dmi = acpi_backlight_native;
127 return 0;
128}
129
130static int video_detect_portege_r100(const struct dmi_system_id *d)
131{
132 struct pci_dev *dev;
133 /* Search for Trident CyberBlade XP4m32 to confirm Portégé R100 */
134 dev = pci_get_device(PCI_VENDOR_ID_TRIDENT, 0x2100, NULL);
135 if (dev) {
136 acpi_backlight_dmi = acpi_backlight_vendor;
137 pci_dev_put(dev);
138 }
139 return 0;
140}
141
142static const struct dmi_system_id video_detect_dmi_table[] = {
143 /*
144 * Models which should use the vendor backlight interface,
145 * because of broken ACPI video backlight control.
146 */
147 {
148 /* https://bugzilla.redhat.com/show_bug.cgi?id=1128309 */
149 .callback = video_detect_force_vendor,
150 /* Acer KAV80 */
151 .matches = {
152 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
153 DMI_MATCH(DMI_PRODUCT_NAME, "KAV80"),
154 },
155 },
156 {
157 .callback = video_detect_force_vendor,
158 /* Asus UL30VT */
159 .matches = {
160 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
161 DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"),
162 },
163 },
164 {
165 .callback = video_detect_force_vendor,
166 /* Asus UL30A */
167 .matches = {
168 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
169 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
170 },
171 },
172 {
173 .callback = video_detect_force_vendor,
174 /* Asus X55U */
175 .matches = {
176 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
177 DMI_MATCH(DMI_PRODUCT_NAME, "X55U"),
178 },
179 },
180 {
181 /* https://bugs.launchpad.net/bugs/1000146 */
182 .callback = video_detect_force_vendor,
183 /* Asus X101CH */
184 .matches = {
185 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
186 DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
187 },
188 },
189 {
190 .callback = video_detect_force_vendor,
191 /* Asus X401U */
192 .matches = {
193 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
194 DMI_MATCH(DMI_PRODUCT_NAME, "X401U"),
195 },
196 },
197 {
198 .callback = video_detect_force_vendor,
199 /* Asus X501U */
200 .matches = {
201 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
202 DMI_MATCH(DMI_PRODUCT_NAME, "X501U"),
203 },
204 },
205 {
206 /* https://bugs.launchpad.net/bugs/1000146 */
207 .callback = video_detect_force_vendor,
208 /* Asus 1015CX */
209 .matches = {
210 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
211 DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
212 },
213 },
214 {
215 .callback = video_detect_force_vendor,
216 /* Samsung N150/N210/N220 */
217 .matches = {
218 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
219 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"),
220 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"),
221 },
222 },
223 {
224 .callback = video_detect_force_vendor,
225 /* Samsung NF110/NF210/NF310 */
226 .matches = {
227 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
228 DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"),
229 DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"),
230 },
231 },
232 {
233 .callback = video_detect_force_vendor,
234 /* Samsung NC210 */
235 .matches = {
236 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
237 DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"),
238 DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
239 },
240 },
241
242 /*
243 * Models which should use the vendor backlight interface,
244 * because of broken native backlight control.
245 */
246 {
247 .callback = video_detect_force_vendor,
248 /* Sony Vaio PCG-FRV35 */
249 .matches = {
250 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
251 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-FRV35"),
252 },
253 },
254 {
255 .callback = video_detect_force_vendor,
256 /* Panasonic Toughbook CF-18 */
257 .matches = {
258 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita Electric Industrial"),
259 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
260 },
261 },
262
263 /*
264 * Toshiba models with Transflective display, these need to use
265 * the toshiba_acpi vendor driver for proper Transflective handling.
266 */
267 {
268 .callback = video_detect_force_vendor,
269 .matches = {
270 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
271 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R500"),
272 },
273 },
274 {
275 .callback = video_detect_force_vendor,
276 .matches = {
277 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
278 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R600"),
279 },
280 },
281
282 /*
283 * Toshiba Portégé R100 has working both acpi_video and toshiba_acpi
284 * vendor driver. But none of them gets activated as it has a VGA with
285 * no kernel driver (Trident CyberBlade XP4m32).
286 * The DMI strings are generic so check for the VGA chip in callback.
287 */
288 {
289 .callback = video_detect_portege_r100,
290 .matches = {
291 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
292 DMI_MATCH(DMI_PRODUCT_NAME, "Portable PC"),
293 DMI_MATCH(DMI_PRODUCT_VERSION, "Version 1.0"),
294 DMI_MATCH(DMI_BOARD_NAME, "Portable PC")
295 },
296 },
297
298 /*
299 * Models which need acpi_video backlight control where the GPU drivers
300 * do not call acpi_video_register_backlight() because no internal panel
301 * is detected. Typically these are all-in-ones (monitors with builtin
302 * PC) where the panel connection shows up as regular DP instead of eDP.
303 */
304 {
305 .callback = video_detect_force_video,
306 /* Apple iMac14,1 */
307 .matches = {
308 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
309 DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,1"),
310 },
311 },
312 {
313 .callback = video_detect_force_video,
314 /* Apple iMac14,2 */
315 .matches = {
316 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
317 DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,2"),
318 },
319 },
320
321 /*
322 * These models have a working acpi_video backlight control, and using
323 * native backlight causes a regression where backlight does not work
324 * when userspace is not handling brightness key events. Disable
325 * native_backlight on these to fix this:
326 * https://bugzilla.kernel.org/show_bug.cgi?id=81691
327 */
328 {
329 .callback = video_detect_force_video,
330 /* ThinkPad T420 */
331 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
333 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T420"),
334 },
335 },
336 {
337 .callback = video_detect_force_video,
338 /* ThinkPad T520 */
339 .matches = {
340 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
341 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"),
342 },
343 },
344 {
345 .callback = video_detect_force_video,
346 /* ThinkPad X201s */
347 .matches = {
348 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
349 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
350 },
351 },
352 {
353 .callback = video_detect_force_video,
354 /* ThinkPad X201T */
355 .matches = {
356 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
357 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"),
358 },
359 },
360
361 /* The native backlight controls do not work on some older machines */
362 {
363 /* https://bugs.freedesktop.org/show_bug.cgi?id=81515 */
364 .callback = video_detect_force_video,
365 /* HP ENVY 15 Notebook */
366 .matches = {
367 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
368 DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"),
369 },
370 },
371 {
372 .callback = video_detect_force_video,
373 /* SAMSUNG 870Z5E/880Z5E/680Z5E */
374 .matches = {
375 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
376 DMI_MATCH(DMI_PRODUCT_NAME, "870Z5E/880Z5E/680Z5E"),
377 },
378 },
379 {
380 .callback = video_detect_force_video,
381 /* SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V */
382 .matches = {
383 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
384 DMI_MATCH(DMI_PRODUCT_NAME,
385 "370R4E/370R4V/370R5E/3570RE/370R5V"),
386 },
387 },
388 {
389 /* https://bugzilla.redhat.com/show_bug.cgi?id=1186097 */
390 .callback = video_detect_force_video,
391 /* SAMSUNG 3570R/370R/470R/450R/510R/4450RV */
392 .matches = {
393 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
394 DMI_MATCH(DMI_PRODUCT_NAME,
395 "3570R/370R/470R/450R/510R/4450RV"),
396 },
397 },
398 {
399 /* https://bugzilla.redhat.com/show_bug.cgi?id=1557060 */
400 .callback = video_detect_force_video,
401 /* SAMSUNG 670Z5E */
402 .matches = {
403 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
404 DMI_MATCH(DMI_PRODUCT_NAME, "670Z5E"),
405 },
406 },
407 {
408 /* https://bugzilla.redhat.com/show_bug.cgi?id=1094948 */
409 .callback = video_detect_force_video,
410 /* SAMSUNG 730U3E/740U3E */
411 .matches = {
412 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
413 DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"),
414 },
415 },
416 {
417 /* https://bugs.freedesktop.org/show_bug.cgi?id=87286 */
418 .callback = video_detect_force_video,
419 /* SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D */
420 .matches = {
421 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
422 DMI_MATCH(DMI_PRODUCT_NAME,
423 "900X3C/900X3D/900X3E/900X4C/900X4D"),
424 },
425 },
426 {
427 /* https://bugzilla.redhat.com/show_bug.cgi?id=1272633 */
428 .callback = video_detect_force_video,
429 /* Dell XPS14 L421X */
430 .matches = {
431 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
432 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
433 },
434 },
435 {
436 /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */
437 .callback = video_detect_force_video,
438 /* Dell XPS15 L521X */
439 .matches = {
440 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
441 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
442 },
443 },
444 {
445 /* https://bugzilla.kernel.org/show_bug.cgi?id=108971 */
446 .callback = video_detect_force_video,
447 /* SAMSUNG 530U4E/540U4E */
448 .matches = {
449 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
450 DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"),
451 },
452 },
453 {
454 /* https://bugs.launchpad.net/bugs/1894667 */
455 .callback = video_detect_force_video,
456 /* HP 635 Notebook */
457 .matches = {
458 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
459 DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"),
460 },
461 },
462
463 /* Non win8 machines which need native backlight nevertheless */
464 {
465 /* https://bugzilla.redhat.com/show_bug.cgi?id=1201530 */
466 .callback = video_detect_force_native,
467 /* Lenovo Ideapad S405 */
468 .matches = {
469 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
470 DMI_MATCH(DMI_BOARD_NAME, "Lenovo IdeaPad S405"),
471 },
472 },
473 {
474 /* https://bugzilla.suse.com/show_bug.cgi?id=1208724 */
475 .callback = video_detect_force_native,
476 /* Lenovo Ideapad Z470 */
477 .matches = {
478 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
479 DMI_MATCH(DMI_PRODUCT_VERSION, "IdeaPad Z470"),
480 },
481 },
482 {
483 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
484 .callback = video_detect_force_native,
485 /* Lenovo Ideapad Z570 */
486 .matches = {
487 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
488 DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
489 },
490 },
491 {
492 .callback = video_detect_force_native,
493 /* Lenovo E41-25 */
494 .matches = {
495 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
496 DMI_MATCH(DMI_PRODUCT_NAME, "81FS"),
497 },
498 },
499 {
500 .callback = video_detect_force_native,
501 /* Lenovo E41-45 */
502 .matches = {
503 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
504 DMI_MATCH(DMI_PRODUCT_NAME, "82BK"),
505 },
506 },
507 {
508 .callback = video_detect_force_native,
509 /* Lenovo Slim 7 16ARH7 */
510 .matches = {
511 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
512 DMI_MATCH(DMI_PRODUCT_NAME, "82UX"),
513 },
514 },
515 {
516 .callback = video_detect_force_native,
517 /* Lenovo ThinkPad X131e (3371 AMD version) */
518 .matches = {
519 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
520 DMI_MATCH(DMI_PRODUCT_NAME, "3371"),
521 },
522 },
523 {
524 .callback = video_detect_force_native,
525 /* Apple iMac11,3 */
526 .matches = {
527 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
528 DMI_MATCH(DMI_PRODUCT_NAME, "iMac11,3"),
529 },
530 },
531 {
532 /* https://gitlab.freedesktop.org/drm/amd/-/issues/1838 */
533 .callback = video_detect_force_native,
534 /* Apple iMac12,1 */
535 .matches = {
536 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
537 DMI_MATCH(DMI_PRODUCT_NAME, "iMac12,1"),
538 },
539 },
540 {
541 /* https://gitlab.freedesktop.org/drm/amd/-/issues/2753 */
542 .callback = video_detect_force_native,
543 /* Apple iMac12,2 */
544 .matches = {
545 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
546 DMI_MATCH(DMI_PRODUCT_NAME, "iMac12,2"),
547 },
548 },
549 {
550 .callback = video_detect_force_native,
551 /* Apple MacBook Air 7,2 */
552 .matches = {
553 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
554 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir7,2"),
555 },
556 },
557 {
558 .callback = video_detect_force_native,
559 /* Apple MacBook Air 9,1 */
560 .matches = {
561 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
562 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir9,1"),
563 },
564 },
565 {
566 .callback = video_detect_force_native,
567 /* Apple MacBook Pro 9,2 */
568 .matches = {
569 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
570 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro9,2"),
571 },
572 },
573 {
574 .callback = video_detect_force_native,
575 /* Apple MacBook Pro 11,2 */
576 .matches = {
577 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
578 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro11,2"),
579 },
580 },
581 {
582 /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
583 .callback = video_detect_force_native,
584 /* Apple MacBook Pro 12,1 */
585 .matches = {
586 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
587 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"),
588 },
589 },
590 {
591 .callback = video_detect_force_native,
592 /* Apple MacBook Pro 16,2 */
593 .matches = {
594 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
595 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
596 },
597 },
598 {
599 .callback = video_detect_force_native,
600 /* Dell Inspiron N4010 */
601 .matches = {
602 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
603 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N4010"),
604 },
605 },
606 {
607 .callback = video_detect_force_native,
608 /* Dell Vostro V131 */
609 .matches = {
610 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
611 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
612 },
613 },
614 {
615 /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */
616 .callback = video_detect_force_native,
617 /* Dell XPS 17 L702X */
618 .matches = {
619 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
620 DMI_MATCH(DMI_PRODUCT_NAME, "Dell System XPS L702X"),
621 },
622 },
623 {
624 .callback = video_detect_force_native,
625 /* Dell Precision 7510 */
626 .matches = {
627 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
628 DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"),
629 },
630 },
631 {
632 .callback = video_detect_force_native,
633 /* Dell Studio 1569 */
634 .matches = {
635 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
636 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1569"),
637 },
638 },
639 {
640 .callback = video_detect_force_native,
641 /* Acer Aspire 3830TG */
642 .matches = {
643 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
644 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3830TG"),
645 },
646 },
647 {
648 .callback = video_detect_force_native,
649 /* Acer Aspire 4810T */
650 .matches = {
651 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
652 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 4810T"),
653 },
654 },
655 {
656 .callback = video_detect_force_native,
657 /* Acer Aspire 5738z */
658 .matches = {
659 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
660 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
661 DMI_MATCH(DMI_BOARD_NAME, "JV50"),
662 },
663 },
664 {
665 /* https://bugzilla.redhat.com/show_bug.cgi?id=1012674 */
666 .callback = video_detect_force_native,
667 /* Acer Aspire 5741 */
668 .matches = {
669 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
670 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"),
671 },
672 },
673 {
674 /* https://bugzilla.kernel.org/show_bug.cgi?id=42993 */
675 .callback = video_detect_force_native,
676 /* Acer Aspire 5750 */
677 .matches = {
678 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
679 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"),
680 },
681 },
682 {
683 /* https://bugzilla.kernel.org/show_bug.cgi?id=42833 */
684 .callback = video_detect_force_native,
685 /* Acer Extensa 5235 */
686 .matches = {
687 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
688 DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5235"),
689 },
690 },
691 {
692 .callback = video_detect_force_native,
693 /* Acer TravelMate 4750 */
694 .matches = {
695 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
696 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4750"),
697 },
698 },
699 {
700 /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */
701 .callback = video_detect_force_native,
702 /* Acer TravelMate 5735Z */
703 .matches = {
704 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
705 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"),
706 DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"),
707 },
708 },
709 {
710 /* https://bugzilla.kernel.org/show_bug.cgi?id=36322 */
711 .callback = video_detect_force_native,
712 /* Acer TravelMate 5760 */
713 .matches = {
714 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
715 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5760"),
716 },
717 },
718 {
719 .callback = video_detect_force_native,
720 /* ASUSTeK COMPUTER INC. GA401 */
721 .matches = {
722 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
723 DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
724 },
725 },
726 {
727 .callback = video_detect_force_native,
728 /* ASUSTeK COMPUTER INC. GA502 */
729 .matches = {
730 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
731 DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
732 },
733 },
734 {
735 .callback = video_detect_force_native,
736 /* ASUSTeK COMPUTER INC. GA503 */
737 .matches = {
738 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
739 DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
740 },
741 },
742 {
743 .callback = video_detect_force_native,
744 /* Asus U46E */
745 .matches = {
746 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
747 DMI_MATCH(DMI_PRODUCT_NAME, "U46E"),
748 },
749 },
750 {
751 .callback = video_detect_force_native,
752 /* Asus UX303UB */
753 .matches = {
754 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
755 DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
756 },
757 },
758 {
759 .callback = video_detect_force_native,
760 /* HP EliteBook 8460p */
761 .matches = {
762 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
763 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8460p"),
764 },
765 },
766 {
767 .callback = video_detect_force_native,
768 /* HP Pavilion g6-1d80nr / B4U19UA */
769 .matches = {
770 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
771 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion g6 Notebook PC"),
772 DMI_MATCH(DMI_PRODUCT_SKU, "B4U19UA"),
773 },
774 },
775 {
776 .callback = video_detect_force_native,
777 /* Samsung N150P */
778 .matches = {
779 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
780 DMI_MATCH(DMI_PRODUCT_NAME, "N150P"),
781 DMI_MATCH(DMI_BOARD_NAME, "N150P"),
782 },
783 },
784 {
785 .callback = video_detect_force_native,
786 /* Samsung N145P/N250P/N260P */
787 .matches = {
788 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
789 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
790 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
791 },
792 },
793 {
794 .callback = video_detect_force_native,
795 /* Samsung N250P */
796 .matches = {
797 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
798 DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
799 DMI_MATCH(DMI_BOARD_NAME, "N250P"),
800 },
801 },
802 {
803 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
804 .callback = video_detect_force_native,
805 /* Sony Vaio VPCEH3U1E */
806 .matches = {
807 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
808 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
809 },
810 },
811 {
812 .callback = video_detect_force_native,
813 /* Sony Vaio VPCY11S1E */
814 .matches = {
815 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
816 DMI_MATCH(DMI_PRODUCT_NAME, "VPCY11S1E"),
817 },
818 },
819
820 /*
821 * These Toshibas have a broken acpi-video interface for brightness
822 * control. They also have an issue where the panel is off after
823 * suspend until a special firmware call is made to turn it back
824 * on. This is handled by the toshiba_acpi kernel module, so that
825 * module must be enabled for these models to work correctly.
826 */
827 {
828 /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
829 .callback = video_detect_force_native,
830 /* Toshiba Portégé R700 */
831 .matches = {
832 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
833 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"),
834 },
835 },
836 {
837 /* Portégé: https://bugs.freedesktop.org/show_bug.cgi?id=82634 */
838 /* Satellite: https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
839 .callback = video_detect_force_native,
840 /* Toshiba Satellite/Portégé R830 */
841 .matches = {
842 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
843 DMI_MATCH(DMI_PRODUCT_NAME, "R830"),
844 },
845 },
846 {
847 .callback = video_detect_force_native,
848 /* Toshiba Satellite/Portégé Z830 */
849 .matches = {
850 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
851 DMI_MATCH(DMI_PRODUCT_NAME, "Z830"),
852 },
853 },
854
855 /*
856 * Dell AIO (All in Ones) which advertise an UART attached backlight
857 * controller board in their ACPI tables (and may even have one), but
858 * which need native backlight control nevertheless.
859 */
860 {
861 /* https://github.com/zabbly/linux/issues/26 */
862 .callback = video_detect_force_native,
863 /* Dell OptiPlex 5480 AIO */
864 .matches = {
865 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
866 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 5480 AIO"),
867 },
868 },
869 {
870 /* https://bugzilla.redhat.com/show_bug.cgi?id=2303936 */
871 .callback = video_detect_force_native,
872 /* Dell OptiPlex 7760 AIO */
873 .matches = {
874 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
875 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 7760 AIO"),
876 },
877 },
878 {
879 .callback = video_detect_force_native,
880 /* Dell OptiPlex 7770 AIO */
881 .matches = {
882 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
883 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 7770 AIO"),
884 },
885 },
886
887 /*
888 * Models which have nvidia-ec-wmi support, but should not use it.
889 * Note this indicates a likely firmware bug on these models and should
890 * be revisited if/when Linux gets support for dynamic mux mode.
891 */
892 {
893 .callback = video_detect_force_native,
894 /* Dell G15 5515 */
895 .matches = {
896 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
897 DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
898 },
899 },
900 {
901 .callback = video_detect_force_native,
902 .matches = {
903 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
904 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 15 3535"),
905 },
906 },
907 {
908 /* https://gitlab.freedesktop.org/drm/amd/-/issues/4512 */
909 .callback = video_detect_force_native,
910 /* Lenovo Legion S7 15ACH6 */
911 .matches = {
912 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
913 DMI_MATCH(DMI_PRODUCT_NAME, "82K8"),
914 },
915 },
916 {
917 .callback = video_detect_force_native,
918 /* HP OMEN Gaming Laptop 16-n0xxx */
919 .matches = {
920 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
921 DMI_MATCH(DMI_PRODUCT_NAME, "OMEN by HP Gaming Laptop 16-n0xxx"),
922 },
923 },
924 {
925 .callback = video_detect_force_native,
926 /* Acer Nitro AN515-46 */
927 .matches = {
928 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
929 DMI_MATCH(DMI_PRODUCT_NAME, "Nitro AN515-46"),
930 },
931 },
932
933 /*
934 * x86 android tablets which directly control the backlight through
935 * an external backlight controller, typically TI's LP8557.
936 * The backlight is directly controlled by the lp855x driver on these.
937 * This setup means that neither i915's native nor acpi_video backlight
938 * control works. Add a "vendor" quirk to disable both. Note these
939 * devices do not use vendor control in the typical meaning of
940 * vendor specific SMBIOS or ACPI calls being used.
941 */
942 {
943 .callback = video_detect_force_vendor,
944 /* Lenovo Yoga Book X90F / X90L */
945 .matches = {
946 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
947 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
948 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"),
949 },
950 },
951 {
952 .callback = video_detect_force_vendor,
953 /*
954 * Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10"
955 * Lenovo Yoga Tablet 2 use the same mainboard)
956 */
957 .matches = {
958 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
959 DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
960 DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
961 /* Partial match on beginning of BIOS version */
962 DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"),
963 },
964 },
965 {
966 .callback = video_detect_force_vendor,
967 /* Lenovo Yoga Tab 3 Pro YT3-X90F */
968 .matches = {
969 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
970 DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
971 },
972 },
973 {
974 .callback = video_detect_force_vendor,
975 /* Xiaomi Mi Pad 2 */
976 .matches = {
977 DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"),
978 DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"),
979 },
980 },
981 { },
982};
983
984static bool google_cros_ec_present(void)
985{
986 return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
987}
988
989/*
990 * Windows 8 and newer no longer use the ACPI video interface, so it often
991 * does not work. So on win8+ systems prefer native brightness control.
992 * Chromebooks should always prefer native backlight control.
993 */
994static bool prefer_native_over_acpi_video(void)
995{
996 return acpi_osi_is_win8() || google_cros_ec_present();
997}
998
999/*
1000 * Determine which type of backlight interface to use on this system,
1001 * First check cmdline, then dmi quirks, then do autodetect.
1002 */
1003enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect)
1004{
1005 static DEFINE_MUTEX(init_mutex);
1006 static bool nvidia_wmi_ec_present;
1007 static bool apple_gmux_present;
1008 static bool dell_uart_present;
1009 static bool native_available;
1010 static bool init_done;
1011 static long video_caps;
1012
1013 /* Parse cmdline, dmi and acpi only once */
1014 mutex_lock(&init_mutex);
1015 if (!init_done) {
1016 acpi_video_parse_cmdline();
1017 dmi_check_system(video_detect_dmi_table);
1018 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1019 ACPI_UINT32_MAX, find_video, NULL,
1020 &video_caps, NULL);
1021 nvidia_wmi_ec_present = nvidia_wmi_ec_supported();
1022 apple_gmux_present = apple_gmux_detect(NULL, NULL);
1023 dell_uart_present = acpi_dev_present("DELL0501", NULL, -1);
1024 init_done = true;
1025 }
1026 if (native)
1027 native_available = true;
1028 mutex_unlock(&init_mutex);
1029
1030 if (auto_detect)
1031 *auto_detect = false;
1032
1033 /*
1034 * The below heuristics / detection steps are in order of descending
1035 * presedence. The commandline takes presedence over anything else.
1036 */
1037 if (acpi_backlight_cmdline != acpi_backlight_undef)
1038 return acpi_backlight_cmdline;
1039
1040 /* DMI quirks override any autodetection. */
1041 if (acpi_backlight_dmi != acpi_backlight_undef)
1042 return acpi_backlight_dmi;
1043
1044 if (auto_detect)
1045 *auto_detect = true;
1046
1047 /* Special cases such as nvidia_wmi_ec and apple gmux. */
1048 if (nvidia_wmi_ec_present)
1049 return acpi_backlight_nvidia_wmi_ec;
1050
1051 if (apple_gmux_present)
1052 return acpi_backlight_apple_gmux;
1053
1054 if (dell_uart_present)
1055 return acpi_backlight_dell_uart;
1056
1057 /* Use ACPI video if available, except when native should be preferred. */
1058 if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
1059 !(native_available && prefer_native_over_acpi_video()))
1060 return acpi_backlight_video;
1061
1062 /* Use native if available */
1063 if (native_available)
1064 return acpi_backlight_native;
1065
1066 /*
1067 * The vendor specific BIOS interfaces are only necessary for
1068 * laptops from before ~2008.
1069 *
1070 * For laptops from ~2008 till ~2023 this point is never reached
1071 * because on those (video_caps & ACPI_VIDEO_BACKLIGHT) above is true.
1072 *
1073 * Laptops from after ~2023 no longer support ACPI_VIDEO_BACKLIGHT,
1074 * if this point is reached on those, this likely means that
1075 * the GPU kms driver which sets native_available has not loaded yet.
1076 *
1077 * Returning acpi_backlight_vendor in this case is known to sometimes
1078 * cause a non working vendor specific /sys/class/backlight device to
1079 * get registered.
1080 *
1081 * Return acpi_backlight_none on laptops with ACPI tables written
1082 * for Windows 8 (laptops from after ~2012) to avoid this problem.
1083 */
1084 if (acpi_osi_is_win8())
1085 return acpi_backlight_none;
1086
1087 /* No ACPI video/native (old hw), use vendor specific fw methods. */
1088 return acpi_backlight_vendor;
1089}
1090EXPORT_SYMBOL(__acpi_video_get_backlight_type);