video_detect.c 29 KB

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