2 * Copyright (C) 2015 Red Hat Inc.
3 * Hans de Goede <hdegoede@redhat.com>
4 * Copyright (C) 2008 SuSE Linux Products GmbH
5 * Thomas Renninger <trenn@suse.de>
7 * May be copied or modified under the terms of the GNU General Public License
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
14 * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B)
15 * are available, video.ko should be used to handle the device.
17 * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop,
18 * sony_acpi,... can take care about backlight brightness.
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.
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.
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>
42 static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef;
43 static enum acpi_backlight_type acpi_backlight_dmi = acpi_backlight_undef;
45 static void acpi_video_parse_cmdline(void)
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("none", acpi_video_backlight_string))
58 acpi_backlight_cmdline = acpi_backlight_none;
62 find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
64 struct acpi_device *acpi_dev = acpi_fetch_acpi_dev(handle);
68 static const struct acpi_device_id video_ids[] = {
73 if (acpi_dev && !acpi_match_device_ids(acpi_dev, video_ids)) {
74 dev = acpi_get_pci_dev(handle);
78 *cap |= acpi_is_video_device(handle);
83 /* This depends on ACPI_WMI which is X86 only */
85 static bool nvidia_wmi_ec_supported(void)
87 struct wmi_brightness_args args = {
88 .mode = WMI_BRIGHTNESS_MODE_GET,
92 struct acpi_buffer buf = { (acpi_size)sizeof(args), &args };
95 status = wmi_evaluate_method(WMI_BRIGHTNESS_GUID, 0,
96 WMI_BRIGHTNESS_METHOD_SOURCE, &buf, &buf);
97 if (ACPI_FAILURE(status))
101 * If brightness is handled by the EC then nvidia-wmi-ec-backlight
102 * should be used, else the GPU driver(s) should be used.
104 return args.ret == WMI_BRIGHTNESS_SOURCE_EC;
107 static bool nvidia_wmi_ec_supported(void)
113 static bool apple_gmux_backlight_present(void)
115 struct acpi_device *adev;
118 adev = acpi_dev_get_first_match_dev(GMUX_ACPI_HID, NULL, -1);
122 dev = acpi_get_first_physical_node(adev);
127 * drivers/platform/x86/apple-gmux.c only supports old style
128 * Apple GMUX with an IO-resource.
130 return pnp_get_resource(to_pnp_dev(dev), IORESOURCE_IO, 0) != NULL;
133 /* Force to use vendor driver when the ACPI device is known to be
135 static int video_detect_force_vendor(const struct dmi_system_id *d)
137 acpi_backlight_dmi = acpi_backlight_vendor;
141 static int video_detect_force_video(const struct dmi_system_id *d)
143 acpi_backlight_dmi = acpi_backlight_video;
147 static int video_detect_force_native(const struct dmi_system_id *d)
149 acpi_backlight_dmi = acpi_backlight_native;
153 static int video_detect_force_none(const struct dmi_system_id *d)
155 acpi_backlight_dmi = acpi_backlight_none;
159 static const struct dmi_system_id video_detect_dmi_table[] = {
161 * Models which should use the vendor backlight interface,
162 * because of broken ACPI video backlight control.
165 /* https://bugzilla.redhat.com/show_bug.cgi?id=1128309 */
166 .callback = video_detect_force_vendor,
169 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
170 DMI_MATCH(DMI_PRODUCT_NAME, "KAV80"),
174 .callback = video_detect_force_vendor,
177 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
178 DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"),
182 .callback = video_detect_force_vendor,
185 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
186 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
190 .callback = video_detect_force_vendor,
193 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
194 DMI_MATCH(DMI_PRODUCT_NAME, "X55U"),
198 .callback = video_detect_force_vendor,
201 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
202 DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
206 .callback = video_detect_force_vendor,
209 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
210 DMI_MATCH(DMI_PRODUCT_NAME, "X401U"),
214 .callback = video_detect_force_vendor,
217 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
218 DMI_MATCH(DMI_PRODUCT_NAME, "X501U"),
222 .callback = video_detect_force_vendor,
225 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
226 DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
230 .callback = video_detect_force_vendor,
231 /* Samsung N150/N210/N220 */
233 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
234 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"),
235 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"),
239 .callback = video_detect_force_vendor,
240 /* Samsung NF110/NF210/NF310 */
242 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
243 DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"),
244 DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"),
248 .callback = video_detect_force_vendor,
251 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
252 DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"),
253 DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
257 .callback = video_detect_force_vendor,
258 /* Xiaomi Mi Pad 2 */
260 DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"),
261 DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"),
266 * Models which should use the vendor backlight interface,
267 * because of broken native backlight control.
270 .callback = video_detect_force_vendor,
271 /* Sony Vaio PCG-FRV35 */
273 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
274 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-FRV35"),
279 * Toshiba models with Transflective display, these need to use
280 * the toshiba_acpi vendor driver for proper Transflective handling.
283 .callback = video_detect_force_vendor,
285 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
286 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R500"),
290 .callback = video_detect_force_vendor,
292 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
293 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R600"),
298 * These models have a working acpi_video backlight control, and using
299 * native backlight causes a regression where backlight does not work
300 * when userspace is not handling brightness key events. Disable
301 * native_backlight on these to fix this:
302 * https://bugzilla.kernel.org/show_bug.cgi?id=81691
305 .callback = video_detect_force_video,
308 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
309 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T420"),
313 .callback = video_detect_force_video,
316 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
317 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"),
321 .callback = video_detect_force_video,
324 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
325 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
329 .callback = video_detect_force_video,
332 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
333 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"),
337 /* The native backlight controls do not work on some older machines */
339 /* https://bugs.freedesktop.org/show_bug.cgi?id=81515 */
340 .callback = video_detect_force_video,
341 /* HP ENVY 15 Notebook */
343 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
344 DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"),
348 .callback = video_detect_force_video,
349 /* SAMSUNG 870Z5E/880Z5E/680Z5E */
351 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
352 DMI_MATCH(DMI_PRODUCT_NAME, "870Z5E/880Z5E/680Z5E"),
356 .callback = video_detect_force_video,
357 /* SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V */
359 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
360 DMI_MATCH(DMI_PRODUCT_NAME,
361 "370R4E/370R4V/370R5E/3570RE/370R5V"),
365 /* https://bugzilla.redhat.com/show_bug.cgi?id=1186097 */
366 .callback = video_detect_force_video,
367 /* SAMSUNG 3570R/370R/470R/450R/510R/4450RV */
369 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
370 DMI_MATCH(DMI_PRODUCT_NAME,
371 "3570R/370R/470R/450R/510R/4450RV"),
375 /* https://bugzilla.redhat.com/show_bug.cgi?id=1557060 */
376 .callback = video_detect_force_video,
379 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
380 DMI_MATCH(DMI_PRODUCT_NAME, "670Z5E"),
384 /* https://bugzilla.redhat.com/show_bug.cgi?id=1094948 */
385 .callback = video_detect_force_video,
386 /* SAMSUNG 730U3E/740U3E */
388 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
389 DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"),
393 /* https://bugs.freedesktop.org/show_bug.cgi?id=87286 */
394 .callback = video_detect_force_video,
395 /* SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D */
397 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
398 DMI_MATCH(DMI_PRODUCT_NAME,
399 "900X3C/900X3D/900X3E/900X4C/900X4D"),
403 /* https://bugzilla.redhat.com/show_bug.cgi?id=1272633 */
404 .callback = video_detect_force_video,
405 /* Dell XPS14 L421X */
407 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
408 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
412 /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */
413 .callback = video_detect_force_video,
414 /* Dell XPS15 L521X */
416 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
417 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
421 /* https://bugzilla.kernel.org/show_bug.cgi?id=108971 */
422 .callback = video_detect_force_video,
423 /* SAMSUNG 530U4E/540U4E */
425 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
426 DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"),
429 /* https://bugs.launchpad.net/bugs/1894667 */
431 .callback = video_detect_force_video,
432 /* HP 635 Notebook */
434 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
435 DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"),
439 /* Non win8 machines which need native backlight nevertheless */
441 /* https://bugzilla.redhat.com/show_bug.cgi?id=1201530 */
442 .callback = video_detect_force_native,
443 /* Lenovo Ideapad S405 */
445 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
446 DMI_MATCH(DMI_BOARD_NAME, "Lenovo IdeaPad S405"),
450 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
451 .callback = video_detect_force_native,
452 /* Lenovo Ideapad Z570 */
454 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
455 DMI_MATCH(DMI_PRODUCT_NAME, "102434U"),
459 .callback = video_detect_force_native,
462 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
463 DMI_MATCH(DMI_PRODUCT_NAME, "81FS"),
467 .callback = video_detect_force_native,
470 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
471 DMI_MATCH(DMI_PRODUCT_NAME, "82BK"),
475 /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
476 .callback = video_detect_force_native,
477 /* Apple MacBook Pro 12,1 */
479 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
480 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"),
484 .callback = video_detect_force_native,
485 /* Dell Inspiron N4010 */
487 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
488 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N4010"),
492 .callback = video_detect_force_native,
493 /* Dell Vostro V131 */
495 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
496 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
500 /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */
501 .callback = video_detect_force_native,
502 /* Dell XPS 17 L702X */
504 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
505 DMI_MATCH(DMI_PRODUCT_NAME, "Dell System XPS L702X"),
509 .callback = video_detect_force_native,
510 /* Dell Precision 7510 */
512 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
513 DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"),
517 .callback = video_detect_force_native,
518 /* Acer Aspire 5738z */
520 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
521 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
522 DMI_MATCH(DMI_BOARD_NAME, "JV50"),
526 /* https://bugzilla.redhat.com/show_bug.cgi?id=1012674 */
527 .callback = video_detect_force_native,
528 /* Acer Aspire 5741 */
530 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
531 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"),
535 /* https://bugzilla.kernel.org/show_bug.cgi?id=42993 */
536 .callback = video_detect_force_native,
537 /* Acer Aspire 5750 */
539 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
540 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"),
544 /* https://bugzilla.kernel.org/show_bug.cgi?id=42833 */
545 .callback = video_detect_force_native,
546 /* Acer Extensa 5235 */
548 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
549 DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5235"),
553 .callback = video_detect_force_native,
554 /* Acer TravelMate 4750 */
556 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
557 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4750"),
561 /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */
562 .callback = video_detect_force_native,
563 /* Acer TravelMate 5735Z */
565 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
566 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"),
567 DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"),
571 /* https://bugzilla.kernel.org/show_bug.cgi?id=36322 */
572 .callback = video_detect_force_native,
573 /* Acer TravelMate 5760 */
575 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
576 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5760"),
580 .callback = video_detect_force_native,
581 /* ASUSTeK COMPUTER INC. GA401 */
583 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
584 DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
588 .callback = video_detect_force_native,
589 /* ASUSTeK COMPUTER INC. GA502 */
591 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
592 DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
596 .callback = video_detect_force_native,
597 /* ASUSTeK COMPUTER INC. GA503 */
599 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
600 DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
604 .callback = video_detect_force_native,
607 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
608 DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
612 .callback = video_detect_force_native,
615 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
616 DMI_MATCH(DMI_PRODUCT_NAME, "N150P"),
617 DMI_MATCH(DMI_BOARD_NAME, "N150P"),
621 .callback = video_detect_force_native,
622 /* Samsung N145P/N250P/N260P */
624 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
625 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
626 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
630 .callback = video_detect_force_native,
633 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
634 DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
635 DMI_MATCH(DMI_BOARD_NAME, "N250P"),
639 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
640 .callback = video_detect_force_native,
641 /* Sony Vaio VPCEH3U1E */
643 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
644 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
648 .callback = video_detect_force_native,
649 /* Sony Vaio VPCY11S1E */
651 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
652 DMI_MATCH(DMI_PRODUCT_NAME, "VPCY11S1E"),
657 * These Toshibas have a broken acpi-video interface for brightness
658 * control. They also have an issue where the panel is off after
659 * suspend until a special firmware call is made to turn it back
660 * on. This is handled by the toshiba_acpi kernel module, so that
661 * module must be enabled for these models to work correctly.
664 /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
665 .callback = video_detect_force_native,
666 /* Toshiba Portégé R700 */
668 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
669 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"),
673 /* Portégé: https://bugs.freedesktop.org/show_bug.cgi?id=82634 */
674 /* Satellite: https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
675 .callback = video_detect_force_native,
676 /* Toshiba Satellite/Portégé R830 */
678 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
679 DMI_MATCH(DMI_PRODUCT_NAME, "R830"),
683 .callback = video_detect_force_native,
684 /* Toshiba Satellite/Portégé Z830 */
686 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
687 DMI_MATCH(DMI_PRODUCT_NAME, "Z830"),
692 * Models which have nvidia-ec-wmi support, but should not use it.
693 * Note this indicates a likely firmware bug on these models and should
694 * be revisited if/when Linux gets support for dynamic mux mode.
697 .callback = video_detect_force_native,
700 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
701 DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
706 * Desktops which falsely report a backlight and which our heuristics
707 * for this do not catch.
710 .callback = video_detect_force_none,
711 /* Dell OptiPlex 9020M */
713 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
714 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"),
718 .callback = video_detect_force_none,
719 /* GIGABYTE GB-BXBT-2807 */
721 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
722 DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"),
726 .callback = video_detect_force_none,
729 DMI_MATCH(DMI_SYS_VENDOR, "MSI"),
730 DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"),
736 static bool google_cros_ec_present(void)
738 return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
742 * Windows 8 and newer no longer use the ACPI video interface, so it often
743 * does not work. So on win8+ systems prefer native brightness control.
744 * Chromebooks should always prefer native backlight control.
746 static bool prefer_native_over_acpi_video(void)
748 return acpi_osi_is_win8() || google_cros_ec_present();
752 * Determine which type of backlight interface to use on this system,
753 * First check cmdline, then dmi quirks, then do autodetect.
755 static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
757 static DEFINE_MUTEX(init_mutex);
758 static bool nvidia_wmi_ec_present;
759 static bool native_available;
760 static bool init_done;
761 static long video_caps;
763 /* Parse cmdline, dmi and acpi only once */
764 mutex_lock(&init_mutex);
766 acpi_video_parse_cmdline();
767 dmi_check_system(video_detect_dmi_table);
768 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
769 ACPI_UINT32_MAX, find_video, NULL,
771 nvidia_wmi_ec_present = nvidia_wmi_ec_supported();
775 native_available = true;
776 mutex_unlock(&init_mutex);
779 * The below heuristics / detection steps are in order of descending
780 * presedence. The commandline takes presedence over anything else.
782 if (acpi_backlight_cmdline != acpi_backlight_undef)
783 return acpi_backlight_cmdline;
785 /* DMI quirks override any autodetection. */
786 if (acpi_backlight_dmi != acpi_backlight_undef)
787 return acpi_backlight_dmi;
789 /* Special cases such as nvidia_wmi_ec and apple gmux. */
790 if (nvidia_wmi_ec_present)
791 return acpi_backlight_nvidia_wmi_ec;
793 if (apple_gmux_backlight_present())
794 return acpi_backlight_apple_gmux;
796 /* Use ACPI video if available, except when native should be preferred. */
797 if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
798 !(native_available && prefer_native_over_acpi_video()))
799 return acpi_backlight_video;
801 /* Use native if available */
802 if (native_available)
803 return acpi_backlight_native;
805 /* No ACPI video/native (old hw), use vendor specific fw methods. */
806 return acpi_backlight_vendor;
809 enum acpi_backlight_type acpi_video_get_backlight_type(void)
811 return __acpi_video_get_backlight_type(false);
813 EXPORT_SYMBOL(acpi_video_get_backlight_type);
815 bool acpi_video_backlight_use_native(void)
817 return __acpi_video_get_backlight_type(true) == acpi_backlight_native;
819 EXPORT_SYMBOL(acpi_video_backlight_use_native);