2 * video.c - ACPI Video Driver ($Revision:$)
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
6 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/types.h>
31 #include <linux/list.h>
32 #include <linux/proc_fs.h>
33 #include <linux/seq_file.h>
35 #include <linux/backlight.h>
36 #include <asm/uaccess.h>
38 #include <acpi/acpi_bus.h>
39 #include <acpi/acpi_drivers.h>
41 #define ACPI_VIDEO_COMPONENT 0x08000000
42 #define ACPI_VIDEO_CLASS "video"
43 #define ACPI_VIDEO_BUS_NAME "Video Bus"
44 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
45 #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
46 #define ACPI_VIDEO_NOTIFY_PROBE 0x81
47 #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
48 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
49 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
51 #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
52 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
53 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
54 #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
55 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
57 #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
58 #define ACPI_VIDEO_HEAD_END (~0u)
59 #define MAX_NAME_LEN 20
61 #define ACPI_VIDEO_DISPLAY_CRT 1
62 #define ACPI_VIDEO_DISPLAY_TV 2
63 #define ACPI_VIDEO_DISPLAY_DVI 3
64 #define ACPI_VIDEO_DISPLAY_LCD 4
66 #define _COMPONENT ACPI_VIDEO_COMPONENT
67 ACPI_MODULE_NAME("video");
69 MODULE_AUTHOR("Bruno Ducrot");
70 MODULE_DESCRIPTION("ACPI Video Driver");
71 MODULE_LICENSE("GPL");
73 static int acpi_video_bus_add(struct acpi_device *device);
74 static int acpi_video_bus_remove(struct acpi_device *device, int type);
76 static struct acpi_driver acpi_video_bus = {
78 .class = ACPI_VIDEO_CLASS,
79 .ids = ACPI_VIDEO_HID,
81 .add = acpi_video_bus_add,
82 .remove = acpi_video_bus_remove,
86 struct acpi_video_bus_flags {
87 u8 multihead:1; /* can switch video heads */
88 u8 rom:1; /* can retrieve a video rom */
89 u8 post:1; /* can configure the head to */
93 struct acpi_video_bus_cap {
94 u8 _DOS:1; /*Enable/Disable output switching */
95 u8 _DOD:1; /*Enumerate all devices attached to display adapter */
96 u8 _ROM:1; /*Get ROM Data */
97 u8 _GPD:1; /*Get POST Device */
98 u8 _SPD:1; /*Set POST Device */
99 u8 _VPO:1; /*Video POST Options */
103 struct acpi_video_device_attrib {
104 u32 display_index:4; /* A zero-based instance of the Display */
105 u32 display_port_attachment:4; /*This field differenates displays type */
106 u32 display_type:4; /*Describe the specific type in use */
107 u32 vendor_specific:4; /*Chipset Vendor Specifi */
108 u32 bios_can_detect:1; /*BIOS can detect the device */
109 u32 depend_on_vga:1; /*Non-VGA output device whose power is related to
111 u32 pipe_id:3; /*For VGA multiple-head devices. */
112 u32 reserved:10; /*Must be 0 */
113 u32 device_id_scheme:1; /*Device ID Scheme */
116 struct acpi_video_enumerated_device {
119 struct acpi_video_device_attrib attrib;
121 struct acpi_video_device *bind_info;
124 struct acpi_video_bus {
125 struct acpi_device *device;
127 struct acpi_video_enumerated_device *attached_array;
129 struct acpi_video_bus_cap cap;
130 struct acpi_video_bus_flags flags;
131 struct semaphore sem;
132 struct list_head video_device_list;
133 struct proc_dir_entry *dir;
136 struct acpi_video_device_flags {
146 struct acpi_video_device_cap {
147 u8 _ADR:1; /*Return the unique ID */
148 u8 _BCL:1; /*Query list of brightness control levels supported */
149 u8 _BCM:1; /*Set the brightness level */
150 u8 _BQC:1; /* Get current brightness level */
151 u8 _DDC:1; /*Return the EDID for this device */
152 u8 _DCS:1; /*Return status of output device */
153 u8 _DGS:1; /*Query graphics state */
154 u8 _DSS:1; /*Device state set */
157 struct acpi_video_device_brightness {
163 struct acpi_video_device {
164 unsigned long device_id;
165 struct acpi_video_device_flags flags;
166 struct acpi_video_device_cap cap;
167 struct list_head entry;
168 struct acpi_video_bus *video;
169 struct acpi_device *dev;
170 struct acpi_video_device_brightness *brightness;
171 struct backlight_device *backlight;
172 struct backlight_properties *data;
176 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
177 static struct file_operations acpi_video_bus_info_fops = {
178 .open = acpi_video_bus_info_open_fs,
181 .release = single_release,
184 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
185 static struct file_operations acpi_video_bus_ROM_fops = {
186 .open = acpi_video_bus_ROM_open_fs,
189 .release = single_release,
192 static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
194 static struct file_operations acpi_video_bus_POST_info_fops = {
195 .open = acpi_video_bus_POST_info_open_fs,
198 .release = single_release,
201 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
202 static struct file_operations acpi_video_bus_POST_fops = {
203 .open = acpi_video_bus_POST_open_fs,
206 .release = single_release,
209 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
210 static struct file_operations acpi_video_bus_DOS_fops = {
211 .open = acpi_video_bus_DOS_open_fs,
214 .release = single_release,
218 static int acpi_video_device_info_open_fs(struct inode *inode,
220 static struct file_operations acpi_video_device_info_fops = {
221 .open = acpi_video_device_info_open_fs,
224 .release = single_release,
227 static int acpi_video_device_state_open_fs(struct inode *inode,
229 static struct file_operations acpi_video_device_state_fops = {
230 .open = acpi_video_device_state_open_fs,
233 .release = single_release,
236 static int acpi_video_device_brightness_open_fs(struct inode *inode,
238 static struct file_operations acpi_video_device_brightness_fops = {
239 .open = acpi_video_device_brightness_open_fs,
242 .release = single_release,
245 static int acpi_video_device_EDID_open_fs(struct inode *inode,
247 static struct file_operations acpi_video_device_EDID_fops = {
248 .open = acpi_video_device_EDID_open_fs,
251 .release = single_release,
254 static char device_decode[][30] = {
255 "motherboard VGA device",
261 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data);
262 static void acpi_video_device_rebind(struct acpi_video_bus *video);
263 static void acpi_video_device_bind(struct acpi_video_bus *video,
264 struct acpi_video_device *device);
265 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
266 static int acpi_video_switch_output(struct acpi_video_bus *video, int event);
267 static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
269 static int acpi_video_device_lcd_get_level_current(
270 struct acpi_video_device *device,
271 unsigned long *level);
272 static int acpi_video_get_next_level(struct acpi_video_device *device,
273 u32 level_current, u32 event);
274 static void acpi_video_switch_brightness(struct acpi_video_device *device,
277 /*backlight device sysfs support*/
278 static int acpi_video_get_brightness(struct backlight_device *bd)
280 unsigned long cur_level;
281 struct acpi_video_device *vd =
282 (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
283 acpi_video_device_lcd_get_level_current(vd, &cur_level);
284 return (int) cur_level;
287 static int acpi_video_set_brightness(struct backlight_device *bd)
289 int request_level = bd->props->brightness;
290 struct acpi_video_device *vd =
291 (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
292 acpi_video_device_lcd_set_level(vd, request_level);
296 /* --------------------------------------------------------------------------
298 -------------------------------------------------------------------------- */
303 acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
307 status = acpi_evaluate_integer(device->dev->handle, "_DGS", NULL, state);
313 acpi_video_device_get_state(struct acpi_video_device *device,
314 unsigned long *state)
318 status = acpi_evaluate_integer(device->dev->handle, "_DCS", NULL, state);
324 acpi_video_device_set_state(struct acpi_video_device *device, int state)
327 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
328 struct acpi_object_list args = { 1, &arg0 };
332 arg0.integer.value = state;
333 status = acpi_evaluate_integer(device->dev->handle, "_DSS", &args, &ret);
339 acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
340 union acpi_object **levels)
343 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
344 union acpi_object *obj;
349 status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer);
350 if (!ACPI_SUCCESS(status))
352 obj = (union acpi_object *)buffer.pointer;
353 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
354 printk(KERN_ERR PREFIX "Invalid _BCL data\n");
364 kfree(buffer.pointer);
370 acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
373 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
374 struct acpi_object_list args = { 1, &arg0 };
377 arg0.integer.value = level;
378 status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
380 printk(KERN_DEBUG "set_level status: %x\n", status);
385 acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
386 unsigned long *level)
390 status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
396 acpi_video_device_EDID(struct acpi_video_device *device,
397 union acpi_object **edid, ssize_t length)
400 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
401 union acpi_object *obj;
402 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
403 struct acpi_object_list args = { 1, &arg0 };
411 arg0.integer.value = 1;
412 else if (length == 256)
413 arg0.integer.value = 2;
417 status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer);
418 if (ACPI_FAILURE(status))
421 obj = buffer.pointer;
423 if (obj && obj->type == ACPI_TYPE_BUFFER)
426 printk(KERN_ERR PREFIX "Invalid _DDC data\n");
437 acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
441 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
442 struct acpi_object_list args = { 1, &arg0 };
445 arg0.integer.value = option;
447 status = acpi_evaluate_integer(video->device->handle, "_SPD", &args, &tmp);
448 if (ACPI_SUCCESS(status))
449 status = tmp ? (-EINVAL) : (AE_OK);
455 acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
459 status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id);
465 acpi_video_bus_POST_options(struct acpi_video_bus *video,
466 unsigned long *options)
470 status = acpi_evaluate_integer(video->device->handle, "_VPO", NULL, options);
478 * video : video bus device pointer
480 * 0. The system BIOS should NOT automatically switch(toggle)
481 * the active display output.
482 * 1. The system BIOS should automatically switch (toggle) the
483 * active display output. No swich event.
484 * 2. The _DGS value should be locked.
485 * 3. The system BIOS should not automatically switch (toggle) the
486 * active display output, but instead generate the display switch
489 * 0. The system BIOS should automatically control the brightness level
490 * of the LCD, when the power changes from AC to DC
491 * 1. The system BIOS should NOT automatically control the brightness
492 * level of the LCD, when the power changes from AC to DC.
498 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
500 acpi_integer status = 0;
501 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
502 struct acpi_object_list args = { 1, &arg0 };
505 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
509 arg0.integer.value = (lcd_flag << 2) | bios_flag;
510 video->dos_setting = arg0.integer.value;
511 acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
519 * device : video output device (LCD, CRT, ..)
524 * Find out all required AML method defined under the output
528 static void acpi_video_device_find_cap(struct acpi_video_device *device)
531 acpi_handle h_dummy1;
534 union acpi_object *obj = NULL;
535 struct acpi_video_device_brightness *br = NULL;
538 memset(&device->cap, 0, 4);
540 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
541 device->cap._ADR = 1;
543 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) {
544 device->cap._BCL = 1;
546 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
547 device->cap._BCM = 1;
549 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle,"_BQC",&h_dummy1)))
550 device->cap._BQC = 1;
551 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) {
552 device->cap._DDC = 1;
554 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DCS", &h_dummy1))) {
555 device->cap._DCS = 1;
557 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DGS", &h_dummy1))) {
558 device->cap._DGS = 1;
560 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DSS", &h_dummy1))) {
561 device->cap._DSS = 1;
564 status = acpi_video_device_lcd_query_levels(device, &obj);
566 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
568 union acpi_object *o;
570 br = kzalloc(sizeof(*br), GFP_KERNEL);
572 printk(KERN_ERR "can't allocate memory\n");
574 br->levels = kmalloc(obj->package.count *
575 sizeof *(br->levels), GFP_KERNEL);
579 for (i = 0; i < obj->package.count; i++) {
580 o = (union acpi_object *)&obj->package.
582 if (o->type != ACPI_TYPE_INTEGER) {
583 printk(KERN_ERR PREFIX "Invalid data\n");
586 br->levels[count] = (u32) o->integer.value;
587 if (br->levels[count] > max_level)
588 max_level = br->levels[count];
597 device->brightness = br;
598 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
599 "found %d brightness levels\n",
607 if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
609 static int count = 0;
611 struct backlight_properties *acpi_video_data;
613 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
617 acpi_video_data = kzalloc(
618 sizeof(struct backlight_properties),
620 if (!acpi_video_data){
624 acpi_video_data->owner = THIS_MODULE;
625 acpi_video_data->get_brightness =
626 acpi_video_get_brightness;
627 acpi_video_data->update_status =
628 acpi_video_set_brightness;
629 sprintf(name, "acpi_video%d", count++);
630 device->data = acpi_video_data;
631 acpi_video_data->max_brightness = max_level;
632 acpi_video_device_lcd_get_level_current(device, &tmp);
633 acpi_video_data->brightness = (int)tmp;
634 device->backlight = backlight_device_register(name,
635 NULL, device, acpi_video_data);
643 * device : video output device (VGA)
648 * Find out all required AML method defined under the video bus device.
651 static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
653 acpi_handle h_dummy1;
655 memset(&video->cap, 0, 4);
656 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) {
659 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) {
662 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) {
665 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) {
668 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) {
671 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) {
677 * Check whether the video bus device has required AML method to
678 * support the desired features
681 static int acpi_video_bus_check(struct acpi_video_bus *video)
683 acpi_status status = -ENOENT;
689 /* Since there is no HID, CID and so on for VGA driver, we have
690 * to check well known required nodes.
693 /* Does this device able to support video switching ? */
694 if (video->cap._DOS) {
695 video->flags.multihead = 1;
699 /* Does this device able to retrieve a retrieve a video ROM ? */
700 if (video->cap._ROM) {
701 video->flags.rom = 1;
705 /* Does this device able to configure which video device to POST ? */
706 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) {
707 video->flags.post = 1;
714 /* --------------------------------------------------------------------------
716 -------------------------------------------------------------------------- */
718 static struct proc_dir_entry *acpi_video_dir;
722 static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
724 struct acpi_video_device *dev = seq->private;
730 seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
731 seq_printf(seq, "type: ");
733 seq_printf(seq, "CRT\n");
734 else if (dev->flags.lcd)
735 seq_printf(seq, "LCD\n");
736 else if (dev->flags.tvout)
737 seq_printf(seq, "TVOUT\n");
738 else if (dev->flags.dvi)
739 seq_printf(seq, "DVI\n");
741 seq_printf(seq, "UNKNOWN\n");
743 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
750 acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
752 return single_open(file, acpi_video_device_info_seq_show,
756 static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
759 struct acpi_video_device *dev = seq->private;
766 status = acpi_video_device_get_state(dev, &state);
767 seq_printf(seq, "state: ");
768 if (ACPI_SUCCESS(status))
769 seq_printf(seq, "0x%02lx\n", state);
771 seq_printf(seq, "<not supported>\n");
773 status = acpi_video_device_query(dev, &state);
774 seq_printf(seq, "query: ");
775 if (ACPI_SUCCESS(status))
776 seq_printf(seq, "0x%02lx\n", state);
778 seq_printf(seq, "<not supported>\n");
785 acpi_video_device_state_open_fs(struct inode *inode, struct file *file)
787 return single_open(file, acpi_video_device_state_seq_show,
792 acpi_video_device_write_state(struct file *file,
793 const char __user * buffer,
794 size_t count, loff_t * data)
797 struct seq_file *m = file->private_data;
798 struct acpi_video_device *dev = m->private;
799 char str[12] = { 0 };
803 if (!dev || count + 1 > sizeof str)
806 if (copy_from_user(str, buffer, count))
810 state = simple_strtoul(str, NULL, 0);
811 state &= ((1ul << 31) | (1ul << 30) | (1ul << 0));
813 status = acpi_video_device_set_state(dev, state);
822 acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
824 struct acpi_video_device *dev = seq->private;
828 if (!dev || !dev->brightness) {
829 seq_printf(seq, "<not supported>\n");
833 seq_printf(seq, "levels: ");
834 for (i = 0; i < dev->brightness->count; i++)
835 seq_printf(seq, " %d", dev->brightness->levels[i]);
836 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
842 acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file)
844 return single_open(file, acpi_video_device_brightness_seq_show,
849 acpi_video_device_write_brightness(struct file *file,
850 const char __user * buffer,
851 size_t count, loff_t * data)
853 struct seq_file *m = file->private_data;
854 struct acpi_video_device *dev = m->private;
856 unsigned int level = 0;
860 if (!dev || !dev->brightness || count + 1 > sizeof str)
863 if (copy_from_user(str, buffer, count))
867 level = simple_strtoul(str, NULL, 0);
872 /* validate though the list of available levels */
873 for (i = 0; i < dev->brightness->count; i++)
874 if (level == dev->brightness->levels[i]) {
876 (acpi_video_device_lcd_set_level(dev, level)))
877 dev->brightness->curr = level;
884 static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
886 struct acpi_video_device *dev = seq->private;
889 union acpi_object *edid = NULL;
895 status = acpi_video_device_EDID(dev, &edid, 128);
896 if (ACPI_FAILURE(status)) {
897 status = acpi_video_device_EDID(dev, &edid, 256);
900 if (ACPI_FAILURE(status)) {
904 if (edid && edid->type == ACPI_TYPE_BUFFER) {
905 for (i = 0; i < edid->buffer.length; i++)
906 seq_putc(seq, edid->buffer.pointer[i]);
911 seq_printf(seq, "<not supported>\n");
919 acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
921 return single_open(file, acpi_video_device_EDID_seq_show,
925 static int acpi_video_device_add_fs(struct acpi_device *device)
927 struct proc_dir_entry *entry = NULL;
928 struct acpi_video_device *vid_dev;
934 vid_dev = acpi_driver_data(device);
938 if (!acpi_device_dir(device)) {
939 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
940 vid_dev->video->dir);
941 if (!acpi_device_dir(device))
943 acpi_device_dir(device)->owner = THIS_MODULE;
947 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
951 entry->proc_fops = &acpi_video_device_info_fops;
952 entry->data = acpi_driver_data(device);
953 entry->owner = THIS_MODULE;
958 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
959 acpi_device_dir(device));
963 acpi_video_device_state_fops.write = acpi_video_device_write_state;
964 entry->proc_fops = &acpi_video_device_state_fops;
965 entry->data = acpi_driver_data(device);
966 entry->owner = THIS_MODULE;
969 /* 'brightness' [R/W] */
971 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
972 acpi_device_dir(device));
976 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
977 entry->proc_fops = &acpi_video_device_brightness_fops;
978 entry->data = acpi_driver_data(device);
979 entry->owner = THIS_MODULE;
983 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
987 entry->proc_fops = &acpi_video_device_EDID_fops;
988 entry->data = acpi_driver_data(device);
989 entry->owner = THIS_MODULE;
995 static int acpi_video_device_remove_fs(struct acpi_device *device)
997 struct acpi_video_device *vid_dev;
999 vid_dev = acpi_driver_data(device);
1000 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1003 if (acpi_device_dir(device)) {
1004 remove_proc_entry("info", acpi_device_dir(device));
1005 remove_proc_entry("state", acpi_device_dir(device));
1006 remove_proc_entry("brightness", acpi_device_dir(device));
1007 remove_proc_entry("EDID", acpi_device_dir(device));
1008 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1009 acpi_device_dir(device) = NULL;
1016 static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
1018 struct acpi_video_bus *video = seq->private;
1024 seq_printf(seq, "Switching heads: %s\n",
1025 video->flags.multihead ? "yes" : "no");
1026 seq_printf(seq, "Video ROM: %s\n",
1027 video->flags.rom ? "yes" : "no");
1028 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1029 video->flags.post ? "yes" : "no");
1035 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
1037 return single_open(file, acpi_video_bus_info_seq_show,
1041 static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1043 struct acpi_video_bus *video = seq->private;
1049 printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
1050 seq_printf(seq, "<TODO>\n");
1056 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
1058 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1061 static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1063 struct acpi_video_bus *video = seq->private;
1064 unsigned long options;
1071 status = acpi_video_bus_POST_options(video, &options);
1072 if (ACPI_SUCCESS(status)) {
1073 if (!(options & 1)) {
1074 printk(KERN_WARNING PREFIX
1075 "The motherboard VGA device is not listed as a possible POST device.\n");
1076 printk(KERN_WARNING PREFIX
1077 "This indicate a BIOS bug. Please contact the manufacturer.\n");
1079 printk("%lx\n", options);
1080 seq_printf(seq, "can POST: <intgrated video>");
1082 seq_printf(seq, " <PCI video>");
1084 seq_printf(seq, " <AGP video>");
1085 seq_putc(seq, '\n');
1087 seq_printf(seq, "<not supported>\n");
1093 acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1095 return single_open(file, acpi_video_bus_POST_info_seq_show,
1099 static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1101 struct acpi_video_bus *video = seq->private;
1109 status = acpi_video_bus_get_POST(video, &id);
1110 if (!ACPI_SUCCESS(status)) {
1111 seq_printf(seq, "<not supported>\n");
1114 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1120 static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1122 struct acpi_video_bus *video = seq->private;
1125 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1130 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
1132 return single_open(file, acpi_video_bus_POST_seq_show,
1136 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file)
1138 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1142 acpi_video_bus_write_POST(struct file *file,
1143 const char __user * buffer,
1144 size_t count, loff_t * data)
1147 struct seq_file *m = file->private_data;
1148 struct acpi_video_bus *video = m->private;
1149 char str[12] = { 0 };
1150 unsigned long opt, options;
1153 if (!video || count + 1 > sizeof str)
1156 status = acpi_video_bus_POST_options(video, &options);
1157 if (!ACPI_SUCCESS(status))
1160 if (copy_from_user(str, buffer, count))
1164 opt = strtoul(str, NULL, 0);
1168 /* just in case an OEM 'forget' the motherboard... */
1171 if (options & (1ul << opt)) {
1172 status = acpi_video_bus_set_POST(video, opt);
1173 if (!ACPI_SUCCESS(status))
1182 acpi_video_bus_write_DOS(struct file *file,
1183 const char __user * buffer,
1184 size_t count, loff_t * data)
1187 struct seq_file *m = file->private_data;
1188 struct acpi_video_bus *video = m->private;
1189 char str[12] = { 0 };
1193 if (!video || count + 1 > sizeof str)
1196 if (copy_from_user(str, buffer, count))
1200 opt = strtoul(str, NULL, 0);
1204 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1206 if (!ACPI_SUCCESS(status))
1212 static int acpi_video_bus_add_fs(struct acpi_device *device)
1214 struct proc_dir_entry *entry = NULL;
1215 struct acpi_video_bus *video;
1218 video = acpi_driver_data(device);
1220 if (!acpi_device_dir(device)) {
1221 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1223 if (!acpi_device_dir(device))
1225 video->dir = acpi_device_dir(device);
1226 acpi_device_dir(device)->owner = THIS_MODULE;
1230 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1234 entry->proc_fops = &acpi_video_bus_info_fops;
1235 entry->data = acpi_driver_data(device);
1236 entry->owner = THIS_MODULE;
1240 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1244 entry->proc_fops = &acpi_video_bus_ROM_fops;
1245 entry->data = acpi_driver_data(device);
1246 entry->owner = THIS_MODULE;
1249 /* 'POST_info' [R] */
1251 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1255 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1256 entry->data = acpi_driver_data(device);
1257 entry->owner = THIS_MODULE;
1262 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1263 acpi_device_dir(device));
1267 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1268 entry->proc_fops = &acpi_video_bus_POST_fops;
1269 entry->data = acpi_driver_data(device);
1270 entry->owner = THIS_MODULE;
1275 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1276 acpi_device_dir(device));
1280 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1281 entry->proc_fops = &acpi_video_bus_DOS_fops;
1282 entry->data = acpi_driver_data(device);
1283 entry->owner = THIS_MODULE;
1289 static int acpi_video_bus_remove_fs(struct acpi_device *device)
1291 struct acpi_video_bus *video;
1294 video = acpi_driver_data(device);
1296 if (acpi_device_dir(device)) {
1297 remove_proc_entry("info", acpi_device_dir(device));
1298 remove_proc_entry("ROM", acpi_device_dir(device));
1299 remove_proc_entry("POST_info", acpi_device_dir(device));
1300 remove_proc_entry("POST", acpi_device_dir(device));
1301 remove_proc_entry("DOS", acpi_device_dir(device));
1302 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1303 acpi_device_dir(device) = NULL;
1309 /* --------------------------------------------------------------------------
1311 -------------------------------------------------------------------------- */
1313 /* device interface */
1314 static struct acpi_video_device_attrib*
1315 acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id)
1319 for(count = 0; count < video->attached_count; count++)
1320 if((video->attached_array[count].value.int_val & 0xffff) == device_id)
1321 return &(video->attached_array[count].value.attrib);
1326 acpi_video_bus_get_one_device(struct acpi_device *device,
1327 struct acpi_video_bus *video)
1329 unsigned long device_id;
1331 struct acpi_video_device *data;
1332 struct acpi_video_device_attrib* attribute;
1334 if (!device || !video)
1338 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1339 if (ACPI_SUCCESS(status)) {
1341 data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
1345 strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
1346 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1347 acpi_driver_data(device) = data;
1349 data->device_id = device_id;
1350 data->video = video;
1353 attribute = acpi_video_get_device_attr(video, device_id);
1355 if((attribute != NULL) && attribute->device_id_scheme) {
1356 switch (attribute->display_type) {
1357 case ACPI_VIDEO_DISPLAY_CRT:
1358 data->flags.crt = 1;
1360 case ACPI_VIDEO_DISPLAY_TV:
1361 data->flags.tvout = 1;
1363 case ACPI_VIDEO_DISPLAY_DVI:
1364 data->flags.dvi = 1;
1366 case ACPI_VIDEO_DISPLAY_LCD:
1367 data->flags.lcd = 1;
1370 data->flags.unknown = 1;
1373 if(attribute->bios_can_detect)
1374 data->flags.bios = 1;
1376 data->flags.unknown = 1;
1378 acpi_video_device_bind(video, data);
1379 acpi_video_device_find_cap(data);
1381 status = acpi_install_notify_handler(device->handle,
1383 acpi_video_device_notify,
1385 if (ACPI_FAILURE(status)) {
1386 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1387 "Error installing notify handler\n"));
1388 if(data->brightness)
1389 kfree(data->brightness->levels);
1390 kfree(data->brightness);
1396 list_add_tail(&data->entry, &video->video_device_list);
1399 acpi_video_device_add_fs(device);
1409 * video : video bus device
1414 * Enumerate the video device list of the video bus,
1415 * bind the ids with the corresponding video devices
1416 * under the video bus.
1419 static void acpi_video_device_rebind(struct acpi_video_bus *video)
1421 struct list_head *node, *next;
1422 list_for_each_safe(node, next, &video->video_device_list) {
1423 struct acpi_video_device *dev =
1424 container_of(node, struct acpi_video_device, entry);
1425 acpi_video_device_bind(video, dev);
1431 * video : video bus device
1432 * device : video output device under the video
1438 * Bind the ids with the corresponding video devices
1439 * under the video bus.
1443 acpi_video_device_bind(struct acpi_video_bus *video,
1444 struct acpi_video_device *device)
1448 #define IDS_VAL(i) video->attached_array[i].value.int_val
1449 #define IDS_BIND(i) video->attached_array[i].bind_info
1451 for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
1452 i < video->attached_count; i++) {
1453 if (device->device_id == (IDS_VAL(i) & 0xffff)) {
1454 IDS_BIND(i) = device;
1455 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
1464 * video : video bus device
1469 * Call _DOD to enumerate all devices attached to display adapter
1473 static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1478 struct acpi_video_enumerated_device *active_device_list;
1479 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1480 union acpi_object *dod = NULL;
1481 union acpi_object *obj;
1483 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer);
1484 if (!ACPI_SUCCESS(status)) {
1485 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
1489 dod = buffer.pointer;
1490 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1491 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
1496 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
1497 dod->package.count));
1499 active_device_list = kmalloc((1 +
1500 dod->package.count) *
1502 acpi_video_enumerated_device),
1505 if (!active_device_list) {
1511 for (i = 0; i < dod->package.count; i++) {
1512 obj = &dod->package.elements[i];
1514 if (obj->type != ACPI_TYPE_INTEGER) {
1515 printk(KERN_ERR PREFIX "Invalid _DOD data\n");
1516 active_device_list[i].value.int_val =
1517 ACPI_VIDEO_HEAD_INVALID;
1519 active_device_list[i].value.int_val = obj->integer.value;
1520 active_device_list[i].bind_info = NULL;
1521 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i,
1522 (int)obj->integer.value));
1525 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1527 kfree(video->attached_array);
1529 video->attached_array = active_device_list;
1530 video->attached_count = count;
1532 kfree(buffer.pointer);
1538 * video : video bus device
1539 * event : Nontify Event
1544 * 1. Find out the current active output device.
1545 * 2. Identify the next output device to switch
1546 * 3. call _DSS to do actual switch.
1549 static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1551 struct list_head *node, *next;
1552 struct acpi_video_device *dev = NULL;
1553 struct acpi_video_device *dev_next = NULL;
1554 struct acpi_video_device *dev_prev = NULL;
1555 unsigned long state;
1559 list_for_each_safe(node, next, &video->video_device_list) {
1560 dev = container_of(node, struct acpi_video_device, entry);
1561 status = acpi_video_device_get_state(dev, &state);
1564 container_of(node->next, struct acpi_video_device,
1567 container_of(node->prev, struct acpi_video_device,
1572 dev_next = container_of(node->next, struct acpi_video_device, entry);
1573 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1576 case ACPI_VIDEO_NOTIFY_CYCLE:
1577 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
1578 acpi_video_device_set_state(dev, 0);
1579 acpi_video_device_set_state(dev_next, 0x80000001);
1581 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
1582 acpi_video_device_set_state(dev, 0);
1583 acpi_video_device_set_state(dev_prev, 0x80000001);
1592 acpi_video_get_next_level(struct acpi_video_device *device,
1593 u32 level_current, u32 event)
1595 int min, max, min_above, max_below, i, l;
1596 max = max_below = 0;
1597 min = min_above = 255;
1598 for (i = 0; i < device->brightness->count; i++) {
1599 l = device->brightness->levels[i];
1604 if (l < min_above && l > level_current)
1606 if (l > max_below && l < level_current)
1611 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
1612 return (level_current < max) ? min_above : min;
1613 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
1614 return (level_current < max) ? min_above : max;
1615 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
1616 return (level_current > min) ? max_below : min;
1617 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
1618 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
1621 return level_current;
1626 acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1628 unsigned long level_current, level_next;
1629 acpi_video_device_lcd_get_level_current(device, &level_current);
1630 level_next = acpi_video_get_next_level(device, level_current, event);
1631 acpi_video_device_lcd_set_level(device, level_next);
1635 acpi_video_bus_get_devices(struct acpi_video_bus *video,
1636 struct acpi_device *device)
1639 struct list_head *node, *next;
1642 acpi_video_device_enumerate(video);
1644 list_for_each_safe(node, next, &device->children) {
1645 struct acpi_device *dev =
1646 list_entry(node, struct acpi_device, node);
1651 status = acpi_video_bus_get_one_device(dev, video);
1652 if (ACPI_FAILURE(status)) {
1653 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
1661 static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1664 struct acpi_video_bus *video;
1667 if (!device || !device->video)
1670 video = device->video;
1673 list_del(&device->entry);
1675 acpi_video_device_remove_fs(device->dev);
1677 status = acpi_remove_notify_handler(device->dev->handle,
1679 acpi_video_device_notify);
1680 if (device->backlight){
1681 backlight_device_unregister(device->backlight);
1682 kfree(device->data);
1687 static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1690 struct list_head *node, *next;
1693 list_for_each_safe(node, next, &video->video_device_list) {
1694 struct acpi_video_device *data =
1695 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
1702 "hhuuhhuu bug in acpi video driver.\n");
1704 if (data->brightness)
1705 kfree(data->brightness->levels);
1706 kfree(data->brightness);
1713 /* acpi_video interface */
1715 static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1717 return acpi_video_bus_DOS(video, 1, 0);
1720 static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1722 return acpi_video_bus_DOS(video, 0, 1);
1725 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1727 struct acpi_video_bus *video = data;
1728 struct acpi_device *device = NULL;
1730 printk("video bus notify\n");
1735 device = video->device;
1738 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur,
1739 * most likely via hotkey. */
1740 acpi_bus_generate_event(device, event, 0);
1743 case ACPI_VIDEO_NOTIFY_PROBE: /* User plug or remove a video
1745 acpi_video_device_enumerate(video);
1746 acpi_video_device_rebind(video);
1747 acpi_video_switch_output(video, event);
1748 acpi_bus_generate_event(device, event, 0);
1751 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1752 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1753 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1754 acpi_video_switch_output(video, event);
1755 acpi_bus_generate_event(device, event, 0);
1759 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1760 "Unsupported event [0x%x]\n", event));
1767 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1769 struct acpi_video_device *video_device = data;
1770 struct acpi_device *device = NULL;
1775 device = video_device->dev;
1778 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1779 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1780 acpi_bus_generate_event(device, event, 0);
1782 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1783 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1784 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1785 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1786 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1787 acpi_video_switch_brightness(video_device, event);
1788 acpi_bus_generate_event(device, event, 0);
1791 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1792 "Unsupported event [0x%x]\n", event));
1798 static int acpi_video_bus_add(struct acpi_device *device)
1801 acpi_status status = 0;
1802 struct acpi_video_bus *video = NULL;
1808 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1812 video->device = device;
1813 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
1814 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1815 acpi_driver_data(device) = video;
1817 acpi_video_bus_find_cap(video);
1818 result = acpi_video_bus_check(video);
1822 result = acpi_video_bus_add_fs(device);
1826 init_MUTEX(&video->sem);
1827 INIT_LIST_HEAD(&video->video_device_list);
1829 acpi_video_bus_get_devices(video, device);
1830 acpi_video_bus_start_devices(video);
1832 status = acpi_install_notify_handler(device->handle,
1834 acpi_video_bus_notify, video);
1835 if (ACPI_FAILURE(status)) {
1836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1837 "Error installing notify handler\n"));
1838 acpi_video_bus_stop_devices(video);
1839 acpi_video_bus_put_devices(video);
1840 kfree(video->attached_array);
1841 acpi_video_bus_remove_fs(device);
1846 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1847 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1848 video->flags.multihead ? "yes" : "no",
1849 video->flags.rom ? "yes" : "no",
1850 video->flags.post ? "yes" : "no");
1859 static int acpi_video_bus_remove(struct acpi_device *device, int type)
1861 acpi_status status = 0;
1862 struct acpi_video_bus *video = NULL;
1865 if (!device || !acpi_driver_data(device))
1868 video = acpi_driver_data(device);
1870 acpi_video_bus_stop_devices(video);
1872 status = acpi_remove_notify_handler(video->device->handle,
1874 acpi_video_bus_notify);
1876 acpi_video_bus_put_devices(video);
1877 acpi_video_bus_remove_fs(device);
1879 kfree(video->attached_array);
1885 static int __init acpi_video_init(void)
1891 acpi_dbg_level = 0xFFFFFFFF;
1892 acpi_dbg_layer = 0x08000000;
1895 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1896 if (!acpi_video_dir)
1898 acpi_video_dir->owner = THIS_MODULE;
1900 result = acpi_bus_register_driver(&acpi_video_bus);
1902 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1909 static void __exit acpi_video_exit(void)
1912 acpi_bus_unregister_driver(&acpi_video_bus);
1914 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1919 module_init(acpi_video_init);
1920 module_exit(acpi_video_exit);