2 * video.c - ACPI Video Driver ($Revision:$)
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
6 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/types.h>
31 #include <linux/list.h>
32 #include <linux/mutex.h>
33 #include <linux/proc_fs.h>
34 #include <linux/seq_file.h>
35 #include <linux/input.h>
36 #include <linux/backlight.h>
37 #include <linux/thermal.h>
38 #include <linux/video_output.h>
39 #include <linux/sort.h>
40 #include <linux/pci.h>
41 #include <linux/pci_ids.h>
42 #include <linux/slab.h>
43 #include <asm/uaccess.h>
44 #include <linux/dmi.h>
45 #include <acpi/acpi_bus.h>
46 #include <acpi/acpi_drivers.h>
47 #include <linux/suspend.h>
49 #define PREFIX "ACPI: "
51 #define ACPI_VIDEO_CLASS "video"
52 #define ACPI_VIDEO_BUS_NAME "Video Bus"
53 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
54 #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
55 #define ACPI_VIDEO_NOTIFY_PROBE 0x81
56 #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
57 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
58 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
60 #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
61 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
62 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
63 #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
64 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
66 #define MAX_NAME_LEN 20
68 #define ACPI_VIDEO_DISPLAY_CRT 1
69 #define ACPI_VIDEO_DISPLAY_TV 2
70 #define ACPI_VIDEO_DISPLAY_DVI 3
71 #define ACPI_VIDEO_DISPLAY_LCD 4
73 #define _COMPONENT ACPI_VIDEO_COMPONENT
74 ACPI_MODULE_NAME("video");
76 MODULE_AUTHOR("Bruno Ducrot");
77 MODULE_DESCRIPTION("ACPI Video Driver");
78 MODULE_LICENSE("GPL");
80 static int brightness_switch_enabled
= 1;
81 module_param(brightness_switch_enabled
, bool, 0644);
84 * By default, we don't allow duplicate ACPI video bus devices
85 * under the same VGA controller
87 static int allow_duplicates
;
88 module_param(allow_duplicates
, bool, 0644);
90 static int register_count
= 0;
91 static int acpi_video_bus_add(struct acpi_device
*device
);
92 static int acpi_video_bus_remove(struct acpi_device
*device
, int type
);
93 static void acpi_video_bus_notify(struct acpi_device
*device
, u32 event
);
95 static const struct acpi_device_id video_device_ids
[] = {
99 MODULE_DEVICE_TABLE(acpi
, video_device_ids
);
101 static struct acpi_driver acpi_video_bus
= {
103 .class = ACPI_VIDEO_CLASS
,
104 .ids
= video_device_ids
,
106 .add
= acpi_video_bus_add
,
107 .remove
= acpi_video_bus_remove
,
108 .notify
= acpi_video_bus_notify
,
112 struct acpi_video_bus_flags
{
113 u8 multihead
:1; /* can switch video heads */
114 u8 rom
:1; /* can retrieve a video rom */
115 u8 post
:1; /* can configure the head to */
119 struct acpi_video_bus_cap
{
120 u8 _DOS
:1; /*Enable/Disable output switching */
121 u8 _DOD
:1; /*Enumerate all devices attached to display adapter */
122 u8 _ROM
:1; /*Get ROM Data */
123 u8 _GPD
:1; /*Get POST Device */
124 u8 _SPD
:1; /*Set POST Device */
125 u8 _VPO
:1; /*Video POST Options */
129 struct acpi_video_device_attrib
{
130 u32 display_index
:4; /* A zero-based instance of the Display */
131 u32 display_port_attachment
:4; /*This field differentiates the display type */
132 u32 display_type
:4; /*Describe the specific type in use */
133 u32 vendor_specific
:4; /*Chipset Vendor Specific */
134 u32 bios_can_detect
:1; /*BIOS can detect the device */
135 u32 depend_on_vga
:1; /*Non-VGA output device whose power is related to
137 u32 pipe_id
:3; /*For VGA multiple-head devices. */
138 u32 reserved
:10; /*Must be 0 */
139 u32 device_id_scheme
:1; /*Device ID Scheme */
142 struct acpi_video_enumerated_device
{
145 struct acpi_video_device_attrib attrib
;
147 struct acpi_video_device
*bind_info
;
150 struct acpi_video_bus
{
151 struct acpi_device
*device
;
153 struct acpi_video_enumerated_device
*attached_array
;
155 struct acpi_video_bus_cap cap
;
156 struct acpi_video_bus_flags flags
;
157 struct list_head video_device_list
;
158 struct mutex device_list_lock
; /* protects video_device_list */
159 struct proc_dir_entry
*dir
;
160 struct input_dev
*input
;
161 char phys
[32]; /* for input device */
162 struct notifier_block pm_nb
;
165 struct acpi_video_device_flags
{
175 struct acpi_video_device_cap
{
176 u8 _ADR
:1; /*Return the unique ID */
177 u8 _BCL
:1; /*Query list of brightness control levels supported */
178 u8 _BCM
:1; /*Set the brightness level */
179 u8 _BQC
:1; /* Get current brightness level */
180 u8 _BCQ
:1; /* Some buggy BIOS uses _BCQ instead of _BQC */
181 u8 _DDC
:1; /*Return the EDID for this device */
182 u8 _DCS
:1; /*Return status of output device */
183 u8 _DGS
:1; /*Query graphics state */
184 u8 _DSS
:1; /*Device state set */
187 struct acpi_video_brightness_flags
{
188 u8 _BCL_no_ac_battery_levels
:1; /* no AC/Battery levels in _BCL */
189 u8 _BCL_reversed
:1; /* _BCL package is in a reversed order*/
190 u8 _BCL_use_index
:1; /* levels in _BCL are index values */
191 u8 _BCM_use_index
:1; /* input of _BCM is an index value */
192 u8 _BQC_use_index
:1; /* _BQC returns an index value */
195 struct acpi_video_device_brightness
{
199 struct acpi_video_brightness_flags flags
;
202 struct acpi_video_device
{
203 unsigned long device_id
;
204 struct acpi_video_device_flags flags
;
205 struct acpi_video_device_cap cap
;
206 struct list_head entry
;
207 struct acpi_video_bus
*video
;
208 struct acpi_device
*dev
;
209 struct acpi_video_device_brightness
*brightness
;
210 struct backlight_device
*backlight
;
211 struct thermal_cooling_device
*cooling_dev
;
212 struct output_device
*output_dev
;
216 static int acpi_video_bus_info_open_fs(struct inode
*inode
, struct file
*file
);
217 static const struct file_operations acpi_video_bus_info_fops
= {
218 .owner
= THIS_MODULE
,
219 .open
= acpi_video_bus_info_open_fs
,
222 .release
= single_release
,
225 static int acpi_video_bus_ROM_open_fs(struct inode
*inode
, struct file
*file
);
226 static const struct file_operations acpi_video_bus_ROM_fops
= {
227 .owner
= THIS_MODULE
,
228 .open
= acpi_video_bus_ROM_open_fs
,
231 .release
= single_release
,
234 static int acpi_video_bus_POST_info_open_fs(struct inode
*inode
,
236 static const struct file_operations acpi_video_bus_POST_info_fops
= {
237 .owner
= THIS_MODULE
,
238 .open
= acpi_video_bus_POST_info_open_fs
,
241 .release
= single_release
,
244 static int acpi_video_bus_POST_open_fs(struct inode
*inode
, struct file
*file
);
245 static ssize_t
acpi_video_bus_write_POST(struct file
*file
,
246 const char __user
*buffer
, size_t count
, loff_t
*data
);
247 static const struct file_operations acpi_video_bus_POST_fops
= {
248 .owner
= THIS_MODULE
,
249 .open
= acpi_video_bus_POST_open_fs
,
251 .write
= acpi_video_bus_write_POST
,
253 .release
= single_release
,
256 static int acpi_video_bus_DOS_open_fs(struct inode
*inode
, struct file
*file
);
257 static ssize_t
acpi_video_bus_write_DOS(struct file
*file
,
258 const char __user
*buffer
, size_t count
, loff_t
*data
);
259 static const struct file_operations acpi_video_bus_DOS_fops
= {
260 .owner
= THIS_MODULE
,
261 .open
= acpi_video_bus_DOS_open_fs
,
263 .write
= acpi_video_bus_write_DOS
,
265 .release
= single_release
,
269 static int acpi_video_device_info_open_fs(struct inode
*inode
,
271 static const struct file_operations acpi_video_device_info_fops
= {
272 .owner
= THIS_MODULE
,
273 .open
= acpi_video_device_info_open_fs
,
276 .release
= single_release
,
279 static int acpi_video_device_state_open_fs(struct inode
*inode
,
281 static ssize_t
acpi_video_device_write_state(struct file
*file
,
282 const char __user
*buffer
, size_t count
, loff_t
*data
);
283 static const struct file_operations acpi_video_device_state_fops
= {
284 .owner
= THIS_MODULE
,
285 .open
= acpi_video_device_state_open_fs
,
287 .write
= acpi_video_device_write_state
,
289 .release
= single_release
,
292 static int acpi_video_device_brightness_open_fs(struct inode
*inode
,
294 static ssize_t
acpi_video_device_write_brightness(struct file
*file
,
295 const char __user
*buffer
, size_t count
, loff_t
*data
);
296 static const struct file_operations acpi_video_device_brightness_fops
= {
297 .owner
= THIS_MODULE
,
298 .open
= acpi_video_device_brightness_open_fs
,
300 .write
= acpi_video_device_write_brightness
,
302 .release
= single_release
,
305 static int acpi_video_device_EDID_open_fs(struct inode
*inode
,
307 static const struct file_operations acpi_video_device_EDID_fops
= {
308 .owner
= THIS_MODULE
,
309 .open
= acpi_video_device_EDID_open_fs
,
312 .release
= single_release
,
315 static const char device_decode
[][30] = {
316 "motherboard VGA device",
322 static void acpi_video_device_notify(acpi_handle handle
, u32 event
, void *data
);
323 static void acpi_video_device_rebind(struct acpi_video_bus
*video
);
324 static void acpi_video_device_bind(struct acpi_video_bus
*video
,
325 struct acpi_video_device
*device
);
326 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
);
327 static int acpi_video_device_lcd_set_level(struct acpi_video_device
*device
,
329 static int acpi_video_device_lcd_get_level_current(
330 struct acpi_video_device
*device
,
331 unsigned long long *level
, int init
);
332 static int acpi_video_get_next_level(struct acpi_video_device
*device
,
333 u32 level_current
, u32 event
);
334 static int acpi_video_switch_brightness(struct acpi_video_device
*device
,
336 static int acpi_video_device_get_state(struct acpi_video_device
*device
,
337 unsigned long long *state
);
338 static int acpi_video_output_get(struct output_device
*od
);
339 static int acpi_video_device_set_state(struct acpi_video_device
*device
, int state
);
341 /*backlight device sysfs support*/
342 static int acpi_video_get_brightness(struct backlight_device
*bd
)
344 unsigned long long cur_level
;
346 struct acpi_video_device
*vd
=
347 (struct acpi_video_device
*)bl_get_data(bd
);
349 if (acpi_video_device_lcd_get_level_current(vd
, &cur_level
, 0))
351 for (i
= 2; i
< vd
->brightness
->count
; i
++) {
352 if (vd
->brightness
->levels
[i
] == cur_level
)
353 /* The first two entries are special - see page 575
354 of the ACPI spec 3.0 */
360 static int acpi_video_set_brightness(struct backlight_device
*bd
)
362 int request_level
= bd
->props
.brightness
+ 2;
363 struct acpi_video_device
*vd
=
364 (struct acpi_video_device
*)bl_get_data(bd
);
366 return acpi_video_device_lcd_set_level(vd
,
367 vd
->brightness
->levels
[request_level
]);
370 static struct backlight_ops acpi_backlight_ops
= {
371 .get_brightness
= acpi_video_get_brightness
,
372 .update_status
= acpi_video_set_brightness
,
375 /*video output device sysfs support*/
376 static int acpi_video_output_get(struct output_device
*od
)
378 unsigned long long state
;
379 struct acpi_video_device
*vd
=
380 (struct acpi_video_device
*)dev_get_drvdata(&od
->dev
);
381 acpi_video_device_get_state(vd
, &state
);
385 static int acpi_video_output_set(struct output_device
*od
)
387 unsigned long state
= od
->request_state
;
388 struct acpi_video_device
*vd
=
389 (struct acpi_video_device
*)dev_get_drvdata(&od
->dev
);
390 return acpi_video_device_set_state(vd
, state
);
393 static struct output_properties acpi_output_properties
= {
394 .set_state
= acpi_video_output_set
,
395 .get_status
= acpi_video_output_get
,
399 /* thermal cooling device callbacks */
400 static int video_get_max_state(struct thermal_cooling_device
*cooling_dev
, unsigned
403 struct acpi_device
*device
= cooling_dev
->devdata
;
404 struct acpi_video_device
*video
= acpi_driver_data(device
);
406 *state
= video
->brightness
->count
- 3;
410 static int video_get_cur_state(struct thermal_cooling_device
*cooling_dev
, unsigned
413 struct acpi_device
*device
= cooling_dev
->devdata
;
414 struct acpi_video_device
*video
= acpi_driver_data(device
);
415 unsigned long long level
;
418 if (acpi_video_device_lcd_get_level_current(video
, &level
, 0))
420 for (offset
= 2; offset
< video
->brightness
->count
; offset
++)
421 if (level
== video
->brightness
->levels
[offset
]) {
422 *state
= video
->brightness
->count
- offset
- 1;
430 video_set_cur_state(struct thermal_cooling_device
*cooling_dev
, unsigned long state
)
432 struct acpi_device
*device
= cooling_dev
->devdata
;
433 struct acpi_video_device
*video
= acpi_driver_data(device
);
436 if ( state
>= video
->brightness
->count
- 2)
439 state
= video
->brightness
->count
- state
;
440 level
= video
->brightness
->levels
[state
-1];
441 return acpi_video_device_lcd_set_level(video
, level
);
444 static struct thermal_cooling_device_ops video_cooling_ops
= {
445 .get_max_state
= video_get_max_state
,
446 .get_cur_state
= video_get_cur_state
,
447 .set_cur_state
= video_set_cur_state
,
450 /* --------------------------------------------------------------------------
452 -------------------------------------------------------------------------- */
457 acpi_video_device_query(struct acpi_video_device
*device
, unsigned long long *state
)
461 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DGS", NULL
, state
);
467 acpi_video_device_get_state(struct acpi_video_device
*device
,
468 unsigned long long *state
)
472 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DCS", NULL
, state
);
478 acpi_video_device_set_state(struct acpi_video_device
*device
, int state
)
481 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
482 struct acpi_object_list args
= { 1, &arg0
};
483 unsigned long long ret
;
486 arg0
.integer
.value
= state
;
487 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DSS", &args
, &ret
);
493 acpi_video_device_lcd_query_levels(struct acpi_video_device
*device
,
494 union acpi_object
**levels
)
497 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
498 union acpi_object
*obj
;
503 status
= acpi_evaluate_object(device
->dev
->handle
, "_BCL", NULL
, &buffer
);
504 if (!ACPI_SUCCESS(status
))
506 obj
= (union acpi_object
*)buffer
.pointer
;
507 if (!obj
|| (obj
->type
!= ACPI_TYPE_PACKAGE
)) {
508 printk(KERN_ERR PREFIX
"Invalid _BCL data\n");
518 kfree(buffer
.pointer
);
524 acpi_video_device_lcd_set_level(struct acpi_video_device
*device
, int level
)
527 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
528 struct acpi_object_list args
= { 1, &arg0
};
531 arg0
.integer
.value
= level
;
533 status
= acpi_evaluate_object(device
->dev
->handle
, "_BCM",
535 if (ACPI_FAILURE(status
)) {
536 ACPI_ERROR((AE_INFO
, "Evaluating _BCM failed"));
540 device
->brightness
->curr
= level
;
541 for (state
= 2; state
< device
->brightness
->count
; state
++)
542 if (level
== device
->brightness
->levels
[state
]) {
543 if (device
->backlight
)
544 device
->backlight
->props
.brightness
= state
- 2;
548 ACPI_ERROR((AE_INFO
, "Current brightness invalid"));
553 * For some buggy _BQC methods, we need to add a constant value to
554 * the _BQC return value to get the actual current brightness level
557 static int bqc_offset_aml_bug_workaround
;
558 static int __init
video_set_bqc_offset(const struct dmi_system_id
*d
)
560 bqc_offset_aml_bug_workaround
= 9;
564 static struct dmi_system_id video_dmi_table
[] __initdata
= {
566 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
569 .callback
= video_set_bqc_offset
,
570 .ident
= "Acer Aspire 5720",
572 DMI_MATCH(DMI_BOARD_VENDOR
, "Acer"),
573 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5720"),
577 .callback
= video_set_bqc_offset
,
578 .ident
= "Acer Aspire 5710Z",
580 DMI_MATCH(DMI_BOARD_VENDOR
, "Acer"),
581 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5710Z"),
585 .callback
= video_set_bqc_offset
,
586 .ident
= "eMachines E510",
588 DMI_MATCH(DMI_BOARD_VENDOR
, "EMACHINES"),
589 DMI_MATCH(DMI_PRODUCT_NAME
, "eMachines E510"),
593 .callback
= video_set_bqc_offset
,
594 .ident
= "Acer Aspire 5315",
596 DMI_MATCH(DMI_BOARD_VENDOR
, "Acer"),
597 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5315"),
601 .callback
= video_set_bqc_offset
,
602 .ident
= "Acer Aspire 7720",
604 DMI_MATCH(DMI_BOARD_VENDOR
, "Acer"),
605 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 7720"),
612 acpi_video_device_lcd_get_level_current(struct acpi_video_device
*device
,
613 unsigned long long *level
, int init
)
615 acpi_status status
= AE_OK
;
618 if (device
->cap
._BQC
|| device
->cap
._BCQ
) {
619 char *buf
= device
->cap
._BQC
? "_BQC" : "_BCQ";
621 status
= acpi_evaluate_integer(device
->dev
->handle
, buf
,
623 if (ACPI_SUCCESS(status
)) {
624 if (device
->brightness
->flags
._BQC_use_index
) {
625 if (device
->brightness
->flags
._BCL_reversed
)
626 *level
= device
->brightness
->count
628 *level
= device
->brightness
->levels
[*level
+ 2];
631 *level
+= bqc_offset_aml_bug_workaround
;
632 for (i
= 2; i
< device
->brightness
->count
; i
++)
633 if (device
->brightness
->levels
[i
] == *level
) {
634 device
->brightness
->curr
= *level
;
639 * BQC returned an invalid level.
642 ACPI_WARNING((AE_INFO
,
643 "%s returned an invalid level",
645 device
->cap
._BQC
= device
->cap
._BCQ
= 0;
649 * should we return an error or ignore this failure?
650 * dev->brightness->curr is a cached value which stores
651 * the correct current backlight level in most cases.
652 * ACPI video backlight still works w/ buggy _BQC.
653 * http://bugzilla.kernel.org/show_bug.cgi?id=12233
655 ACPI_WARNING((AE_INFO
, "Evaluating %s failed", buf
));
656 device
->cap
._BQC
= device
->cap
._BCQ
= 0;
660 *level
= device
->brightness
->curr
;
665 acpi_video_device_EDID(struct acpi_video_device
*device
,
666 union acpi_object
**edid
, ssize_t length
)
669 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
670 union acpi_object
*obj
;
671 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
672 struct acpi_object_list args
= { 1, &arg0
};
680 arg0
.integer
.value
= 1;
681 else if (length
== 256)
682 arg0
.integer
.value
= 2;
686 status
= acpi_evaluate_object(device
->dev
->handle
, "_DDC", &args
, &buffer
);
687 if (ACPI_FAILURE(status
))
690 obj
= buffer
.pointer
;
692 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
)
695 printk(KERN_ERR PREFIX
"Invalid _DDC data\n");
706 acpi_video_bus_set_POST(struct acpi_video_bus
*video
, unsigned long option
)
709 unsigned long long tmp
;
710 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
711 struct acpi_object_list args
= { 1, &arg0
};
714 arg0
.integer
.value
= option
;
716 status
= acpi_evaluate_integer(video
->device
->handle
, "_SPD", &args
, &tmp
);
717 if (ACPI_SUCCESS(status
))
718 status
= tmp
? (-EINVAL
) : (AE_OK
);
724 acpi_video_bus_get_POST(struct acpi_video_bus
*video
, unsigned long long *id
)
728 status
= acpi_evaluate_integer(video
->device
->handle
, "_GPD", NULL
, id
);
734 acpi_video_bus_POST_options(struct acpi_video_bus
*video
,
735 unsigned long long *options
)
739 status
= acpi_evaluate_integer(video
->device
->handle
, "_VPO", NULL
, options
);
747 * video : video bus device pointer
749 * 0. The system BIOS should NOT automatically switch(toggle)
750 * the active display output.
751 * 1. The system BIOS should automatically switch (toggle) the
752 * active display output. No switch event.
753 * 2. The _DGS value should be locked.
754 * 3. The system BIOS should not automatically switch (toggle) the
755 * active display output, but instead generate the display switch
758 * 0. The system BIOS should automatically control the brightness level
759 * of the LCD when the power changes from AC to DC
760 * 1. The system BIOS should NOT automatically control the brightness
761 * level of the LCD when the power changes from AC to DC.
767 acpi_video_bus_DOS(struct acpi_video_bus
*video
, int bios_flag
, int lcd_flag
)
770 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
771 struct acpi_object_list args
= { 1, &arg0
};
774 if (bios_flag
< 0 || bios_flag
> 3 || lcd_flag
< 0 || lcd_flag
> 1) {
778 arg0
.integer
.value
= (lcd_flag
<< 2) | bios_flag
;
779 video
->dos_setting
= arg0
.integer
.value
;
780 acpi_evaluate_object(video
->device
->handle
, "_DOS", &args
, NULL
);
787 * Simple comparison function used to sort backlight levels.
791 acpi_video_cmp_level(const void *a
, const void *b
)
793 return *(int *)a
- *(int *)b
;
798 * device : video output device (LCD, CRT, ..)
801 * Maximum brightness level
803 * Allocate and initialize device->brightness.
807 acpi_video_init_brightness(struct acpi_video_device
*device
)
809 union acpi_object
*obj
= NULL
;
810 int i
, max_level
= 0, count
= 0, level_ac_battery
= 0;
811 unsigned long long level
, level_old
;
812 union acpi_object
*o
;
813 struct acpi_video_device_brightness
*br
= NULL
;
814 int result
= -EINVAL
;
816 if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device
, &obj
))) {
817 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Could not query available "
818 "LCD brightness level\n"));
822 if (obj
->package
.count
< 2)
825 br
= kzalloc(sizeof(*br
), GFP_KERNEL
);
827 printk(KERN_ERR
"can't allocate memory\n");
832 br
->levels
= kmalloc((obj
->package
.count
+ 2) * sizeof *(br
->levels
),
839 for (i
= 0; i
< obj
->package
.count
; i
++) {
840 o
= (union acpi_object
*)&obj
->package
.elements
[i
];
841 if (o
->type
!= ACPI_TYPE_INTEGER
) {
842 printk(KERN_ERR PREFIX
"Invalid data\n");
845 br
->levels
[count
] = (u32
) o
->integer
.value
;
847 if (br
->levels
[count
] > max_level
)
848 max_level
= br
->levels
[count
];
853 * some buggy BIOS don't export the levels
854 * when machine is on AC/Battery in _BCL package.
855 * In this case, the first two elements in _BCL packages
856 * are also supported brightness levels that OS should take care of.
858 for (i
= 2; i
< count
; i
++) {
859 if (br
->levels
[i
] == br
->levels
[0])
861 if (br
->levels
[i
] == br
->levels
[1])
865 if (level_ac_battery
< 2) {
866 level_ac_battery
= 2 - level_ac_battery
;
867 br
->flags
._BCL_no_ac_battery_levels
= 1;
868 for (i
= (count
- 1 + level_ac_battery
); i
>= 2; i
--)
869 br
->levels
[i
] = br
->levels
[i
- level_ac_battery
];
870 count
+= level_ac_battery
;
871 } else if (level_ac_battery
> 2)
872 ACPI_ERROR((AE_INFO
, "Too many duplicates in _BCL package\n"));
874 /* Check if the _BCL package is in a reversed order */
875 if (max_level
== br
->levels
[2]) {
876 br
->flags
._BCL_reversed
= 1;
877 sort(&br
->levels
[2], count
- 2, sizeof(br
->levels
[2]),
878 acpi_video_cmp_level
, NULL
);
879 } else if (max_level
!= br
->levels
[count
- 1])
881 "Found unordered _BCL package\n"));
884 device
->brightness
= br
;
886 /* Check the input/output of _BQC/_BCL/_BCM */
887 if ((max_level
< 100) && (max_level
<= (count
- 2)))
888 br
->flags
._BCL_use_index
= 1;
891 * _BCM is always consistent with _BCL,
892 * at least for all the laptops we have ever seen.
894 br
->flags
._BCM_use_index
= br
->flags
._BCL_use_index
;
896 /* _BQC uses INDEX while _BCL uses VALUE in some laptops */
897 br
->curr
= level
= max_level
;
899 if (!device
->cap
._BQC
)
902 result
= acpi_video_device_lcd_get_level_current(device
, &level_old
, 1);
904 goto out_free_levels
;
907 * Set the level to maximum and check if _BQC uses indexed value
909 result
= acpi_video_device_lcd_set_level(device
, max_level
);
911 goto out_free_levels
;
913 result
= acpi_video_device_lcd_get_level_current(device
, &level
, 0);
915 goto out_free_levels
;
917 br
->flags
._BQC_use_index
= (level
== max_level
? 0 : 1);
919 if (!br
->flags
._BQC_use_index
) {
921 * Set the backlight to the initial state.
922 * On some buggy laptops, _BQC returns an uninitialized value
923 * when invoked for the first time, i.e. level_old is invalid.
924 * set the backlight to max_level in this case
926 for (i
= 2; i
< br
->count
; i
++)
927 if (level_old
== br
->levels
[i
])
932 if (br
->flags
._BCL_reversed
)
933 level_old
= (br
->count
- 1) - level_old
;
934 level
= br
->levels
[level_old
];
937 result
= acpi_video_device_lcd_set_level(device
, level
);
939 goto out_free_levels
;
941 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
942 "found %d brightness levels\n", count
- 2));
951 device
->brightness
= NULL
;
958 * device : video output device (LCD, CRT, ..)
963 * Find out all required AML methods defined under the output
967 static void acpi_video_device_find_cap(struct acpi_video_device
*device
)
969 acpi_handle h_dummy1
;
971 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_ADR", &h_dummy1
))) {
972 device
->cap
._ADR
= 1;
974 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCL", &h_dummy1
))) {
975 device
->cap
._BCL
= 1;
977 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCM", &h_dummy1
))) {
978 device
->cap
._BCM
= 1;
980 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
,"_BQC",&h_dummy1
)))
981 device
->cap
._BQC
= 1;
982 else if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCQ",
984 printk(KERN_WARNING FW_BUG
"_BCQ is used instead of _BQC\n");
985 device
->cap
._BCQ
= 1;
988 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DDC", &h_dummy1
))) {
989 device
->cap
._DDC
= 1;
991 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DCS", &h_dummy1
))) {
992 device
->cap
._DCS
= 1;
994 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DGS", &h_dummy1
))) {
995 device
->cap
._DGS
= 1;
997 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DSS", &h_dummy1
))) {
998 device
->cap
._DSS
= 1;
1001 if (acpi_video_backlight_support()) {
1002 struct backlight_properties props
;
1004 static int count
= 0;
1007 result
= acpi_video_init_brightness(device
);
1010 name
= kzalloc(MAX_NAME_LEN
, GFP_KERNEL
);
1014 sprintf(name
, "acpi_video%d", count
++);
1015 memset(&props
, 0, sizeof(struct backlight_properties
));
1016 props
.max_brightness
= device
->brightness
->count
- 3;
1017 device
->backlight
= backlight_device_register(name
, NULL
, device
,
1018 &acpi_backlight_ops
,
1021 if (IS_ERR(device
->backlight
))
1025 * Save current brightness level in case we have to restore it
1026 * before acpi_video_device_lcd_set_level() is called next time.
1028 device
->backlight
->props
.brightness
=
1029 acpi_video_get_brightness(device
->backlight
);
1031 result
= sysfs_create_link(&device
->backlight
->dev
.kobj
,
1032 &device
->dev
->dev
.kobj
, "device");
1034 printk(KERN_ERR PREFIX
"Create sysfs link\n");
1036 device
->cooling_dev
= thermal_cooling_device_register("LCD",
1037 device
->dev
, &video_cooling_ops
);
1038 if (IS_ERR(device
->cooling_dev
)) {
1040 * Set cooling_dev to NULL so we don't crash trying to
1042 * Also, why the hell we are returning early and
1043 * not attempt to register video output if cooling
1044 * device registration failed?
1047 device
->cooling_dev
= NULL
;
1051 dev_info(&device
->dev
->dev
, "registered as cooling_device%d\n",
1052 device
->cooling_dev
->id
);
1053 result
= sysfs_create_link(&device
->dev
->dev
.kobj
,
1054 &device
->cooling_dev
->device
.kobj
,
1057 printk(KERN_ERR PREFIX
"Create sysfs link\n");
1058 result
= sysfs_create_link(&device
->cooling_dev
->device
.kobj
,
1059 &device
->dev
->dev
.kobj
, "device");
1061 printk(KERN_ERR PREFIX
"Create sysfs link\n");
1065 if (acpi_video_display_switch_support()) {
1067 if (device
->cap
._DCS
&& device
->cap
._DSS
) {
1070 name
= kzalloc(MAX_NAME_LEN
, GFP_KERNEL
);
1073 sprintf(name
, "acpi_video%d", count
++);
1074 device
->output_dev
= video_output_register(name
,
1075 NULL
, device
, &acpi_output_properties
);
1083 * device : video output device (VGA)
1088 * Find out all required AML methods defined under the video bus device.
1091 static void acpi_video_bus_find_cap(struct acpi_video_bus
*video
)
1093 acpi_handle h_dummy1
;
1095 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_DOS", &h_dummy1
))) {
1096 video
->cap
._DOS
= 1;
1098 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_DOD", &h_dummy1
))) {
1099 video
->cap
._DOD
= 1;
1101 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_ROM", &h_dummy1
))) {
1102 video
->cap
._ROM
= 1;
1104 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_GPD", &h_dummy1
))) {
1105 video
->cap
._GPD
= 1;
1107 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_SPD", &h_dummy1
))) {
1108 video
->cap
._SPD
= 1;
1110 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_VPO", &h_dummy1
))) {
1111 video
->cap
._VPO
= 1;
1116 * Check whether the video bus device has required AML method to
1117 * support the desired features
1120 static int acpi_video_bus_check(struct acpi_video_bus
*video
)
1122 acpi_status status
= -ENOENT
;
1123 struct pci_dev
*dev
;
1128 dev
= acpi_get_pci_dev(video
->device
->handle
);
1133 /* Since there is no HID, CID and so on for VGA driver, we have
1134 * to check well known required nodes.
1137 /* Does this device support video switching? */
1138 if (video
->cap
._DOS
|| video
->cap
._DOD
) {
1139 if (!video
->cap
._DOS
) {
1140 printk(KERN_WARNING FW_BUG
1141 "ACPI(%s) defines _DOD but not _DOS\n",
1142 acpi_device_bid(video
->device
));
1144 video
->flags
.multihead
= 1;
1148 /* Does this device support retrieving a video ROM? */
1149 if (video
->cap
._ROM
) {
1150 video
->flags
.rom
= 1;
1154 /* Does this device support configuring which video device to POST? */
1155 if (video
->cap
._GPD
&& video
->cap
._SPD
&& video
->cap
._VPO
) {
1156 video
->flags
.post
= 1;
1163 /* --------------------------------------------------------------------------
1164 FS Interface (/proc)
1165 -------------------------------------------------------------------------- */
1167 static struct proc_dir_entry
*acpi_video_dir
;
1171 static int acpi_video_device_info_seq_show(struct seq_file
*seq
, void *offset
)
1173 struct acpi_video_device
*dev
= seq
->private;
1179 seq_printf(seq
, "device_id: 0x%04x\n", (u32
) dev
->device_id
);
1180 seq_printf(seq
, "type: ");
1182 seq_printf(seq
, "CRT\n");
1183 else if (dev
->flags
.lcd
)
1184 seq_printf(seq
, "LCD\n");
1185 else if (dev
->flags
.tvout
)
1186 seq_printf(seq
, "TVOUT\n");
1187 else if (dev
->flags
.dvi
)
1188 seq_printf(seq
, "DVI\n");
1190 seq_printf(seq
, "UNKNOWN\n");
1192 seq_printf(seq
, "known by bios: %s\n", dev
->flags
.bios
? "yes" : "no");
1199 acpi_video_device_info_open_fs(struct inode
*inode
, struct file
*file
)
1201 return single_open(file
, acpi_video_device_info_seq_show
,
1205 static int acpi_video_device_state_seq_show(struct seq_file
*seq
, void *offset
)
1208 struct acpi_video_device
*dev
= seq
->private;
1209 unsigned long long state
;
1215 status
= acpi_video_device_get_state(dev
, &state
);
1216 seq_printf(seq
, "state: ");
1217 if (ACPI_SUCCESS(status
))
1218 seq_printf(seq
, "0x%02llx\n", state
);
1220 seq_printf(seq
, "<not supported>\n");
1222 status
= acpi_video_device_query(dev
, &state
);
1223 seq_printf(seq
, "query: ");
1224 if (ACPI_SUCCESS(status
))
1225 seq_printf(seq
, "0x%02llx\n", state
);
1227 seq_printf(seq
, "<not supported>\n");
1234 acpi_video_device_state_open_fs(struct inode
*inode
, struct file
*file
)
1236 return single_open(file
, acpi_video_device_state_seq_show
,
1241 acpi_video_device_write_state(struct file
*file
,
1242 const char __user
* buffer
,
1243 size_t count
, loff_t
* data
)
1246 struct seq_file
*m
= file
->private_data
;
1247 struct acpi_video_device
*dev
= m
->private;
1248 char str
[12] = { 0 };
1252 if (!dev
|| count
>= sizeof(str
))
1255 if (copy_from_user(str
, buffer
, count
))
1259 state
= simple_strtoul(str
, NULL
, 0);
1260 state
&= ((1ul << 31) | (1ul << 30) | (1ul << 0));
1262 status
= acpi_video_device_set_state(dev
, state
);
1271 acpi_video_device_brightness_seq_show(struct seq_file
*seq
, void *offset
)
1273 struct acpi_video_device
*dev
= seq
->private;
1277 if (!dev
|| !dev
->brightness
) {
1278 seq_printf(seq
, "<not supported>\n");
1282 seq_printf(seq
, "levels: ");
1283 for (i
= 2; i
< dev
->brightness
->count
; i
++)
1284 seq_printf(seq
, " %d", dev
->brightness
->levels
[i
]);
1285 seq_printf(seq
, "\ncurrent: %d\n", dev
->brightness
->curr
);
1291 acpi_video_device_brightness_open_fs(struct inode
*inode
, struct file
*file
)
1293 return single_open(file
, acpi_video_device_brightness_seq_show
,
1298 acpi_video_device_write_brightness(struct file
*file
,
1299 const char __user
* buffer
,
1300 size_t count
, loff_t
* data
)
1302 struct seq_file
*m
= file
->private_data
;
1303 struct acpi_video_device
*dev
= m
->private;
1304 char str
[5] = { 0 };
1305 unsigned int level
= 0;
1309 if (!dev
|| !dev
->brightness
|| count
>= sizeof(str
))
1312 if (copy_from_user(str
, buffer
, count
))
1316 level
= simple_strtoul(str
, NULL
, 0);
1321 /* validate through the list of available levels */
1322 for (i
= 2; i
< dev
->brightness
->count
; i
++)
1323 if (level
== dev
->brightness
->levels
[i
]) {
1324 if (!acpi_video_device_lcd_set_level(dev
, level
))
1332 static int acpi_video_device_EDID_seq_show(struct seq_file
*seq
, void *offset
)
1334 struct acpi_video_device
*dev
= seq
->private;
1337 union acpi_object
*edid
= NULL
;
1343 status
= acpi_video_device_EDID(dev
, &edid
, 128);
1344 if (ACPI_FAILURE(status
)) {
1345 status
= acpi_video_device_EDID(dev
, &edid
, 256);
1348 if (ACPI_FAILURE(status
)) {
1352 if (edid
&& edid
->type
== ACPI_TYPE_BUFFER
) {
1353 for (i
= 0; i
< edid
->buffer
.length
; i
++)
1354 seq_putc(seq
, edid
->buffer
.pointer
[i
]);
1359 seq_printf(seq
, "<not supported>\n");
1367 acpi_video_device_EDID_open_fs(struct inode
*inode
, struct file
*file
)
1369 return single_open(file
, acpi_video_device_EDID_seq_show
,
1373 static int acpi_video_device_add_fs(struct acpi_device
*device
)
1375 struct proc_dir_entry
*entry
, *device_dir
;
1376 struct acpi_video_device
*vid_dev
;
1378 vid_dev
= acpi_driver_data(device
);
1382 device_dir
= proc_mkdir(acpi_device_bid(device
),
1383 vid_dev
->video
->dir
);
1388 entry
= proc_create_data("info", S_IRUGO
, device_dir
,
1389 &acpi_video_device_info_fops
, acpi_driver_data(device
));
1391 goto err_remove_dir
;
1394 entry
= proc_create_data("state", S_IFREG
| S_IRUGO
| S_IWUSR
,
1396 &acpi_video_device_state_fops
,
1397 acpi_driver_data(device
));
1399 goto err_remove_info
;
1401 /* 'brightness' [R/W] */
1402 entry
= proc_create_data("brightness", S_IFREG
| S_IRUGO
| S_IWUSR
,
1404 &acpi_video_device_brightness_fops
,
1405 acpi_driver_data(device
));
1407 goto err_remove_state
;
1410 entry
= proc_create_data("EDID", S_IRUGO
, device_dir
,
1411 &acpi_video_device_EDID_fops
,
1412 acpi_driver_data(device
));
1414 goto err_remove_brightness
;
1416 acpi_device_dir(device
) = device_dir
;
1420 err_remove_brightness
:
1421 remove_proc_entry("brightness", device_dir
);
1423 remove_proc_entry("state", device_dir
);
1425 remove_proc_entry("info", device_dir
);
1427 remove_proc_entry(acpi_device_bid(device
), vid_dev
->video
->dir
);
1431 static int acpi_video_device_remove_fs(struct acpi_device
*device
)
1433 struct acpi_video_device
*vid_dev
;
1434 struct proc_dir_entry
*device_dir
;
1436 vid_dev
= acpi_driver_data(device
);
1437 if (!vid_dev
|| !vid_dev
->video
|| !vid_dev
->video
->dir
)
1440 device_dir
= acpi_device_dir(device
);
1442 remove_proc_entry("info", device_dir
);
1443 remove_proc_entry("state", device_dir
);
1444 remove_proc_entry("brightness", device_dir
);
1445 remove_proc_entry("EDID", device_dir
);
1446 remove_proc_entry(acpi_device_bid(device
), vid_dev
->video
->dir
);
1447 acpi_device_dir(device
) = NULL
;
1454 static int acpi_video_bus_info_seq_show(struct seq_file
*seq
, void *offset
)
1456 struct acpi_video_bus
*video
= seq
->private;
1462 seq_printf(seq
, "Switching heads: %s\n",
1463 video
->flags
.multihead
? "yes" : "no");
1464 seq_printf(seq
, "Video ROM: %s\n",
1465 video
->flags
.rom
? "yes" : "no");
1466 seq_printf(seq
, "Device to be POSTed on boot: %s\n",
1467 video
->flags
.post
? "yes" : "no");
1473 static int acpi_video_bus_info_open_fs(struct inode
*inode
, struct file
*file
)
1475 return single_open(file
, acpi_video_bus_info_seq_show
,
1479 static int acpi_video_bus_ROM_seq_show(struct seq_file
*seq
, void *offset
)
1481 struct acpi_video_bus
*video
= seq
->private;
1487 printk(KERN_INFO PREFIX
"Please implement %s\n", __func__
);
1488 seq_printf(seq
, "<TODO>\n");
1494 static int acpi_video_bus_ROM_open_fs(struct inode
*inode
, struct file
*file
)
1496 return single_open(file
, acpi_video_bus_ROM_seq_show
, PDE(inode
)->data
);
1499 static int acpi_video_bus_POST_info_seq_show(struct seq_file
*seq
, void *offset
)
1501 struct acpi_video_bus
*video
= seq
->private;
1502 unsigned long long options
;
1509 status
= acpi_video_bus_POST_options(video
, &options
);
1510 if (ACPI_SUCCESS(status
)) {
1511 if (!(options
& 1)) {
1512 printk(KERN_WARNING PREFIX
1513 "The motherboard VGA device is not listed as a possible POST device.\n");
1514 printk(KERN_WARNING PREFIX
1515 "This indicates a BIOS bug. Please contact the manufacturer.\n");
1517 printk(KERN_WARNING
"%llx\n", options
);
1518 seq_printf(seq
, "can POST: <integrated video>");
1520 seq_printf(seq
, " <PCI video>");
1522 seq_printf(seq
, " <AGP video>");
1523 seq_putc(seq
, '\n');
1525 seq_printf(seq
, "<not supported>\n");
1531 acpi_video_bus_POST_info_open_fs(struct inode
*inode
, struct file
*file
)
1533 return single_open(file
, acpi_video_bus_POST_info_seq_show
,
1537 static int acpi_video_bus_POST_seq_show(struct seq_file
*seq
, void *offset
)
1539 struct acpi_video_bus
*video
= seq
->private;
1541 unsigned long long id
;
1547 status
= acpi_video_bus_get_POST(video
, &id
);
1548 if (!ACPI_SUCCESS(status
)) {
1549 seq_printf(seq
, "<not supported>\n");
1552 seq_printf(seq
, "device POSTed is <%s>\n", device_decode
[id
& 3]);
1558 static int acpi_video_bus_DOS_seq_show(struct seq_file
*seq
, void *offset
)
1560 struct acpi_video_bus
*video
= seq
->private;
1563 seq_printf(seq
, "DOS setting: <%d>\n", video
->dos_setting
);
1568 static int acpi_video_bus_POST_open_fs(struct inode
*inode
, struct file
*file
)
1570 return single_open(file
, acpi_video_bus_POST_seq_show
,
1574 static int acpi_video_bus_DOS_open_fs(struct inode
*inode
, struct file
*file
)
1576 return single_open(file
, acpi_video_bus_DOS_seq_show
, PDE(inode
)->data
);
1580 acpi_video_bus_write_POST(struct file
*file
,
1581 const char __user
* buffer
,
1582 size_t count
, loff_t
* data
)
1585 struct seq_file
*m
= file
->private_data
;
1586 struct acpi_video_bus
*video
= m
->private;
1587 char str
[12] = { 0 };
1588 unsigned long long opt
, options
;
1591 if (!video
|| count
>= sizeof(str
))
1594 status
= acpi_video_bus_POST_options(video
, &options
);
1595 if (!ACPI_SUCCESS(status
))
1598 if (copy_from_user(str
, buffer
, count
))
1602 opt
= strtoul(str
, NULL
, 0);
1606 /* just in case an OEM 'forgot' the motherboard... */
1609 if (options
& (1ul << opt
)) {
1610 status
= acpi_video_bus_set_POST(video
, opt
);
1611 if (!ACPI_SUCCESS(status
))
1620 acpi_video_bus_write_DOS(struct file
*file
,
1621 const char __user
* buffer
,
1622 size_t count
, loff_t
* data
)
1625 struct seq_file
*m
= file
->private_data
;
1626 struct acpi_video_bus
*video
= m
->private;
1627 char str
[12] = { 0 };
1631 if (!video
|| count
>= sizeof(str
))
1634 if (copy_from_user(str
, buffer
, count
))
1638 opt
= strtoul(str
, NULL
, 0);
1642 status
= acpi_video_bus_DOS(video
, opt
& 0x3, (opt
& 0x4) >> 2);
1644 if (!ACPI_SUCCESS(status
))
1650 static int acpi_video_bus_add_fs(struct acpi_device
*device
)
1652 struct acpi_video_bus
*video
= acpi_driver_data(device
);
1653 struct proc_dir_entry
*device_dir
;
1654 struct proc_dir_entry
*entry
;
1656 device_dir
= proc_mkdir(acpi_device_bid(device
), acpi_video_dir
);
1661 entry
= proc_create_data("info", S_IRUGO
, device_dir
,
1662 &acpi_video_bus_info_fops
,
1663 acpi_driver_data(device
));
1665 goto err_remove_dir
;
1668 entry
= proc_create_data("ROM", S_IRUGO
, device_dir
,
1669 &acpi_video_bus_ROM_fops
,
1670 acpi_driver_data(device
));
1672 goto err_remove_info
;
1674 /* 'POST_info' [R] */
1675 entry
= proc_create_data("POST_info", S_IRUGO
, device_dir
,
1676 &acpi_video_bus_POST_info_fops
,
1677 acpi_driver_data(device
));
1679 goto err_remove_rom
;
1682 entry
= proc_create_data("POST", S_IFREG
| S_IRUGO
| S_IWUSR
,
1684 &acpi_video_bus_POST_fops
,
1685 acpi_driver_data(device
));
1687 goto err_remove_post_info
;
1690 entry
= proc_create_data("DOS", S_IFREG
| S_IRUGO
| S_IWUSR
,
1692 &acpi_video_bus_DOS_fops
,
1693 acpi_driver_data(device
));
1695 goto err_remove_post
;
1697 video
->dir
= acpi_device_dir(device
) = device_dir
;
1701 remove_proc_entry("POST", device_dir
);
1702 err_remove_post_info
:
1703 remove_proc_entry("POST_info", device_dir
);
1705 remove_proc_entry("ROM", device_dir
);
1707 remove_proc_entry("info", device_dir
);
1709 remove_proc_entry(acpi_device_bid(device
), acpi_video_dir
);
1713 static int acpi_video_bus_remove_fs(struct acpi_device
*device
)
1715 struct proc_dir_entry
*device_dir
= acpi_device_dir(device
);
1718 remove_proc_entry("info", device_dir
);
1719 remove_proc_entry("ROM", device_dir
);
1720 remove_proc_entry("POST_info", device_dir
);
1721 remove_proc_entry("POST", device_dir
);
1722 remove_proc_entry("DOS", device_dir
);
1723 remove_proc_entry(acpi_device_bid(device
), acpi_video_dir
);
1724 acpi_device_dir(device
) = NULL
;
1730 /* --------------------------------------------------------------------------
1732 -------------------------------------------------------------------------- */
1734 /* device interface */
1735 static struct acpi_video_device_attrib
*
1736 acpi_video_get_device_attr(struct acpi_video_bus
*video
, unsigned long device_id
)
1738 struct acpi_video_enumerated_device
*ids
;
1741 for (i
= 0; i
< video
->attached_count
; i
++) {
1742 ids
= &video
->attached_array
[i
];
1743 if ((ids
->value
.int_val
& 0xffff) == device_id
)
1744 return &ids
->value
.attrib
;
1751 acpi_video_bus_get_one_device(struct acpi_device
*device
,
1752 struct acpi_video_bus
*video
)
1754 unsigned long long device_id
;
1756 struct acpi_video_device
*data
;
1757 struct acpi_video_device_attrib
* attribute
;
1759 if (!device
|| !video
)
1763 acpi_evaluate_integer(device
->handle
, "_ADR", NULL
, &device_id
);
1764 if (ACPI_SUCCESS(status
)) {
1766 data
= kzalloc(sizeof(struct acpi_video_device
), GFP_KERNEL
);
1770 strcpy(acpi_device_name(device
), ACPI_VIDEO_DEVICE_NAME
);
1771 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1772 device
->driver_data
= data
;
1774 data
->device_id
= device_id
;
1775 data
->video
= video
;
1778 attribute
= acpi_video_get_device_attr(video
, device_id
);
1780 if((attribute
!= NULL
) && attribute
->device_id_scheme
) {
1781 switch (attribute
->display_type
) {
1782 case ACPI_VIDEO_DISPLAY_CRT
:
1783 data
->flags
.crt
= 1;
1785 case ACPI_VIDEO_DISPLAY_TV
:
1786 data
->flags
.tvout
= 1;
1788 case ACPI_VIDEO_DISPLAY_DVI
:
1789 data
->flags
.dvi
= 1;
1791 case ACPI_VIDEO_DISPLAY_LCD
:
1792 data
->flags
.lcd
= 1;
1795 data
->flags
.unknown
= 1;
1798 if(attribute
->bios_can_detect
)
1799 data
->flags
.bios
= 1;
1801 data
->flags
.unknown
= 1;
1803 acpi_video_device_bind(video
, data
);
1804 acpi_video_device_find_cap(data
);
1806 status
= acpi_install_notify_handler(device
->handle
,
1808 acpi_video_device_notify
,
1810 if (ACPI_FAILURE(status
)) {
1811 printk(KERN_ERR PREFIX
1812 "Error installing notify handler\n");
1813 if(data
->brightness
)
1814 kfree(data
->brightness
->levels
);
1815 kfree(data
->brightness
);
1820 mutex_lock(&video
->device_list_lock
);
1821 list_add_tail(&data
->entry
, &video
->video_device_list
);
1822 mutex_unlock(&video
->device_list_lock
);
1824 acpi_video_device_add_fs(device
);
1834 * video : video bus device
1839 * Enumerate the video device list of the video bus,
1840 * bind the ids with the corresponding video devices
1841 * under the video bus.
1844 static void acpi_video_device_rebind(struct acpi_video_bus
*video
)
1846 struct acpi_video_device
*dev
;
1848 mutex_lock(&video
->device_list_lock
);
1850 list_for_each_entry(dev
, &video
->video_device_list
, entry
)
1851 acpi_video_device_bind(video
, dev
);
1853 mutex_unlock(&video
->device_list_lock
);
1858 * video : video bus device
1859 * device : video output device under the video
1865 * Bind the ids with the corresponding video devices
1866 * under the video bus.
1870 acpi_video_device_bind(struct acpi_video_bus
*video
,
1871 struct acpi_video_device
*device
)
1873 struct acpi_video_enumerated_device
*ids
;
1876 for (i
= 0; i
< video
->attached_count
; i
++) {
1877 ids
= &video
->attached_array
[i
];
1878 if (device
->device_id
== (ids
->value
.int_val
& 0xffff)) {
1879 ids
->bind_info
= device
;
1880 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "device_bind %d\n", i
));
1887 * video : video bus device
1892 * Call _DOD to enumerate all devices attached to display adapter
1896 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
)
1901 struct acpi_video_enumerated_device
*active_list
;
1902 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1903 union acpi_object
*dod
= NULL
;
1904 union acpi_object
*obj
;
1906 status
= acpi_evaluate_object(video
->device
->handle
, "_DOD", NULL
, &buffer
);
1907 if (!ACPI_SUCCESS(status
)) {
1908 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _DOD"));
1912 dod
= buffer
.pointer
;
1913 if (!dod
|| (dod
->type
!= ACPI_TYPE_PACKAGE
)) {
1914 ACPI_EXCEPTION((AE_INFO
, status
, "Invalid _DOD data"));
1919 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found %d video heads in _DOD\n",
1920 dod
->package
.count
));
1922 active_list
= kcalloc(1 + dod
->package
.count
,
1923 sizeof(struct acpi_video_enumerated_device
),
1931 for (i
= 0; i
< dod
->package
.count
; i
++) {
1932 obj
= &dod
->package
.elements
[i
];
1934 if (obj
->type
!= ACPI_TYPE_INTEGER
) {
1935 printk(KERN_ERR PREFIX
1936 "Invalid _DOD data in element %d\n", i
);
1940 active_list
[count
].value
.int_val
= obj
->integer
.value
;
1941 active_list
[count
].bind_info
= NULL
;
1942 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "dod element[%d] = %d\n", i
,
1943 (int)obj
->integer
.value
));
1947 kfree(video
->attached_array
);
1949 video
->attached_array
= active_list
;
1950 video
->attached_count
= count
;
1953 kfree(buffer
.pointer
);
1958 acpi_video_get_next_level(struct acpi_video_device
*device
,
1959 u32 level_current
, u32 event
)
1961 int min
, max
, min_above
, max_below
, i
, l
, delta
= 255;
1962 max
= max_below
= 0;
1963 min
= min_above
= 255;
1964 /* Find closest level to level_current */
1965 for (i
= 2; i
< device
->brightness
->count
; i
++) {
1966 l
= device
->brightness
->levels
[i
];
1967 if (abs(l
- level_current
) < abs(delta
)) {
1968 delta
= l
- level_current
;
1973 /* Ajust level_current to closest available level */
1974 level_current
+= delta
;
1975 for (i
= 2; i
< device
->brightness
->count
; i
++) {
1976 l
= device
->brightness
->levels
[i
];
1981 if (l
< min_above
&& l
> level_current
)
1983 if (l
> max_below
&& l
< level_current
)
1988 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
:
1989 return (level_current
< max
) ? min_above
: min
;
1990 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
:
1991 return (level_current
< max
) ? min_above
: max
;
1992 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
:
1993 return (level_current
> min
) ? max_below
: min
;
1994 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
:
1995 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
:
1998 return level_current
;
2003 acpi_video_switch_brightness(struct acpi_video_device
*device
, int event
)
2005 unsigned long long level_current
, level_next
;
2006 int result
= -EINVAL
;
2008 /* no warning message if acpi_backlight=vendor is used */
2009 if (!acpi_video_backlight_support())
2012 if (!device
->brightness
)
2015 result
= acpi_video_device_lcd_get_level_current(device
,
2020 level_next
= acpi_video_get_next_level(device
, level_current
, event
);
2022 result
= acpi_video_device_lcd_set_level(device
, level_next
);
2025 backlight_force_update(device
->backlight
,
2026 BACKLIGHT_UPDATE_HOTKEY
);
2030 printk(KERN_ERR PREFIX
"Failed to switch the brightness\n");
2036 acpi_video_bus_get_devices(struct acpi_video_bus
*video
,
2037 struct acpi_device
*device
)
2040 struct acpi_device
*dev
;
2042 acpi_video_device_enumerate(video
);
2044 list_for_each_entry(dev
, &device
->children
, node
) {
2046 status
= acpi_video_bus_get_one_device(dev
, video
);
2047 if (ACPI_FAILURE(status
)) {
2048 printk(KERN_WARNING PREFIX
2049 "Cant attach device");
2056 static int acpi_video_bus_put_one_device(struct acpi_video_device
*device
)
2059 struct acpi_video_bus
*video
;
2062 if (!device
|| !device
->video
)
2065 video
= device
->video
;
2067 acpi_video_device_remove_fs(device
->dev
);
2069 status
= acpi_remove_notify_handler(device
->dev
->handle
,
2071 acpi_video_device_notify
);
2072 if (device
->backlight
) {
2073 sysfs_remove_link(&device
->backlight
->dev
.kobj
, "device");
2074 backlight_device_unregister(device
->backlight
);
2075 device
->backlight
= NULL
;
2077 if (device
->cooling_dev
) {
2078 sysfs_remove_link(&device
->dev
->dev
.kobj
,
2080 sysfs_remove_link(&device
->cooling_dev
->device
.kobj
,
2082 thermal_cooling_device_unregister(device
->cooling_dev
);
2083 device
->cooling_dev
= NULL
;
2085 video_output_unregister(device
->output_dev
);
2090 static int acpi_video_bus_put_devices(struct acpi_video_bus
*video
)
2093 struct acpi_video_device
*dev
, *next
;
2095 mutex_lock(&video
->device_list_lock
);
2097 list_for_each_entry_safe(dev
, next
, &video
->video_device_list
, entry
) {
2099 status
= acpi_video_bus_put_one_device(dev
);
2100 if (ACPI_FAILURE(status
))
2101 printk(KERN_WARNING PREFIX
2102 "hhuuhhuu bug in acpi video driver.\n");
2104 if (dev
->brightness
) {
2105 kfree(dev
->brightness
->levels
);
2106 kfree(dev
->brightness
);
2108 list_del(&dev
->entry
);
2112 mutex_unlock(&video
->device_list_lock
);
2117 /* acpi_video interface */
2119 static int acpi_video_bus_start_devices(struct acpi_video_bus
*video
)
2121 return acpi_video_bus_DOS(video
, 0, 0);
2124 static int acpi_video_bus_stop_devices(struct acpi_video_bus
*video
)
2126 return acpi_video_bus_DOS(video
, 0, 1);
2129 static void acpi_video_bus_notify(struct acpi_device
*device
, u32 event
)
2131 struct acpi_video_bus
*video
= acpi_driver_data(device
);
2132 struct input_dev
*input
;
2138 input
= video
->input
;
2141 case ACPI_VIDEO_NOTIFY_SWITCH
: /* User requested a switch,
2142 * most likely via hotkey. */
2143 acpi_bus_generate_proc_event(device
, event
, 0);
2144 keycode
= KEY_SWITCHVIDEOMODE
;
2147 case ACPI_VIDEO_NOTIFY_PROBE
: /* User plugged in or removed a video
2149 acpi_video_device_enumerate(video
);
2150 acpi_video_device_rebind(video
);
2151 acpi_bus_generate_proc_event(device
, event
, 0);
2152 keycode
= KEY_SWITCHVIDEOMODE
;
2155 case ACPI_VIDEO_NOTIFY_CYCLE
: /* Cycle Display output hotkey pressed. */
2156 acpi_bus_generate_proc_event(device
, event
, 0);
2157 keycode
= KEY_SWITCHVIDEOMODE
;
2159 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
: /* Next Display output hotkey pressed. */
2160 acpi_bus_generate_proc_event(device
, event
, 0);
2161 keycode
= KEY_VIDEO_NEXT
;
2163 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
: /* previous Display output hotkey pressed. */
2164 acpi_bus_generate_proc_event(device
, event
, 0);
2165 keycode
= KEY_VIDEO_PREV
;
2169 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
2170 "Unsupported event [0x%x]\n", event
));
2174 acpi_notifier_call_chain(device
, event
, 0);
2177 input_report_key(input
, keycode
, 1);
2179 input_report_key(input
, keycode
, 0);
2186 static void acpi_video_device_notify(acpi_handle handle
, u32 event
, void *data
)
2188 struct acpi_video_device
*video_device
= data
;
2189 struct acpi_device
*device
= NULL
;
2190 struct acpi_video_bus
*bus
;
2191 struct input_dev
*input
;
2197 device
= video_device
->dev
;
2198 bus
= video_device
->video
;
2202 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
: /* Cycle brightness */
2203 if (brightness_switch_enabled
)
2204 acpi_video_switch_brightness(video_device
, event
);
2205 acpi_bus_generate_proc_event(device
, event
, 0);
2206 keycode
= KEY_BRIGHTNESS_CYCLE
;
2208 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
: /* Increase brightness */
2209 if (brightness_switch_enabled
)
2210 acpi_video_switch_brightness(video_device
, event
);
2211 acpi_bus_generate_proc_event(device
, event
, 0);
2212 keycode
= KEY_BRIGHTNESSUP
;
2214 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
: /* Decrease brightness */
2215 if (brightness_switch_enabled
)
2216 acpi_video_switch_brightness(video_device
, event
);
2217 acpi_bus_generate_proc_event(device
, event
, 0);
2218 keycode
= KEY_BRIGHTNESSDOWN
;
2220 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
: /* zero brightnesss */
2221 if (brightness_switch_enabled
)
2222 acpi_video_switch_brightness(video_device
, event
);
2223 acpi_bus_generate_proc_event(device
, event
, 0);
2224 keycode
= KEY_BRIGHTNESS_ZERO
;
2226 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
: /* display device off */
2227 if (brightness_switch_enabled
)
2228 acpi_video_switch_brightness(video_device
, event
);
2229 acpi_bus_generate_proc_event(device
, event
, 0);
2230 keycode
= KEY_DISPLAY_OFF
;
2233 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
2234 "Unsupported event [0x%x]\n", event
));
2238 acpi_notifier_call_chain(device
, event
, 0);
2241 input_report_key(input
, keycode
, 1);
2243 input_report_key(input
, keycode
, 0);
2250 static int acpi_video_resume(struct notifier_block
*nb
,
2251 unsigned long val
, void *ign
)
2253 struct acpi_video_bus
*video
;
2254 struct acpi_video_device
*video_device
;
2258 case PM_HIBERNATION_PREPARE
:
2259 case PM_SUSPEND_PREPARE
:
2260 case PM_RESTORE_PREPARE
:
2264 video
= container_of(nb
, struct acpi_video_bus
, pm_nb
);
2266 dev_info(&video
->device
->dev
, "Restoring backlight state\n");
2268 for (i
= 0; i
< video
->attached_count
; i
++) {
2269 video_device
= video
->attached_array
[i
].bind_info
;
2270 if (video_device
&& video_device
->backlight
)
2271 acpi_video_set_brightness(video_device
->backlight
);
2278 acpi_video_bus_match(acpi_handle handle
, u32 level
, void *context
,
2279 void **return_value
)
2281 struct acpi_device
*device
= context
;
2282 struct acpi_device
*sibling
;
2285 if (handle
== device
->handle
)
2286 return AE_CTRL_TERMINATE
;
2288 result
= acpi_bus_get_device(handle
, &sibling
);
2292 if (!strcmp(acpi_device_name(sibling
), ACPI_VIDEO_BUS_NAME
))
2293 return AE_ALREADY_EXISTS
;
2298 static int instance
;
2300 static int acpi_video_bus_add(struct acpi_device
*device
)
2302 struct acpi_video_bus
*video
;
2303 struct input_dev
*input
;
2307 status
= acpi_walk_namespace(ACPI_TYPE_DEVICE
,
2308 device
->parent
->handle
, 1,
2309 acpi_video_bus_match
, NULL
,
2311 if (status
== AE_ALREADY_EXISTS
) {
2312 printk(KERN_WARNING FW_BUG
2313 "Duplicate ACPI video bus devices for the"
2314 " same VGA controller, please try module "
2315 "parameter \"video.allow_duplicates=1\""
2316 "if the current driver doesn't work.\n");
2317 if (!allow_duplicates
)
2321 video
= kzalloc(sizeof(struct acpi_video_bus
), GFP_KERNEL
);
2325 /* a hack to fix the duplicate name "VID" problem on T61 */
2326 if (!strcmp(device
->pnp
.bus_id
, "VID")) {
2328 device
->pnp
.bus_id
[3] = '0' + instance
;
2331 /* a hack to fix the duplicate name "VGA" problem on Pa 3553 */
2332 if (!strcmp(device
->pnp
.bus_id
, "VGA")) {
2334 device
->pnp
.bus_id
[3] = '0' + instance
;
2338 video
->device
= device
;
2339 strcpy(acpi_device_name(device
), ACPI_VIDEO_BUS_NAME
);
2340 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
2341 device
->driver_data
= video
;
2343 acpi_video_bus_find_cap(video
);
2344 error
= acpi_video_bus_check(video
);
2346 goto err_free_video
;
2348 error
= acpi_video_bus_add_fs(device
);
2350 goto err_free_video
;
2352 mutex_init(&video
->device_list_lock
);
2353 INIT_LIST_HEAD(&video
->video_device_list
);
2355 acpi_video_bus_get_devices(video
, device
);
2356 acpi_video_bus_start_devices(video
);
2358 video
->input
= input
= input_allocate_device();
2361 goto err_stop_video
;
2364 snprintf(video
->phys
, sizeof(video
->phys
),
2365 "%s/video/input0", acpi_device_hid(video
->device
));
2367 input
->name
= acpi_device_name(video
->device
);
2368 input
->phys
= video
->phys
;
2369 input
->id
.bustype
= BUS_HOST
;
2370 input
->id
.product
= 0x06;
2371 input
->dev
.parent
= &device
->dev
;
2372 input
->evbit
[0] = BIT(EV_KEY
);
2373 set_bit(KEY_SWITCHVIDEOMODE
, input
->keybit
);
2374 set_bit(KEY_VIDEO_NEXT
, input
->keybit
);
2375 set_bit(KEY_VIDEO_PREV
, input
->keybit
);
2376 set_bit(KEY_BRIGHTNESS_CYCLE
, input
->keybit
);
2377 set_bit(KEY_BRIGHTNESSUP
, input
->keybit
);
2378 set_bit(KEY_BRIGHTNESSDOWN
, input
->keybit
);
2379 set_bit(KEY_BRIGHTNESS_ZERO
, input
->keybit
);
2380 set_bit(KEY_DISPLAY_OFF
, input
->keybit
);
2382 error
= input_register_device(input
);
2384 goto err_free_input_dev
;
2386 printk(KERN_INFO PREFIX
"%s [%s] (multi-head: %s rom: %s post: %s)\n",
2387 ACPI_VIDEO_DEVICE_NAME
, acpi_device_bid(device
),
2388 video
->flags
.multihead
? "yes" : "no",
2389 video
->flags
.rom
? "yes" : "no",
2390 video
->flags
.post
? "yes" : "no");
2392 video
->pm_nb
.notifier_call
= acpi_video_resume
;
2393 video
->pm_nb
.priority
= 0;
2394 register_pm_notifier(&video
->pm_nb
);
2399 input_free_device(input
);
2401 acpi_video_bus_stop_devices(video
);
2402 acpi_video_bus_put_devices(video
);
2403 kfree(video
->attached_array
);
2404 acpi_video_bus_remove_fs(device
);
2407 device
->driver_data
= NULL
;
2412 static int acpi_video_bus_remove(struct acpi_device
*device
, int type
)
2414 struct acpi_video_bus
*video
= NULL
;
2417 if (!device
|| !acpi_driver_data(device
))
2420 video
= acpi_driver_data(device
);
2422 unregister_pm_notifier(&video
->pm_nb
);
2424 acpi_video_bus_stop_devices(video
);
2425 acpi_video_bus_put_devices(video
);
2426 acpi_video_bus_remove_fs(device
);
2428 input_unregister_device(video
->input
);
2429 kfree(video
->attached_array
);
2435 static int __init
intel_opregion_present(void)
2437 #if defined(CONFIG_DRM_I915) || defined(CONFIG_DRM_I915_MODULE)
2438 struct pci_dev
*dev
= NULL
;
2441 for_each_pci_dev(dev
) {
2442 if ((dev
->class >> 8) != PCI_CLASS_DISPLAY_VGA
)
2444 if (dev
->vendor
!= PCI_VENDOR_ID_INTEL
)
2446 pci_read_config_dword(dev
, 0xfc, &address
);
2455 int acpi_video_register(void)
2458 if (register_count
) {
2460 * if the function of acpi_video_register is already called,
2461 * don't register the acpi_vide_bus again and return no error.
2466 acpi_video_dir
= proc_mkdir(ACPI_VIDEO_CLASS
, acpi_root_dir
);
2467 if (!acpi_video_dir
)
2470 result
= acpi_bus_register_driver(&acpi_video_bus
);
2472 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
2477 * When the acpi_video_bus is loaded successfully, increase
2478 * the counter reference.
2484 EXPORT_SYMBOL(acpi_video_register
);
2486 void acpi_video_unregister(void)
2488 if (!register_count
) {
2490 * If the acpi video bus is already unloaded, don't
2491 * unload it again and return directly.
2495 acpi_bus_unregister_driver(&acpi_video_bus
);
2497 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
2503 EXPORT_SYMBOL(acpi_video_unregister
);
2506 * This is kind of nasty. Hardware using Intel chipsets may require
2507 * the video opregion code to be run first in order to initialise
2508 * state before any ACPI video calls are made. To handle this we defer
2509 * registration of the video class until the opregion code has run.
2512 static int __init
acpi_video_init(void)
2514 dmi_check_system(video_dmi_table
);
2516 if (intel_opregion_present())
2519 return acpi_video_register();
2522 static void __exit
acpi_video_exit(void)
2524 acpi_video_unregister();
2529 module_init(acpi_video_init
);
2530 module_exit(acpi_video_exit
);