acpi-video-detect: Move acpi_osi_is_win8 to osl.c
[deliverable/linux.git] / drivers / acpi / video_detect.c
CommitLineData
c3d6de69
TR
1/*
2 * Copyright (C) 2008 SuSE Linux Products GmbH
3 * Thomas Renninger <trenn@suse.de>
4 *
5 * May be copied or modified under the terms of the GNU General Public License
6 *
7 * video_detect.c:
c3d6de69 8 * After PCI devices are glued with ACPI devices
1e4cffe7 9 * acpi_get_pci_dev() can be called to identify ACPI graphics
c3d6de69
TR
10 * devices for which a real graphics card is plugged in
11 *
12 * Now acpi_video_get_capabilities() can be called to check which
13 * capabilities the graphics cards plugged in support. The check for general
14 * video capabilities will be triggered by the first caller of
15 * acpi_video_get_capabilities(NULL); which will happen when the first
677bd810 16 * backlight switching supporting driver calls:
c3d6de69
TR
17 * acpi_video_backlight_support();
18 *
19 * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B)
20 * are available, video.ko should be used to handle the device.
21 *
7ec48ced 22 * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop,
677bd810 23 * sony_acpi,... can take care about backlight brightness.
c3d6de69
TR
24 *
25 * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m)
26 * this file will not be compiled, acpi_video_get_capabilities() and
27 * acpi_video_backlight_support() will always return 0 and vendor specific
28 * drivers always can handle backlight.
29 *
30 */
31
214f2c90 32#include <linux/export.h>
c3d6de69
TR
33#include <linux/acpi.h>
34#include <linux/dmi.h>
1e4cffe7 35#include <linux/pci.h>
c3d6de69 36
8c5bd7ad
RW
37#include "internal.h"
38
c3d6de69 39ACPI_MODULE_NAME("video");
c3d6de69
TR
40#define _COMPONENT ACPI_VIDEO_COMPONENT
41
42static long acpi_video_support;
43static bool acpi_video_caps_checked;
44
c3d6de69
TR
45static acpi_status
46find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
47{
48 long *cap = context;
1e4cffe7 49 struct pci_dev *dev;
c3d6de69
TR
50 struct acpi_device *acpi_dev;
51
4a4f01a6 52 static const struct acpi_device_id video_ids[] = {
c3d6de69
TR
53 {ACPI_VIDEO_HID, 0},
54 {"", 0},
55 };
56 if (acpi_bus_get_device(handle, &acpi_dev))
57 return AE_OK;
58
59 if (!acpi_match_device_ids(acpi_dev, video_ids)) {
1e4cffe7 60 dev = acpi_get_pci_dev(handle);
c3d6de69
TR
61 if (!dev)
62 return AE_OK;
1e4cffe7 63 pci_dev_put(dev);
d4e1a692 64 *cap |= acpi_is_video_device(handle);
c3d6de69
TR
65 }
66 return AE_OK;
67}
68
084940d5
CC
69/* Force to use vendor driver when the ACPI device is known to be
70 * buggy */
71static int video_detect_force_vendor(const struct dmi_system_id *d)
72{
73 acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
74 return 0;
75}
76
4a4f01a6 77static const struct dmi_system_id video_detect_dmi_table[] = {
084940d5
CC
78 /* On Samsung X360, the BIOS will set a flag (VDRV) if generic
79 * ACPI backlight device is used. This flag will definitively break
80 * the backlight interface (even the vendor interface) untill next
81 * reboot. It's why we should prevent video.ko from being used here
82 * and we can't rely on a later call to acpi_video_unregister().
83 */
84 {
85 .callback = video_detect_force_vendor,
86 .ident = "X360",
87 .matches = {
88 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
89 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
90 DMI_MATCH(DMI_BOARD_NAME, "X360"),
91 },
92 },
d0c2ce16
LT
93 {
94 .callback = video_detect_force_vendor,
95 .ident = "Asus UL30VT",
96 .matches = {
97 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
98 DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"),
99 },
100 },
c8f6d835
BT
101 {
102 .callback = video_detect_force_vendor,
103 .ident = "Asus UL30A",
104 .matches = {
105 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
106 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
107 },
108 },
08a56226
EL
109 {
110 .callback = video_detect_force_vendor,
111 .ident = "Dell Inspiron 5737",
112 .matches = {
113 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
114 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
115 },
116 },
084940d5
CC
117 { },
118};
119
c3d6de69
TR
120/*
121 * Returns the video capabilities of a specific ACPI graphics device
122 *
123 * if NULL is passed as argument all ACPI devices are enumerated and
124 * all graphics capabilities of physically present devices are
94e2bd68 125 * summarized and returned. This is cached and done only once.
c3d6de69 126 */
fb105d96 127static long acpi_video_get_capabilities(acpi_handle graphics_handle)
c3d6de69
TR
128{
129 long caps = 0;
130 struct acpi_device *tmp_dev;
131 acpi_status status;
132
133 if (acpi_video_caps_checked && graphics_handle == NULL)
134 return acpi_video_support;
135
136 if (!graphics_handle) {
137 /* Only do the global walk through all graphics devices once */
138 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
2263576c 139 ACPI_UINT32_MAX, find_video, NULL,
c3d6de69
TR
140 &caps, NULL);
141 /* There might be boot param flags set already... */
142 acpi_video_support |= caps;
143 acpi_video_caps_checked = 1;
144 /* Add blacklists here. Be careful to use the right *DMI* bits
145 * to still be able to override logic via boot params, e.g.:
146 *
147 * if (dmi_name_in_vendors("XY")) {
148 * acpi_video_support |=
c3d6de69
TR
149 * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
150 *}
151 */
084940d5
CC
152
153 dmi_check_system(video_detect_dmi_table);
c3d6de69
TR
154 } else {
155 status = acpi_bus_get_device(graphics_handle, &tmp_dev);
156 if (ACPI_FAILURE(status)) {
157 ACPI_EXCEPTION((AE_INFO, status, "Invalid device"));
158 return 0;
159 }
160 acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle,
2263576c 161 ACPI_UINT32_MAX, find_video, NULL,
c3d6de69
TR
162 &caps, NULL);
163 }
164 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n",
165 graphics_handle ? caps : acpi_video_support,
166 graphics_handle ? "on device " : "in general",
167 graphics_handle ? acpi_device_bid(tmp_dev) : ""));
168 return caps;
169}
c3d6de69 170
f838eb5b 171static void acpi_video_caps_check(void)
c3d6de69
TR
172{
173 /*
174 * We must check whether the ACPI graphics device is physically plugged
175 * in. Therefore this must be called after binding PCI and ACPI devices
176 */
177 if (!acpi_video_caps_checked)
178 acpi_video_get_capabilities(NULL);
f838eb5b
CC
179}
180
181/* Promote the vendor interface instead of the generic video module.
182 * This function allow DMI blacklists to be implemented by externals
183 * platform drivers instead of putting a big blacklist in video_detect.c
184 * After calling this function you will probably want to call
185 * acpi_video_unregister() to make sure the video module is not loaded
186 */
187void acpi_video_dmi_promote_vendor(void)
188{
189 acpi_video_caps_check();
190 acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
191}
192EXPORT_SYMBOL(acpi_video_dmi_promote_vendor);
193
f838eb5b
CC
194/* Returns true if video.ko can do backlight switching */
195int acpi_video_backlight_support(void)
196{
197 acpi_video_caps_check();
c3d6de69
TR
198
199 /* First check for boot param -> highest prio */
200 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR)
201 return 0;
202 else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO)
203 return 1;
204
205 /* Then check for DMI blacklist -> second highest prio */
206 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VENDOR)
207 return 0;
208 else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VIDEO)
209 return 1;
210
211 /* Then go the default way */
212 return acpi_video_support & ACPI_VIDEO_BACKLIGHT;
213}
214EXPORT_SYMBOL(acpi_video_backlight_support);
215
216/*
677bd810
ZR
217 * Use acpi_backlight=vendor/video to force that backlight switching
218 * is processed by vendor specific acpi drivers or video.ko driver.
c3d6de69 219 */
8a383ef0 220static int __init acpi_backlight(char *str)
c3d6de69
TR
221{
222 if (str == NULL || *str == '\0')
223 return 1;
224 else {
225 if (!strcmp("vendor", str))
226 acpi_video_support |=
227 ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR;
228 if (!strcmp("video", str))
229 acpi_video_support |=
eeb4bcb4 230 ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO;
c3d6de69
TR
231 }
232 return 1;
233}
234__setup("acpi_backlight=", acpi_backlight);
This page took 0.631263 seconds and 5 git commands to generate.