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/proc_fs.h>
33 #include <linux/seq_file.h>
35 #include <asm/uaccess.h>
37 #include <acpi/acpi_bus.h>
38 #include <acpi/acpi_drivers.h>
40 #define ACPI_VIDEO_COMPONENT 0x08000000
41 #define ACPI_VIDEO_CLASS "video"
42 #define ACPI_VIDEO_DRIVER_NAME "ACPI Video Driver"
43 #define ACPI_VIDEO_BUS_NAME "Video Bus"
44 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
45 #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
46 #define ACPI_VIDEO_NOTIFY_PROBE 0x81
47 #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
48 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
49 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
51 #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
52 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
53 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
54 #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
55 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
57 #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
58 #define ACPI_VIDEO_HEAD_END (~0u)
60 #define _COMPONENT ACPI_VIDEO_COMPONENT
61 ACPI_MODULE_NAME("acpi_video")
63 MODULE_AUTHOR("Bruno Ducrot");
64 MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME
);
65 MODULE_LICENSE("GPL");
67 static int acpi_video_bus_add(struct acpi_device
*device
);
68 static int acpi_video_bus_remove(struct acpi_device
*device
, int type
);
69 static int acpi_video_bus_match(struct acpi_device
*device
,
70 struct acpi_driver
*driver
);
72 static struct acpi_driver acpi_video_bus
= {
73 .name
= ACPI_VIDEO_DRIVER_NAME
,
74 .class = ACPI_VIDEO_CLASS
,
76 .add
= acpi_video_bus_add
,
77 .remove
= acpi_video_bus_remove
,
78 .match
= acpi_video_bus_match
,
82 struct acpi_video_bus_flags
{
83 u8 multihead
:1; /* can switch video heads */
84 u8 rom
:1; /* can retrieve a video rom */
85 u8 post
:1; /* can configure the head to */
89 struct acpi_video_bus_cap
{
90 u8 _DOS
:1; /*Enable/Disable output switching */
91 u8 _DOD
:1; /*Enumerate all devices attached to display adapter */
92 u8 _ROM
:1; /*Get ROM Data */
93 u8 _GPD
:1; /*Get POST Device */
94 u8 _SPD
:1; /*Set POST Device */
95 u8 _VPO
:1; /*Video POST Options */
99 struct acpi_video_device_attrib
{
100 u32 display_index
:4; /* A zero-based instance of the Display */
101 u32 display_port_attachment
:4; /*This field differenates displays type */
102 u32 display_type
:4; /*Describe the specific type in use */
103 u32 vendor_specific
:4; /*Chipset Vendor Specifi */
104 u32 bios_can_detect
:1; /*BIOS can detect the device */
105 u32 depend_on_vga
:1; /*Non-VGA output device whose power is related to
107 u32 pipe_id
:3; /*For VGA multiple-head devices. */
108 u32 reserved
:10; /*Must be 0 */
109 u32 device_id_scheme
:1; /*Device ID Scheme */
112 struct acpi_video_enumerated_device
{
115 struct acpi_video_device_attrib attrib
;
117 struct acpi_video_device
*bind_info
;
120 struct acpi_video_bus
{
121 struct acpi_device
*device
;
123 struct acpi_video_enumerated_device
*attached_array
;
125 struct acpi_video_bus_cap cap
;
126 struct acpi_video_bus_flags flags
;
127 struct semaphore sem
;
128 struct list_head video_device_list
;
129 struct proc_dir_entry
*dir
;
132 struct acpi_video_device_flags
{
141 struct acpi_video_device_cap
{
142 u8 _ADR
:1; /*Return the unique ID */
143 u8 _BCL
:1; /*Query list of brightness control levels supported */
144 u8 _BCM
:1; /*Set the brightness level */
145 u8 _DDC
:1; /*Return the EDID for this device */
146 u8 _DCS
:1; /*Return status of output device */
147 u8 _DGS
:1; /*Query graphics state */
148 u8 _DSS
:1; /*Device state set */
152 struct acpi_video_device_brightness
{
158 struct acpi_video_device
{
159 unsigned long device_id
;
160 struct acpi_video_device_flags flags
;
161 struct acpi_video_device_cap cap
;
162 struct list_head entry
;
163 struct acpi_video_bus
*video
;
164 struct acpi_device
*dev
;
165 struct acpi_video_device_brightness
*brightness
;
169 static int acpi_video_bus_info_open_fs(struct inode
*inode
, struct file
*file
);
170 static struct file_operations acpi_video_bus_info_fops
= {
171 .open
= acpi_video_bus_info_open_fs
,
174 .release
= single_release
,
177 static int acpi_video_bus_ROM_open_fs(struct inode
*inode
, struct file
*file
);
178 static struct file_operations acpi_video_bus_ROM_fops
= {
179 .open
= acpi_video_bus_ROM_open_fs
,
182 .release
= single_release
,
185 static int acpi_video_bus_POST_info_open_fs(struct inode
*inode
,
187 static struct file_operations acpi_video_bus_POST_info_fops
= {
188 .open
= acpi_video_bus_POST_info_open_fs
,
191 .release
= single_release
,
194 static int acpi_video_bus_POST_open_fs(struct inode
*inode
, struct file
*file
);
195 static struct file_operations acpi_video_bus_POST_fops
= {
196 .open
= acpi_video_bus_POST_open_fs
,
199 .release
= single_release
,
202 static int acpi_video_bus_DOS_open_fs(struct inode
*inode
, struct file
*file
);
203 static struct file_operations acpi_video_bus_DOS_fops
= {
204 .open
= acpi_video_bus_DOS_open_fs
,
207 .release
= single_release
,
211 static int acpi_video_device_info_open_fs(struct inode
*inode
,
213 static struct file_operations acpi_video_device_info_fops
= {
214 .open
= acpi_video_device_info_open_fs
,
217 .release
= single_release
,
220 static int acpi_video_device_state_open_fs(struct inode
*inode
,
222 static struct file_operations acpi_video_device_state_fops
= {
223 .open
= acpi_video_device_state_open_fs
,
226 .release
= single_release
,
229 static int acpi_video_device_brightness_open_fs(struct inode
*inode
,
231 static struct file_operations acpi_video_device_brightness_fops
= {
232 .open
= acpi_video_device_brightness_open_fs
,
235 .release
= single_release
,
238 static int acpi_video_device_EDID_open_fs(struct inode
*inode
,
240 static struct file_operations acpi_video_device_EDID_fops
= {
241 .open
= acpi_video_device_EDID_open_fs
,
244 .release
= single_release
,
247 static char device_decode
[][30] = {
248 "motherboard VGA device",
254 static void acpi_video_device_notify(acpi_handle handle
, u32 event
, void *data
);
255 static void acpi_video_device_rebind(struct acpi_video_bus
*video
);
256 static void acpi_video_device_bind(struct acpi_video_bus
*video
,
257 struct acpi_video_device
*device
);
258 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
);
259 static int acpi_video_switch_output(struct acpi_video_bus
*video
, int event
);
260 static int acpi_video_get_next_level(struct acpi_video_device
*device
,
261 u32 level_current
, u32 event
);
262 static void acpi_video_switch_brightness(struct acpi_video_device
*device
,
265 /* --------------------------------------------------------------------------
267 -------------------------------------------------------------------------- */
272 acpi_video_device_query(struct acpi_video_device
*device
, unsigned long *state
)
276 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DGS", NULL
, state
);
282 acpi_video_device_get_state(struct acpi_video_device
*device
,
283 unsigned long *state
)
287 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DCS", NULL
, state
);
293 acpi_video_device_set_state(struct acpi_video_device
*device
, int state
)
296 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
297 struct acpi_object_list args
= { 1, &arg0
};
301 arg0
.integer
.value
= state
;
302 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DSS", &args
, &ret
);
308 acpi_video_device_lcd_query_levels(struct acpi_video_device
*device
,
309 union acpi_object
**levels
)
312 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
313 union acpi_object
*obj
;
318 status
= acpi_evaluate_object(device
->dev
->handle
, "_BCL", NULL
, &buffer
);
319 if (!ACPI_SUCCESS(status
))
321 obj
= (union acpi_object
*)buffer
.pointer
;
322 if (!obj
|| (obj
->type
!= ACPI_TYPE_PACKAGE
)) {
323 printk(KERN_ERR PREFIX
"Invalid _BCL data\n");
333 kfree(buffer
.pointer
);
339 acpi_video_device_lcd_set_level(struct acpi_video_device
*device
, int level
)
342 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
343 struct acpi_object_list args
= { 1, &arg0
};
346 arg0
.integer
.value
= level
;
347 status
= acpi_evaluate_object(device
->dev
->handle
, "_BCM", &args
, NULL
);
349 printk(KERN_DEBUG
"set_level status: %x\n", status
);
354 acpi_video_device_lcd_get_level_current(struct acpi_video_device
*device
,
355 unsigned long *level
)
359 status
= acpi_evaluate_integer(device
->dev
->handle
, "_BQC", NULL
, level
);
365 acpi_video_device_EDID(struct acpi_video_device
*device
,
366 union acpi_object
**edid
, ssize_t length
)
369 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
370 union acpi_object
*obj
;
371 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
372 struct acpi_object_list args
= { 1, &arg0
};
380 arg0
.integer
.value
= 1;
381 else if (length
== 256)
382 arg0
.integer
.value
= 2;
386 status
= acpi_evaluate_object(device
->dev
->handle
, "_DDC", &args
, &buffer
);
387 if (ACPI_FAILURE(status
))
390 obj
= buffer
.pointer
;
392 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
)
395 printk(KERN_ERR PREFIX
"Invalid _DDC data\n");
406 acpi_video_bus_set_POST(struct acpi_video_bus
*video
, unsigned long option
)
410 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
411 struct acpi_object_list args
= { 1, &arg0
};
414 arg0
.integer
.value
= option
;
416 status
= acpi_evaluate_integer(video
->device
->handle
, "_SPD", &args
, &tmp
);
417 if (ACPI_SUCCESS(status
))
418 status
= tmp
? (-EINVAL
) : (AE_OK
);
424 acpi_video_bus_get_POST(struct acpi_video_bus
*video
, unsigned long *id
)
428 status
= acpi_evaluate_integer(video
->device
->handle
, "_GPD", NULL
, id
);
434 acpi_video_bus_POST_options(struct acpi_video_bus
*video
,
435 unsigned long *options
)
439 status
= acpi_evaluate_integer(video
->device
->handle
, "_VPO", NULL
, options
);
447 * video : video bus device pointer
449 * 0. The system BIOS should NOT automatically switch(toggle)
450 * the active display output.
451 * 1. The system BIOS should automatically switch (toggle) the
452 * active display output. No swich event.
453 * 2. The _DGS value should be locked.
454 * 3. The system BIOS should not automatically switch (toggle) the
455 * active display output, but instead generate the display switch
458 * 0. The system BIOS should automatically control the brightness level
459 * of the LCD, when the power changes from AC to DC
460 * 1. The system BIOS should NOT automatically control the brightness
461 * level of the LCD, when the power changes from AC to DC.
467 acpi_video_bus_DOS(struct acpi_video_bus
*video
, int bios_flag
, int lcd_flag
)
469 acpi_integer status
= 0;
470 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
471 struct acpi_object_list args
= { 1, &arg0
};
474 if (bios_flag
< 0 || bios_flag
> 3 || lcd_flag
< 0 || lcd_flag
> 1) {
478 arg0
.integer
.value
= (lcd_flag
<< 2) | bios_flag
;
479 video
->dos_setting
= arg0
.integer
.value
;
480 acpi_evaluate_object(video
->device
->handle
, "_DOS", &args
, NULL
);
488 * device : video output device (LCD, CRT, ..)
493 * Find out all required AML method defined under the output
497 static void acpi_video_device_find_cap(struct acpi_video_device
*device
)
500 acpi_handle h_dummy1
;
502 union acpi_object
*obj
= NULL
;
503 struct acpi_video_device_brightness
*br
= NULL
;
506 memset(&device
->cap
, 0, 4);
508 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_ADR", &h_dummy1
))) {
509 device
->cap
._ADR
= 1;
511 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCL", &h_dummy1
))) {
512 device
->cap
._BCL
= 1;
514 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCM", &h_dummy1
))) {
515 device
->cap
._BCM
= 1;
517 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DDC", &h_dummy1
))) {
518 device
->cap
._DDC
= 1;
520 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DCS", &h_dummy1
))) {
521 device
->cap
._DCS
= 1;
523 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DGS", &h_dummy1
))) {
524 device
->cap
._DGS
= 1;
526 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DSS", &h_dummy1
))) {
527 device
->cap
._DSS
= 1;
530 status
= acpi_video_device_lcd_query_levels(device
, &obj
);
532 if (obj
&& obj
->type
== ACPI_TYPE_PACKAGE
&& obj
->package
.count
>= 2) {
534 union acpi_object
*o
;
536 br
= kzalloc(sizeof(*br
), GFP_KERNEL
);
538 printk(KERN_ERR
"can't allocate memory\n");
540 br
->levels
= kmalloc(obj
->package
.count
*
541 sizeof *(br
->levels
), GFP_KERNEL
);
545 for (i
= 0; i
< obj
->package
.count
; i
++) {
546 o
= (union acpi_object
*)&obj
->package
.
548 if (o
->type
!= ACPI_TYPE_INTEGER
) {
549 printk(KERN_ERR PREFIX
"Invalid data\n");
552 br
->levels
[count
] = (u32
) o
->integer
.value
;
561 device
->brightness
= br
;
562 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
563 "found %d brightness levels\n",
576 * device : video output device (VGA)
581 * Find out all required AML method defined under the video bus device.
584 static void acpi_video_bus_find_cap(struct acpi_video_bus
*video
)
586 acpi_handle h_dummy1
;
588 memset(&video
->cap
, 0, 4);
589 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_DOS", &h_dummy1
))) {
592 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_DOD", &h_dummy1
))) {
595 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_ROM", &h_dummy1
))) {
598 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_GPD", &h_dummy1
))) {
601 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_SPD", &h_dummy1
))) {
604 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_VPO", &h_dummy1
))) {
610 * Check whether the video bus device has required AML method to
611 * support the desired features
614 static int acpi_video_bus_check(struct acpi_video_bus
*video
)
616 acpi_status status
= -ENOENT
;
622 /* Since there is no HID, CID and so on for VGA driver, we have
623 * to check well known required nodes.
626 /* Does this device able to support video switching ? */
627 if (video
->cap
._DOS
) {
628 video
->flags
.multihead
= 1;
632 /* Does this device able to retrieve a retrieve a video ROM ? */
633 if (video
->cap
._ROM
) {
634 video
->flags
.rom
= 1;
638 /* Does this device able to configure which video device to POST ? */
639 if (video
->cap
._GPD
&& video
->cap
._SPD
&& video
->cap
._VPO
) {
640 video
->flags
.post
= 1;
647 /* --------------------------------------------------------------------------
649 -------------------------------------------------------------------------- */
651 static struct proc_dir_entry
*acpi_video_dir
;
655 static int acpi_video_device_info_seq_show(struct seq_file
*seq
, void *offset
)
657 struct acpi_video_device
*dev
= seq
->private;
663 seq_printf(seq
, "device_id: 0x%04x\n", (u32
) dev
->device_id
);
664 seq_printf(seq
, "type: ");
666 seq_printf(seq
, "CRT\n");
667 else if (dev
->flags
.lcd
)
668 seq_printf(seq
, "LCD\n");
669 else if (dev
->flags
.tvout
)
670 seq_printf(seq
, "TVOUT\n");
672 seq_printf(seq
, "UNKNOWN\n");
674 seq_printf(seq
, "known by bios: %s\n", dev
->flags
.bios
? "yes" : "no");
681 acpi_video_device_info_open_fs(struct inode
*inode
, struct file
*file
)
683 return single_open(file
, acpi_video_device_info_seq_show
,
687 static int acpi_video_device_state_seq_show(struct seq_file
*seq
, void *offset
)
690 struct acpi_video_device
*dev
= seq
->private;
697 status
= acpi_video_device_get_state(dev
, &state
);
698 seq_printf(seq
, "state: ");
699 if (ACPI_SUCCESS(status
))
700 seq_printf(seq
, "0x%02lx\n", state
);
702 seq_printf(seq
, "<not supported>\n");
704 status
= acpi_video_device_query(dev
, &state
);
705 seq_printf(seq
, "query: ");
706 if (ACPI_SUCCESS(status
))
707 seq_printf(seq
, "0x%02lx\n", state
);
709 seq_printf(seq
, "<not supported>\n");
716 acpi_video_device_state_open_fs(struct inode
*inode
, struct file
*file
)
718 return single_open(file
, acpi_video_device_state_seq_show
,
723 acpi_video_device_write_state(struct file
*file
,
724 const char __user
* buffer
,
725 size_t count
, loff_t
* data
)
728 struct seq_file
*m
= file
->private_data
;
729 struct acpi_video_device
*dev
= m
->private;
730 char str
[12] = { 0 };
734 if (!dev
|| count
+ 1 > sizeof str
)
737 if (copy_from_user(str
, buffer
, count
))
741 state
= simple_strtoul(str
, NULL
, 0);
742 state
&= ((1ul << 31) | (1ul << 30) | (1ul << 0));
744 status
= acpi_video_device_set_state(dev
, state
);
753 acpi_video_device_brightness_seq_show(struct seq_file
*seq
, void *offset
)
755 struct acpi_video_device
*dev
= seq
->private;
759 if (!dev
|| !dev
->brightness
) {
760 seq_printf(seq
, "<not supported>\n");
764 seq_printf(seq
, "levels: ");
765 for (i
= 0; i
< dev
->brightness
->count
; i
++)
766 seq_printf(seq
, " %d", dev
->brightness
->levels
[i
]);
767 seq_printf(seq
, "\ncurrent: %d\n", dev
->brightness
->curr
);
773 acpi_video_device_brightness_open_fs(struct inode
*inode
, struct file
*file
)
775 return single_open(file
, acpi_video_device_brightness_seq_show
,
780 acpi_video_device_write_brightness(struct file
*file
,
781 const char __user
* buffer
,
782 size_t count
, loff_t
* data
)
784 struct seq_file
*m
= file
->private_data
;
785 struct acpi_video_device
*dev
= m
->private;
787 unsigned int level
= 0;
791 if (!dev
|| !dev
->brightness
|| count
+ 1 > sizeof str
)
794 if (copy_from_user(str
, buffer
, count
))
798 level
= simple_strtoul(str
, NULL
, 0);
803 /* validate though the list of available levels */
804 for (i
= 0; i
< dev
->brightness
->count
; i
++)
805 if (level
== dev
->brightness
->levels
[i
]) {
807 (acpi_video_device_lcd_set_level(dev
, level
)))
808 dev
->brightness
->curr
= level
;
815 static int acpi_video_device_EDID_seq_show(struct seq_file
*seq
, void *offset
)
817 struct acpi_video_device
*dev
= seq
->private;
820 union acpi_object
*edid
= NULL
;
826 status
= acpi_video_device_EDID(dev
, &edid
, 128);
827 if (ACPI_FAILURE(status
)) {
828 status
= acpi_video_device_EDID(dev
, &edid
, 256);
831 if (ACPI_FAILURE(status
)) {
835 if (edid
&& edid
->type
== ACPI_TYPE_BUFFER
) {
836 for (i
= 0; i
< edid
->buffer
.length
; i
++)
837 seq_putc(seq
, edid
->buffer
.pointer
[i
]);
842 seq_printf(seq
, "<not supported>\n");
850 acpi_video_device_EDID_open_fs(struct inode
*inode
, struct file
*file
)
852 return single_open(file
, acpi_video_device_EDID_seq_show
,
856 static int acpi_video_device_add_fs(struct acpi_device
*device
)
858 struct proc_dir_entry
*entry
= NULL
;
859 struct acpi_video_device
*vid_dev
;
865 vid_dev
= acpi_driver_data(device
);
869 if (!acpi_device_dir(device
)) {
870 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
871 vid_dev
->video
->dir
);
872 if (!acpi_device_dir(device
))
874 acpi_device_dir(device
)->owner
= THIS_MODULE
;
878 entry
= create_proc_entry("info", S_IRUGO
, acpi_device_dir(device
));
882 entry
->proc_fops
= &acpi_video_device_info_fops
;
883 entry
->data
= acpi_driver_data(device
);
884 entry
->owner
= THIS_MODULE
;
889 create_proc_entry("state", S_IFREG
| S_IRUGO
| S_IWUSR
,
890 acpi_device_dir(device
));
894 acpi_video_device_state_fops
.write
= acpi_video_device_write_state
;
895 entry
->proc_fops
= &acpi_video_device_state_fops
;
896 entry
->data
= acpi_driver_data(device
);
897 entry
->owner
= THIS_MODULE
;
900 /* 'brightness' [R/W] */
902 create_proc_entry("brightness", S_IFREG
| S_IRUGO
| S_IWUSR
,
903 acpi_device_dir(device
));
907 acpi_video_device_brightness_fops
.write
= acpi_video_device_write_brightness
;
908 entry
->proc_fops
= &acpi_video_device_brightness_fops
;
909 entry
->data
= acpi_driver_data(device
);
910 entry
->owner
= THIS_MODULE
;
914 entry
= create_proc_entry("EDID", S_IRUGO
, acpi_device_dir(device
));
918 entry
->proc_fops
= &acpi_video_device_EDID_fops
;
919 entry
->data
= acpi_driver_data(device
);
920 entry
->owner
= THIS_MODULE
;
926 static int acpi_video_device_remove_fs(struct acpi_device
*device
)
928 struct acpi_video_device
*vid_dev
;
930 vid_dev
= acpi_driver_data(device
);
931 if (!vid_dev
|| !vid_dev
->video
|| !vid_dev
->video
->dir
)
934 if (acpi_device_dir(device
)) {
935 remove_proc_entry("info", acpi_device_dir(device
));
936 remove_proc_entry("state", acpi_device_dir(device
));
937 remove_proc_entry("brightness", acpi_device_dir(device
));
938 remove_proc_entry("EDID", acpi_device_dir(device
));
939 remove_proc_entry(acpi_device_bid(device
), vid_dev
->video
->dir
);
940 acpi_device_dir(device
) = NULL
;
947 static int acpi_video_bus_info_seq_show(struct seq_file
*seq
, void *offset
)
949 struct acpi_video_bus
*video
= seq
->private;
955 seq_printf(seq
, "Switching heads: %s\n",
956 video
->flags
.multihead
? "yes" : "no");
957 seq_printf(seq
, "Video ROM: %s\n",
958 video
->flags
.rom
? "yes" : "no");
959 seq_printf(seq
, "Device to be POSTed on boot: %s\n",
960 video
->flags
.post
? "yes" : "no");
966 static int acpi_video_bus_info_open_fs(struct inode
*inode
, struct file
*file
)
968 return single_open(file
, acpi_video_bus_info_seq_show
,
972 static int acpi_video_bus_ROM_seq_show(struct seq_file
*seq
, void *offset
)
974 struct acpi_video_bus
*video
= seq
->private;
980 printk(KERN_INFO PREFIX
"Please implement %s\n", __FUNCTION__
);
981 seq_printf(seq
, "<TODO>\n");
987 static int acpi_video_bus_ROM_open_fs(struct inode
*inode
, struct file
*file
)
989 return single_open(file
, acpi_video_bus_ROM_seq_show
, PDE(inode
)->data
);
992 static int acpi_video_bus_POST_info_seq_show(struct seq_file
*seq
, void *offset
)
994 struct acpi_video_bus
*video
= seq
->private;
995 unsigned long options
;
1002 status
= acpi_video_bus_POST_options(video
, &options
);
1003 if (ACPI_SUCCESS(status
)) {
1004 if (!(options
& 1)) {
1005 printk(KERN_WARNING PREFIX
1006 "The motherboard VGA device is not listed as a possible POST device.\n");
1007 printk(KERN_WARNING PREFIX
1008 "This indicate a BIOS bug. Please contact the manufacturer.\n");
1010 printk("%lx\n", options
);
1011 seq_printf(seq
, "can POST: <intgrated video>");
1013 seq_printf(seq
, " <PCI video>");
1015 seq_printf(seq
, " <AGP video>");
1016 seq_putc(seq
, '\n');
1018 seq_printf(seq
, "<not supported>\n");
1024 acpi_video_bus_POST_info_open_fs(struct inode
*inode
, struct file
*file
)
1026 return single_open(file
, acpi_video_bus_POST_info_seq_show
,
1030 static int acpi_video_bus_POST_seq_show(struct seq_file
*seq
, void *offset
)
1032 struct acpi_video_bus
*video
= seq
->private;
1040 status
= acpi_video_bus_get_POST(video
, &id
);
1041 if (!ACPI_SUCCESS(status
)) {
1042 seq_printf(seq
, "<not supported>\n");
1045 seq_printf(seq
, "device posted is <%s>\n", device_decode
[id
& 3]);
1051 static int acpi_video_bus_DOS_seq_show(struct seq_file
*seq
, void *offset
)
1053 struct acpi_video_bus
*video
= seq
->private;
1056 seq_printf(seq
, "DOS setting: <%d>\n", video
->dos_setting
);
1061 static int acpi_video_bus_POST_open_fs(struct inode
*inode
, struct file
*file
)
1063 return single_open(file
, acpi_video_bus_POST_seq_show
,
1067 static int acpi_video_bus_DOS_open_fs(struct inode
*inode
, struct file
*file
)
1069 return single_open(file
, acpi_video_bus_DOS_seq_show
, PDE(inode
)->data
);
1073 acpi_video_bus_write_POST(struct file
*file
,
1074 const char __user
* buffer
,
1075 size_t count
, loff_t
* data
)
1078 struct seq_file
*m
= file
->private_data
;
1079 struct acpi_video_bus
*video
= m
->private;
1080 char str
[12] = { 0 };
1081 unsigned long opt
, options
;
1084 if (!video
|| count
+ 1 > sizeof str
)
1087 status
= acpi_video_bus_POST_options(video
, &options
);
1088 if (!ACPI_SUCCESS(status
))
1091 if (copy_from_user(str
, buffer
, count
))
1095 opt
= strtoul(str
, NULL
, 0);
1099 /* just in case an OEM 'forget' the motherboard... */
1102 if (options
& (1ul << opt
)) {
1103 status
= acpi_video_bus_set_POST(video
, opt
);
1104 if (!ACPI_SUCCESS(status
))
1113 acpi_video_bus_write_DOS(struct file
*file
,
1114 const char __user
* buffer
,
1115 size_t count
, loff_t
* data
)
1118 struct seq_file
*m
= file
->private_data
;
1119 struct acpi_video_bus
*video
= m
->private;
1120 char str
[12] = { 0 };
1124 if (!video
|| count
+ 1 > sizeof str
)
1127 if (copy_from_user(str
, buffer
, count
))
1131 opt
= strtoul(str
, NULL
, 0);
1135 status
= acpi_video_bus_DOS(video
, opt
& 0x3, (opt
& 0x4) >> 2);
1137 if (!ACPI_SUCCESS(status
))
1143 static int acpi_video_bus_add_fs(struct acpi_device
*device
)
1145 struct proc_dir_entry
*entry
= NULL
;
1146 struct acpi_video_bus
*video
;
1149 video
= acpi_driver_data(device
);
1151 if (!acpi_device_dir(device
)) {
1152 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
1154 if (!acpi_device_dir(device
))
1156 video
->dir
= acpi_device_dir(device
);
1157 acpi_device_dir(device
)->owner
= THIS_MODULE
;
1161 entry
= create_proc_entry("info", S_IRUGO
, acpi_device_dir(device
));
1165 entry
->proc_fops
= &acpi_video_bus_info_fops
;
1166 entry
->data
= acpi_driver_data(device
);
1167 entry
->owner
= THIS_MODULE
;
1171 entry
= create_proc_entry("ROM", S_IRUGO
, acpi_device_dir(device
));
1175 entry
->proc_fops
= &acpi_video_bus_ROM_fops
;
1176 entry
->data
= acpi_driver_data(device
);
1177 entry
->owner
= THIS_MODULE
;
1180 /* 'POST_info' [R] */
1182 create_proc_entry("POST_info", S_IRUGO
, acpi_device_dir(device
));
1186 entry
->proc_fops
= &acpi_video_bus_POST_info_fops
;
1187 entry
->data
= acpi_driver_data(device
);
1188 entry
->owner
= THIS_MODULE
;
1193 create_proc_entry("POST", S_IFREG
| S_IRUGO
| S_IRUSR
,
1194 acpi_device_dir(device
));
1198 acpi_video_bus_POST_fops
.write
= acpi_video_bus_write_POST
;
1199 entry
->proc_fops
= &acpi_video_bus_POST_fops
;
1200 entry
->data
= acpi_driver_data(device
);
1201 entry
->owner
= THIS_MODULE
;
1206 create_proc_entry("DOS", S_IFREG
| S_IRUGO
| S_IRUSR
,
1207 acpi_device_dir(device
));
1211 acpi_video_bus_DOS_fops
.write
= acpi_video_bus_write_DOS
;
1212 entry
->proc_fops
= &acpi_video_bus_DOS_fops
;
1213 entry
->data
= acpi_driver_data(device
);
1214 entry
->owner
= THIS_MODULE
;
1220 static int acpi_video_bus_remove_fs(struct acpi_device
*device
)
1222 struct acpi_video_bus
*video
;
1225 video
= acpi_driver_data(device
);
1227 if (acpi_device_dir(device
)) {
1228 remove_proc_entry("info", acpi_device_dir(device
));
1229 remove_proc_entry("ROM", acpi_device_dir(device
));
1230 remove_proc_entry("POST_info", acpi_device_dir(device
));
1231 remove_proc_entry("POST", acpi_device_dir(device
));
1232 remove_proc_entry("DOS", acpi_device_dir(device
));
1233 remove_proc_entry(acpi_device_bid(device
), acpi_video_dir
);
1234 acpi_device_dir(device
) = NULL
;
1240 /* --------------------------------------------------------------------------
1242 -------------------------------------------------------------------------- */
1244 /* device interface */
1247 acpi_video_bus_get_one_device(struct acpi_device
*device
,
1248 struct acpi_video_bus
*video
)
1250 unsigned long device_id
;
1252 struct acpi_video_device
*data
;
1255 if (!device
|| !video
)
1259 acpi_evaluate_integer(device
->handle
, "_ADR", NULL
, &device_id
);
1260 if (ACPI_SUCCESS(status
)) {
1262 data
= kzalloc(sizeof(struct acpi_video_device
), GFP_KERNEL
);
1266 strcpy(acpi_device_name(device
), ACPI_VIDEO_DEVICE_NAME
);
1267 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1268 acpi_driver_data(device
) = data
;
1270 data
->device_id
= device_id
;
1271 data
->video
= video
;
1274 switch (device_id
& 0xffff) {
1276 data
->flags
.crt
= 1;
1279 data
->flags
.lcd
= 1;
1282 data
->flags
.tvout
= 1;
1285 data
->flags
.unknown
= 1;
1289 acpi_video_device_bind(video
, data
);
1290 acpi_video_device_find_cap(data
);
1292 status
= acpi_install_notify_handler(device
->handle
,
1294 acpi_video_device_notify
,
1296 if (ACPI_FAILURE(status
)) {
1297 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1298 "Error installing notify handler\n"));
1299 if(data
->brightness
)
1300 kfree(data
->brightness
->levels
);
1301 kfree(data
->brightness
);
1307 list_add_tail(&data
->entry
, &video
->video_device_list
);
1310 acpi_video_device_add_fs(device
);
1320 * video : video bus device
1325 * Enumerate the video device list of the video bus,
1326 * bind the ids with the corresponding video devices
1327 * under the video bus.
1330 static void acpi_video_device_rebind(struct acpi_video_bus
*video
)
1332 struct list_head
*node
, *next
;
1333 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1334 struct acpi_video_device
*dev
=
1335 container_of(node
, struct acpi_video_device
, entry
);
1336 acpi_video_device_bind(video
, dev
);
1342 * video : video bus device
1343 * device : video output device under the video
1349 * Bind the ids with the corresponding video devices
1350 * under the video bus.
1354 acpi_video_device_bind(struct acpi_video_bus
*video
,
1355 struct acpi_video_device
*device
)
1359 #define IDS_VAL(i) video->attached_array[i].value.int_val
1360 #define IDS_BIND(i) video->attached_array[i].bind_info
1362 for (i
= 0; IDS_VAL(i
) != ACPI_VIDEO_HEAD_INVALID
&&
1363 i
< video
->attached_count
; i
++) {
1364 if (device
->device_id
== (IDS_VAL(i
) & 0xffff)) {
1365 IDS_BIND(i
) = device
;
1366 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "device_bind %d\n", i
));
1375 * video : video bus device
1380 * Call _DOD to enumerate all devices attached to display adapter
1384 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
)
1389 struct acpi_video_enumerated_device
*active_device_list
;
1390 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1391 union acpi_object
*dod
= NULL
;
1392 union acpi_object
*obj
;
1394 status
= acpi_evaluate_object(video
->device
->handle
, "_DOD", NULL
, &buffer
);
1395 if (!ACPI_SUCCESS(status
)) {
1396 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _DOD"));
1400 dod
= buffer
.pointer
;
1401 if (!dod
|| (dod
->type
!= ACPI_TYPE_PACKAGE
)) {
1402 ACPI_EXCEPTION((AE_INFO
, status
, "Invalid _DOD data"));
1407 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found %d video heads in _DOD\n",
1408 dod
->package
.count
));
1410 active_device_list
= kmalloc((1 +
1411 dod
->package
.count
) *
1413 acpi_video_enumerated_device
),
1416 if (!active_device_list
) {
1422 for (i
= 0; i
< dod
->package
.count
; i
++) {
1423 obj
= &dod
->package
.elements
[i
];
1425 if (obj
->type
!= ACPI_TYPE_INTEGER
) {
1426 printk(KERN_ERR PREFIX
"Invalid _DOD data\n");
1427 active_device_list
[i
].value
.int_val
=
1428 ACPI_VIDEO_HEAD_INVALID
;
1430 active_device_list
[i
].value
.int_val
= obj
->integer
.value
;
1431 active_device_list
[i
].bind_info
= NULL
;
1432 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "dod element[%d] = %d\n", i
,
1433 (int)obj
->integer
.value
));
1436 active_device_list
[count
].value
.int_val
= ACPI_VIDEO_HEAD_END
;
1438 kfree(video
->attached_array
);
1440 video
->attached_array
= active_device_list
;
1441 video
->attached_count
= count
;
1443 kfree(buffer
.pointer
);
1449 * video : video bus device
1450 * event : Nontify Event
1455 * 1. Find out the current active output device.
1456 * 2. Identify the next output device to switch
1457 * 3. call _DSS to do actual switch.
1460 static int acpi_video_switch_output(struct acpi_video_bus
*video
, int event
)
1462 struct list_head
*node
, *next
;
1463 struct acpi_video_device
*dev
= NULL
;
1464 struct acpi_video_device
*dev_next
= NULL
;
1465 struct acpi_video_device
*dev_prev
= NULL
;
1466 unsigned long state
;
1470 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1471 dev
= container_of(node
, struct acpi_video_device
, entry
);
1472 status
= acpi_video_device_get_state(dev
, &state
);
1475 container_of(node
->next
, struct acpi_video_device
,
1478 container_of(node
->prev
, struct acpi_video_device
,
1483 dev_next
= container_of(node
->next
, struct acpi_video_device
, entry
);
1484 dev_prev
= container_of(node
->prev
, struct acpi_video_device
, entry
);
1487 case ACPI_VIDEO_NOTIFY_CYCLE
:
1488 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
:
1489 acpi_video_device_set_state(dev
, 0);
1490 acpi_video_device_set_state(dev_next
, 0x80000001);
1492 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
:
1493 acpi_video_device_set_state(dev
, 0);
1494 acpi_video_device_set_state(dev_prev
, 0x80000001);
1503 acpi_video_get_next_level(struct acpi_video_device
*device
,
1504 u32 level_current
, u32 event
)
1506 int min
, max
, min_above
, max_below
, i
, l
;
1507 max
= max_below
= 0;
1508 min
= min_above
= 255;
1509 for (i
= 0; i
< device
->brightness
->count
; i
++) {
1510 l
= device
->brightness
->levels
[i
];
1515 if (l
< min_above
&& l
> level_current
)
1517 if (l
> max_below
&& l
< level_current
)
1522 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
:
1523 return (level_current
< max
) ? min_above
: min
;
1524 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
:
1525 return (level_current
< max
) ? min_above
: max
;
1526 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
:
1527 return (level_current
> min
) ? max_below
: min
;
1528 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
:
1529 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
:
1532 return level_current
;
1537 acpi_video_switch_brightness(struct acpi_video_device
*device
, int event
)
1539 unsigned long level_current
, level_next
;
1540 acpi_video_device_lcd_get_level_current(device
, &level_current
);
1541 level_next
= acpi_video_get_next_level(device
, level_current
, event
);
1542 acpi_video_device_lcd_set_level(device
, level_next
);
1546 acpi_video_bus_get_devices(struct acpi_video_bus
*video
,
1547 struct acpi_device
*device
)
1550 struct list_head
*node
, *next
;
1553 acpi_video_device_enumerate(video
);
1555 list_for_each_safe(node
, next
, &device
->children
) {
1556 struct acpi_device
*dev
=
1557 list_entry(node
, struct acpi_device
, node
);
1562 status
= acpi_video_bus_get_one_device(dev
, video
);
1563 if (ACPI_FAILURE(status
)) {
1564 ACPI_EXCEPTION((AE_INFO
, status
, "Cant attach device"));
1572 static int acpi_video_bus_put_one_device(struct acpi_video_device
*device
)
1575 struct acpi_video_bus
*video
;
1578 if (!device
|| !device
->video
)
1581 video
= device
->video
;
1584 list_del(&device
->entry
);
1586 acpi_video_device_remove_fs(device
->dev
);
1588 status
= acpi_remove_notify_handler(device
->dev
->handle
,
1590 acpi_video_device_notify
);
1595 static int acpi_video_bus_put_devices(struct acpi_video_bus
*video
)
1598 struct list_head
*node
, *next
;
1601 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1602 struct acpi_video_device
*data
=
1603 list_entry(node
, struct acpi_video_device
, entry
);
1607 status
= acpi_video_bus_put_one_device(data
);
1608 if (ACPI_FAILURE(status
))
1609 printk(KERN_WARNING PREFIX
1610 "hhuuhhuu bug in acpi video driver.\n");
1612 if (data
->brightness
)
1613 kfree(data
->brightness
->levels
);
1614 kfree(data
->brightness
);
1621 /* acpi_video interface */
1623 static int acpi_video_bus_start_devices(struct acpi_video_bus
*video
)
1625 return acpi_video_bus_DOS(video
, 1, 0);
1628 static int acpi_video_bus_stop_devices(struct acpi_video_bus
*video
)
1630 return acpi_video_bus_DOS(video
, 0, 1);
1633 static void acpi_video_bus_notify(acpi_handle handle
, u32 event
, void *data
)
1635 struct acpi_video_bus
*video
= data
;
1636 struct acpi_device
*device
= NULL
;
1638 printk("video bus notify\n");
1643 device
= video
->device
;
1646 case ACPI_VIDEO_NOTIFY_SWITCH
: /* User request that a switch occur,
1647 * most likely via hotkey. */
1648 acpi_bus_generate_event(device
, event
, 0);
1651 case ACPI_VIDEO_NOTIFY_PROBE
: /* User plug or remove a video
1653 acpi_video_device_enumerate(video
);
1654 acpi_video_device_rebind(video
);
1655 acpi_video_switch_output(video
, event
);
1656 acpi_bus_generate_event(device
, event
, 0);
1659 case ACPI_VIDEO_NOTIFY_CYCLE
: /* Cycle Display output hotkey pressed. */
1660 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
: /* Next Display output hotkey pressed. */
1661 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
: /* previous Display output hotkey pressed. */
1662 acpi_video_switch_output(video
, event
);
1663 acpi_bus_generate_event(device
, event
, 0);
1667 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1668 "Unsupported event [0x%x]\n", event
));
1675 static void acpi_video_device_notify(acpi_handle handle
, u32 event
, void *data
)
1677 struct acpi_video_device
*video_device
= data
;
1678 struct acpi_device
*device
= NULL
;
1683 device
= video_device
->dev
;
1686 case ACPI_VIDEO_NOTIFY_SWITCH
: /* change in status (cycle output device) */
1687 case ACPI_VIDEO_NOTIFY_PROBE
: /* change in status (output device status) */
1688 acpi_bus_generate_event(device
, event
, 0);
1690 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
: /* Cycle brightness */
1691 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
: /* Increase brightness */
1692 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
: /* Decrease brightness */
1693 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
: /* zero brightnesss */
1694 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
: /* display device off */
1695 acpi_video_switch_brightness(video_device
, event
);
1696 acpi_bus_generate_event(device
, event
, 0);
1699 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1700 "Unsupported event [0x%x]\n", event
));
1706 static int acpi_video_bus_add(struct acpi_device
*device
)
1709 acpi_status status
= 0;
1710 struct acpi_video_bus
*video
= NULL
;
1716 video
= kzalloc(sizeof(struct acpi_video_bus
), GFP_KERNEL
);
1720 video
->device
= device
;
1721 strcpy(acpi_device_name(device
), ACPI_VIDEO_BUS_NAME
);
1722 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1723 acpi_driver_data(device
) = video
;
1725 acpi_video_bus_find_cap(video
);
1726 result
= acpi_video_bus_check(video
);
1730 result
= acpi_video_bus_add_fs(device
);
1734 init_MUTEX(&video
->sem
);
1735 INIT_LIST_HEAD(&video
->video_device_list
);
1737 acpi_video_bus_get_devices(video
, device
);
1738 acpi_video_bus_start_devices(video
);
1740 status
= acpi_install_notify_handler(device
->handle
,
1742 acpi_video_bus_notify
, video
);
1743 if (ACPI_FAILURE(status
)) {
1744 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1745 "Error installing notify handler\n"));
1746 acpi_video_bus_stop_devices(video
);
1747 acpi_video_bus_put_devices(video
);
1748 kfree(video
->attached_array
);
1749 acpi_video_bus_remove_fs(device
);
1754 printk(KERN_INFO PREFIX
"%s [%s] (multi-head: %s rom: %s post: %s)\n",
1755 ACPI_VIDEO_DEVICE_NAME
, acpi_device_bid(device
),
1756 video
->flags
.multihead
? "yes" : "no",
1757 video
->flags
.rom
? "yes" : "no",
1758 video
->flags
.post
? "yes" : "no");
1767 static int acpi_video_bus_remove(struct acpi_device
*device
, int type
)
1769 acpi_status status
= 0;
1770 struct acpi_video_bus
*video
= NULL
;
1773 if (!device
|| !acpi_driver_data(device
))
1776 video
= acpi_driver_data(device
);
1778 acpi_video_bus_stop_devices(video
);
1780 status
= acpi_remove_notify_handler(video
->device
->handle
,
1782 acpi_video_bus_notify
);
1784 acpi_video_bus_put_devices(video
);
1785 acpi_video_bus_remove_fs(device
);
1787 kfree(video
->attached_array
);
1794 acpi_video_bus_match(struct acpi_device
*device
, struct acpi_driver
*driver
)
1796 acpi_handle h_dummy1
;
1797 acpi_handle h_dummy2
;
1798 acpi_handle h_dummy3
;
1801 if (!device
|| !driver
)
1804 /* Since there is no HID, CID for ACPI Video drivers, we have
1805 * to check well known required nodes for each feature we support.
1808 /* Does this device able to support video switching ? */
1809 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DOD", &h_dummy1
)) &&
1810 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DOS", &h_dummy2
)))
1813 /* Does this device able to retrieve a video ROM ? */
1814 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_ROM", &h_dummy1
)))
1817 /* Does this device able to configure which video head to be POSTed ? */
1818 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_VPO", &h_dummy1
)) &&
1819 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_GPD", &h_dummy2
)) &&
1820 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_SPD", &h_dummy3
)))
1826 static int __init
acpi_video_init(void)
1832 acpi_dbg_level = 0xFFFFFFFF;
1833 acpi_dbg_layer = 0x08000000;
1836 acpi_video_dir
= proc_mkdir(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1837 if (!acpi_video_dir
)
1839 acpi_video_dir
->owner
= THIS_MODULE
;
1841 result
= acpi_bus_register_driver(&acpi_video_bus
);
1843 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1850 static void __exit
acpi_video_exit(void)
1853 acpi_bus_unregister_driver(&acpi_video_bus
);
1855 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1860 module_init(acpi_video_init
);
1861 module_exit(acpi_video_exit
);