xref: /openbmc/linux/drivers/acpi/video_detect.c (revision f4356947)
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 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
475 	 .callback = video_detect_force_native,
476 	 /* Apple MacBook Pro 12,1 */
477 	 .matches = {
478 		DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
479 		DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"),
480 		},
481 	},
482 	{
483 	 .callback = video_detect_force_native,
484 	 /* Dell Inspiron N4010 */
485 	 .matches = {
486 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
487 		DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N4010"),
488 		},
489 	},
490 	{
491 	 .callback = video_detect_force_native,
492 	 /* Dell Vostro V131 */
493 	 .matches = {
494 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
495 		DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
496 		},
497 	},
498 	{
499 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */
500 	 .callback = video_detect_force_native,
501 	 /* Dell XPS 17 L702X */
502 	 .matches = {
503 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
504 		DMI_MATCH(DMI_PRODUCT_NAME, "Dell System XPS L702X"),
505 		},
506 	},
507 	{
508 	 .callback = video_detect_force_native,
509 	 /* Dell Precision 7510 */
510 	 .matches = {
511 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
512 		DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"),
513 		},
514 	},
515 	{
516 	 .callback = video_detect_force_native,
517 	 /* Acer Aspire 3830TG */
518 	 .matches = {
519 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
520 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3830TG"),
521 		},
522 	},
523 	{
524 	 .callback = video_detect_force_native,
525 	 /* Acer Aspire 4810T */
526 	 .matches = {
527 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
528 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 4810T"),
529 		},
530 	},
531 	{
532 	 .callback = video_detect_force_native,
533 	 /* Acer Aspire 5738z */
534 	 .matches = {
535 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
536 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
537 		DMI_MATCH(DMI_BOARD_NAME, "JV50"),
538 		},
539 	},
540 	{
541 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1012674 */
542 	 .callback = video_detect_force_native,
543 	 /* Acer Aspire 5741 */
544 	 .matches = {
545 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
546 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"),
547 		},
548 	},
549 	{
550 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=42993 */
551 	 .callback = video_detect_force_native,
552 	 /* Acer Aspire 5750 */
553 	 .matches = {
554 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
555 		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"),
556 		},
557 	},
558 	{
559 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=42833 */
560 	 .callback = video_detect_force_native,
561 	 /* Acer Extensa 5235 */
562 	 .matches = {
563 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
564 		DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5235"),
565 		},
566 	},
567 	{
568 	 .callback = video_detect_force_native,
569 	 /* Acer TravelMate 4750 */
570 	 .matches = {
571 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
572 		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4750"),
573 		},
574 	},
575 	{
576 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */
577 	 .callback = video_detect_force_native,
578 	 /* Acer TravelMate 5735Z */
579 	 .matches = {
580 		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
581 		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"),
582 		DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"),
583 		},
584 	},
585 	{
586 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=36322 */
587 	 .callback = video_detect_force_native,
588 	 /* Acer TravelMate 5760 */
589 	 .matches = {
590 		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
591 		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5760"),
592 		},
593 	},
594 	{
595 	 .callback = video_detect_force_native,
596 	 /* ASUSTeK COMPUTER INC. GA401 */
597 	 .matches = {
598 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
599 		DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
600 		},
601 	},
602 	{
603 	 .callback = video_detect_force_native,
604 	 /* ASUSTeK COMPUTER INC. GA502 */
605 	 .matches = {
606 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
607 		DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
608 		},
609 	},
610 	{
611 	 .callback = video_detect_force_native,
612 	 /* ASUSTeK COMPUTER INC. GA503 */
613 	 .matches = {
614 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
615 		DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
616 		},
617 	},
618 	{
619 	 .callback = video_detect_force_native,
620 	 /* Asus U46E */
621 	 .matches = {
622 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
623 		DMI_MATCH(DMI_PRODUCT_NAME, "U46E"),
624 		},
625 	},
626 	{
627 	 .callback = video_detect_force_native,
628 	 /* Asus UX303UB */
629 	 .matches = {
630 		DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
631 		DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
632 		},
633 	},
634 	{
635 	 .callback = video_detect_force_native,
636 	 /* HP EliteBook 8460p */
637 	 .matches = {
638 		DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
639 		DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8460p"),
640 		},
641 	},
642 	{
643 	 .callback = video_detect_force_native,
644 	 /* HP Pavilion g6-1d80nr / B4U19UA */
645 	 .matches = {
646 		DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
647 		DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion g6 Notebook PC"),
648 		DMI_MATCH(DMI_PRODUCT_SKU, "B4U19UA"),
649 		},
650 	},
651 	{
652 	 .callback = video_detect_force_native,
653 	 /* Samsung N150P */
654 	 .matches = {
655 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
656 		DMI_MATCH(DMI_PRODUCT_NAME, "N150P"),
657 		DMI_MATCH(DMI_BOARD_NAME, "N150P"),
658 		},
659 	},
660 	{
661 	 .callback = video_detect_force_native,
662 	 /* Samsung N145P/N250P/N260P */
663 	 .matches = {
664 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
665 		DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
666 		DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
667 		},
668 	},
669 	{
670 	 .callback = video_detect_force_native,
671 	 /* Samsung N250P */
672 	 .matches = {
673 		DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
674 		DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
675 		DMI_MATCH(DMI_BOARD_NAME, "N250P"),
676 		},
677 	},
678 	{
679 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
680 	 .callback = video_detect_force_native,
681 	 /* Sony Vaio VPCEH3U1E */
682 	 .matches = {
683 		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
684 		DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
685 		},
686 	},
687 	{
688 	 .callback = video_detect_force_native,
689 	 /* Sony Vaio VPCY11S1E */
690 	 .matches = {
691 		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
692 		DMI_MATCH(DMI_PRODUCT_NAME, "VPCY11S1E"),
693 		},
694 	},
695 
696 	/*
697 	 * These Toshibas have a broken acpi-video interface for brightness
698 	 * control. They also have an issue where the panel is off after
699 	 * suspend until a special firmware call is made to turn it back
700 	 * on. This is handled by the toshiba_acpi kernel module, so that
701 	 * module must be enabled for these models to work correctly.
702 	 */
703 	{
704 	 /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
705 	 .callback = video_detect_force_native,
706 	 /* Toshiba Portégé R700 */
707 	 .matches = {
708 		DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
709 		DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"),
710 		},
711 	},
712 	{
713 	 /* Portégé: https://bugs.freedesktop.org/show_bug.cgi?id=82634 */
714 	 /* Satellite: https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
715 	 .callback = video_detect_force_native,
716 	 /* Toshiba Satellite/Portégé R830 */
717 	 .matches = {
718 		DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
719 		DMI_MATCH(DMI_PRODUCT_NAME, "R830"),
720 		},
721 	},
722 	{
723 	 .callback = video_detect_force_native,
724 	 /* Toshiba Satellite/Portégé Z830 */
725 	 .matches = {
726 		DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
727 		DMI_MATCH(DMI_PRODUCT_NAME, "Z830"),
728 		},
729 	},
730 
731 	/*
732 	 * Models which have nvidia-ec-wmi support, but should not use it.
733 	 * Note this indicates a likely firmware bug on these models and should
734 	 * be revisited if/when Linux gets support for dynamic mux mode.
735 	 */
736 	{
737 	 .callback = video_detect_force_native,
738 	 /* Dell G15 5515 */
739 	 .matches = {
740 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
741 		DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
742 		},
743 	},
744 	{
745 	 .callback = video_detect_force_native,
746 	 .matches = {
747 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
748 		DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 15 3535"),
749 		},
750 	},
751 	{ },
752 };
753 
754 static bool google_cros_ec_present(void)
755 {
756 	return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
757 }
758 
759 /*
760  * Windows 8 and newer no longer use the ACPI video interface, so it often
761  * does not work. So on win8+ systems prefer native brightness control.
762  * Chromebooks should always prefer native backlight control.
763  */
764 static bool prefer_native_over_acpi_video(void)
765 {
766 	return acpi_osi_is_win8() || google_cros_ec_present();
767 }
768 
769 /*
770  * Determine which type of backlight interface to use on this system,
771  * First check cmdline, then dmi quirks, then do autodetect.
772  */
773 enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect)
774 {
775 	static DEFINE_MUTEX(init_mutex);
776 	static bool nvidia_wmi_ec_present;
777 	static bool apple_gmux_present;
778 	static bool native_available;
779 	static bool init_done;
780 	static long video_caps;
781 
782 	/* Parse cmdline, dmi and acpi only once */
783 	mutex_lock(&init_mutex);
784 	if (!init_done) {
785 		acpi_video_parse_cmdline();
786 		dmi_check_system(video_detect_dmi_table);
787 		acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
788 				    ACPI_UINT32_MAX, find_video, NULL,
789 				    &video_caps, NULL);
790 		nvidia_wmi_ec_present = nvidia_wmi_ec_supported();
791 		apple_gmux_present = apple_gmux_detect(NULL, NULL);
792 		init_done = true;
793 	}
794 	if (native)
795 		native_available = true;
796 	mutex_unlock(&init_mutex);
797 
798 	if (auto_detect)
799 		*auto_detect = false;
800 
801 	/*
802 	 * The below heuristics / detection steps are in order of descending
803 	 * presedence. The commandline takes presedence over anything else.
804 	 */
805 	if (acpi_backlight_cmdline != acpi_backlight_undef)
806 		return acpi_backlight_cmdline;
807 
808 	/* DMI quirks override any autodetection. */
809 	if (acpi_backlight_dmi != acpi_backlight_undef)
810 		return acpi_backlight_dmi;
811 
812 	if (auto_detect)
813 		*auto_detect = true;
814 
815 	/* Special cases such as nvidia_wmi_ec and apple gmux. */
816 	if (nvidia_wmi_ec_present)
817 		return acpi_backlight_nvidia_wmi_ec;
818 
819 	if (apple_gmux_present)
820 		return acpi_backlight_apple_gmux;
821 
822 	/* Use ACPI video if available, except when native should be preferred. */
823 	if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
824 	     !(native_available && prefer_native_over_acpi_video()))
825 		return acpi_backlight_video;
826 
827 	/* Use native if available */
828 	if (native_available)
829 		return acpi_backlight_native;
830 
831 	/* No ACPI video/native (old hw), use vendor specific fw methods. */
832 	return acpi_backlight_vendor;
833 }
834 EXPORT_SYMBOL(__acpi_video_get_backlight_type);
835