video_detect.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  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. /* https://gitlab.freedesktop.org/drm/amd/-/issues/4512 */
  927. {
  928. .callback = video_detect_force_native,
  929. .matches = {
  930. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  931. DMI_MATCH(DMI_PRODUCT_NAME, "82K8"),
  932. },
  933. },
  934. { },
  935. };
  936. static bool google_cros_ec_present(void)
  937. {
  938. return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
  939. }
  940. /*
  941. * Windows 8 and newer no longer use the ACPI video interface, so it often
  942. * does not work. So on win8+ systems prefer native brightness control.
  943. * Chromebooks should always prefer native backlight control.
  944. */
  945. static bool prefer_native_over_acpi_video(void)
  946. {
  947. return acpi_osi_is_win8() || google_cros_ec_present();
  948. }
  949. /*
  950. * Determine which type of backlight interface to use on this system,
  951. * First check cmdline, then dmi quirks, then do autodetect.
  952. */
  953. enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect)
  954. {
  955. static DEFINE_MUTEX(init_mutex);
  956. static bool nvidia_wmi_ec_present;
  957. static bool apple_gmux_present;
  958. static bool dell_uart_present;
  959. static bool native_available;
  960. static bool init_done;
  961. static long video_caps;
  962. /* Parse cmdline, dmi and acpi only once */
  963. mutex_lock(&init_mutex);
  964. if (!init_done) {
  965. acpi_video_parse_cmdline();
  966. dmi_check_system(video_detect_dmi_table);
  967. acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
  968. ACPI_UINT32_MAX, find_video, NULL,
  969. &video_caps, NULL);
  970. nvidia_wmi_ec_present = nvidia_wmi_ec_supported();
  971. apple_gmux_present = apple_gmux_detect(NULL, NULL);
  972. dell_uart_present = acpi_dev_present("DELL0501", NULL, -1);
  973. init_done = true;
  974. }
  975. if (native)
  976. native_available = true;
  977. mutex_unlock(&init_mutex);
  978. if (auto_detect)
  979. *auto_detect = false;
  980. /*
  981. * The below heuristics / detection steps are in order of descending
  982. * presedence. The commandline takes presedence over anything else.
  983. */
  984. if (acpi_backlight_cmdline != acpi_backlight_undef)
  985. return acpi_backlight_cmdline;
  986. /* DMI quirks override any autodetection. */
  987. if (acpi_backlight_dmi != acpi_backlight_undef)
  988. return acpi_backlight_dmi;
  989. if (auto_detect)
  990. *auto_detect = true;
  991. /* Special cases such as nvidia_wmi_ec and apple gmux. */
  992. if (nvidia_wmi_ec_present)
  993. return acpi_backlight_nvidia_wmi_ec;
  994. if (apple_gmux_present)
  995. return acpi_backlight_apple_gmux;
  996. if (dell_uart_present)
  997. return acpi_backlight_dell_uart;
  998. /* Use ACPI video if available, except when native should be preferred. */
  999. if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
  1000. !(native_available && prefer_native_over_acpi_video()))
  1001. return acpi_backlight_video;
  1002. /* Use native if available */
  1003. if (native_available)
  1004. return acpi_backlight_native;
  1005. /*
  1006. * The vendor specific BIOS interfaces are only necessary for
  1007. * laptops from before ~2008.
  1008. *
  1009. * For laptops from ~2008 till ~2023 this point is never reached
  1010. * because on those (video_caps & ACPI_VIDEO_BACKLIGHT) above is true.
  1011. *
  1012. * Laptops from after ~2023 no longer support ACPI_VIDEO_BACKLIGHT,
  1013. * if this point is reached on those, this likely means that
  1014. * the GPU kms driver which sets native_available has not loaded yet.
  1015. *
  1016. * Returning acpi_backlight_vendor in this case is known to sometimes
  1017. * cause a non working vendor specific /sys/class/backlight device to
  1018. * get registered.
  1019. *
  1020. * Return acpi_backlight_none on laptops with ACPI tables written
  1021. * for Windows 8 (laptops from after ~2012) to avoid this problem.
  1022. */
  1023. if (acpi_osi_is_win8())
  1024. return acpi_backlight_none;
  1025. /* No ACPI video/native (old hw), use vendor specific fw methods. */
  1026. return acpi_backlight_vendor;
  1027. }
  1028. EXPORT_SYMBOL(__acpi_video_get_backlight_type);