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 <linux/backlight.h>
36 #include <asm/uaccess.h>
38 #include <acpi/acpi_bus.h>
39 #include <acpi/acpi_drivers.h>
41 #define ACPI_VIDEO_COMPONENT 0x08000000
42 #define ACPI_VIDEO_CLASS "video"
43 #define ACPI_VIDEO_DRIVER_NAME "ACPI Video Driver"
44 #define ACPI_VIDEO_BUS_NAME "Video Bus"
45 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
46 #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
47 #define ACPI_VIDEO_NOTIFY_PROBE 0x81
48 #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
49 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
50 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
52 #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
53 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
54 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
55 #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
56 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
58 #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
59 #define ACPI_VIDEO_HEAD_END (~0u)
60 #define MAX_NAME_LEN 20
62 #define ACPI_VIDEO_DISPLAY_CRT 1
63 #define ACPI_VIDEO_DISPLAY_TV 2
64 #define ACPI_VIDEO_DISPLAY_DVI 3
65 #define ACPI_VIDEO_DISPLAY_LCD 4
67 #define _COMPONENT ACPI_VIDEO_COMPONENT
68 ACPI_MODULE_NAME("acpi_video")
70 MODULE_AUTHOR("Bruno Ducrot");
71 MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
72 MODULE_LICENSE("GPL");
74 static int acpi_video_bus_add(struct acpi_device *device);
75 static int acpi_video_bus_remove(struct acpi_device *device, int type);
76 static int acpi_video_bus_match(struct acpi_device *device,
77 struct acpi_driver *driver);
79 static struct acpi_driver acpi_video_bus = {
80 .name = ACPI_VIDEO_DRIVER_NAME,
81 .class = ACPI_VIDEO_CLASS,
83 .add = acpi_video_bus_add,
84 .remove = acpi_video_bus_remove,
85 .match = acpi_video_bus_match,
89 struct acpi_video_bus_flags {
90 u8 multihead:1; /* can switch video heads */
91 u8 rom:1; /* can retrieve a video rom */
92 u8 post:1; /* can configure the head to */
96 struct acpi_video_bus_cap {
97 u8 _DOS:1; /*Enable/Disable output switching */
98 u8 _DOD:1; /*Enumerate all devices attached to display adapter */
99 u8 _ROM:1; /*Get ROM Data */
100 u8 _GPD:1; /*Get POST Device */
101 u8 _SPD:1; /*Set POST Device */
102 u8 _VPO:1; /*Video POST Options */
106 struct acpi_video_device_attrib {
107 u32 display_index:4; /* A zero-based instance of the Display */
108 u32 display_port_attachment:4; /*This field differenates displays type */
109 u32 display_type:4; /*Describe the specific type in use */
110 u32 vendor_specific:4; /*Chipset Vendor Specifi */
111 u32 bios_can_detect:1; /*BIOS can detect the device */
112 u32 depend_on_vga:1; /*Non-VGA output device whose power is related to
114 u32 pipe_id:3; /*For VGA multiple-head devices. */
115 u32 reserved:10; /*Must be 0 */
116 u32 device_id_scheme:1; /*Device ID Scheme */
119 struct acpi_video_enumerated_device {
122 struct acpi_video_device_attrib attrib;
124 struct acpi_video_device *bind_info;
127 struct acpi_video_bus {
128 struct acpi_device *device;
130 struct acpi_video_enumerated_device *attached_array;
132 struct acpi_video_bus_cap cap;
133 struct acpi_video_bus_flags flags;
134 struct semaphore sem;
135 struct list_head video_device_list;
136 struct proc_dir_entry *dir;
139 struct acpi_video_device_flags {
149 struct acpi_video_device_cap {
150 u8 _ADR:1; /*Return the unique ID */
151 u8 _BCL:1; /*Query list of brightness control levels supported */
152 u8 _BCM:1; /*Set the brightness level */
153 u8 _BQC:1; /* Get current brightness level */
154 u8 _DDC:1; /*Return the EDID for this device */
155 u8 _DCS:1; /*Return status of output device */
156 u8 _DGS:1; /*Query graphics state */
157 u8 _DSS:1; /*Device state set */
160 struct acpi_video_device_brightness {
166 struct acpi_video_device {
167 unsigned long device_id;
168 struct acpi_video_device_flags flags;
169 struct acpi_video_device_cap cap;
170 struct list_head entry;
171 struct acpi_video_bus *video;
172 struct acpi_device *dev;
173 struct acpi_video_device_brightness *brightness;
174 struct backlight_device *backlight;
175 struct backlight_properties *data;
179 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
180 static struct file_operations acpi_video_bus_info_fops = {
181 .open = acpi_video_bus_info_open_fs,
184 .release = single_release,
187 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
188 static struct file_operations acpi_video_bus_ROM_fops = {
189 .open = acpi_video_bus_ROM_open_fs,
192 .release = single_release,
195 static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
197 static struct file_operations acpi_video_bus_POST_info_fops = {
198 .open = acpi_video_bus_POST_info_open_fs,
201 .release = single_release,
204 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
205 static struct file_operations acpi_video_bus_POST_fops = {
206 .open = acpi_video_bus_POST_open_fs,
209 .release = single_release,
212 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
213 static struct file_operations acpi_video_bus_DOS_fops = {
214 .open = acpi_video_bus_DOS_open_fs,
217 .release = single_release,
221 static int acpi_video_device_info_open_fs(struct inode *inode,
223 static struct file_operations acpi_video_device_info_fops = {
224 .open = acpi_video_device_info_open_fs,
227 .release = single_release,
230 static int acpi_video_device_state_open_fs(struct inode *inode,
232 static struct file_operations acpi_video_device_state_fops = {
233 .open = acpi_video_device_state_open_fs,
236 .release = single_release,
239 static int acpi_video_device_brightness_open_fs(struct inode *inode,
241 static struct file_operations acpi_video_device_brightness_fops = {
242 .open = acpi_video_device_brightness_open_fs,
245 .release = single_release,
248 static int acpi_video_device_EDID_open_fs(struct inode *inode,
250 static struct file_operations acpi_video_device_EDID_fops = {
251 .open = acpi_video_device_EDID_open_fs,
254 .release = single_release,
257 static char device_decode[][30] = {
258 "motherboard VGA device",
264 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data);
265 static void acpi_video_device_rebind(struct acpi_video_bus *video);
266 static void acpi_video_device_bind(struct acpi_video_bus *video,
267 struct acpi_video_device *device);
268 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
269 static int acpi_video_switch_output(struct acpi_video_bus *video, int event);
270 static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
272 static int acpi_video_device_lcd_get_level_current(
273 struct acpi_video_device *device,
274 unsigned long *level);
275 static int acpi_video_get_next_level(struct acpi_video_device *device,
276 u32 level_current, u32 event);
277 static void acpi_video_switch_brightness(struct acpi_video_device *device,
280 /*backlight device sysfs support*/
281 static int acpi_video_get_brightness(struct backlight_device *bd)
283 unsigned long cur_level;
284 struct acpi_video_device *vd =
285 (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
286 acpi_video_device_lcd_get_level_current(vd, &cur_level);
287 return (int) cur_level;
290 static int acpi_video_set_brightness(struct backlight_device *bd)
292 int request_level = bd->props->brightness;
293 struct acpi_video_device *vd =
294 (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
295 acpi_video_device_lcd_set_level(vd, request_level);
299 /* --------------------------------------------------------------------------
301 -------------------------------------------------------------------------- */
306 acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
310 status = acpi_evaluate_integer(device->dev->handle, "_DGS", NULL, state);
316 acpi_video_device_get_state(struct acpi_video_device *device,
317 unsigned long *state)
321 status = acpi_evaluate_integer(device->dev->handle, "_DCS", NULL, state);
327 acpi_video_device_set_state(struct acpi_video_device *device, int state)
330 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
331 struct acpi_object_list args = { 1, &arg0 };
335 arg0.integer.value = state;
336 status = acpi_evaluate_integer(device->dev->handle, "_DSS", &args, &ret);
342 acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
343 union acpi_object **levels)
346 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
347 union acpi_object *obj;
352 status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer);
353 if (!ACPI_SUCCESS(status))
355 obj = (union acpi_object *)buffer.pointer;
356 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
357 printk(KERN_ERR PREFIX "Invalid _BCL data\n");
367 kfree(buffer.pointer);
373 acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
376 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
377 struct acpi_object_list args = { 1, &arg0 };
380 arg0.integer.value = level;
381 status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
383 printk(KERN_DEBUG "set_level status: %x\n", status);
388 acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
389 unsigned long *level)
393 status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
399 acpi_video_device_EDID(struct acpi_video_device *device,
400 union acpi_object **edid, ssize_t length)
403 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
404 union acpi_object *obj;
405 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
406 struct acpi_object_list args = { 1, &arg0 };
414 arg0.integer.value = 1;
415 else if (length == 256)
416 arg0.integer.value = 2;
420 status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer);
421 if (ACPI_FAILURE(status))
424 obj = buffer.pointer;
426 if (obj && obj->type == ACPI_TYPE_BUFFER)
429 printk(KERN_ERR PREFIX "Invalid _DDC data\n");
440 acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
444 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
445 struct acpi_object_list args = { 1, &arg0 };
448 arg0.integer.value = option;
450 status = acpi_evaluate_integer(video->device->handle, "_SPD", &args, &tmp);
451 if (ACPI_SUCCESS(status))
452 status = tmp ? (-EINVAL) : (AE_OK);
458 acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
462 status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id);
468 acpi_video_bus_POST_options(struct acpi_video_bus *video,
469 unsigned long *options)
473 status = acpi_evaluate_integer(video->device->handle, "_VPO", NULL, options);
481 * video : video bus device pointer
483 * 0. The system BIOS should NOT automatically switch(toggle)
484 * the active display output.
485 * 1. The system BIOS should automatically switch (toggle) the
486 * active display output. No swich event.
487 * 2. The _DGS value should be locked.
488 * 3. The system BIOS should not automatically switch (toggle) the
489 * active display output, but instead generate the display switch
492 * 0. The system BIOS should automatically control the brightness level
493 * of the LCD, when the power changes from AC to DC
494 * 1. The system BIOS should NOT automatically control the brightness
495 * level of the LCD, when the power changes from AC to DC.
501 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
503 acpi_integer status = 0;
504 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
505 struct acpi_object_list args = { 1, &arg0 };
508 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
512 arg0.integer.value = (lcd_flag << 2) | bios_flag;
513 video->dos_setting = arg0.integer.value;
514 acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
522 * device : video output device (LCD, CRT, ..)
527 * Find out all required AML method defined under the output
531 static void acpi_video_device_find_cap(struct acpi_video_device *device)
534 acpi_handle h_dummy1;
537 union acpi_object *obj = NULL;
538 struct acpi_video_device_brightness *br = NULL;
541 memset(&device->cap, 0, 4);
543 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
544 device->cap._ADR = 1;
546 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) {
547 device->cap._BCL = 1;
549 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
550 device->cap._BCM = 1;
552 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle,"_BQC",&h_dummy1)))
553 device->cap._BQC = 1;
554 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) {
555 device->cap._DDC = 1;
557 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DCS", &h_dummy1))) {
558 device->cap._DCS = 1;
560 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DGS", &h_dummy1))) {
561 device->cap._DGS = 1;
563 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DSS", &h_dummy1))) {
564 device->cap._DSS = 1;
567 status = acpi_video_device_lcd_query_levels(device, &obj);
569 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
571 union acpi_object *o;
573 br = kzalloc(sizeof(*br), GFP_KERNEL);
575 printk(KERN_ERR "can't allocate memory\n");
577 br->levels = kmalloc(obj->package.count *
578 sizeof *(br->levels), GFP_KERNEL);
582 for (i = 0; i < obj->package.count; i++) {
583 o = (union acpi_object *)&obj->package.
585 if (o->type != ACPI_TYPE_INTEGER) {
586 printk(KERN_ERR PREFIX "Invalid data\n");
589 br->levels[count] = (u32) o->integer.value;
590 if (br->levels[count] > max_level)
591 max_level = br->levels[count];
600 device->brightness = br;
601 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
602 "found %d brightness levels\n",
610 if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
612 static int count = 0;
614 struct backlight_properties *acpi_video_data;
616 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
620 acpi_video_data = kzalloc(
621 sizeof(struct backlight_properties),
623 if (!acpi_video_data){
627 acpi_video_data->owner = THIS_MODULE;
628 acpi_video_data->get_brightness =
629 acpi_video_get_brightness;
630 acpi_video_data->update_status =
631 acpi_video_set_brightness;
632 sprintf(name, "acpi_video%d", count++);
633 device->data = acpi_video_data;
634 acpi_video_data->max_brightness = max_level;
635 acpi_video_device_lcd_get_level_current(device, &tmp);
636 acpi_video_data->brightness = (int)tmp;
637 device->backlight = backlight_device_register(name,
638 NULL, device, acpi_video_data);
646 * device : video output device (VGA)
651 * Find out all required AML method defined under the video bus device.
654 static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
656 acpi_handle h_dummy1;
658 memset(&video->cap, 0, 4);
659 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) {
662 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) {
665 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) {
668 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) {
671 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) {
674 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) {
680 * Check whether the video bus device has required AML method to
681 * support the desired features
684 static int acpi_video_bus_check(struct acpi_video_bus *video)
686 acpi_status status = -ENOENT;
692 /* Since there is no HID, CID and so on for VGA driver, we have
693 * to check well known required nodes.
696 /* Does this device able to support video switching ? */
697 if (video->cap._DOS) {
698 video->flags.multihead = 1;
702 /* Does this device able to retrieve a retrieve a video ROM ? */
703 if (video->cap._ROM) {
704 video->flags.rom = 1;
708 /* Does this device able to configure which video device to POST ? */
709 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) {
710 video->flags.post = 1;
717 /* --------------------------------------------------------------------------
719 -------------------------------------------------------------------------- */
721 static struct proc_dir_entry *acpi_video_dir;
725 static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
727 struct acpi_video_device *dev = seq->private;
733 seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
734 seq_printf(seq, "type: ");
736 seq_printf(seq, "CRT\n");
737 else if (dev->flags.lcd)
738 seq_printf(seq, "LCD\n");
739 else if (dev->flags.tvout)
740 seq_printf(seq, "TVOUT\n");
741 else if (dev->flags.dvi)
742 seq_printf(seq, "DVI\n");
744 seq_printf(seq, "UNKNOWN\n");
746 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
753 acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
755 return single_open(file, acpi_video_device_info_seq_show,
759 static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
762 struct acpi_video_device *dev = seq->private;
769 status = acpi_video_device_get_state(dev, &state);
770 seq_printf(seq, "state: ");
771 if (ACPI_SUCCESS(status))
772 seq_printf(seq, "0x%02lx\n", state);
774 seq_printf(seq, "<not supported>\n");
776 status = acpi_video_device_query(dev, &state);
777 seq_printf(seq, "query: ");
778 if (ACPI_SUCCESS(status))
779 seq_printf(seq, "0x%02lx\n", state);
781 seq_printf(seq, "<not supported>\n");
788 acpi_video_device_state_open_fs(struct inode *inode, struct file *file)
790 return single_open(file, acpi_video_device_state_seq_show,
795 acpi_video_device_write_state(struct file *file,
796 const char __user * buffer,
797 size_t count, loff_t * data)
800 struct seq_file *m = file->private_data;
801 struct acpi_video_device *dev = m->private;
802 char str[12] = { 0 };
806 if (!dev || count + 1 > sizeof str)
809 if (copy_from_user(str, buffer, count))
813 state = simple_strtoul(str, NULL, 0);
814 state &= ((1ul << 31) | (1ul << 30) | (1ul << 0));
816 status = acpi_video_device_set_state(dev, state);
825 acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
827 struct acpi_video_device *dev = seq->private;
831 if (!dev || !dev->brightness) {
832 seq_printf(seq, "<not supported>\n");
836 seq_printf(seq, "levels: ");
837 for (i = 0; i < dev->brightness->count; i++)
838 seq_printf(seq, " %d", dev->brightness->levels[i]);
839 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
845 acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file)
847 return single_open(file, acpi_video_device_brightness_seq_show,
852 acpi_video_device_write_brightness(struct file *file,
853 const char __user * buffer,
854 size_t count, loff_t * data)
856 struct seq_file *m = file->private_data;
857 struct acpi_video_device *dev = m->private;
859 unsigned int level = 0;
863 if (!dev || !dev->brightness || count + 1 > sizeof str)
866 if (copy_from_user(str, buffer, count))
870 level = simple_strtoul(str, NULL, 0);
875 /* validate though the list of available levels */
876 for (i = 0; i < dev->brightness->count; i++)
877 if (level == dev->brightness->levels[i]) {
879 (acpi_video_device_lcd_set_level(dev, level)))
880 dev->brightness->curr = level;
887 static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
889 struct acpi_video_device *dev = seq->private;
892 union acpi_object *edid = NULL;
898 status = acpi_video_device_EDID(dev, &edid, 128);
899 if (ACPI_FAILURE(status)) {
900 status = acpi_video_device_EDID(dev, &edid, 256);
903 if (ACPI_FAILURE(status)) {
907 if (edid && edid->type == ACPI_TYPE_BUFFER) {
908 for (i = 0; i < edid->buffer.length; i++)
909 seq_putc(seq, edid->buffer.pointer[i]);
914 seq_printf(seq, "<not supported>\n");
922 acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
924 return single_open(file, acpi_video_device_EDID_seq_show,
928 static int acpi_video_device_add_fs(struct acpi_device *device)
930 struct proc_dir_entry *entry = NULL;
931 struct acpi_video_device *vid_dev;
937 vid_dev = acpi_driver_data(device);
941 if (!acpi_device_dir(device)) {
942 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
943 vid_dev->video->dir);
944 if (!acpi_device_dir(device))
946 acpi_device_dir(device)->owner = THIS_MODULE;
950 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
954 entry->proc_fops = &acpi_video_device_info_fops;
955 entry->data = acpi_driver_data(device);
956 entry->owner = THIS_MODULE;
961 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
962 acpi_device_dir(device));
966 acpi_video_device_state_fops.write = acpi_video_device_write_state;
967 entry->proc_fops = &acpi_video_device_state_fops;
968 entry->data = acpi_driver_data(device);
969 entry->owner = THIS_MODULE;
972 /* 'brightness' [R/W] */
974 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
975 acpi_device_dir(device));
979 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
980 entry->proc_fops = &acpi_video_device_brightness_fops;
981 entry->data = acpi_driver_data(device);
982 entry->owner = THIS_MODULE;
986 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
990 entry->proc_fops = &acpi_video_device_EDID_fops;
991 entry->data = acpi_driver_data(device);
992 entry->owner = THIS_MODULE;
998 static int acpi_video_device_remove_fs(struct acpi_device *device)
1000 struct acpi_video_device *vid_dev;
1002 vid_dev = acpi_driver_data(device);
1003 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1006 if (acpi_device_dir(device)) {
1007 remove_proc_entry("info", acpi_device_dir(device));
1008 remove_proc_entry("state", acpi_device_dir(device));
1009 remove_proc_entry("brightness", acpi_device_dir(device));
1010 remove_proc_entry("EDID", acpi_device_dir(device));
1011 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1012 acpi_device_dir(device) = NULL;
1019 static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
1021 struct acpi_video_bus *video = seq->private;
1027 seq_printf(seq, "Switching heads: %s\n",
1028 video->flags.multihead ? "yes" : "no");
1029 seq_printf(seq, "Video ROM: %s\n",
1030 video->flags.rom ? "yes" : "no");
1031 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1032 video->flags.post ? "yes" : "no");
1038 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
1040 return single_open(file, acpi_video_bus_info_seq_show,
1044 static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1046 struct acpi_video_bus *video = seq->private;
1052 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1053 seq_printf(seq, "<TODO>\n");
1059 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
1061 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1064 static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1066 struct acpi_video_bus *video = seq->private;
1067 unsigned long options;
1074 status = acpi_video_bus_POST_options(video, &options);
1075 if (ACPI_SUCCESS(status)) {
1076 if (!(options & 1)) {
1077 printk(KERN_WARNING PREFIX
1078 "The motherboard VGA device is not listed as a possible POST device.\n");
1079 printk(KERN_WARNING PREFIX
1080 "This indicate a BIOS bug. Please contact the manufacturer.\n");
1082 printk("%lx\n", options);
1083 seq_printf(seq, "can POST: <intgrated video>");
1085 seq_printf(seq, " <PCI video>");
1087 seq_printf(seq, " <AGP video>");
1088 seq_putc(seq, '\n');
1090 seq_printf(seq, "<not supported>\n");
1096 acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1098 return single_open(file, acpi_video_bus_POST_info_seq_show,
1102 static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1104 struct acpi_video_bus *video = seq->private;
1112 status = acpi_video_bus_get_POST(video, &id);
1113 if (!ACPI_SUCCESS(status)) {
1114 seq_printf(seq, "<not supported>\n");
1117 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1123 static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1125 struct acpi_video_bus *video = seq->private;
1128 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1133 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
1135 return single_open(file, acpi_video_bus_POST_seq_show,
1139 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file)
1141 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1145 acpi_video_bus_write_POST(struct file *file,
1146 const char __user * buffer,
1147 size_t count, loff_t * data)
1150 struct seq_file *m = file->private_data;
1151 struct acpi_video_bus *video = m->private;
1152 char str[12] = { 0 };
1153 unsigned long opt, options;
1156 if (!video || count + 1 > sizeof str)
1159 status = acpi_video_bus_POST_options(video, &options);
1160 if (!ACPI_SUCCESS(status))
1163 if (copy_from_user(str, buffer, count))
1167 opt = strtoul(str, NULL, 0);
1171 /* just in case an OEM 'forget' the motherboard... */
1174 if (options & (1ul << opt)) {
1175 status = acpi_video_bus_set_POST(video, opt);
1176 if (!ACPI_SUCCESS(status))
1185 acpi_video_bus_write_DOS(struct file *file,
1186 const char __user * buffer,
1187 size_t count, loff_t * data)
1190 struct seq_file *m = file->private_data;
1191 struct acpi_video_bus *video = m->private;
1192 char str[12] = { 0 };
1196 if (!video || count + 1 > sizeof str)
1199 if (copy_from_user(str, buffer, count))
1203 opt = strtoul(str, NULL, 0);
1207 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1209 if (!ACPI_SUCCESS(status))
1215 static int acpi_video_bus_add_fs(struct acpi_device *device)
1217 struct proc_dir_entry *entry = NULL;
1218 struct acpi_video_bus *video;
1221 video = acpi_driver_data(device);
1223 if (!acpi_device_dir(device)) {
1224 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1226 if (!acpi_device_dir(device))
1228 video->dir = acpi_device_dir(device);
1229 acpi_device_dir(device)->owner = THIS_MODULE;
1233 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1237 entry->proc_fops = &acpi_video_bus_info_fops;
1238 entry->data = acpi_driver_data(device);
1239 entry->owner = THIS_MODULE;
1243 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1247 entry->proc_fops = &acpi_video_bus_ROM_fops;
1248 entry->data = acpi_driver_data(device);
1249 entry->owner = THIS_MODULE;
1252 /* 'POST_info' [R] */
1254 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1258 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1259 entry->data = acpi_driver_data(device);
1260 entry->owner = THIS_MODULE;
1265 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1266 acpi_device_dir(device));
1270 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1271 entry->proc_fops = &acpi_video_bus_POST_fops;
1272 entry->data = acpi_driver_data(device);
1273 entry->owner = THIS_MODULE;
1278 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1279 acpi_device_dir(device));
1283 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1284 entry->proc_fops = &acpi_video_bus_DOS_fops;
1285 entry->data = acpi_driver_data(device);
1286 entry->owner = THIS_MODULE;
1292 static int acpi_video_bus_remove_fs(struct acpi_device *device)
1294 struct acpi_video_bus *video;
1297 video = acpi_driver_data(device);
1299 if (acpi_device_dir(device)) {
1300 remove_proc_entry("info", acpi_device_dir(device));
1301 remove_proc_entry("ROM", acpi_device_dir(device));
1302 remove_proc_entry("POST_info", acpi_device_dir(device));
1303 remove_proc_entry("POST", acpi_device_dir(device));
1304 remove_proc_entry("DOS", acpi_device_dir(device));
1305 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1306 acpi_device_dir(device) = NULL;
1312 /* --------------------------------------------------------------------------
1314 -------------------------------------------------------------------------- */
1316 /* device interface */
1317 static struct acpi_video_device_attrib*
1318 acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id)
1322 for(count = 0; count < video->attached_count; count++)
1323 if((video->attached_array[count].value.int_val & 0xffff) == device_id)
1324 return &(video->attached_array[count].value.attrib);
1329 acpi_video_bus_get_one_device(struct acpi_device *device,
1330 struct acpi_video_bus *video)
1332 unsigned long device_id;
1334 struct acpi_video_device *data;
1335 struct acpi_video_device_attrib* attribute;
1337 if (!device || !video)
1341 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1342 if (ACPI_SUCCESS(status)) {
1344 data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
1348 strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
1349 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1350 acpi_driver_data(device) = data;
1352 data->device_id = device_id;
1353 data->video = video;
1356 attribute = acpi_video_get_device_attr(video, device_id);
1358 if((attribute != NULL) && attribute->device_id_scheme) {
1359 switch (attribute->display_type) {
1360 case ACPI_VIDEO_DISPLAY_CRT:
1361 data->flags.crt = 1;
1363 case ACPI_VIDEO_DISPLAY_TV:
1364 data->flags.tvout = 1;
1366 case ACPI_VIDEO_DISPLAY_DVI:
1367 data->flags.dvi = 1;
1369 case ACPI_VIDEO_DISPLAY_LCD:
1370 data->flags.lcd = 1;
1373 data->flags.unknown = 1;
1376 if(attribute->bios_can_detect)
1377 data->flags.bios = 1;
1379 data->flags.unknown = 1;
1381 acpi_video_device_bind(video, data);
1382 acpi_video_device_find_cap(data);
1384 status = acpi_install_notify_handler(device->handle,
1386 acpi_video_device_notify,
1388 if (ACPI_FAILURE(status)) {
1389 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1390 "Error installing notify handler\n"));
1391 if(data->brightness)
1392 kfree(data->brightness->levels);
1393 kfree(data->brightness);
1399 list_add_tail(&data->entry, &video->video_device_list);
1402 acpi_video_device_add_fs(device);
1412 * video : video bus device
1417 * Enumerate the video device list of the video bus,
1418 * bind the ids with the corresponding video devices
1419 * under the video bus.
1422 static void acpi_video_device_rebind(struct acpi_video_bus *video)
1424 struct list_head *node, *next;
1425 list_for_each_safe(node, next, &video->video_device_list) {
1426 struct acpi_video_device *dev =
1427 container_of(node, struct acpi_video_device, entry);
1428 acpi_video_device_bind(video, dev);
1434 * video : video bus device
1435 * device : video output device under the video
1441 * Bind the ids with the corresponding video devices
1442 * under the video bus.
1446 acpi_video_device_bind(struct acpi_video_bus *video,
1447 struct acpi_video_device *device)
1451 #define IDS_VAL(i) video->attached_array[i].value.int_val
1452 #define IDS_BIND(i) video->attached_array[i].bind_info
1454 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
1455 i < video->attached_count; i++) {
1456 if (device->device_id == (IDS_VAL(i) & 0xffff)) {
1457 IDS_BIND(i) = device;
1458 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
1467 * video : video bus device
1472 * Call _DOD to enumerate all devices attached to display adapter
1476 static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1481 struct acpi_video_enumerated_device *active_device_list;
1482 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1483 union acpi_object *dod = NULL;
1484 union acpi_object *obj;
1486 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer);
1487 if (!ACPI_SUCCESS(status)) {
1488 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
1492 dod = buffer.pointer;
1493 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1494 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
1499 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
1500 dod->package.count));
1502 active_device_list = kmalloc((1 +
1503 dod->package.count) *
1505 acpi_video_enumerated_device),
1508 if (!active_device_list) {
1514 for (i = 0; i < dod->package.count; i++) {
1515 obj = &dod->package.elements[i];
1517 if (obj->type != ACPI_TYPE_INTEGER) {
1518 printk(KERN_ERR PREFIX "Invalid _DOD data\n");
1519 active_device_list[i].value.int_val =
1520 ACPI_VIDEO_HEAD_INVALID;
1522 active_device_list[i].value.int_val = obj->integer.value;
1523 active_device_list[i].bind_info = NULL;
1524 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i,
1525 (int)obj->integer.value));
1528 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1530 kfree(video->attached_array);
1532 video->attached_array = active_device_list;
1533 video->attached_count = count;
1535 kfree(buffer.pointer);
1541 * video : video bus device
1542 * event : Nontify Event
1547 * 1. Find out the current active output device.
1548 * 2. Identify the next output device to switch
1549 * 3. call _DSS to do actual switch.
1552 static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1554 struct list_head *node, *next;
1555 struct acpi_video_device *dev = NULL;
1556 struct acpi_video_device *dev_next = NULL;
1557 struct acpi_video_device *dev_prev = NULL;
1558 unsigned long state;
1562 list_for_each_safe(node, next, &video->video_device_list) {
1563 dev = container_of(node, struct acpi_video_device, entry);
1564 status = acpi_video_device_get_state(dev, &state);
1567 container_of(node->next, struct acpi_video_device,
1570 container_of(node->prev, struct acpi_video_device,
1575 dev_next = container_of(node->next, struct acpi_video_device, entry);
1576 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1579 case ACPI_VIDEO_NOTIFY_CYCLE:
1580 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
1581 acpi_video_device_set_state(dev, 0);
1582 acpi_video_device_set_state(dev_next, 0x80000001);
1584 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
1585 acpi_video_device_set_state(dev, 0);
1586 acpi_video_device_set_state(dev_prev, 0x80000001);
1595 acpi_video_get_next_level(struct acpi_video_device *device,
1596 u32 level_current, u32 event)
1598 int min, max, min_above, max_below, i, l;
1599 max = max_below = 0;
1600 min = min_above = 255;
1601 for (i = 0; i < device->brightness->count; i++) {
1602 l = device->brightness->levels[i];
1607 if (l < min_above && l > level_current)
1609 if (l > max_below && l < level_current)
1614 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
1615 return (level_current < max) ? min_above : min;
1616 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
1617 return (level_current < max) ? min_above : max;
1618 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
1619 return (level_current > min) ? max_below : min;
1620 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
1621 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
1624 return level_current;
1629 acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1631 unsigned long level_current, level_next;
1632 acpi_video_device_lcd_get_level_current(device, &level_current);
1633 level_next = acpi_video_get_next_level(device, level_current, event);
1634 acpi_video_device_lcd_set_level(device, level_next);
1638 acpi_video_bus_get_devices(struct acpi_video_bus *video,
1639 struct acpi_device *device)
1642 struct list_head *node, *next;
1645 acpi_video_device_enumerate(video);
1647 list_for_each_safe(node, next, &device->children) {
1648 struct acpi_device *dev =
1649 list_entry(node, struct acpi_device, node);
1654 status = acpi_video_bus_get_one_device(dev, video);
1655 if (ACPI_FAILURE(status)) {
1656 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
1664 static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1667 struct acpi_video_bus *video;
1670 if (!device || !device->video)
1673 video = device->video;
1676 list_del(&device->entry);
1678 acpi_video_device_remove_fs(device->dev);
1680 status = acpi_remove_notify_handler(device->dev->handle,
1682 acpi_video_device_notify);
1683 if (device->backlight){
1684 backlight_device_unregister(device->backlight);
1685 kfree(device->data);
1690 static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1693 struct list_head *node, *next;
1696 list_for_each_safe(node, next, &video->video_device_list) {
1697 struct acpi_video_device *data =
1698 list_entry(node, struct acpi_video_device, entry);
1702 status = acpi_video_bus_put_one_device(data);
1703 if (ACPI_FAILURE(status))
1704 printk(KERN_WARNING PREFIX
1705 "hhuuhhuu bug in acpi video driver.\n");
1707 if (data->brightness)
1708 kfree(data->brightness->levels);
1709 kfree(data->brightness);
1716 /* acpi_video interface */
1718 static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1720 return acpi_video_bus_DOS(video, 1, 0);
1723 static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1725 return acpi_video_bus_DOS(video, 0, 1);
1728 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1730 struct acpi_video_bus *video = data;
1731 struct acpi_device *device = NULL;
1733 printk("video bus notify\n");
1738 device = video->device;
1741 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur,
1742 * most likely via hotkey. */
1743 acpi_bus_generate_event(device, event, 0);
1746 case ACPI_VIDEO_NOTIFY_PROBE: /* User plug or remove a video
1748 acpi_video_device_enumerate(video);
1749 acpi_video_device_rebind(video);
1750 acpi_video_switch_output(video, event);
1751 acpi_bus_generate_event(device, event, 0);
1754 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1755 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1756 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1757 acpi_video_switch_output(video, event);
1758 acpi_bus_generate_event(device, event, 0);
1762 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1763 "Unsupported event [0x%x]\n", event));
1770 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1772 struct acpi_video_device *video_device = data;
1773 struct acpi_device *device = NULL;
1778 device = video_device->dev;
1781 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1782 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1783 acpi_bus_generate_event(device, event, 0);
1785 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1786 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1787 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1788 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1789 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1790 acpi_video_switch_brightness(video_device, event);
1791 acpi_bus_generate_event(device, event, 0);
1794 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1795 "Unsupported event [0x%x]\n", event));
1801 static int acpi_video_bus_add(struct acpi_device *device)
1804 acpi_status status = 0;
1805 struct acpi_video_bus *video = NULL;
1811 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1815 video->device = device;
1816 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
1817 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1818 acpi_driver_data(device) = video;
1820 acpi_video_bus_find_cap(video);
1821 result = acpi_video_bus_check(video);
1825 result = acpi_video_bus_add_fs(device);
1829 init_MUTEX(&video->sem);
1830 INIT_LIST_HEAD(&video->video_device_list);
1832 acpi_video_bus_get_devices(video, device);
1833 acpi_video_bus_start_devices(video);
1835 status = acpi_install_notify_handler(device->handle,
1837 acpi_video_bus_notify, video);
1838 if (ACPI_FAILURE(status)) {
1839 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1840 "Error installing notify handler\n"));
1841 acpi_video_bus_stop_devices(video);
1842 acpi_video_bus_put_devices(video);
1843 kfree(video->attached_array);
1844 acpi_video_bus_remove_fs(device);
1849 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1850 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1851 video->flags.multihead ? "yes" : "no",
1852 video->flags.rom ? "yes" : "no",
1853 video->flags.post ? "yes" : "no");
1862 static int acpi_video_bus_remove(struct acpi_device *device, int type)
1864 acpi_status status = 0;
1865 struct acpi_video_bus *video = NULL;
1868 if (!device || !acpi_driver_data(device))
1871 video = acpi_driver_data(device);
1873 acpi_video_bus_stop_devices(video);
1875 status = acpi_remove_notify_handler(video->device->handle,
1877 acpi_video_bus_notify);
1879 acpi_video_bus_put_devices(video);
1880 acpi_video_bus_remove_fs(device);
1882 kfree(video->attached_array);
1889 acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1891 acpi_handle h_dummy1;
1892 acpi_handle h_dummy2;
1893 acpi_handle h_dummy3;
1896 if (!device || !driver)
1899 /* Since there is no HID, CID for ACPI Video drivers, we have
1900 * to check well known required nodes for each feature we support.
1903 /* Does this device able to support video switching ? */
1904 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
1905 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
1908 /* Does this device able to retrieve a video ROM ? */
1909 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
1912 /* Does this device able to configure which video head to be POSTed ? */
1913 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
1914 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
1915 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
1921 static int __init acpi_video_init(void)
1927 acpi_dbg_level = 0xFFFFFFFF;
1928 acpi_dbg_layer = 0x08000000;
1931 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1932 if (!acpi_video_dir)
1934 acpi_video_dir->owner = THIS_MODULE;
1936 result = acpi_bus_register_driver(&acpi_video_bus);
1938 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1945 static void __exit acpi_video_exit(void)
1948 acpi_bus_unregister_driver(&acpi_video_bus);
1950 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1955 module_init(acpi_video_init);
1956 module_exit(acpi_video_exit);