Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
14ca7a4
Documentation
arch
block
crypto
drivers
accessibility
acpi
acpica
apei
pmic
Kconfig
Makefile
ac.c
acpi_apd.c
acpi_cmos_rtc.c
acpi_extlog.c
acpi_ipmi.c
acpi_lpat.c
acpi_lpss.c
acpi_memhotplug.c
acpi_pad.c
acpi_platform.c
acpi_pnp.c
acpi_processor.c
acpi_video.c
battery.c
battery.h
bgrt.c
blacklist.c
bus.c
button.c
cm_sbs.c
container.c
custom_method.c
debugfs.c
device_pm.c
dock.c
ec.c
ec_sys.c
event.c
fan.c
glue.c
gsi.c
hed.c
int340x_thermal.c
internal.h
ioapic.c
numa.c
nvs.c
osl.c
pci_irq.c
pci_link.c
pci_root.c
pci_slot.c
power.c
proc.c
processor_core.c
processor_driver.c
processor_idle.c
processor_pdc.c
processor_perflib.c
processor_thermal.c
processor_throttling.c
property.c
reboot.c
resource.c
sbs.c
sbshc.c
sbshc.h
scan.c
sleep.c
sleep.h
sysfs.c
tables.c
thermal.c
utils.c
video_detect.c
wakeup.c
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
connector
cpufreq
cpuidle
crypto
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fmc
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
ide
idle
iio
infiniband
input
iommu
ipack
irqchip
isdn
leds
lguest
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
net
nfc
ntb
nubus
of
oprofile
parisc
parport
pci
pcmcia
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
sn
soc
spi
spmi
ssb
staging
target
tc
thermal
thunderbolt
tty
uio
usb
uwb
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
drivers
/
acpi
/
video_detect.c
Blame
Blame
Latest commit
History
History
223 lines (204 loc) · 6.76 KB
Breadcrumbs
linux
/
drivers
/
acpi
/
video_detect.c
Top
File metadata and controls
Code
Blame
223 lines (204 loc) · 6.76 KB
Raw
/* * Copyright (C) 2008 SuSE Linux Products GmbH * Thomas Renninger <trenn@suse.de> * * May be copied or modified under the terms of the GNU General Public License * * video_detect.c: * After PCI devices are glued with ACPI devices * acpi_get_pci_dev() can be called to identify ACPI graphics * devices for which a real graphics card is plugged in * * Now acpi_video_get_capabilities() can be called to check which * capabilities the graphics cards plugged in support. The check for general * video capabilities will be triggered by the first caller of * acpi_video_get_capabilities(NULL); which will happen when the first * backlight switching supporting driver calls: * acpi_video_backlight_support(); * * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B) * are available, video.ko should be used to handle the device. * * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, * sony_acpi,... can take care about backlight brightness. * * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) * this file will not be compiled, acpi_video_get_capabilities() and * acpi_video_backlight_support() will always return 0 and vendor specific * drivers always can handle backlight. * */ #include <linux/export.h> #include <linux/acpi.h> #include <linux/dmi.h> #include <linux/module.h> #include <linux/pci.h> ACPI_MODULE_NAME("video"); #define _COMPONENT ACPI_VIDEO_COMPONENT static long acpi_video_support; static bool acpi_video_caps_checked; static void acpi_video_parse_cmdline(void) { if (!strcmp("vendor", acpi_video_backlight_string)) acpi_video_support |= ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR; if (!strcmp("video", acpi_video_backlight_string)) acpi_video_support |= ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO; } static acpi_status find_video(acpi_handle handle, u32 lvl, void *context, void **rv) { long *cap = context; struct pci_dev *dev; struct acpi_device *acpi_dev; static const struct acpi_device_id video_ids[] = { {ACPI_VIDEO_HID, 0}, {"", 0}, }; if (acpi_bus_get_device(handle, &acpi_dev)) return AE_OK; if (!acpi_match_device_ids(acpi_dev, video_ids)) { dev = acpi_get_pci_dev(handle); if (!dev) return AE_OK; pci_dev_put(dev); *cap |= acpi_is_video_device(handle); } return AE_OK; } /* Force to use vendor driver when the ACPI device is known to be * buggy */ static int video_detect_force_vendor(const struct dmi_system_id *d) { acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; return 0; } static const struct dmi_system_id video_detect_dmi_table[] = { /* On Samsung X360, the BIOS will set a flag (VDRV) if generic * ACPI backlight device is used. This flag will definitively break * the backlight interface (even the vendor interface) untill next * reboot. It's why we should prevent video.ko from being used here * and we can't rely on a later call to acpi_video_unregister(). */ { .callback = video_detect_force_vendor, .ident = "X360", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), DMI_MATCH(DMI_PRODUCT_NAME, "X360"), DMI_MATCH(DMI_BOARD_NAME, "X360"), }, }, { .callback = video_detect_force_vendor, .ident = "Asus UL30VT", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"), }, }, { .callback = video_detect_force_vendor, .ident = "Asus UL30A", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), }, }, { .callback = video_detect_force_vendor, .ident = "Dell Inspiron 5737", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"), }, }, { }, }; /* * Returns the video capabilities of a specific ACPI graphics device * * if NULL is passed as argument all ACPI devices are enumerated and * all graphics capabilities of physically present devices are * summarized and returned. This is cached and done only once. */ static long acpi_video_get_capabilities(acpi_handle graphics_handle) { long caps = 0; struct acpi_device *tmp_dev; acpi_status status; if (acpi_video_caps_checked && graphics_handle == NULL) return acpi_video_support; if (!graphics_handle) { /* Only do the global walk through all graphics devices once */ acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, find_video, NULL, &caps, NULL); /* There might be boot param flags set already... */ acpi_video_support |= caps; acpi_video_caps_checked = 1; /* Add blacklists here. Be careful to use the right *DMI* bits * to still be able to override logic via boot params, e.g.: * * if (dmi_name_in_vendors("XY")) { * acpi_video_support |= * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; *} */ dmi_check_system(video_detect_dmi_table); } else { status = acpi_bus_get_device(graphics_handle, &tmp_dev); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Invalid device")); return 0; } acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle, ACPI_UINT32_MAX, find_video, NULL, &caps, NULL); } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n", graphics_handle ? caps : acpi_video_support, graphics_handle ? "on device " : "in general", graphics_handle ? acpi_device_bid(tmp_dev) : "")); return caps; } static void acpi_video_caps_check(void) { /* * We must check whether the ACPI graphics device is physically plugged * in. Therefore this must be called after binding PCI and ACPI devices */ if (!acpi_video_caps_checked) { acpi_video_parse_cmdline(); acpi_video_get_capabilities(NULL); } } /* Promote the vendor interface instead of the generic video module. * This function allow DMI blacklists to be implemented by externals * platform drivers instead of putting a big blacklist in video_detect.c * After calling this function you will probably want to call * acpi_video_unregister() to make sure the video module is not loaded */ void acpi_video_dmi_promote_vendor(void) { acpi_video_caps_check(); acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; } EXPORT_SYMBOL(acpi_video_dmi_promote_vendor); /* Returns true if video.ko can do backlight switching */ int acpi_video_backlight_support(void) { acpi_video_caps_check(); /* First check for boot param -> highest prio */ if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR) return 0; else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO) return 1; /* Then check for DMI blacklist -> second highest prio */ if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VENDOR) return 0; else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VIDEO) return 1; /* Then go the default way */ return acpi_video_support & ACPI_VIDEO_BACKLIGHT; } EXPORT_SYMBOL(acpi_video_backlight_support);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
You can’t perform that action at this time.