xref: /openbmc/linux/drivers/acpi/video_detect.c (revision 2a598d0b)
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 	 * These models have a working acpi_video backlight control, and using
298 	 * native backlight causes a regression where backlight does not work
299 	 * when userspace is not handling brightness key events. Disable
300 	 * native_backlight on these to fix this:
301 	 * https://bugzilla.kernel.org/show_bug.cgi?id=81691
302 	 */
303 	{
304 	 .callback = video_detect_force_video,
305 	 /* ThinkPad T420 */
306 	 .matches = {
307 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
308 		DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T420"),
309 		},
310 	},
311 	{
312 	 .callback = video_detect_force_video,
313 	 /* ThinkPad T520 */
314 	 .matches = {
315 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
316 		DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"),
317 		},
318 	},
319 	{
320 	 .callback = video_detect_force_video,
321 	 /* ThinkPad X201s */
322 	 .matches = {
323 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
324 		DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
325 		},
326 	},
327 	{
328 	 .callback = video_detect_force_video,
329 	 /* ThinkPad X201T */
330 	 .matches = {
331 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
332 		DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"),
333 		},
334 	},
335 
336 	/* The native backlight controls do not work on some older machines */
337 	{
338 	 /* https://bugs.freedesktop.org/show_bug.cgi?id=81515 */
339 	 .callback = video_detect_force_video,
340 	 /* HP ENVY 15 Notebook */
341 	 .matches = {
342 		DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
343 		DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"),
344 		},
345 	},
346 	{
347 	 .callback = video_detect_force_video,
348 	 /* SAMSUNG 870Z5E/880Z5E/680Z5E */
349 	 .matches = {
350 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
351 		DMI_MATCH(DMI_PRODUCT_NAME, "870Z5E/880Z5E/680Z5E"),
352 		},
353 	},
354 	{
355 	 .callback = video_detect_force_video,
356 	 /* SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V */
357 	 .matches = {
358 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
359 		DMI_MATCH(DMI_PRODUCT_NAME,
360 			  "370R4E/370R4V/370R5E/3570RE/370R5V"),
361 		},
362 	},
363 	{
364 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1186097 */
365 	 .callback = video_detect_force_video,
366 	 /* SAMSUNG 3570R/370R/470R/450R/510R/4450RV */
367 	 .matches = {
368 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
369 		DMI_MATCH(DMI_PRODUCT_NAME,
370 			  "3570R/370R/470R/450R/510R/4450RV"),
371 		},
372 	},
373 	{
374 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1557060 */
375 	 .callback = video_detect_force_video,
376 	 /* SAMSUNG 670Z5E */
377 	 .matches = {
378 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
379 		DMI_MATCH(DMI_PRODUCT_NAME, "670Z5E"),
380 		},
381 	},
382 	{
383 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1094948 */
384 	 .callback = video_detect_force_video,
385 	 /* SAMSUNG 730U3E/740U3E */
386 	 .matches = {
387 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
388 		DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"),
389 		},
390 	},
391 	{
392 	 /* https://bugs.freedesktop.org/show_bug.cgi?id=87286 */
393 	 .callback = video_detect_force_video,
394 	 /* SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D */
395 	 .matches = {
396 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
397 		DMI_MATCH(DMI_PRODUCT_NAME,
398 			  "900X3C/900X3D/900X3E/900X4C/900X4D"),
399 		},
400 	},
401 	{
402 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1272633 */
403 	 .callback = video_detect_force_video,
404 	 /* Dell XPS14 L421X */
405 	 .matches = {
406 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
407 		DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
408 		},
409 	},
410 	{
411 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */
412 	 .callback = video_detect_force_video,
413 	 /* Dell XPS15 L521X */
414 	 .matches = {
415 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
416 		DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
417 		},
418 	},
419 	{
420 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=108971 */
421 	 .callback = video_detect_force_video,
422 	 /* SAMSUNG 530U4E/540U4E */
423 	 .matches = {
424 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
425 		DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"),
426 		},
427 	},
428 	{
429 	 /* https://bugs.launchpad.net/bugs/1894667 */
430 	 .callback = video_detect_force_video,
431 	 /* HP 635 Notebook */
432 	 .matches = {
433 		DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
434 		DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"),
435 		},
436 	},
437 
438 	/* Non win8 machines which need native backlight nevertheless */
439 	{
440 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1201530 */
441 	 .callback = video_detect_force_native,
442 	 /* Lenovo Ideapad S405 */
443 	 .matches = {
444 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
445 		DMI_MATCH(DMI_BOARD_NAME, "Lenovo IdeaPad S405"),
446 		},
447 	},
448 	{
449 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
450 	 .callback = video_detect_force_native,
451 	 /* Lenovo Ideapad Z570 */
452 	 .matches = {
453 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
454 		DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
455 		},
456 	},
457 	{
458 	 .callback = video_detect_force_native,
459 	 /* Lenovo E41-25 */
460 	 .matches = {
461 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
462 		DMI_MATCH(DMI_PRODUCT_NAME, "81FS"),
463 		},
464 	},
465 	{
466 	 .callback = video_detect_force_native,
467 	 /* Lenovo E41-45 */
468 	 .matches = {
469 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
470 		DMI_MATCH(DMI_PRODUCT_NAME, "82BK"),
471 		},
472 	},
473 	{
474 	 .callback = video_detect_force_native,
475 	 /* Lenovo ThinkPad X131e (3371 AMD version) */
476 	 .matches = {
477 		DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
478 		DMI_MATCH(DMI_PRODUCT_NAME, "3371"),
479 		},
480 	},
481 	{
482 	 .callback = video_detect_force_native,
483 	 /* Apple iMac11,3 */
484 	 .matches = {
485 		DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
486 		DMI_MATCH(DMI_PRODUCT_NAME, "iMac11,3"),
487 		},
488 	},
489 	{
490 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
491 	 .callback = video_detect_force_native,
492 	 /* Apple MacBook Pro 12,1 */
493 	 .matches = {
494 		DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
495 		DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"),
496 		},
497 	},
498 	{
499 	 .callback = video_detect_force_native,
500 	 /* Dell Inspiron N4010 */
501 	 .matches = {
502 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
503 		DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N4010"),
504 		},
505 	},
506 	{
507 	 .callback = video_detect_force_native,
508 	 /* Dell Vostro V131 */
509 	 .matches = {
510 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
511 		DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
512 		},
513 	},
514 	{
515 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */
516 	 .callback = video_detect_force_native,
517 	 /* Dell XPS 17 L702X */
518 	 .matches = {
519 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
520 		DMI_MATCH(DMI_PRODUCT_NAME, "Dell System XPS L702X"),
521 		},
522 	},
523 	{
524 	 .callback = video_detect_force_native,
525 	 /* Dell Precision 7510 */
526 	 .matches = {
527 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
528 		DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"),
529 		},
530 	},
531 	{
532 	 .callback = video_detect_force_native,
533 	 /* Dell Studio 1569 */
534 	 .matches = {
535 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
536 		DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1569"),
537 		},
538 	},
539 	{
540 	 .callback = video_detect_force_native,
541 	 /* Acer Aspire 3830TG */
542 	 .matches = {
543 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
544 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3830TG"),
545 		},
546 	},
547 	{
548 	 .callback = video_detect_force_native,
549 	 /* Acer Aspire 4810T */
550 	 .matches = {
551 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
552 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 4810T"),
553 		},
554 	},
555 	{
556 	 .callback = video_detect_force_native,
557 	 /* Acer Aspire 5738z */
558 	 .matches = {
559 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
560 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
561 		DMI_MATCH(DMI_BOARD_NAME, "JV50"),
562 		},
563 	},
564 	{
565 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1012674 */
566 	 .callback = video_detect_force_native,
567 	 /* Acer Aspire 5741 */
568 	 .matches = {
569 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
570 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"),
571 		},
572 	},
573 	{
574 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=42993 */
575 	 .callback = video_detect_force_native,
576 	 /* Acer Aspire 5750 */
577 	 .matches = {
578 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
579 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"),
580 		},
581 	},
582 	{
583 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=42833 */
584 	 .callback = video_detect_force_native,
585 	 /* Acer Extensa 5235 */
586 	 .matches = {
587 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
588 		DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5235"),
589 		},
590 	},
591 	{
592 	 .callback = video_detect_force_native,
593 	 /* Acer TravelMate 4750 */
594 	 .matches = {
595 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
596 		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4750"),
597 		},
598 	},
599 	{
600 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */
601 	 .callback = video_detect_force_native,
602 	 /* Acer TravelMate 5735Z */
603 	 .matches = {
604 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
605 		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"),
606 		DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"),
607 		},
608 	},
609 	{
610 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=36322 */
611 	 .callback = video_detect_force_native,
612 	 /* Acer TravelMate 5760 */
613 	 .matches = {
614 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
615 		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5760"),
616 		},
617 	},
618 	{
619 	 .callback = video_detect_force_native,
620 	 /* ASUSTeK COMPUTER INC. GA401 */
621 	 .matches = {
622 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
623 		DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
624 		},
625 	},
626 	{
627 	 .callback = video_detect_force_native,
628 	 /* ASUSTeK COMPUTER INC. GA502 */
629 	 .matches = {
630 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
631 		DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
632 		},
633 	},
634 	{
635 	 .callback = video_detect_force_native,
636 	 /* ASUSTeK COMPUTER INC. GA503 */
637 	 .matches = {
638 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
639 		DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
640 		},
641 	},
642 	{
643 	 .callback = video_detect_force_native,
644 	 /* Asus U46E */
645 	 .matches = {
646 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
647 		DMI_MATCH(DMI_PRODUCT_NAME, "U46E"),
648 		},
649 	},
650 	{
651 	 .callback = video_detect_force_native,
652 	 /* Asus UX303UB */
653 	 .matches = {
654 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
655 		DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
656 		},
657 	},
658 	{
659 	 .callback = video_detect_force_native,
660 	 /* HP EliteBook 8460p */
661 	 .matches = {
662 		DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
663 		DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8460p"),
664 		},
665 	},
666 	{
667 	 .callback = video_detect_force_native,
668 	 /* HP Pavilion g6-1d80nr / B4U19UA */
669 	 .matches = {
670 		DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
671 		DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion g6 Notebook PC"),
672 		DMI_MATCH(DMI_PRODUCT_SKU, "B4U19UA"),
673 		},
674 	},
675 	{
676 	 .callback = video_detect_force_native,
677 	 /* Samsung N150P */
678 	 .matches = {
679 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
680 		DMI_MATCH(DMI_PRODUCT_NAME, "N150P"),
681 		DMI_MATCH(DMI_BOARD_NAME, "N150P"),
682 		},
683 	},
684 	{
685 	 .callback = video_detect_force_native,
686 	 /* Samsung N145P/N250P/N260P */
687 	 .matches = {
688 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
689 		DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
690 		DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
691 		},
692 	},
693 	{
694 	 .callback = video_detect_force_native,
695 	 /* Samsung N250P */
696 	 .matches = {
697 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
698 		DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
699 		DMI_MATCH(DMI_BOARD_NAME, "N250P"),
700 		},
701 	},
702 	{
703 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
704 	 .callback = video_detect_force_native,
705 	 /* Sony Vaio VPCEH3U1E */
706 	 .matches = {
707 		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
708 		DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
709 		},
710 	},
711 	{
712 	 .callback = video_detect_force_native,
713 	 /* Sony Vaio VPCY11S1E */
714 	 .matches = {
715 		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
716 		DMI_MATCH(DMI_PRODUCT_NAME, "VPCY11S1E"),
717 		},
718 	},
719 
720 	/*
721 	 * These Toshibas have a broken acpi-video interface for brightness
722 	 * control. They also have an issue where the panel is off after
723 	 * suspend until a special firmware call is made to turn it back
724 	 * on. This is handled by the toshiba_acpi kernel module, so that
725 	 * module must be enabled for these models to work correctly.
726 	 */
727 	{
728 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
729 	 .callback = video_detect_force_native,
730 	 /* Toshiba Portégé R700 */
731 	 .matches = {
732 		DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
733 		DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"),
734 		},
735 	},
736 	{
737 	 /* Portégé: https://bugs.freedesktop.org/show_bug.cgi?id=82634 */
738 	 /* Satellite: https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
739 	 .callback = video_detect_force_native,
740 	 /* Toshiba Satellite/Portégé R830 */
741 	 .matches = {
742 		DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
743 		DMI_MATCH(DMI_PRODUCT_NAME, "R830"),
744 		},
745 	},
746 	{
747 	 .callback = video_detect_force_native,
748 	 /* Toshiba Satellite/Portégé Z830 */
749 	 .matches = {
750 		DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
751 		DMI_MATCH(DMI_PRODUCT_NAME, "Z830"),
752 		},
753 	},
754 
755 	/*
756 	 * Models which have nvidia-ec-wmi support, but should not use it.
757 	 * Note this indicates a likely firmware bug on these models and should
758 	 * be revisited if/when Linux gets support for dynamic mux mode.
759 	 */
760 	{
761 	 .callback = video_detect_force_native,
762 	 /* Dell G15 5515 */
763 	 .matches = {
764 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
765 		DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
766 		},
767 	},
768 	{
769 	 .callback = video_detect_force_native,
770 	 .matches = {
771 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
772 		DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 15 3535"),
773 		},
774 	},
775 	{ },
776 };
777 
778 static bool google_cros_ec_present(void)
779 {
780 	return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
781 }
782 
783 /*
784  * Windows 8 and newer no longer use the ACPI video interface, so it often
785  * does not work. So on win8+ systems prefer native brightness control.
786  * Chromebooks should always prefer native backlight control.
787  */
788 static bool prefer_native_over_acpi_video(void)
789 {
790 	return acpi_osi_is_win8() || google_cros_ec_present();
791 }
792 
793 /*
794  * Determine which type of backlight interface to use on this system,
795  * First check cmdline, then dmi quirks, then do autodetect.
796  */
797 enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect)
798 {
799 	static DEFINE_MUTEX(init_mutex);
800 	static bool nvidia_wmi_ec_present;
801 	static bool apple_gmux_present;
802 	static bool native_available;
803 	static bool init_done;
804 	static long video_caps;
805 
806 	/* Parse cmdline, dmi and acpi only once */
807 	mutex_lock(&init_mutex);
808 	if (!init_done) {
809 		acpi_video_parse_cmdline();
810 		dmi_check_system(video_detect_dmi_table);
811 		acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
812 				    ACPI_UINT32_MAX, find_video, NULL,
813 				    &video_caps, NULL);
814 		nvidia_wmi_ec_present = nvidia_wmi_ec_supported();
815 		apple_gmux_present = apple_gmux_detect(NULL, NULL);
816 		init_done = true;
817 	}
818 	if (native)
819 		native_available = true;
820 	mutex_unlock(&init_mutex);
821 
822 	if (auto_detect)
823 		*auto_detect = false;
824 
825 	/*
826 	 * The below heuristics / detection steps are in order of descending
827 	 * presedence. The commandline takes presedence over anything else.
828 	 */
829 	if (acpi_backlight_cmdline != acpi_backlight_undef)
830 		return acpi_backlight_cmdline;
831 
832 	/* DMI quirks override any autodetection. */
833 	if (acpi_backlight_dmi != acpi_backlight_undef)
834 		return acpi_backlight_dmi;
835 
836 	if (auto_detect)
837 		*auto_detect = true;
838 
839 	/* Special cases such as nvidia_wmi_ec and apple gmux. */
840 	if (nvidia_wmi_ec_present)
841 		return acpi_backlight_nvidia_wmi_ec;
842 
843 	if (apple_gmux_present)
844 		return acpi_backlight_apple_gmux;
845 
846 	/* Use ACPI video if available, except when native should be preferred. */
847 	if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
848 	     !(native_available && prefer_native_over_acpi_video()))
849 		return acpi_backlight_video;
850 
851 	/* Use native if available */
852 	if (native_available)
853 		return acpi_backlight_native;
854 
855 	/*
856 	 * The vendor specific BIOS interfaces are only necessary for
857 	 * laptops from before ~2008.
858 	 *
859 	 * For laptops from ~2008 till ~2023 this point is never reached
860 	 * because on those (video_caps & ACPI_VIDEO_BACKLIGHT) above is true.
861 	 *
862 	 * Laptops from after ~2023 no longer support ACPI_VIDEO_BACKLIGHT,
863 	 * if this point is reached on those, this likely means that
864 	 * the GPU kms driver which sets native_available has not loaded yet.
865 	 *
866 	 * Returning acpi_backlight_vendor in this case is known to sometimes
867 	 * cause a non working vendor specific /sys/class/backlight device to
868 	 * get registered.
869 	 *
870 	 * Return acpi_backlight_none on laptops with ACPI tables written
871 	 * for Windows 8 (laptops from after ~2012) to avoid this problem.
872 	 */
873 	if (acpi_osi_is_win8())
874 		return acpi_backlight_none;
875 
876 	/* No ACPI video/native (old hw), use vendor specific fw methods. */
877 	return acpi_backlight_vendor;
878 }
879 EXPORT_SYMBOL(__acpi_video_get_backlight_type);
880