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>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/list.h>
31 #include <linux/proc_fs.h>
32 #include <linux/seq_file.h>
34 #include <asm/uaccess.h>
36 #include <acpi/acpi_bus.h>
37 #include <acpi/acpi_drivers.h>
39 #define ACPI_VIDEO_COMPONENT 0x08000000
40 #define ACPI_VIDEO_CLASS "video"
41 #define ACPI_VIDEO_DRIVER_NAME "ACPI Video Driver"
42 #define ACPI_VIDEO_BUS_NAME "Video Bus"
43 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
44 #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
45 #define ACPI_VIDEO_NOTIFY_PROBE 0x81
46 #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
47 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
48 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
50 #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82
51 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83
52 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84
53 #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
54 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
57 #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
58 #define ACPI_VIDEO_HEAD_END (~0u)
61 #define _COMPONENT ACPI_VIDEO_COMPONENT
62 ACPI_MODULE_NAME ("acpi_video")
64 MODULE_AUTHOR("Bruno Ducrot");
65 MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
66 MODULE_LICENSE("GPL");
68 static int acpi_video_bus_add (struct acpi_device *device);
69 static int acpi_video_bus_remove (struct acpi_device *device, int type);
70 static int acpi_video_bus_match (struct acpi_device *device, 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 {
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 {
160 unsigned long device_id;
161 struct acpi_video_device_flags flags;
162 struct acpi_video_device_cap cap;
163 struct list_head entry;
164 struct acpi_video_bus *video;
165 struct acpi_device *dev;
166 struct acpi_video_device_brightness *brightness;
171 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
172 static struct file_operations acpi_video_bus_info_fops = {
173 .open = acpi_video_bus_info_open_fs,
176 .release = single_release,
179 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
180 static struct file_operations acpi_video_bus_ROM_fops = {
181 .open = acpi_video_bus_ROM_open_fs,
184 .release = single_release,
187 static int acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file);
188 static struct file_operations acpi_video_bus_POST_info_fops = {
189 .open = acpi_video_bus_POST_info_open_fs,
192 .release = single_release,
195 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
196 static struct file_operations acpi_video_bus_POST_fops = {
197 .open = acpi_video_bus_POST_open_fs,
200 .release = single_release,
204 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
205 static struct file_operations acpi_video_bus_DOS_fops = {
206 .open = acpi_video_bus_DOS_open_fs,
209 .release = single_release,
213 static int acpi_video_device_info_open_fs(struct inode *inode, struct file *file);
214 static struct file_operations acpi_video_device_info_fops = {
215 .open = acpi_video_device_info_open_fs,
218 .release = single_release,
221 static int acpi_video_device_state_open_fs(struct inode *inode, struct file *file);
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, struct file *file);
230 static struct file_operations acpi_video_device_brightness_fops = {
231 .open = acpi_video_device_brightness_open_fs,
234 .release = single_release,
237 static int acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file);
238 static struct file_operations acpi_video_device_EDID_fops = {
239 .open = acpi_video_device_EDID_open_fs,
242 .release = single_release,
245 static char device_decode[][30] = {
246 "motherboard VGA device",
252 static void acpi_video_device_notify ( acpi_handle handle, u32 event, void *data);
253 static void acpi_video_device_rebind( struct acpi_video_bus *video);
254 static void acpi_video_device_bind( struct acpi_video_bus *video, struct acpi_video_device *device);
255 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
256 static int acpi_video_switch_output( struct acpi_video_bus *video, int event);
257 static int acpi_video_get_next_level( struct acpi_video_device *device, u32 level_current,u32 event);
258 static void acpi_video_switch_brightness ( struct acpi_video_device *device, int event);
261 /* --------------------------------------------------------------------------
263 -------------------------------------------------------------------------- */
268 acpi_video_device_query (
269 struct acpi_video_device *device,
270 unsigned long *state)
273 ACPI_FUNCTION_TRACE("acpi_video_device_query");
274 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
276 return_VALUE(status);
280 acpi_video_device_get_state (
281 struct acpi_video_device *device,
282 unsigned long *state)
286 ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
288 status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
290 return_VALUE(status);
294 acpi_video_device_set_state (
295 struct acpi_video_device *device,
299 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
300 struct acpi_object_list args = {1, &arg0};
302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
304 arg0.integer.value = state;
305 status = acpi_evaluate_integer(device->handle, "_DSS", &args, NULL);
307 return_VALUE(status);
311 acpi_video_device_lcd_query_levels (
312 struct acpi_video_device *device,
313 union acpi_object **levels)
316 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
317 union acpi_object *obj;
320 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
324 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
325 if (!ACPI_SUCCESS(status))
326 return_VALUE(status);
327 obj = (union acpi_object *) buffer.pointer;
328 if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) {
329 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
340 kfree(buffer.pointer);
342 return_VALUE(status);
346 acpi_video_device_lcd_set_level (
347 struct acpi_video_device *device,
351 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
352 struct acpi_object_list args = {1, &arg0};
354 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
356 arg0.integer.value = level;
357 status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
359 printk(KERN_DEBUG "set_level status: %x\n", status);
360 return_VALUE(status);
364 acpi_video_device_lcd_get_level_current (
365 struct acpi_video_device *device,
366 unsigned long *level)
369 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
371 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
373 return_VALUE(status);
377 acpi_video_device_EDID (
378 struct acpi_video_device *device,
379 union acpi_object **edid,
383 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
384 union acpi_object *obj;
385 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
386 struct acpi_object_list args = {1, &arg0};
388 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
393 return_VALUE(-ENODEV);
395 arg0.integer.value = 1;
396 else if (length == 256)
397 arg0.integer.value = 2;
399 return_VALUE(-EINVAL);
401 status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
402 if (ACPI_FAILURE(status))
403 return_VALUE(-ENODEV);
405 obj = (union acpi_object *) buffer.pointer;
407 if (obj && obj->type == ACPI_TYPE_BUFFER)
410 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n"));
415 return_VALUE(status);
422 acpi_video_bus_set_POST (
423 struct acpi_video_bus *video,
424 unsigned long option)
428 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
429 struct acpi_object_list args = {1, &arg0};
431 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
433 arg0.integer.value = option;
435 status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
436 if (ACPI_SUCCESS(status))
437 status = tmp ? (-EINVAL):(AE_OK);
439 return_VALUE(status);
443 acpi_video_bus_get_POST (
444 struct acpi_video_bus *video,
449 ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
451 status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
453 return_VALUE(status);
457 acpi_video_bus_POST_options (
458 struct acpi_video_bus *video,
459 unsigned long *options)
462 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
464 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
467 return_VALUE(status);
472 * video : video bus device pointer
474 * 0. The system BIOS should NOT automatically switch(toggle)
475 * the active display output.
476 * 1. The system BIOS should automatically switch (toggle) the
477 * active display output. No swich event.
478 * 2. The _DGS value should be locked.
479 * 3. The system BIOS should not automatically switch (toggle) the
480 * active display output, but instead generate the display switch
483 * 0. The system BIOS should automatically control the brightness level
484 * of the LCD, when the power changes from AC to DC
485 * 1. The system BIOS should NOT automatically control the brightness
486 * level of the LCD, when the power changes from AC to DC.
493 struct acpi_video_bus *video,
497 acpi_integer status = 0;
498 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
499 struct acpi_object_list args = {1, &arg0};
501 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
503 if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){
507 arg0.integer.value = (lcd_flag << 2) | bios_flag;
508 video->dos_setting = arg0.integer.value;
509 acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
512 return_VALUE(status);
517 * device : video output device (LCD, CRT, ..)
522 * Find out all required AML method defined under the output
527 acpi_video_device_find_cap (struct acpi_video_device *device)
530 acpi_handle h_dummy1;
532 union acpi_object *obj = NULL;
533 struct acpi_video_device_brightness *br = NULL;
535 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
537 memset( &device->cap, 0, 4);
539 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
540 device->cap._ADR = 1;
542 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
545 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
548 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
551 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
552 device->cap._DCS = 1;
554 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
555 device->cap._DGS = 1;
557 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
558 device->cap._DSS = 1;
561 status = acpi_video_device_lcd_query_levels(device, &obj);
563 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
565 union acpi_object *o;
567 br = kmalloc(sizeof(*br), GFP_KERNEL);
569 printk(KERN_ERR "can't allocate memory\n");
571 memset(br, 0, sizeof(*br));
572 br->levels = kmalloc(obj->package.count *
573 sizeof *(br->levels), GFP_KERNEL);
577 for (i = 0; i < obj->package.count; i++) {
578 o = (union acpi_object *) &obj->package.elements[i];
579 if (o->type != ACPI_TYPE_INTEGER) {
580 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
583 br->levels[count] = (u32) o->integer.value;
592 device->brightness = br;
593 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
605 * device : video output device (VGA)
610 * Find out all required AML method defined under the video bus device.
614 acpi_video_bus_find_cap (struct acpi_video_bus *video)
616 acpi_handle h_dummy1;
618 memset(&video->cap ,0, 4);
619 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
622 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
625 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
628 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
631 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
634 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
640 * Check whether the video bus device has required AML method to
641 * support the desired features
645 acpi_video_bus_check (
646 struct acpi_video_bus *video)
648 acpi_status status = -ENOENT;
651 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
654 return_VALUE(-EINVAL);
656 /* Since there is no HID, CID and so on for VGA driver, we have
657 * to check well known required nodes.
660 /* Does this device able to support video switching ? */
662 video->flags.multihead = 1;
666 /* Does this device able to retrieve a retrieve a video ROM ? */
668 video->flags.rom = 1;
672 /* Does this device able to configure which video device to POST ? */
673 if(video->cap._GPD && video->cap._SPD && video->cap._VPO){
674 video->flags.post = 1;
678 return_VALUE(status);
681 /* --------------------------------------------------------------------------
683 -------------------------------------------------------------------------- */
685 static struct proc_dir_entry *acpi_video_dir;
690 acpi_video_device_info_seq_show (
691 struct seq_file *seq,
694 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
696 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
701 seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
702 seq_printf(seq, "type: ");
704 seq_printf(seq, "CRT\n");
705 else if (dev->flags.lcd)
706 seq_printf(seq, "LCD\n");
707 else if (dev->flags.tvout)
708 seq_printf(seq, "TVOUT\n");
710 seq_printf(seq, "UNKNOWN\n");
712 seq_printf(seq,"known by bios: %s\n",
713 dev->flags.bios ? "yes":"no");
720 acpi_video_device_info_open_fs (
724 return single_open(file, acpi_video_device_info_seq_show,
729 acpi_video_device_state_seq_show (
730 struct seq_file *seq,
734 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
737 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
742 status = acpi_video_device_get_state(dev, &state);
743 seq_printf(seq, "state: ");
744 if (ACPI_SUCCESS(status))
745 seq_printf(seq, "0x%02lx\n", state);
747 seq_printf(seq, "<not supported>\n");
749 status = acpi_video_device_query(dev, &state);
750 seq_printf(seq, "query: ");
751 if (ACPI_SUCCESS(status))
752 seq_printf(seq, "0x%02lx\n", state);
754 seq_printf(seq, "<not supported>\n");
761 acpi_video_device_state_open_fs (
765 return single_open(file, acpi_video_device_state_seq_show,
770 acpi_video_device_write_state (
772 const char __user *buffer,
777 struct seq_file *m = (struct seq_file *) file->private_data;
778 struct acpi_video_device *dev = (struct acpi_video_device *) m->private;
782 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
784 if (!dev || count + 1 > sizeof str)
785 return_VALUE(-EINVAL);
787 if (copy_from_user(str, buffer, count))
788 return_VALUE(-EFAULT);
791 state = simple_strtoul(str, NULL, 0);
792 state &= ((1ul<<31) | (1ul<<30) | (1ul<<0));
794 status = acpi_video_device_set_state(dev, state);
797 return_VALUE(-EFAULT);
803 acpi_video_device_brightness_seq_show (
804 struct seq_file *seq,
807 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
810 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
812 if (!dev || !dev->brightness) {
813 seq_printf(seq, "<not supported>\n");
817 seq_printf(seq, "levels: ");
818 for (i = 0; i < dev->brightness->count; i++)
819 seq_printf(seq, " %d", dev->brightness->levels[i]);
820 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
826 acpi_video_device_brightness_open_fs (
830 return single_open(file, acpi_video_device_brightness_seq_show,
835 acpi_video_device_write_brightness (
837 const char __user *buffer,
841 struct seq_file *m = (struct seq_file *) file->private_data;
842 struct acpi_video_device *dev = (struct acpi_video_device *) m->private;
844 unsigned int level = 0;
847 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
849 if (!dev || count + 1 > sizeof str)
850 return_VALUE(-EINVAL);
852 if (copy_from_user(str, buffer, count))
853 return_VALUE(-EFAULT);
856 level = simple_strtoul(str, NULL, 0);
859 return_VALUE(-EFAULT);
861 /* validate though the list of available levels */
862 for (i = 0; i < dev->brightness->count; i++)
863 if (level == dev->brightness->levels[i]) {
864 if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level)))
865 dev->brightness->curr = level;
873 acpi_video_device_EDID_seq_show (
874 struct seq_file *seq,
877 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
880 union acpi_object *edid = NULL;
882 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
887 status = acpi_video_device_EDID (dev, &edid, 128);
888 if (ACPI_FAILURE(status)) {
889 status = acpi_video_device_EDID (dev, &edid, 256);
892 if (ACPI_FAILURE(status)) {
896 if (edid && edid->type == ACPI_TYPE_BUFFER) {
897 for (i = 0; i < edid->buffer.length; i++)
898 seq_putc(seq, edid->buffer.pointer[i]);
903 seq_printf(seq, "<not supported>\n");
911 acpi_video_device_EDID_open_fs (
915 return single_open(file, acpi_video_device_EDID_seq_show,
921 acpi_video_device_add_fs (
922 struct acpi_device *device)
924 struct proc_dir_entry *entry = NULL;
925 struct acpi_video_device *vid_dev;
927 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
930 return_VALUE(-ENODEV);
932 vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
934 return_VALUE(-ENODEV);
936 if (!acpi_device_dir(device)) {
937 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
938 vid_dev->video->dir);
939 if (!acpi_device_dir(device))
940 return_VALUE(-ENODEV);
941 acpi_device_dir(device)->owner = THIS_MODULE;
945 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
947 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
948 "Unable to create 'info' fs entry\n"));
950 entry->proc_fops = &acpi_video_device_info_fops;
951 entry->data = acpi_driver_data(device);
952 entry->owner = THIS_MODULE;
956 entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
958 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
959 "Unable to create 'state' fs entry\n"));
961 entry->proc_fops = &acpi_video_device_state_fops;
962 entry->proc_fops->write = acpi_video_device_write_state;
963 entry->data = acpi_driver_data(device);
964 entry->owner = THIS_MODULE;
967 /* 'brightness' [R/W] */
968 entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
970 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
971 "Unable to create 'brightness' fs entry\n"));
973 entry->proc_fops = &acpi_video_device_brightness_fops;
974 entry->proc_fops->write = acpi_video_device_write_brightness;
975 entry->data = acpi_driver_data(device);
976 entry->owner = THIS_MODULE;
980 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
982 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
983 "Unable to create 'brightness' fs entry\n"));
985 entry->proc_fops = &acpi_video_device_EDID_fops;
986 entry->data = acpi_driver_data(device);
987 entry->owner = THIS_MODULE;
994 acpi_video_device_remove_fs (
995 struct acpi_device *device)
997 struct acpi_video_device *vid_dev;
998 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
1000 vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
1001 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1002 return_VALUE(-ENODEV);
1004 if (acpi_device_dir(device)) {
1005 remove_proc_entry("info", acpi_device_dir(device));
1006 remove_proc_entry("state", acpi_device_dir(device));
1007 remove_proc_entry("brightness", acpi_device_dir(device));
1008 remove_proc_entry("EDID", acpi_device_dir(device));
1009 remove_proc_entry(acpi_device_bid(device),
1010 vid_dev->video->dir);
1011 acpi_device_dir(device) = NULL;
1020 acpi_video_bus_info_seq_show (
1021 struct seq_file *seq,
1024 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1026 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
1031 seq_printf(seq, "Switching heads: %s\n",
1032 video->flags.multihead ? "yes":"no");
1033 seq_printf(seq, "Video ROM: %s\n",
1034 video->flags.rom ? "yes":"no");
1035 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1036 video->flags.post ? "yes":"no");
1043 acpi_video_bus_info_open_fs (
1044 struct inode *inode,
1047 return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data);
1051 acpi_video_bus_ROM_seq_show (
1052 struct seq_file *seq,
1055 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1057 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1062 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1063 seq_printf(seq, "<TODO>\n");
1070 acpi_video_bus_ROM_open_fs (
1071 struct inode *inode,
1074 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1078 acpi_video_bus_POST_info_seq_show (
1079 struct seq_file *seq,
1082 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1083 unsigned long options;
1086 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1091 status = acpi_video_bus_POST_options(video, &options);
1092 if (ACPI_SUCCESS(status)) {
1093 if (!(options & 1)) {
1094 printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n");
1095 printk(KERN_WARNING PREFIX "This indicate a BIOS bug. Please contact the manufacturer.\n");
1097 printk("%lx\n", options);
1098 seq_printf(seq, "can POST: <intgrated video>");
1100 seq_printf(seq, " <PCI video>");
1102 seq_printf(seq, " <AGP video>");
1103 seq_putc(seq, '\n');
1105 seq_printf(seq, "<not supported>\n");
1111 acpi_video_bus_POST_info_open_fs (
1112 struct inode *inode,
1115 return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data);
1119 acpi_video_bus_POST_seq_show (
1120 struct seq_file *seq,
1123 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1127 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
1132 status = acpi_video_bus_get_POST (video, &id);
1133 if (!ACPI_SUCCESS(status)) {
1134 seq_printf(seq, "<not supported>\n");
1137 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1144 acpi_video_bus_DOS_seq_show (
1145 struct seq_file *seq,
1148 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1150 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
1152 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting );
1158 acpi_video_bus_POST_open_fs (
1159 struct inode *inode,
1162 return single_open(file, acpi_video_bus_POST_seq_show, PDE(inode)->data);
1166 acpi_video_bus_DOS_open_fs (
1167 struct inode *inode,
1170 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1174 acpi_video_bus_write_POST (
1176 const char __user *buffer,
1181 struct seq_file *m = (struct seq_file *) file->private_data;
1182 struct acpi_video_bus *video = (struct acpi_video_bus *) m->private;
1184 unsigned long opt, options;
1186 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
1189 if (!video || count + 1 > sizeof str)
1190 return_VALUE(-EINVAL);
1192 status = acpi_video_bus_POST_options(video, &options);
1193 if (!ACPI_SUCCESS(status))
1194 return_VALUE(-EINVAL);
1196 if (copy_from_user(str, buffer, count))
1197 return_VALUE(-EFAULT);
1200 opt = strtoul(str, NULL, 0);
1202 return_VALUE(-EFAULT);
1204 /* just in case an OEM 'forget' the motherboard... */
1207 if (options & (1ul << opt)) {
1208 status = acpi_video_bus_set_POST (video, opt);
1209 if (!ACPI_SUCCESS(status))
1210 return_VALUE(-EFAULT);
1215 return_VALUE(count);
1219 acpi_video_bus_write_DOS (
1221 const char __user *buffer,
1226 struct seq_file *m = (struct seq_file *) file->private_data;
1227 struct acpi_video_bus *video = (struct acpi_video_bus *) m->private;
1231 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
1234 if (!video || count + 1 > sizeof str)
1235 return_VALUE(-EINVAL);
1237 if (copy_from_user(str, buffer, count))
1238 return_VALUE(-EFAULT);
1241 opt = strtoul(str, NULL, 0);
1243 return_VALUE(-EFAULT);
1245 status = acpi_video_bus_DOS (video, opt & 0x3, (opt & 0x4)>>2);
1247 if (!ACPI_SUCCESS(status))
1248 return_VALUE(-EFAULT);
1250 return_VALUE(count);
1254 acpi_video_bus_add_fs (
1255 struct acpi_device *device)
1257 struct proc_dir_entry *entry = NULL;
1258 struct acpi_video_bus *video;
1260 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
1262 video = (struct acpi_video_bus *) acpi_driver_data(device);
1264 if (!acpi_device_dir(device)) {
1265 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1267 if (!acpi_device_dir(device))
1268 return_VALUE(-ENODEV);
1269 video->dir = acpi_device_dir(device);
1270 acpi_device_dir(device)->owner = THIS_MODULE;
1274 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'info' fs entry\n"));
1278 entry->proc_fops = &acpi_video_bus_info_fops;
1279 entry->data = acpi_driver_data(device);
1280 entry->owner = THIS_MODULE;
1284 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'ROM' fs entry\n"));
1288 entry->proc_fops = &acpi_video_bus_ROM_fops;
1289 entry->data = acpi_driver_data(device);
1290 entry->owner = THIS_MODULE;
1293 /* 'POST_info' [R] */
1294 entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1296 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST_info' fs entry\n"));
1298 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1299 entry->data = acpi_driver_data(device);
1300 entry->owner = THIS_MODULE;
1304 entry = create_proc_entry("POST", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device));
1306 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST' fs entry\n"));
1308 entry->proc_fops = &acpi_video_bus_POST_fops;
1309 entry->proc_fops->write = acpi_video_bus_write_POST;
1310 entry->data = acpi_driver_data(device);
1311 entry->owner = THIS_MODULE;
1315 entry = create_proc_entry("DOS", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device));
1317 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'DOS' fs entry\n"));
1319 entry->proc_fops = &acpi_video_bus_DOS_fops;
1320 entry->proc_fops->write = acpi_video_bus_write_DOS;
1321 entry->data = acpi_driver_data(device);
1322 entry->owner = THIS_MODULE;
1329 acpi_video_bus_remove_fs (
1330 struct acpi_device *device)
1332 struct acpi_video_bus *video;
1334 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
1336 video = (struct acpi_video_bus *) acpi_driver_data(device);
1338 if (acpi_device_dir(device)) {
1339 remove_proc_entry("info", acpi_device_dir(device));
1340 remove_proc_entry("ROM", acpi_device_dir(device));
1341 remove_proc_entry("POST_info", acpi_device_dir(device));
1342 remove_proc_entry("POST", acpi_device_dir(device));
1343 remove_proc_entry("DOS", acpi_device_dir(device));
1344 remove_proc_entry(acpi_device_bid(device),
1346 acpi_device_dir(device) = NULL;
1352 /* --------------------------------------------------------------------------
1354 -------------------------------------------------------------------------- */
1356 /* device interface */
1359 acpi_video_bus_get_one_device (
1360 struct acpi_device *device,
1361 struct acpi_video_bus *video)
1363 unsigned long device_id;
1365 struct acpi_video_device *data;
1367 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
1369 if (!device || !video)
1370 return_VALUE(-EINVAL);
1372 status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1373 if (ACPI_SUCCESS(status)) {
1375 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
1377 return_VALUE(-ENOMEM);
1379 memset(data, 0, sizeof(struct acpi_video_device));
1381 data->handle = device->handle;
1382 strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
1383 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1384 acpi_driver_data(device) = data;
1386 data->device_id = device_id;
1387 data->video = video;
1390 switch (device_id & 0xffff) {
1392 data->flags.crt = 1;
1395 data->flags.lcd = 1;
1398 data->flags.tvout = 1;
1401 data->flags.unknown = 1;
1405 acpi_video_device_bind(video, data);
1406 acpi_video_device_find_cap(data);
1408 status = acpi_install_notify_handler(data->handle,
1409 ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data);
1410 if (ACPI_FAILURE(status)) {
1411 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1412 "Error installing notify handler\n"));
1418 list_add_tail(&data->entry, &video->video_device_list);
1421 acpi_video_device_add_fs(device);
1427 return_VALUE(-ENOENT);
1432 * video : video bus device
1437 * Enumerate the video device list of the video bus,
1438 * bind the ids with the corresponding video devices
1439 * under the video bus.
1443 acpi_video_device_rebind( struct acpi_video_bus *video)
1445 struct list_head * node, * next;
1446 list_for_each_safe(node, next, &video->video_device_list) {
1447 struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry);
1448 acpi_video_device_bind( video, dev);
1454 * video : video bus device
1455 * device : video output device under the video
1461 * Bind the ids with the corresponding video devices
1462 * under the video bus.
1466 acpi_video_device_bind( struct acpi_video_bus *video,
1467 struct acpi_video_device *device)
1470 ACPI_FUNCTION_TRACE("acpi_video_device_bind");
1472 #define IDS_VAL(i) video->attached_array[i].value.int_val
1473 #define IDS_BIND(i) video->attached_array[i].bind_info
1475 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
1476 i < video->attached_count; i++) {
1477 if (device->device_id == (IDS_VAL(i)& 0xffff)) {
1478 IDS_BIND(i) = device;
1479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
1488 * video : video bus device
1493 * Call _DOD to enumerate all devices attached to display adapter
1497 static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1502 struct acpi_video_enumerated_device *active_device_list;
1503 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
1504 union acpi_object *dod = NULL;
1505 union acpi_object *obj;
1507 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
1509 status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
1510 if (!ACPI_SUCCESS(status)) {
1511 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n"));
1512 return_VALUE(status);
1515 dod = (union acpi_object *) buffer.pointer;
1516 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1517 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
1522 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
1523 dod->package.count));
1525 active_device_list= kmalloc(
1526 (1+dod->package.count)*sizeof(struct acpi_video_enumerated_device),
1529 if (!active_device_list) {
1535 for (i = 0; i < dod->package.count; i++) {
1536 obj = (union acpi_object *) &dod->package.elements[i];
1538 if (obj->type != ACPI_TYPE_INTEGER) {
1539 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
1540 active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID;
1542 active_device_list[i].value.int_val = obj->integer.value;
1543 active_device_list[i].bind_info = NULL;
1544 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, (int) obj->integer.value));
1547 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1549 if(video->attached_array)
1550 kfree(video->attached_array);
1552 video->attached_array = active_device_list;
1553 video->attached_count = count;
1555 acpi_os_free(buffer.pointer);
1556 return_VALUE(status);
1561 * video : video bus device
1562 * event : Nontify Event
1567 * 1. Find out the current active output device.
1568 * 2. Identify the next output device to switch
1569 * 3. call _DSS to do actual switch.
1573 acpi_video_switch_output(
1574 struct acpi_video_bus *video,
1577 struct list_head * node, * next;
1578 struct acpi_video_device *dev=NULL;
1579 struct acpi_video_device *dev_next=NULL;
1580 struct acpi_video_device *dev_prev=NULL;
1581 unsigned long state;
1584 ACPI_FUNCTION_TRACE("acpi_video_switch_output");
1586 list_for_each_safe(node, next, &video->video_device_list) {
1587 dev = container_of(node, struct acpi_video_device, entry);
1588 status = acpi_video_device_get_state(dev, &state);
1590 dev_next = container_of(node->next, struct acpi_video_device, entry);
1591 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1595 dev_next = container_of(node->next, struct acpi_video_device, entry);
1596 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1599 case ACPI_VIDEO_NOTIFY_CYCLE:
1600 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
1601 acpi_video_device_set_state(dev, 0);
1602 acpi_video_device_set_state(dev_next, 0x80000001);
1604 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
1605 acpi_video_device_set_state(dev, 0);
1606 acpi_video_device_set_state(dev_prev, 0x80000001);
1611 return_VALUE(status);
1615 acpi_video_get_next_level(
1616 struct acpi_video_device *device,
1621 return level_current;
1626 acpi_video_switch_brightness (
1627 struct acpi_video_device *device,
1630 unsigned long level_current, level_next;
1631 acpi_video_device_lcd_get_level_current(device, &level_current);
1632 level_next = acpi_video_get_next_level(device, level_current, event);
1633 acpi_video_device_lcd_set_level(device, level_next);
1637 acpi_video_bus_get_devices (
1638 struct acpi_video_bus *video,
1639 struct acpi_device *device)
1642 struct list_head *node, *next;
1644 ACPI_FUNCTION_TRACE("acpi_video_get_devices");
1646 acpi_video_device_enumerate(video);
1648 list_for_each_safe(node, next, &device->children) {
1649 struct acpi_device *dev = list_entry(node, struct acpi_device, node);
1654 status = acpi_video_bus_get_one_device(dev, video);
1655 if (ACPI_FAILURE(status)) {
1656 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Cant attach device\n"));
1661 return_VALUE(status);
1665 acpi_video_bus_put_one_device(
1666 struct acpi_video_device *device)
1668 struct acpi_video_bus *video;
1670 ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
1672 if (!device || !device->video)
1673 return_VALUE(-ENOENT);
1675 video = device->video;
1678 list_del(&device->entry);
1680 acpi_video_device_remove_fs(device->dev);
1686 acpi_video_bus_put_devices (
1687 struct acpi_video_bus *video)
1690 struct list_head *node, *next;
1692 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
1694 list_for_each_safe(node, next, &video->video_device_list) {
1695 struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry);
1699 status = acpi_video_bus_put_one_device(data);
1700 if(ACPI_FAILURE(status))
1701 printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n");
1703 if (data->brightness)
1704 kfree(data->brightness);
1712 /* acpi_video interface */
1715 acpi_video_bus_start_devices(
1716 struct acpi_video_bus *video)
1718 return acpi_video_bus_DOS(video, 1, 0);
1722 acpi_video_bus_stop_devices(
1723 struct acpi_video_bus *video)
1725 return acpi_video_bus_DOS(video, 0, 1);
1729 acpi_video_bus_notify (
1734 struct acpi_video_bus *video = (struct acpi_video_bus *) data;
1735 struct acpi_device *device = NULL;
1737 ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
1738 printk("video bus notify\n");
1743 if (acpi_bus_get_device(handle, &device))
1747 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur,
1748 * most likely via hotkey. */
1749 acpi_bus_generate_event(device, event, 0);
1752 case ACPI_VIDEO_NOTIFY_PROBE: /* User plug or remove a video
1754 acpi_video_device_enumerate(video);
1755 acpi_video_device_rebind(video);
1756 acpi_video_switch_output(video, event);
1757 acpi_bus_generate_event(device, event, 0);
1760 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed.*/
1761 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1762 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1763 acpi_video_switch_output(video, event);
1764 acpi_bus_generate_event(device, event, 0);
1768 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1769 "Unsupported event [0x%x]\n", event));
1777 acpi_video_device_notify (
1782 struct acpi_video_device *video_device = (struct acpi_video_device *) data;
1783 struct acpi_device *device = NULL;
1785 ACPI_FUNCTION_TRACE("acpi_video_device_notify");
1787 printk("video device notify\n");
1791 if (acpi_bus_get_device(handle, &device))
1795 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1796 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1797 acpi_bus_generate_event(device, event, 0);
1799 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1800 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1801 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1802 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1803 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1804 acpi_video_switch_brightness (video_device, event);
1805 acpi_bus_generate_event(device, event, 0);
1808 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1809 "Unsupported event [0x%x]\n", event));
1816 acpi_video_bus_add (
1817 struct acpi_device *device)
1820 acpi_status status = 0;
1821 struct acpi_video_bus *video = NULL;
1823 ACPI_FUNCTION_TRACE("acpi_video_bus_add");
1826 return_VALUE(-EINVAL);
1828 video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1830 return_VALUE(-ENOMEM);
1831 memset(video, 0, sizeof(struct acpi_video_bus));
1833 video->handle = device->handle;
1834 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
1835 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1836 acpi_driver_data(device) = video;
1838 acpi_video_bus_find_cap(video);
1839 result = acpi_video_bus_check(video);
1843 result = acpi_video_bus_add_fs(device);
1847 init_MUTEX(&video->sem);
1848 INIT_LIST_HEAD(&video->video_device_list);
1850 acpi_video_bus_get_devices(video, device);
1851 acpi_video_bus_start_devices(video);
1853 status = acpi_install_notify_handler(video->handle,
1854 ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video);
1855 if (ACPI_FAILURE(status)) {
1856 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1857 "Error installing notify handler\n"));
1862 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1863 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1864 video->flags.multihead ? "yes":"no",
1865 video->flags.rom ? "yes":"no",
1866 video->flags.post ? "yes":"no");
1870 acpi_video_bus_remove_fs(device);
1874 return_VALUE(result);
1878 acpi_video_bus_remove (
1879 struct acpi_device *device,
1882 acpi_status status = 0;
1883 struct acpi_video_bus *video = NULL;
1885 ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
1887 if (!device || !acpi_driver_data(device))
1888 return_VALUE(-EINVAL);
1890 video = (struct acpi_video_bus *) acpi_driver_data(device);
1892 acpi_video_bus_stop_devices(video);
1894 status = acpi_remove_notify_handler(video->handle,
1895 ACPI_DEVICE_NOTIFY, acpi_video_bus_notify);
1896 if (ACPI_FAILURE(status))
1897 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1898 "Error removing notify handler\n"));
1900 acpi_video_bus_put_devices(video);
1901 acpi_video_bus_remove_fs(device);
1903 if (video->attached_array)
1904 kfree(video->attached_array);
1912 acpi_video_bus_match (
1913 struct acpi_device *device,
1914 struct acpi_driver *driver)
1916 acpi_handle h_dummy1;
1917 acpi_handle h_dummy2;
1918 acpi_handle h_dummy3;
1920 ACPI_FUNCTION_TRACE("acpi_video_bus_match");
1922 if (!device || !driver)
1923 return_VALUE(-EINVAL);
1925 /* Since there is no HID, CID for ACPI Video drivers, we have
1926 * to check well known required nodes for each feature we support.
1929 /* Does this device able to support video switching ? */
1930 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
1931 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
1934 /* Does this device able to retrieve a video ROM ? */
1935 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
1938 /* Does this device able to configure which video head to be POSTed ? */
1939 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
1940 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
1941 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
1945 return_VALUE(-ENODEV);
1950 acpi_video_init (void)
1954 ACPI_FUNCTION_TRACE("acpi_video_init");
1957 acpi_dbg_level = 0xFFFFFFFF;
1958 acpi_dbg_layer = 0x08000000;
1961 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1962 if (!acpi_video_dir)
1963 return_VALUE(-ENODEV);
1964 acpi_video_dir->owner = THIS_MODULE;
1966 result = acpi_bus_register_driver(&acpi_video_bus);
1968 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1969 return_VALUE(-ENODEV);
1976 acpi_video_exit (void)
1978 ACPI_FUNCTION_TRACE("acpi_video_exit");
1980 acpi_bus_unregister_driver(&acpi_video_bus);
1982 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1987 module_init(acpi_video_init);
1988 module_exit(acpi_video_exit);