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