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 void acpi_video_device_notify ( acpi_handle handle, u32 event, void *data);
246 static void acpi_video_device_rebind( struct acpi_video_bus *video);
247 static void acpi_video_device_bind( struct acpi_video_bus *video, struct acpi_video_device *device);
248 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
249 static int acpi_video_switch_output( struct acpi_video_bus *video, int event);
250 static int acpi_video_get_next_level( struct acpi_video_device *device, u32 level_current,u32 event);
251 static void acpi_video_switch_brightness ( struct acpi_video_device *device, int event);
254 /* --------------------------------------------------------------------------
256 -------------------------------------------------------------------------- */
261 acpi_video_device_query (
262 struct acpi_video_device *device,
263 unsigned long *state)
266 ACPI_FUNCTION_TRACE("acpi_video_device_query");
267 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
269 return_VALUE(status);
273 acpi_video_device_get_state (
274 struct acpi_video_device *device,
275 unsigned long *state)
279 ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
281 status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
283 return_VALUE(status);
287 acpi_video_device_set_state (
288 struct acpi_video_device *device,
292 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
293 struct acpi_object_list args = {1, &arg0};
295 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
297 arg0.integer.value = state;
298 status = acpi_evaluate_integer(device->handle, "_DSS", &args, NULL);
300 return_VALUE(status);
304 acpi_video_device_lcd_query_levels (
305 struct acpi_video_device *device,
306 union acpi_object **levels)
309 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
310 union acpi_object *obj;
313 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
317 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
318 if (!ACPI_SUCCESS(status))
319 return_VALUE(status);
320 obj = (union acpi_object *) buffer.pointer;
321 if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) {
322 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
333 kfree(buffer.pointer);
335 return_VALUE(status);
339 acpi_video_device_lcd_set_level (
340 struct acpi_video_device *device,
344 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
345 struct acpi_object_list args = {1, &arg0};
347 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
349 arg0.integer.value = level;
350 status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
352 printk(KERN_DEBUG "set_level status: %x\n", status);
353 return_VALUE(status);
357 acpi_video_device_lcd_get_level_current (
358 struct acpi_video_device *device,
359 unsigned long *level)
362 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
364 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
366 return_VALUE(status);
370 acpi_video_device_EDID (
371 struct acpi_video_device *device,
372 union acpi_object **edid,
376 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
377 union acpi_object *obj;
378 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
379 struct acpi_object_list args = {1, &arg0};
381 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
386 return_VALUE(-ENODEV);
388 arg0.integer.value = 1;
389 else if (length == 256)
390 arg0.integer.value = 2;
392 return_VALUE(-EINVAL);
394 status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
395 if (ACPI_FAILURE(status))
396 return_VALUE(-ENODEV);
398 obj = (union acpi_object *) buffer.pointer;
400 if (obj && obj->type == ACPI_TYPE_BUFFER)
403 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n"));
408 return_VALUE(status);
415 acpi_video_bus_set_POST (
416 struct acpi_video_bus *video,
417 unsigned long option)
421 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
422 struct acpi_object_list args = {1, &arg0};
424 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
426 arg0.integer.value = option;
428 status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
429 if (ACPI_SUCCESS(status))
430 status = tmp ? (-EINVAL):(AE_OK);
432 return_VALUE(status);
436 acpi_video_bus_get_POST (
437 struct acpi_video_bus *video,
442 ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
444 status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
446 return_VALUE(status);
450 acpi_video_bus_POST_options (
451 struct acpi_video_bus *video,
452 unsigned long *options)
455 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
457 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
460 return_VALUE(status);
465 * video : video bus device pointer
467 * 0. The system BIOS should NOT automatically switch(toggle)
468 * the active display output.
469 * 1. The system BIOS should automatically switch (toggle) the
470 * active display output. No swich event.
471 * 2. The _DGS value should be locked.
472 * 3. The system BIOS should not automatically switch (toggle) the
473 * active display output, but instead generate the display switch
476 * 0. The system BIOS should automatically control the brightness level
477 * of the LCD, when the power changes from AC to DC
478 * 1. The system BIOS should NOT automatically control the brightness
479 * level of the LCD, when the power changes from AC to DC.
486 struct acpi_video_bus *video,
490 acpi_integer status = 0;
491 union acpi_object arg0 = {ACPI_TYPE_INTEGER};
492 struct acpi_object_list args = {1, &arg0};
494 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
496 if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){
500 arg0.integer.value = (lcd_flag << 2) | bios_flag;
501 video->dos_setting = arg0.integer.value;
502 acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
505 return_VALUE(status);
510 * device : video output device (LCD, CRT, ..)
515 * Find out all required AML method defined under the output
520 acpi_video_device_find_cap (struct acpi_video_device *device)
523 acpi_handle h_dummy1;
525 union acpi_object *obj = NULL;
526 struct acpi_video_device_brightness *br = NULL;
528 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
530 memset( &device->cap, 0, 4);
532 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
533 device->cap._ADR = 1;
535 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
538 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
541 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
544 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
545 device->cap._DCS = 1;
547 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
548 device->cap._DGS = 1;
550 if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
551 device->cap._DSS = 1;
554 status = acpi_video_device_lcd_query_levels(device, &obj);
556 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
558 union acpi_object *o;
560 br = kmalloc(sizeof &br, GFP_KERNEL);
562 printk(KERN_ERR "can't allocate memory\n");
564 memset(br, 0, sizeof &br);
565 br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL);
569 for (i = 0; i < obj->package.count; i++) {
570 o = (union acpi_object *) &obj->package.elements[i];
571 if (o->type != ACPI_TYPE_INTEGER) {
572 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
575 br->levels[count] = (u32) o->integer.value;
585 device->brightness = br;
586 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
599 * device : video output device (VGA)
604 * Find out all required AML method defined under the video bus device.
608 acpi_video_bus_find_cap (struct acpi_video_bus *video)
610 acpi_handle h_dummy1;
612 memset(&video->cap ,0, 4);
613 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
616 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
619 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
622 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
625 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
628 if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
634 * Check whether the video bus device has required AML method to
635 * support the desired features
639 acpi_video_bus_check (
640 struct acpi_video_bus *video)
642 acpi_status status = -ENOENT;
645 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
648 return_VALUE(-EINVAL);
650 /* Since there is no HID, CID and so on for VGA driver, we have
651 * to check well known required nodes.
654 /* Does this device able to support video switching ? */
656 video->flags.multihead = 1;
660 /* Does this device able to retrieve a retrieve a video ROM ? */
662 video->flags.rom = 1;
666 /* Does this device able to configure which video device to POST ? */
667 if(video->cap._GPD && video->cap._SPD && video->cap._VPO){
668 video->flags.post = 1;
672 return_VALUE(status);
675 /* --------------------------------------------------------------------------
677 -------------------------------------------------------------------------- */
679 struct proc_dir_entry *acpi_video_dir;
684 acpi_video_device_info_seq_show (
685 struct seq_file *seq,
688 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
690 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
695 seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
696 seq_printf(seq, "type: ");
698 seq_printf(seq, "CRT\n");
699 else if (dev->flags.lcd)
700 seq_printf(seq, "LCD\n");
701 else if (dev->flags.tvout)
702 seq_printf(seq, "TVOUT\n");
704 seq_printf(seq, "UNKNOWN\n");
706 seq_printf(seq,"known by bios: %s\n",
707 dev->flags.bios ? "yes":"no");
714 acpi_video_device_info_open_fs (
718 return single_open(file, acpi_video_device_info_seq_show,
723 acpi_video_device_state_seq_show (
724 struct seq_file *seq,
728 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
731 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
736 status = acpi_video_device_get_state(dev, &state);
737 seq_printf(seq, "state: ");
738 if (ACPI_SUCCESS(status))
739 seq_printf(seq, "0x%02lx\n", state);
741 seq_printf(seq, "<not supported>\n");
743 status = acpi_video_device_query(dev, &state);
744 seq_printf(seq, "query: ");
745 if (ACPI_SUCCESS(status))
746 seq_printf(seq, "0x%02lx\n", state);
748 seq_printf(seq, "<not supported>\n");
755 acpi_video_device_state_open_fs (
759 return single_open(file, acpi_video_device_state_seq_show,
764 acpi_video_device_write_state (
766 const char __user *buffer,
771 struct seq_file *m = (struct seq_file *) file->private_data;
772 struct acpi_video_device *dev = (struct acpi_video_device *) m->private;
776 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
778 if (!dev || count + 1 > sizeof str)
779 return_VALUE(-EINVAL);
781 if (copy_from_user(str, buffer, count))
782 return_VALUE(-EFAULT);
785 state = simple_strtoul(str, NULL, 0);
786 state &= ((1ul<<31) | (1ul<<30) | (1ul<<0));
788 status = acpi_video_device_set_state(dev, state);
791 return_VALUE(-EFAULT);
797 acpi_video_device_brightness_seq_show (
798 struct seq_file *seq,
801 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
804 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
806 if (!dev || !dev->brightness) {
807 seq_printf(seq, "<not supported>\n");
811 seq_printf(seq, "levels: ");
812 for (i = 0; i < dev->brightness->count; i++)
813 seq_printf(seq, " %d", dev->brightness->levels[i]);
814 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
820 acpi_video_device_brightness_open_fs (
824 return single_open(file, acpi_video_device_brightness_seq_show,
829 acpi_video_device_write_brightness (
831 const char __user *buffer,
835 struct seq_file *m = (struct seq_file *) file->private_data;
836 struct acpi_video_device *dev = (struct acpi_video_device *) m->private;
838 unsigned int level = 0;
841 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
843 if (!dev || count + 1 > sizeof str)
844 return_VALUE(-EINVAL);
846 if (copy_from_user(str, buffer, count))
847 return_VALUE(-EFAULT);
850 level = simple_strtoul(str, NULL, 0);
853 return_VALUE(-EFAULT);
855 /* validate though the list of available levels */
856 for (i = 0; i < dev->brightness->count; i++)
857 if (level == dev->brightness->levels[i]) {
858 if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level)))
859 dev->brightness->curr = level;
867 acpi_video_device_EDID_seq_show (
868 struct seq_file *seq,
871 struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
874 union acpi_object *edid = NULL;
876 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
881 status = acpi_video_device_EDID (dev, &edid, 128);
882 if (ACPI_FAILURE(status)) {
883 status = acpi_video_device_EDID (dev, &edid, 256);
886 if (ACPI_FAILURE(status)) {
890 if (edid && edid->type == ACPI_TYPE_BUFFER) {
891 for (i = 0; i < edid->buffer.length; i++)
892 seq_putc(seq, edid->buffer.pointer[i]);
897 seq_printf(seq, "<not supported>\n");
905 acpi_video_device_EDID_open_fs (
909 return single_open(file, acpi_video_device_EDID_seq_show,
915 acpi_video_device_add_fs (
916 struct acpi_device *device)
918 struct proc_dir_entry *entry = NULL;
919 struct acpi_video_device *vid_dev;
921 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
924 return_VALUE(-ENODEV);
926 vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
928 return_VALUE(-ENODEV);
930 if (!acpi_device_dir(device)) {
931 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
932 vid_dev->video->dir);
933 if (!acpi_device_dir(device))
934 return_VALUE(-ENODEV);
935 acpi_device_dir(device)->owner = THIS_MODULE;
939 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
941 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
942 "Unable to create 'info' fs entry\n"));
944 entry->proc_fops = &acpi_video_device_info_fops;
945 entry->data = acpi_driver_data(device);
946 entry->owner = THIS_MODULE;
950 entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
952 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
953 "Unable to create 'state' fs entry\n"));
955 entry->proc_fops = &acpi_video_device_state_fops;
956 entry->proc_fops->write = acpi_video_device_write_state;
957 entry->data = acpi_driver_data(device);
958 entry->owner = THIS_MODULE;
961 /* 'brightness' [R/W] */
962 entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
964 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
965 "Unable to create 'brightness' fs entry\n"));
967 entry->proc_fops = &acpi_video_device_brightness_fops;
968 entry->proc_fops->write = acpi_video_device_write_brightness;
969 entry->data = acpi_driver_data(device);
970 entry->owner = THIS_MODULE;
974 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
976 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
977 "Unable to create 'brightness' fs entry\n"));
979 entry->proc_fops = &acpi_video_device_EDID_fops;
980 entry->data = acpi_driver_data(device);
981 entry->owner = THIS_MODULE;
988 acpi_video_device_remove_fs (
989 struct acpi_device *device)
991 struct acpi_video_device *vid_dev;
992 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
994 vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
995 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
996 return_VALUE(-ENODEV);
998 if (acpi_device_dir(device)) {
999 remove_proc_entry("info", acpi_device_dir(device));
1000 remove_proc_entry("state", acpi_device_dir(device));
1001 remove_proc_entry("brightness", acpi_device_dir(device));
1002 remove_proc_entry("EDID", acpi_device_dir(device));
1003 remove_proc_entry(acpi_device_bid(device),
1004 vid_dev->video->dir);
1005 acpi_device_dir(device) = NULL;
1014 acpi_video_bus_info_seq_show (
1015 struct seq_file *seq,
1018 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1020 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
1025 seq_printf(seq, "Switching heads: %s\n",
1026 video->flags.multihead ? "yes":"no");
1027 seq_printf(seq, "Video ROM: %s\n",
1028 video->flags.rom ? "yes":"no");
1029 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1030 video->flags.post ? "yes":"no");
1037 acpi_video_bus_info_open_fs (
1038 struct inode *inode,
1041 return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data);
1045 acpi_video_bus_ROM_seq_show (
1046 struct seq_file *seq,
1049 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1051 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1056 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1057 seq_printf(seq, "<TODO>\n");
1064 acpi_video_bus_ROM_open_fs (
1065 struct inode *inode,
1068 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1072 acpi_video_bus_POST_info_seq_show (
1073 struct seq_file *seq,
1076 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1077 unsigned long options;
1080 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1085 status = acpi_video_bus_POST_options(video, &options);
1086 if (ACPI_SUCCESS(status)) {
1087 if (!(options & 1)) {
1088 printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n");
1089 printk(KERN_WARNING PREFIX "This indicate a BIOS bug. Please contact the manufacturer.\n");
1091 printk("%lx\n", options);
1092 seq_printf(seq, "can POST: <intgrated video>");
1094 seq_printf(seq, " <PCI video>");
1096 seq_printf(seq, " <AGP video>");
1097 seq_putc(seq, '\n');
1099 seq_printf(seq, "<not supported>\n");
1105 acpi_video_bus_POST_info_open_fs (
1106 struct inode *inode,
1109 return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data);
1113 acpi_video_bus_POST_seq_show (
1114 struct seq_file *seq,
1117 struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
1120 char device_decode[][30] = {
1121 "motherboard VGA device",
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 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 struct acpi_video_device * 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);