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 <linux/video_output.h>
37 #include <asm/uaccess.h>
39 #include <acpi/acpi_bus.h>
40 #include <acpi/acpi_drivers.h>
42 #define ACPI_VIDEO_COMPONENT 0x08000000
43 #define ACPI_VIDEO_CLASS "video"
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("video");
70 MODULE_AUTHOR("Bruno Ducrot");
71 MODULE_DESCRIPTION("ACPI Video Driver");
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);
77 static struct acpi_driver acpi_video_bus = {
79 .class = ACPI_VIDEO_CLASS,
80 .ids = ACPI_VIDEO_HID,
82 .add = acpi_video_bus_add,
83 .remove = acpi_video_bus_remove,
87 struct acpi_video_bus_flags {
88 u8 multihead:1; /* can switch video heads */
89 u8 rom:1; /* can retrieve a video rom */
90 u8 post:1; /* can configure the head to */
94 struct acpi_video_bus_cap {
95 u8 _DOS:1; /*Enable/Disable output switching */
96 u8 _DOD:1; /*Enumerate all devices attached to display adapter */
97 u8 _ROM:1; /*Get ROM Data */
98 u8 _GPD:1; /*Get POST Device */
99 u8 _SPD:1; /*Set POST Device */
100 u8 _VPO:1; /*Video POST Options */
104 struct acpi_video_device_attrib {
105 u32 display_index:4; /* A zero-based instance of the Display */
106 u32 display_port_attachment:4; /*This field differentiates the display type */
107 u32 display_type:4; /*Describe the specific type in use */
108 u32 vendor_specific:4; /*Chipset Vendor Specific */
109 u32 bios_can_detect:1; /*BIOS can detect the device */
110 u32 depend_on_vga:1; /*Non-VGA output device whose power is related to
112 u32 pipe_id:3; /*For VGA multiple-head devices. */
113 u32 reserved:10; /*Must be 0 */
114 u32 device_id_scheme:1; /*Device ID Scheme */
117 struct acpi_video_enumerated_device {
120 struct acpi_video_device_attrib attrib;
122 struct acpi_video_device *bind_info;
125 struct acpi_video_bus {
126 struct acpi_device *device;
128 struct acpi_video_enumerated_device *attached_array;
130 struct acpi_video_bus_cap cap;
131 struct acpi_video_bus_flags flags;
132 struct semaphore sem;
133 struct list_head video_device_list;
134 struct proc_dir_entry *dir;
137 struct acpi_video_device_flags {
147 struct acpi_video_device_cap {
148 u8 _ADR:1; /*Return the unique ID */
149 u8 _BCL:1; /*Query list of brightness control levels supported */
150 u8 _BCM:1; /*Set the brightness level */
151 u8 _BQC:1; /* Get current brightness level */
152 u8 _DDC:1; /*Return the EDID for this device */
153 u8 _DCS:1; /*Return status of output device */
154 u8 _DGS:1; /*Query graphics state */
155 u8 _DSS:1; /*Device state set */
158 struct acpi_video_device_brightness {
164 struct acpi_video_device {
165 unsigned long device_id;
166 struct acpi_video_device_flags flags;
167 struct acpi_video_device_cap cap;
168 struct list_head entry;
169 struct acpi_video_bus *video;
170 struct acpi_device *dev;
171 struct acpi_video_device_brightness *brightness;
172 struct backlight_device *backlight;
173 struct output_device *output_dev;
177 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
178 static struct file_operations acpi_video_bus_info_fops = {
179 .open = acpi_video_bus_info_open_fs,
182 .release = single_release,
185 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
186 static struct file_operations acpi_video_bus_ROM_fops = {
187 .open = acpi_video_bus_ROM_open_fs,
190 .release = single_release,
193 static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
195 static struct file_operations acpi_video_bus_POST_info_fops = {
196 .open = acpi_video_bus_POST_info_open_fs,
199 .release = single_release,
202 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
203 static struct file_operations acpi_video_bus_POST_fops = {
204 .open = acpi_video_bus_POST_open_fs,
207 .release = single_release,
210 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
211 static struct file_operations acpi_video_bus_DOS_fops = {
212 .open = acpi_video_bus_DOS_open_fs,
215 .release = single_release,
219 static int acpi_video_device_info_open_fs(struct inode *inode,
221 static struct file_operations acpi_video_device_info_fops = {
222 .open = acpi_video_device_info_open_fs,
225 .release = single_release,
228 static int acpi_video_device_state_open_fs(struct inode *inode,
230 static struct file_operations acpi_video_device_state_fops = {
231 .open = acpi_video_device_state_open_fs,
234 .release = single_release,
237 static int acpi_video_device_brightness_open_fs(struct inode *inode,
239 static struct file_operations acpi_video_device_brightness_fops = {
240 .open = acpi_video_device_brightness_open_fs,
243 .release = single_release,
246 static int acpi_video_device_EDID_open_fs(struct inode *inode,
248 static struct file_operations acpi_video_device_EDID_fops = {
249 .open = acpi_video_device_EDID_open_fs,
252 .release = single_release,
255 static char device_decode[][30] = {
256 "motherboard VGA device",
262 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data);
263 static void acpi_video_device_rebind(struct acpi_video_bus *video);
264 static void acpi_video_device_bind(struct acpi_video_bus *video,
265 struct acpi_video_device *device);
266 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
267 static int acpi_video_switch_output(struct acpi_video_bus *video, int event);
268 static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
270 static int acpi_video_device_lcd_get_level_current(
271 struct acpi_video_device *device,
272 unsigned long *level);
273 static int acpi_video_get_next_level(struct acpi_video_device *device,
274 u32 level_current, u32 event);
275 static void acpi_video_switch_brightness(struct acpi_video_device *device,
277 static int acpi_video_device_get_state(struct acpi_video_device *device,
278 unsigned long *state);
279 static int acpi_video_output_get(struct output_device *od);
280 static int acpi_video_device_set_state(struct acpi_video_device *device, int state);
282 /*backlight device sysfs support*/
283 static int acpi_video_get_brightness(struct backlight_device *bd)
285 unsigned long cur_level;
286 struct acpi_video_device *vd =
287 (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
288 acpi_video_device_lcd_get_level_current(vd, &cur_level);
289 return (int) cur_level;
292 static int acpi_video_set_brightness(struct backlight_device *bd)
294 int request_level = bd->props.brightness;
295 struct acpi_video_device *vd =
296 (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
297 acpi_video_device_lcd_set_level(vd, request_level);
301 static struct backlight_ops acpi_backlight_ops = {
302 .get_brightness = acpi_video_get_brightness,
303 .update_status = acpi_video_set_brightness,
306 /*video output device sysfs support*/
307 static int acpi_video_output_get(struct output_device *od)
310 struct acpi_video_device *vd =
311 (struct acpi_video_device *)class_get_devdata(&od->class_dev);
312 acpi_video_device_get_state(vd, &state);
316 static int acpi_video_output_set(struct output_device *od)
318 unsigned long state = od->request_state;
319 struct acpi_video_device *vd=
320 (struct acpi_video_device *)class_get_devdata(&od->class_dev);
321 return acpi_video_device_set_state(vd, state);
324 static struct output_properties acpi_output_properties = {
325 .set_state = acpi_video_output_set,
326 .get_status = acpi_video_output_get,
328 /* --------------------------------------------------------------------------
330 -------------------------------------------------------------------------- */
335 acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
339 status = acpi_evaluate_integer(device->dev->handle, "_DGS", NULL, state);
345 acpi_video_device_get_state(struct acpi_video_device *device,
346 unsigned long *state)
350 status = acpi_evaluate_integer(device->dev->handle, "_DCS", NULL, state);
356 acpi_video_device_set_state(struct acpi_video_device *device, int state)
359 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
360 struct acpi_object_list args = { 1, &arg0 };
364 arg0.integer.value = state;
365 status = acpi_evaluate_integer(device->dev->handle, "_DSS", &args, &ret);
371 acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
372 union acpi_object **levels)
375 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
376 union acpi_object *obj;
381 status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer);
382 if (!ACPI_SUCCESS(status))
384 obj = (union acpi_object *)buffer.pointer;
385 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
386 printk(KERN_ERR PREFIX "Invalid _BCL data\n");
396 kfree(buffer.pointer);
402 acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
405 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
406 struct acpi_object_list args = { 1, &arg0 };
409 arg0.integer.value = level;
410 status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
412 printk(KERN_DEBUG "set_level status: %x\n", status);
417 acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
418 unsigned long *level)
422 status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
428 acpi_video_device_EDID(struct acpi_video_device *device,
429 union acpi_object **edid, ssize_t length)
432 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
433 union acpi_object *obj;
434 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
435 struct acpi_object_list args = { 1, &arg0 };
443 arg0.integer.value = 1;
444 else if (length == 256)
445 arg0.integer.value = 2;
449 status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer);
450 if (ACPI_FAILURE(status))
453 obj = buffer.pointer;
455 if (obj && obj->type == ACPI_TYPE_BUFFER)
458 printk(KERN_ERR PREFIX "Invalid _DDC data\n");
469 acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
473 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
474 struct acpi_object_list args = { 1, &arg0 };
477 arg0.integer.value = option;
479 status = acpi_evaluate_integer(video->device->handle, "_SPD", &args, &tmp);
480 if (ACPI_SUCCESS(status))
481 status = tmp ? (-EINVAL) : (AE_OK);
487 acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
491 status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id);
497 acpi_video_bus_POST_options(struct acpi_video_bus *video,
498 unsigned long *options)
502 status = acpi_evaluate_integer(video->device->handle, "_VPO", NULL, options);
510 * video : video bus device pointer
512 * 0. The system BIOS should NOT automatically switch(toggle)
513 * the active display output.
514 * 1. The system BIOS should automatically switch (toggle) the
515 * active display output. No switch event.
516 * 2. The _DGS value should be locked.
517 * 3. The system BIOS should not automatically switch (toggle) the
518 * active display output, but instead generate the display switch
521 * 0. The system BIOS should automatically control the brightness level
522 * of the LCD when the power changes from AC to DC
523 * 1. The system BIOS should NOT automatically control the brightness
524 * level of the LCD when the power changes from AC to DC.
530 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
532 acpi_integer status = 0;
533 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
534 struct acpi_object_list args = { 1, &arg0 };
537 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
541 arg0.integer.value = (lcd_flag << 2) | bios_flag;
542 video->dos_setting = arg0.integer.value;
543 acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
551 * device : video output device (LCD, CRT, ..)
556 * Find out all required AML methods defined under the output
560 static void acpi_video_device_find_cap(struct acpi_video_device *device)
562 acpi_handle h_dummy1;
565 union acpi_object *obj = NULL;
566 struct acpi_video_device_brightness *br = NULL;
569 memset(&device->cap, 0, 4);
571 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
572 device->cap._ADR = 1;
574 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) {
575 device->cap._BCL = 1;
577 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
578 device->cap._BCM = 1;
580 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle,"_BQC",&h_dummy1)))
581 device->cap._BQC = 1;
582 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) {
583 device->cap._DDC = 1;
585 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DCS", &h_dummy1))) {
586 device->cap._DCS = 1;
588 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DGS", &h_dummy1))) {
589 device->cap._DGS = 1;
591 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DSS", &h_dummy1))) {
592 device->cap._DSS = 1;
595 if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
597 if (obj->package.count >= 2) {
599 union acpi_object *o;
601 br = kzalloc(sizeof(*br), GFP_KERNEL);
603 printk(KERN_ERR "can't allocate memory\n");
605 br->levels = kmalloc(obj->package.count *
606 sizeof *(br->levels), GFP_KERNEL);
610 for (i = 0; i < obj->package.count; i++) {
611 o = (union acpi_object *)&obj->package.
613 if (o->type != ACPI_TYPE_INTEGER) {
614 printk(KERN_ERR PREFIX "Invalid data\n");
617 br->levels[count] = (u32) o->integer.value;
619 if (br->levels[count] > max_level)
620 max_level = br->levels[count];
629 device->brightness = br;
630 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
631 "found %d brightness levels\n",
638 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
643 if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
645 static int count = 0;
647 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
651 sprintf(name, "acpi_video%d", count++);
652 acpi_video_device_lcd_get_level_current(device, &tmp);
653 device->backlight = backlight_device_register(name,
654 NULL, device, &acpi_backlight_ops);
655 device->backlight->props.max_brightness = max_level;
656 device->backlight->props.brightness = (int)tmp;
657 backlight_update_status(device->backlight);
661 if (device->cap._DCS && device->cap._DSS){
662 static int count = 0;
664 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
667 sprintf(name, "acpi_video%d", count++);
668 device->output_dev = video_output_register(name,
669 NULL, device, &acpi_output_properties);
677 * device : video output device (VGA)
682 * Find out all required AML methods defined under the video bus device.
685 static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
687 acpi_handle h_dummy1;
689 memset(&video->cap, 0, 4);
690 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) {
693 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) {
696 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) {
699 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) {
702 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) {
705 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) {
711 * Check whether the video bus device has required AML method to
712 * support the desired features
715 static int acpi_video_bus_check(struct acpi_video_bus *video)
717 acpi_status status = -ENOENT;
723 /* Since there is no HID, CID and so on for VGA driver, we have
724 * to check well known required nodes.
727 /* Does this device support video switching? */
728 if (video->cap._DOS) {
729 video->flags.multihead = 1;
733 /* Does this device support retrieving a video ROM? */
734 if (video->cap._ROM) {
735 video->flags.rom = 1;
739 /* Does this device support configuring which video device to POST? */
740 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) {
741 video->flags.post = 1;
748 /* --------------------------------------------------------------------------
750 -------------------------------------------------------------------------- */
752 static struct proc_dir_entry *acpi_video_dir;
756 static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
758 struct acpi_video_device *dev = seq->private;
764 seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
765 seq_printf(seq, "type: ");
767 seq_printf(seq, "CRT\n");
768 else if (dev->flags.lcd)
769 seq_printf(seq, "LCD\n");
770 else if (dev->flags.tvout)
771 seq_printf(seq, "TVOUT\n");
772 else if (dev->flags.dvi)
773 seq_printf(seq, "DVI\n");
775 seq_printf(seq, "UNKNOWN\n");
777 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
784 acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
786 return single_open(file, acpi_video_device_info_seq_show,
790 static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
793 struct acpi_video_device *dev = seq->private;
800 status = acpi_video_device_get_state(dev, &state);
801 seq_printf(seq, "state: ");
802 if (ACPI_SUCCESS(status))
803 seq_printf(seq, "0x%02lx\n", state);
805 seq_printf(seq, "<not supported>\n");
807 status = acpi_video_device_query(dev, &state);
808 seq_printf(seq, "query: ");
809 if (ACPI_SUCCESS(status))
810 seq_printf(seq, "0x%02lx\n", state);
812 seq_printf(seq, "<not supported>\n");
819 acpi_video_device_state_open_fs(struct inode *inode, struct file *file)
821 return single_open(file, acpi_video_device_state_seq_show,
826 acpi_video_device_write_state(struct file *file,
827 const char __user * buffer,
828 size_t count, loff_t * data)
831 struct seq_file *m = file->private_data;
832 struct acpi_video_device *dev = m->private;
833 char str[12] = { 0 };
837 if (!dev || count + 1 > sizeof str)
840 if (copy_from_user(str, buffer, count))
844 state = simple_strtoul(str, NULL, 0);
845 state &= ((1ul << 31) | (1ul << 30) | (1ul << 0));
847 status = acpi_video_device_set_state(dev, state);
856 acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
858 struct acpi_video_device *dev = seq->private;
862 if (!dev || !dev->brightness) {
863 seq_printf(seq, "<not supported>\n");
867 seq_printf(seq, "levels: ");
868 for (i = 0; i < dev->brightness->count; i++)
869 seq_printf(seq, " %d", dev->brightness->levels[i]);
870 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
876 acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file)
878 return single_open(file, acpi_video_device_brightness_seq_show,
883 acpi_video_device_write_brightness(struct file *file,
884 const char __user * buffer,
885 size_t count, loff_t * data)
887 struct seq_file *m = file->private_data;
888 struct acpi_video_device *dev = m->private;
890 unsigned int level = 0;
894 if (!dev || !dev->brightness || count + 1 > sizeof str)
897 if (copy_from_user(str, buffer, count))
901 level = simple_strtoul(str, NULL, 0);
906 /* validate through the list of available levels */
907 for (i = 0; i < dev->brightness->count; i++)
908 if (level == dev->brightness->levels[i]) {
910 (acpi_video_device_lcd_set_level(dev, level)))
911 dev->brightness->curr = level;
918 static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
920 struct acpi_video_device *dev = seq->private;
923 union acpi_object *edid = NULL;
929 status = acpi_video_device_EDID(dev, &edid, 128);
930 if (ACPI_FAILURE(status)) {
931 status = acpi_video_device_EDID(dev, &edid, 256);
934 if (ACPI_FAILURE(status)) {
938 if (edid && edid->type == ACPI_TYPE_BUFFER) {
939 for (i = 0; i < edid->buffer.length; i++)
940 seq_putc(seq, edid->buffer.pointer[i]);
945 seq_printf(seq, "<not supported>\n");
953 acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
955 return single_open(file, acpi_video_device_EDID_seq_show,
959 static int acpi_video_device_add_fs(struct acpi_device *device)
961 struct proc_dir_entry *entry = NULL;
962 struct acpi_video_device *vid_dev;
968 vid_dev = acpi_driver_data(device);
972 if (!acpi_device_dir(device)) {
973 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
974 vid_dev->video->dir);
975 if (!acpi_device_dir(device))
977 acpi_device_dir(device)->owner = THIS_MODULE;
981 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
985 entry->proc_fops = &acpi_video_device_info_fops;
986 entry->data = acpi_driver_data(device);
987 entry->owner = THIS_MODULE;
992 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
993 acpi_device_dir(device));
997 acpi_video_device_state_fops.write = acpi_video_device_write_state;
998 entry->proc_fops = &acpi_video_device_state_fops;
999 entry->data = acpi_driver_data(device);
1000 entry->owner = THIS_MODULE;
1003 /* 'brightness' [R/W] */
1005 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
1006 acpi_device_dir(device));
1010 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
1011 entry->proc_fops = &acpi_video_device_brightness_fops;
1012 entry->data = acpi_driver_data(device);
1013 entry->owner = THIS_MODULE;
1017 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
1021 entry->proc_fops = &acpi_video_device_EDID_fops;
1022 entry->data = acpi_driver_data(device);
1023 entry->owner = THIS_MODULE;
1029 static int acpi_video_device_remove_fs(struct acpi_device *device)
1031 struct acpi_video_device *vid_dev;
1033 vid_dev = acpi_driver_data(device);
1034 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1037 if (acpi_device_dir(device)) {
1038 remove_proc_entry("info", acpi_device_dir(device));
1039 remove_proc_entry("state", acpi_device_dir(device));
1040 remove_proc_entry("brightness", acpi_device_dir(device));
1041 remove_proc_entry("EDID", acpi_device_dir(device));
1042 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1043 acpi_device_dir(device) = NULL;
1050 static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
1052 struct acpi_video_bus *video = seq->private;
1058 seq_printf(seq, "Switching heads: %s\n",
1059 video->flags.multihead ? "yes" : "no");
1060 seq_printf(seq, "Video ROM: %s\n",
1061 video->flags.rom ? "yes" : "no");
1062 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1063 video->flags.post ? "yes" : "no");
1069 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
1071 return single_open(file, acpi_video_bus_info_seq_show,
1075 static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1077 struct acpi_video_bus *video = seq->private;
1083 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1084 seq_printf(seq, "<TODO>\n");
1090 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
1092 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1095 static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1097 struct acpi_video_bus *video = seq->private;
1098 unsigned long options;
1105 status = acpi_video_bus_POST_options(video, &options);
1106 if (ACPI_SUCCESS(status)) {
1107 if (!(options & 1)) {
1108 printk(KERN_WARNING PREFIX
1109 "The motherboard VGA device is not listed as a possible POST device.\n");
1110 printk(KERN_WARNING PREFIX
1111 "This indicates a BIOS bug. Please contact the manufacturer.\n");
1113 printk("%lx\n", options);
1114 seq_printf(seq, "can POST: <integrated video>");
1116 seq_printf(seq, " <PCI video>");
1118 seq_printf(seq, " <AGP video>");
1119 seq_putc(seq, '\n');
1121 seq_printf(seq, "<not supported>\n");
1127 acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1129 return single_open(file, acpi_video_bus_POST_info_seq_show,
1133 static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1135 struct acpi_video_bus *video = seq->private;
1143 status = acpi_video_bus_get_POST(video, &id);
1144 if (!ACPI_SUCCESS(status)) {
1145 seq_printf(seq, "<not supported>\n");
1148 seq_printf(seq, "device POSTed is <%s>\n", device_decode[id & 3]);
1154 static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1156 struct acpi_video_bus *video = seq->private;
1159 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1164 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
1166 return single_open(file, acpi_video_bus_POST_seq_show,
1170 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file)
1172 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1176 acpi_video_bus_write_POST(struct file *file,
1177 const char __user * buffer,
1178 size_t count, loff_t * data)
1181 struct seq_file *m = file->private_data;
1182 struct acpi_video_bus *video = m->private;
1183 char str[12] = { 0 };
1184 unsigned long opt, options;
1187 if (!video || count + 1 > sizeof str)
1190 status = acpi_video_bus_POST_options(video, &options);
1191 if (!ACPI_SUCCESS(status))
1194 if (copy_from_user(str, buffer, count))
1198 opt = strtoul(str, NULL, 0);
1202 /* just in case an OEM 'forgot' the motherboard... */
1205 if (options & (1ul << opt)) {
1206 status = acpi_video_bus_set_POST(video, opt);
1207 if (!ACPI_SUCCESS(status))
1216 acpi_video_bus_write_DOS(struct file *file,
1217 const char __user * buffer,
1218 size_t count, loff_t * data)
1221 struct seq_file *m = file->private_data;
1222 struct acpi_video_bus *video = m->private;
1223 char str[12] = { 0 };
1227 if (!video || count + 1 > sizeof str)
1230 if (copy_from_user(str, buffer, count))
1234 opt = strtoul(str, NULL, 0);
1238 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1240 if (!ACPI_SUCCESS(status))
1246 static int acpi_video_bus_add_fs(struct acpi_device *device)
1248 struct proc_dir_entry *entry = NULL;
1249 struct acpi_video_bus *video;
1252 video = acpi_driver_data(device);
1254 if (!acpi_device_dir(device)) {
1255 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1257 if (!acpi_device_dir(device))
1259 video->dir = acpi_device_dir(device);
1260 acpi_device_dir(device)->owner = THIS_MODULE;
1264 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1268 entry->proc_fops = &acpi_video_bus_info_fops;
1269 entry->data = acpi_driver_data(device);
1270 entry->owner = THIS_MODULE;
1274 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1278 entry->proc_fops = &acpi_video_bus_ROM_fops;
1279 entry->data = acpi_driver_data(device);
1280 entry->owner = THIS_MODULE;
1283 /* 'POST_info' [R] */
1285 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1289 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1290 entry->data = acpi_driver_data(device);
1291 entry->owner = THIS_MODULE;
1296 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1297 acpi_device_dir(device));
1301 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1302 entry->proc_fops = &acpi_video_bus_POST_fops;
1303 entry->data = acpi_driver_data(device);
1304 entry->owner = THIS_MODULE;
1309 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1310 acpi_device_dir(device));
1314 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1315 entry->proc_fops = &acpi_video_bus_DOS_fops;
1316 entry->data = acpi_driver_data(device);
1317 entry->owner = THIS_MODULE;
1323 static int acpi_video_bus_remove_fs(struct acpi_device *device)
1325 struct acpi_video_bus *video;
1328 video = acpi_driver_data(device);
1330 if (acpi_device_dir(device)) {
1331 remove_proc_entry("info", acpi_device_dir(device));
1332 remove_proc_entry("ROM", acpi_device_dir(device));
1333 remove_proc_entry("POST_info", acpi_device_dir(device));
1334 remove_proc_entry("POST", acpi_device_dir(device));
1335 remove_proc_entry("DOS", acpi_device_dir(device));
1336 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1337 acpi_device_dir(device) = NULL;
1343 /* --------------------------------------------------------------------------
1345 -------------------------------------------------------------------------- */
1347 /* device interface */
1348 static struct acpi_video_device_attrib*
1349 acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id)
1353 for(count = 0; count < video->attached_count; count++)
1354 if((video->attached_array[count].value.int_val & 0xffff) == device_id)
1355 return &(video->attached_array[count].value.attrib);
1360 acpi_video_bus_get_one_device(struct acpi_device *device,
1361 struct acpi_video_bus *video)
1363 unsigned long device_id;
1365 struct acpi_video_device *data;
1366 struct acpi_video_device_attrib* attribute;
1368 if (!device || !video)
1372 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1373 if (ACPI_SUCCESS(status)) {
1375 data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
1379 strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
1380 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1381 acpi_driver_data(device) = data;
1383 data->device_id = device_id;
1384 data->video = video;
1387 attribute = acpi_video_get_device_attr(video, device_id);
1389 if((attribute != NULL) && attribute->device_id_scheme) {
1390 switch (attribute->display_type) {
1391 case ACPI_VIDEO_DISPLAY_CRT:
1392 data->flags.crt = 1;
1394 case ACPI_VIDEO_DISPLAY_TV:
1395 data->flags.tvout = 1;
1397 case ACPI_VIDEO_DISPLAY_DVI:
1398 data->flags.dvi = 1;
1400 case ACPI_VIDEO_DISPLAY_LCD:
1401 data->flags.lcd = 1;
1404 data->flags.unknown = 1;
1407 if(attribute->bios_can_detect)
1408 data->flags.bios = 1;
1410 data->flags.unknown = 1;
1412 acpi_video_device_bind(video, data);
1413 acpi_video_device_find_cap(data);
1415 status = acpi_install_notify_handler(device->handle,
1417 acpi_video_device_notify,
1419 if (ACPI_FAILURE(status)) {
1420 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1421 "Error installing notify handler\n"));
1422 if(data->brightness)
1423 kfree(data->brightness->levels);
1424 kfree(data->brightness);
1430 list_add_tail(&data->entry, &video->video_device_list);
1433 acpi_video_device_add_fs(device);
1443 * video : video bus device
1448 * Enumerate the video device list of the video bus,
1449 * bind the ids with the corresponding video devices
1450 * under the video bus.
1453 static void acpi_video_device_rebind(struct acpi_video_bus *video)
1455 struct list_head *node, *next;
1456 list_for_each_safe(node, next, &video->video_device_list) {
1457 struct acpi_video_device *dev =
1458 container_of(node, struct acpi_video_device, entry);
1459 acpi_video_device_bind(video, dev);
1465 * video : video bus device
1466 * device : video output device under the video
1472 * Bind the ids with the corresponding video devices
1473 * under the video bus.
1477 acpi_video_device_bind(struct acpi_video_bus *video,
1478 struct acpi_video_device *device)
1482 #define IDS_VAL(i) video->attached_array[i].value.int_val
1483 #define IDS_BIND(i) video->attached_array[i].bind_info
1485 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
1486 i < video->attached_count; i++) {
1487 if (device->device_id == (IDS_VAL(i) & 0xffff)) {
1488 IDS_BIND(i) = device;
1489 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
1498 * video : video bus device
1503 * Call _DOD to enumerate all devices attached to display adapter
1507 static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1512 struct acpi_video_enumerated_device *active_device_list;
1513 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1514 union acpi_object *dod = NULL;
1515 union acpi_object *obj;
1517 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer);
1518 if (!ACPI_SUCCESS(status)) {
1519 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
1523 dod = buffer.pointer;
1524 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1525 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
1530 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
1531 dod->package.count));
1533 active_device_list = kmalloc((1 +
1534 dod->package.count) *
1536 acpi_video_enumerated_device),
1539 if (!active_device_list) {
1545 for (i = 0; i < dod->package.count; i++) {
1546 obj = &dod->package.elements[i];
1548 if (obj->type != ACPI_TYPE_INTEGER) {
1549 printk(KERN_ERR PREFIX "Invalid _DOD data\n");
1550 active_device_list[i].value.int_val =
1551 ACPI_VIDEO_HEAD_INVALID;
1553 active_device_list[i].value.int_val = obj->integer.value;
1554 active_device_list[i].bind_info = NULL;
1555 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i,
1556 (int)obj->integer.value));
1559 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1561 kfree(video->attached_array);
1563 video->attached_array = active_device_list;
1564 video->attached_count = count;
1566 kfree(buffer.pointer);
1572 * video : video bus device
1573 * event : notify event
1578 * 1. Find out the current active output device.
1579 * 2. Identify the next output device to switch to.
1580 * 3. call _DSS to do actual switch.
1583 static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1585 struct list_head *node, *next;
1586 struct acpi_video_device *dev = NULL;
1587 struct acpi_video_device *dev_next = NULL;
1588 struct acpi_video_device *dev_prev = NULL;
1589 unsigned long state;
1593 list_for_each_safe(node, next, &video->video_device_list) {
1594 dev = container_of(node, struct acpi_video_device, entry);
1595 status = acpi_video_device_get_state(dev, &state);
1598 container_of(node->next, struct acpi_video_device,
1601 container_of(node->prev, struct acpi_video_device,
1606 dev_next = container_of(node->next, struct acpi_video_device, entry);
1607 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1610 case ACPI_VIDEO_NOTIFY_CYCLE:
1611 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
1612 acpi_video_device_set_state(dev, 0);
1613 acpi_video_device_set_state(dev_next, 0x80000001);
1615 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
1616 acpi_video_device_set_state(dev, 0);
1617 acpi_video_device_set_state(dev_prev, 0x80000001);
1626 acpi_video_get_next_level(struct acpi_video_device *device,
1627 u32 level_current, u32 event)
1629 int min, max, min_above, max_below, i, l;
1630 max = max_below = 0;
1631 min = min_above = 255;
1632 for (i = 0; i < device->brightness->count; i++) {
1633 l = device->brightness->levels[i];
1638 if (l < min_above && l > level_current)
1640 if (l > max_below && l < level_current)
1645 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
1646 return (level_current < max) ? min_above : min;
1647 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
1648 return (level_current < max) ? min_above : max;
1649 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
1650 return (level_current > min) ? max_below : min;
1651 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
1652 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
1655 return level_current;
1660 acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1662 unsigned long level_current, level_next;
1663 acpi_video_device_lcd_get_level_current(device, &level_current);
1664 level_next = acpi_video_get_next_level(device, level_current, event);
1665 acpi_video_device_lcd_set_level(device, level_next);
1669 acpi_video_bus_get_devices(struct acpi_video_bus *video,
1670 struct acpi_device *device)
1673 struct list_head *node, *next;
1676 acpi_video_device_enumerate(video);
1678 list_for_each_safe(node, next, &device->children) {
1679 struct acpi_device *dev =
1680 list_entry(node, struct acpi_device, node);
1685 status = acpi_video_bus_get_one_device(dev, video);
1686 if (ACPI_FAILURE(status)) {
1687 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
1695 static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1698 struct acpi_video_bus *video;
1701 if (!device || !device->video)
1704 video = device->video;
1707 list_del(&device->entry);
1709 acpi_video_device_remove_fs(device->dev);
1711 status = acpi_remove_notify_handler(device->dev->handle,
1713 acpi_video_device_notify);
1714 backlight_device_unregister(device->backlight);
1715 video_output_unregister(device->output_dev);
1719 static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1722 struct list_head *node, *next;
1725 list_for_each_safe(node, next, &video->video_device_list) {
1726 struct acpi_video_device *data =
1727 list_entry(node, struct acpi_video_device, entry);
1731 status = acpi_video_bus_put_one_device(data);
1732 if (ACPI_FAILURE(status))
1733 printk(KERN_WARNING PREFIX
1734 "hhuuhhuu bug in acpi video driver.\n");
1736 if (data->brightness)
1737 kfree(data->brightness->levels);
1738 kfree(data->brightness);
1745 /* acpi_video interface */
1747 static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1749 return acpi_video_bus_DOS(video, 1, 0);
1752 static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1754 return acpi_video_bus_DOS(video, 0, 1);
1757 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1759 struct acpi_video_bus *video = data;
1760 struct acpi_device *device = NULL;
1762 printk("video bus notify\n");
1767 device = video->device;
1770 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch,
1771 * most likely via hotkey. */
1772 acpi_bus_generate_event(device, event, 0);
1775 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video
1777 acpi_video_device_enumerate(video);
1778 acpi_video_device_rebind(video);
1779 acpi_video_switch_output(video, event);
1780 acpi_bus_generate_event(device, event, 0);
1783 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1784 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1785 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1786 acpi_video_switch_output(video, event);
1787 acpi_bus_generate_event(device, event, 0);
1791 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1792 "Unsupported event [0x%x]\n", event));
1799 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1801 struct acpi_video_device *video_device = data;
1802 struct acpi_device *device = NULL;
1807 device = video_device->dev;
1810 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1811 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1812 acpi_bus_generate_event(device, event, 0);
1814 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1815 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1816 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1817 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1818 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1819 acpi_video_switch_brightness(video_device, event);
1820 acpi_bus_generate_event(device, event, 0);
1823 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1824 "Unsupported event [0x%x]\n", event));
1830 static int acpi_video_bus_add(struct acpi_device *device)
1833 acpi_status status = 0;
1834 struct acpi_video_bus *video = NULL;
1840 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1844 video->device = device;
1845 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
1846 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1847 acpi_driver_data(device) = video;
1849 acpi_video_bus_find_cap(video);
1850 result = acpi_video_bus_check(video);
1854 result = acpi_video_bus_add_fs(device);
1858 init_MUTEX(&video->sem);
1859 INIT_LIST_HEAD(&video->video_device_list);
1861 acpi_video_bus_get_devices(video, device);
1862 acpi_video_bus_start_devices(video);
1864 status = acpi_install_notify_handler(device->handle,
1866 acpi_video_bus_notify, video);
1867 if (ACPI_FAILURE(status)) {
1868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1869 "Error installing notify handler\n"));
1870 acpi_video_bus_stop_devices(video);
1871 acpi_video_bus_put_devices(video);
1872 kfree(video->attached_array);
1873 acpi_video_bus_remove_fs(device);
1878 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1879 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1880 video->flags.multihead ? "yes" : "no",
1881 video->flags.rom ? "yes" : "no",
1882 video->flags.post ? "yes" : "no");
1891 static int acpi_video_bus_remove(struct acpi_device *device, int type)
1893 acpi_status status = 0;
1894 struct acpi_video_bus *video = NULL;
1897 if (!device || !acpi_driver_data(device))
1900 video = acpi_driver_data(device);
1902 acpi_video_bus_stop_devices(video);
1904 status = acpi_remove_notify_handler(video->device->handle,
1906 acpi_video_bus_notify);
1908 acpi_video_bus_put_devices(video);
1909 acpi_video_bus_remove_fs(device);
1911 kfree(video->attached_array);
1917 static int __init acpi_video_init(void)
1923 acpi_dbg_level = 0xFFFFFFFF;
1924 acpi_dbg_layer = 0x08000000;
1927 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1928 if (!acpi_video_dir)
1930 acpi_video_dir->owner = THIS_MODULE;
1932 result = acpi_bus_register_driver(&acpi_video_bus);
1934 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1941 static void __exit acpi_video_exit(void)
1944 acpi_bus_unregister_driver(&acpi_video_bus);
1946 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1951 module_init(acpi_video_init);
1952 module_exit(acpi_video_exit);