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("none", acpi_video_backlight_string)) 58 acpi_backlight_cmdline = acpi_backlight_none; 59 } 60 61 static acpi_status 62 find_video(acpi_handle handle, u32 lvl, void *context, void **rv) 63 { 64 struct acpi_device *acpi_dev = acpi_fetch_acpi_dev(handle); 65 long *cap = context; 66 struct pci_dev *dev; 67 68 static const struct acpi_device_id video_ids[] = { 69 {ACPI_VIDEO_HID, 0}, 70 {"", 0}, 71 }; 72 73 if (acpi_dev && !acpi_match_device_ids(acpi_dev, video_ids)) { 74 dev = acpi_get_pci_dev(handle); 75 if (!dev) 76 return AE_OK; 77 pci_dev_put(dev); 78 *cap |= acpi_is_video_device(handle); 79 } 80 return AE_OK; 81 } 82 83 /* This depends on ACPI_WMI which is X86 only */ 84 #ifdef CONFIG_X86 85 static bool nvidia_wmi_ec_supported(void) 86 { 87 struct wmi_brightness_args args = { 88 .mode = WMI_BRIGHTNESS_MODE_GET, 89 .val = 0, 90 .ret = 0, 91 }; 92 struct acpi_buffer buf = { (acpi_size)sizeof(args), &args }; 93 acpi_status status; 94 95 status = wmi_evaluate_method(WMI_BRIGHTNESS_GUID, 0, 96 WMI_BRIGHTNESS_METHOD_SOURCE, &buf, &buf); 97 if (ACPI_FAILURE(status)) 98 return false; 99 100 /* 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. 103 */ 104 return args.ret == WMI_BRIGHTNESS_SOURCE_EC; 105 } 106 #else 107 static bool nvidia_wmi_ec_supported(void) 108 { 109 return false; 110 } 111 #endif 112 113 /* Force to use vendor driver when the ACPI device is known to be 114 * buggy */ 115 static int video_detect_force_vendor(const struct dmi_system_id *d) 116 { 117 acpi_backlight_dmi = acpi_backlight_vendor; 118 return 0; 119 } 120 121 static int video_detect_force_video(const struct dmi_system_id *d) 122 { 123 acpi_backlight_dmi = acpi_backlight_video; 124 return 0; 125 } 126 127 static int video_detect_force_native(const struct dmi_system_id *d) 128 { 129 acpi_backlight_dmi = acpi_backlight_native; 130 return 0; 131 } 132 133 static const struct dmi_system_id video_detect_dmi_table[] = { 134 /* 135 * Models which should use the vendor backlight interface, 136 * because of broken ACPI video backlight control. 137 */ 138 { 139 /* https://bugzilla.redhat.com/show_bug.cgi?id=1128309 */ 140 .callback = video_detect_force_vendor, 141 /* Acer KAV80 */ 142 .matches = { 143 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 144 DMI_MATCH(DMI_PRODUCT_NAME, "KAV80"), 145 }, 146 }, 147 { 148 .callback = video_detect_force_vendor, 149 /* Asus UL30VT */ 150 .matches = { 151 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), 152 DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"), 153 }, 154 }, 155 { 156 .callback = video_detect_force_vendor, 157 /* Asus UL30A */ 158 .matches = { 159 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), 160 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), 161 }, 162 }, 163 { 164 .callback = video_detect_force_vendor, 165 /* Asus X55U */ 166 .matches = { 167 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 168 DMI_MATCH(DMI_PRODUCT_NAME, "X55U"), 169 }, 170 }, 171 { 172 /* https://bugs.launchpad.net/bugs/1000146 */ 173 .callback = video_detect_force_vendor, 174 /* Asus X101CH */ 175 .matches = { 176 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 177 DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"), 178 }, 179 }, 180 { 181 .callback = video_detect_force_vendor, 182 /* Asus X401U */ 183 .matches = { 184 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 185 DMI_MATCH(DMI_PRODUCT_NAME, "X401U"), 186 }, 187 }, 188 { 189 .callback = video_detect_force_vendor, 190 /* Asus X501U */ 191 .matches = { 192 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 193 DMI_MATCH(DMI_PRODUCT_NAME, "X501U"), 194 }, 195 }, 196 { 197 /* https://bugs.launchpad.net/bugs/1000146 */ 198 .callback = video_detect_force_vendor, 199 /* Asus 1015CX */ 200 .matches = { 201 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 202 DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"), 203 }, 204 }, 205 { 206 .callback = video_detect_force_vendor, 207 /* Samsung N150/N210/N220 */ 208 .matches = { 209 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 210 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"), 211 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"), 212 }, 213 }, 214 { 215 .callback = video_detect_force_vendor, 216 /* Samsung NF110/NF210/NF310 */ 217 .matches = { 218 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 219 DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"), 220 DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"), 221 }, 222 }, 223 { 224 .callback = video_detect_force_vendor, 225 /* Samsung NC210 */ 226 .matches = { 227 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 228 DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"), 229 DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"), 230 }, 231 }, 232 { 233 .callback = video_detect_force_vendor, 234 /* Xiaomi Mi Pad 2 */ 235 .matches = { 236 DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"), 237 DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"), 238 }, 239 }, 240 241 /* 242 * Models which should use the vendor backlight interface, 243 * because of broken native backlight control. 244 */ 245 { 246 .callback = video_detect_force_vendor, 247 /* Sony Vaio PCG-FRV35 */ 248 .matches = { 249 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 250 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-FRV35"), 251 }, 252 }, 253 254 /* 255 * Toshiba models with Transflective display, these need to use 256 * the toshiba_acpi vendor driver for proper Transflective handling. 257 */ 258 { 259 .callback = video_detect_force_vendor, 260 .matches = { 261 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 262 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R500"), 263 }, 264 }, 265 { 266 .callback = video_detect_force_vendor, 267 .matches = { 268 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 269 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R600"), 270 }, 271 }, 272 273 /* 274 * Models which need acpi_video backlight control where the GPU drivers 275 * do not call acpi_video_register_backlight() because no internal panel 276 * is detected. Typically these are all-in-ones (monitors with builtin 277 * PC) where the panel connection shows up as regular DP instead of eDP. 278 */ 279 { 280 .callback = video_detect_force_video, 281 /* Apple iMac14,1 */ 282 .matches = { 283 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 284 DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,1"), 285 }, 286 }, 287 { 288 .callback = video_detect_force_video, 289 /* Apple iMac14,2 */ 290 .matches = { 291 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 292 DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,2"), 293 }, 294 }, 295 296 /* 297 * Older models with nvidia GPU which need acpi_video backlight 298 * control and where the old nvidia binary driver series does not 299 * call acpi_video_register_backlight(). 300 */ 301 { 302 .callback = video_detect_force_video, 303 /* ThinkPad W530 */ 304 .matches = { 305 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 306 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"), 307 }, 308 }, 309 310 /* 311 * These models have a working acpi_video backlight control, and using 312 * native backlight causes a regression where backlight does not work 313 * when userspace is not handling brightness key events. Disable 314 * native_backlight on these to fix this: 315 * https://bugzilla.kernel.org/show_bug.cgi?id=81691 316 */ 317 { 318 .callback = video_detect_force_video, 319 /* ThinkPad T420 */ 320 .matches = { 321 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 322 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T420"), 323 }, 324 }, 325 { 326 .callback = video_detect_force_video, 327 /* ThinkPad T520 */ 328 .matches = { 329 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 330 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"), 331 }, 332 }, 333 { 334 .callback = video_detect_force_video, 335 /* ThinkPad X201s */ 336 .matches = { 337 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 338 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"), 339 }, 340 }, 341 { 342 .callback = video_detect_force_video, 343 /* ThinkPad X201T */ 344 .matches = { 345 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 346 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"), 347 }, 348 }, 349 350 /* The native backlight controls do not work on some older machines */ 351 { 352 /* https://bugs.freedesktop.org/show_bug.cgi?id=81515 */ 353 .callback = video_detect_force_video, 354 /* HP ENVY 15 Notebook */ 355 .matches = { 356 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 357 DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"), 358 }, 359 }, 360 { 361 .callback = video_detect_force_video, 362 /* SAMSUNG 870Z5E/880Z5E/680Z5E */ 363 .matches = { 364 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 365 DMI_MATCH(DMI_PRODUCT_NAME, "870Z5E/880Z5E/680Z5E"), 366 }, 367 }, 368 { 369 .callback = video_detect_force_video, 370 /* SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V */ 371 .matches = { 372 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 373 DMI_MATCH(DMI_PRODUCT_NAME, 374 "370R4E/370R4V/370R5E/3570RE/370R5V"), 375 }, 376 }, 377 { 378 /* https://bugzilla.redhat.com/show_bug.cgi?id=1186097 */ 379 .callback = video_detect_force_video, 380 /* SAMSUNG 3570R/370R/470R/450R/510R/4450RV */ 381 .matches = { 382 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 383 DMI_MATCH(DMI_PRODUCT_NAME, 384 "3570R/370R/470R/450R/510R/4450RV"), 385 }, 386 }, 387 { 388 /* https://bugzilla.redhat.com/show_bug.cgi?id=1557060 */ 389 .callback = video_detect_force_video, 390 /* SAMSUNG 670Z5E */ 391 .matches = { 392 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 393 DMI_MATCH(DMI_PRODUCT_NAME, "670Z5E"), 394 }, 395 }, 396 { 397 /* https://bugzilla.redhat.com/show_bug.cgi?id=1094948 */ 398 .callback = video_detect_force_video, 399 /* SAMSUNG 730U3E/740U3E */ 400 .matches = { 401 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 402 DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"), 403 }, 404 }, 405 { 406 /* https://bugs.freedesktop.org/show_bug.cgi?id=87286 */ 407 .callback = video_detect_force_video, 408 /* SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D */ 409 .matches = { 410 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 411 DMI_MATCH(DMI_PRODUCT_NAME, 412 "900X3C/900X3D/900X3E/900X4C/900X4D"), 413 }, 414 }, 415 { 416 /* https://bugzilla.redhat.com/show_bug.cgi?id=1272633 */ 417 .callback = video_detect_force_video, 418 /* Dell XPS14 L421X */ 419 .matches = { 420 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 421 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"), 422 }, 423 }, 424 { 425 /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */ 426 .callback = video_detect_force_video, 427 /* Dell XPS15 L521X */ 428 .matches = { 429 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 430 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"), 431 }, 432 }, 433 { 434 /* https://bugzilla.kernel.org/show_bug.cgi?id=108971 */ 435 .callback = video_detect_force_video, 436 /* SAMSUNG 530U4E/540U4E */ 437 .matches = { 438 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 439 DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"), 440 }, 441 }, 442 { 443 /* https://bugs.launchpad.net/bugs/1894667 */ 444 .callback = video_detect_force_video, 445 /* HP 635 Notebook */ 446 .matches = { 447 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 448 DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"), 449 }, 450 }, 451 452 /* Non win8 machines which need native backlight nevertheless */ 453 { 454 /* https://bugzilla.redhat.com/show_bug.cgi?id=1201530 */ 455 .callback = video_detect_force_native, 456 /* Lenovo Ideapad S405 */ 457 .matches = { 458 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 459 DMI_MATCH(DMI_BOARD_NAME, "Lenovo IdeaPad S405"), 460 }, 461 }, 462 { 463 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */ 464 .callback = video_detect_force_native, 465 /* Lenovo Ideapad Z570 */ 466 .matches = { 467 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 468 DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"), 469 }, 470 }, 471 { 472 .callback = video_detect_force_native, 473 /* Lenovo E41-25 */ 474 .matches = { 475 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 476 DMI_MATCH(DMI_PRODUCT_NAME, "81FS"), 477 }, 478 }, 479 { 480 .callback = video_detect_force_native, 481 /* Lenovo E41-45 */ 482 .matches = { 483 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 484 DMI_MATCH(DMI_PRODUCT_NAME, "82BK"), 485 }, 486 }, 487 { 488 /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */ 489 .callback = video_detect_force_native, 490 /* Apple MacBook Pro 12,1 */ 491 .matches = { 492 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 493 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"), 494 }, 495 }, 496 { 497 .callback = video_detect_force_native, 498 /* Dell Inspiron N4010 */ 499 .matches = { 500 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 501 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N4010"), 502 }, 503 }, 504 { 505 .callback = video_detect_force_native, 506 /* Dell Vostro V131 */ 507 .matches = { 508 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 509 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"), 510 }, 511 }, 512 { 513 /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */ 514 .callback = video_detect_force_native, 515 /* Dell XPS 17 L702X */ 516 .matches = { 517 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 518 DMI_MATCH(DMI_PRODUCT_NAME, "Dell System XPS L702X"), 519 }, 520 }, 521 { 522 .callback = video_detect_force_native, 523 /* Dell Precision 7510 */ 524 .matches = { 525 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 526 DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"), 527 }, 528 }, 529 { 530 .callback = video_detect_force_native, 531 /* Acer Aspire 3830TG */ 532 .matches = { 533 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 534 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3830TG"), 535 }, 536 }, 537 { 538 .callback = video_detect_force_native, 539 /* Acer Aspire 4810T */ 540 .matches = { 541 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 542 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 4810T"), 543 }, 544 }, 545 { 546 .callback = video_detect_force_native, 547 /* Acer Aspire 5738z */ 548 .matches = { 549 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 550 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"), 551 DMI_MATCH(DMI_BOARD_NAME, "JV50"), 552 }, 553 }, 554 { 555 /* https://bugzilla.redhat.com/show_bug.cgi?id=1012674 */ 556 .callback = video_detect_force_native, 557 /* Acer Aspire 5741 */ 558 .matches = { 559 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"), 560 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"), 561 }, 562 }, 563 { 564 /* https://bugzilla.kernel.org/show_bug.cgi?id=42993 */ 565 .callback = video_detect_force_native, 566 /* Acer Aspire 5750 */ 567 .matches = { 568 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"), 569 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"), 570 }, 571 }, 572 { 573 /* https://bugzilla.kernel.org/show_bug.cgi?id=42833 */ 574 .callback = video_detect_force_native, 575 /* Acer Extensa 5235 */ 576 .matches = { 577 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"), 578 DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5235"), 579 }, 580 }, 581 { 582 .callback = video_detect_force_native, 583 /* Acer TravelMate 4750 */ 584 .matches = { 585 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"), 586 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4750"), 587 }, 588 }, 589 { 590 /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */ 591 .callback = video_detect_force_native, 592 /* Acer TravelMate 5735Z */ 593 .matches = { 594 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 595 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"), 596 DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"), 597 }, 598 }, 599 { 600 /* https://bugzilla.kernel.org/show_bug.cgi?id=36322 */ 601 .callback = video_detect_force_native, 602 /* Acer TravelMate 5760 */ 603 .matches = { 604 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"), 605 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5760"), 606 }, 607 }, 608 { 609 .callback = video_detect_force_native, 610 /* ASUSTeK COMPUTER INC. GA401 */ 611 .matches = { 612 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 613 DMI_MATCH(DMI_PRODUCT_NAME, "GA401"), 614 }, 615 }, 616 { 617 .callback = video_detect_force_native, 618 /* ASUSTeK COMPUTER INC. GA502 */ 619 .matches = { 620 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 621 DMI_MATCH(DMI_PRODUCT_NAME, "GA502"), 622 }, 623 }, 624 { 625 .callback = video_detect_force_native, 626 /* ASUSTeK COMPUTER INC. GA503 */ 627 .matches = { 628 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 629 DMI_MATCH(DMI_PRODUCT_NAME, "GA503"), 630 }, 631 }, 632 { 633 .callback = video_detect_force_native, 634 /* Asus U46E */ 635 .matches = { 636 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), 637 DMI_MATCH(DMI_PRODUCT_NAME, "U46E"), 638 }, 639 }, 640 { 641 .callback = video_detect_force_native, 642 /* Asus UX303UB */ 643 .matches = { 644 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 645 DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"), 646 }, 647 }, 648 { 649 .callback = video_detect_force_native, 650 /* HP EliteBook 8460p */ 651 .matches = { 652 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 653 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8460p"), 654 }, 655 }, 656 { 657 .callback = video_detect_force_native, 658 /* HP Pavilion g6-1d80nr / B4U19UA */ 659 .matches = { 660 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 661 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion g6 Notebook PC"), 662 DMI_MATCH(DMI_PRODUCT_SKU, "B4U19UA"), 663 }, 664 }, 665 { 666 .callback = video_detect_force_native, 667 /* Samsung N150P */ 668 .matches = { 669 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 670 DMI_MATCH(DMI_PRODUCT_NAME, "N150P"), 671 DMI_MATCH(DMI_BOARD_NAME, "N150P"), 672 }, 673 }, 674 { 675 .callback = video_detect_force_native, 676 /* Samsung N145P/N250P/N260P */ 677 .matches = { 678 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 679 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"), 680 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"), 681 }, 682 }, 683 { 684 .callback = video_detect_force_native, 685 /* Samsung N250P */ 686 .matches = { 687 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 688 DMI_MATCH(DMI_PRODUCT_NAME, "N250P"), 689 DMI_MATCH(DMI_BOARD_NAME, "N250P"), 690 }, 691 }, 692 { 693 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */ 694 .callback = video_detect_force_native, 695 /* Sony Vaio VPCEH3U1E */ 696 .matches = { 697 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 698 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"), 699 }, 700 }, 701 { 702 .callback = video_detect_force_native, 703 /* Sony Vaio VPCY11S1E */ 704 .matches = { 705 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 706 DMI_MATCH(DMI_PRODUCT_NAME, "VPCY11S1E"), 707 }, 708 }, 709 710 /* 711 * These Toshibas have a broken acpi-video interface for brightness 712 * control. They also have an issue where the panel is off after 713 * suspend until a special firmware call is made to turn it back 714 * on. This is handled by the toshiba_acpi kernel module, so that 715 * module must be enabled for these models to work correctly. 716 */ 717 { 718 /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */ 719 .callback = video_detect_force_native, 720 /* Toshiba Portégé R700 */ 721 .matches = { 722 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 723 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"), 724 }, 725 }, 726 { 727 /* Portégé: https://bugs.freedesktop.org/show_bug.cgi?id=82634 */ 728 /* Satellite: https://bugzilla.kernel.org/show_bug.cgi?id=21012 */ 729 .callback = video_detect_force_native, 730 /* Toshiba Satellite/Portégé R830 */ 731 .matches = { 732 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 733 DMI_MATCH(DMI_PRODUCT_NAME, "R830"), 734 }, 735 }, 736 { 737 .callback = video_detect_force_native, 738 /* Toshiba Satellite/Portégé Z830 */ 739 .matches = { 740 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 741 DMI_MATCH(DMI_PRODUCT_NAME, "Z830"), 742 }, 743 }, 744 745 /* 746 * Models which have nvidia-ec-wmi support, but should not use it. 747 * Note this indicates a likely firmware bug on these models and should 748 * be revisited if/when Linux gets support for dynamic mux mode. 749 */ 750 { 751 .callback = video_detect_force_native, 752 /* Dell G15 5515 */ 753 .matches = { 754 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 755 DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), 756 }, 757 }, 758 { 759 .callback = video_detect_force_native, 760 .matches = { 761 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 762 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 15 3535"), 763 }, 764 }, 765 { }, 766 }; 767 768 static bool google_cros_ec_present(void) 769 { 770 return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C"); 771 } 772 773 /* 774 * Windows 8 and newer no longer use the ACPI video interface, so it often 775 * does not work. So on win8+ systems prefer native brightness control. 776 * Chromebooks should always prefer native backlight control. 777 */ 778 static bool prefer_native_over_acpi_video(void) 779 { 780 return acpi_osi_is_win8() || google_cros_ec_present(); 781 } 782 783 /* 784 * Determine which type of backlight interface to use on this system, 785 * First check cmdline, then dmi quirks, then do autodetect. 786 */ 787 enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect) 788 { 789 static DEFINE_MUTEX(init_mutex); 790 static bool nvidia_wmi_ec_present; 791 static bool apple_gmux_present; 792 static bool native_available; 793 static bool init_done; 794 static long video_caps; 795 796 /* Parse cmdline, dmi and acpi only once */ 797 mutex_lock(&init_mutex); 798 if (!init_done) { 799 acpi_video_parse_cmdline(); 800 dmi_check_system(video_detect_dmi_table); 801 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 802 ACPI_UINT32_MAX, find_video, NULL, 803 &video_caps, NULL); 804 nvidia_wmi_ec_present = nvidia_wmi_ec_supported(); 805 apple_gmux_present = apple_gmux_detect(NULL, NULL); 806 init_done = true; 807 } 808 if (native) 809 native_available = true; 810 mutex_unlock(&init_mutex); 811 812 if (auto_detect) 813 *auto_detect = false; 814 815 /* 816 * The below heuristics / detection steps are in order of descending 817 * presedence. The commandline takes presedence over anything else. 818 */ 819 if (acpi_backlight_cmdline != acpi_backlight_undef) 820 return acpi_backlight_cmdline; 821 822 /* DMI quirks override any autodetection. */ 823 if (acpi_backlight_dmi != acpi_backlight_undef) 824 return acpi_backlight_dmi; 825 826 if (auto_detect) 827 *auto_detect = true; 828 829 /* Special cases such as nvidia_wmi_ec and apple gmux. */ 830 if (nvidia_wmi_ec_present) 831 return acpi_backlight_nvidia_wmi_ec; 832 833 if (apple_gmux_present) 834 return acpi_backlight_apple_gmux; 835 836 /* Use ACPI video if available, except when native should be preferred. */ 837 if ((video_caps & ACPI_VIDEO_BACKLIGHT) && 838 !(native_available && prefer_native_over_acpi_video())) 839 return acpi_backlight_video; 840 841 /* Use native if available */ 842 if (native_available) 843 return acpi_backlight_native; 844 845 /* No ACPI video/native (old hw), use vendor specific fw methods. */ 846 return acpi_backlight_vendor; 847 } 848 EXPORT_SYMBOL(__acpi_video_get_backlight_type); 849