2 * video.c - ACPI Video Driver ($Revision:$)
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/list.h>
31 #include <linux/proc_fs.h>
32 #include <linux/seq_file.h>
34 #include <asm/uaccess.h>
36 #include <acpi/acpi_bus.h>
37 #include <acpi/acpi_drivers.h>
39 #define ACPI_VIDEO_COMPONENT 0x08000000
40 #define ACPI_VIDEO_CLASS "video"
41 #define ACPI_VIDEO_DRIVER_NAME "ACPI Video Driver"
42 #define ACPI_VIDEO_BUS_NAME "Video Bus"
43 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
44 #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
45 #define ACPI_VIDEO_NOTIFY_PROBE 0x81
46 #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
47 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
48 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
50 #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82
51 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83
52 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84
53 #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
54 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
57 #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
58 #define ACPI_VIDEO_HEAD_END (~0u)
61 #define _COMPONENT ACPI_VIDEO_COMPONENT
62 ACPI_MODULE_NAME ("acpi_video")
64 MODULE_AUTHOR("Bruno Ducrot");
65 MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME
);
66 MODULE_LICENSE("GPL");
68 static int acpi_video_bus_add (struct acpi_device
*device
);
69 static int acpi_video_bus_remove (struct acpi_device
*device
, int type
);
70 static int acpi_video_bus_match (struct acpi_device
*device
, struct acpi_driver
*driver
);
72 static struct acpi_driver acpi_video_bus
= {
73 .name
= ACPI_VIDEO_DRIVER_NAME
,
74 .class = ACPI_VIDEO_CLASS
,
76 .add
= acpi_video_bus_add
,
77 .remove
= acpi_video_bus_remove
,
78 .match
= acpi_video_bus_match
,
82 struct acpi_video_bus_flags
{
83 u8 multihead
:1; /* can switch video heads */
84 u8 rom
:1; /* can retrieve a video rom */
85 u8 post
:1; /* can configure the head to */
89 struct acpi_video_bus_cap
{
90 u8 _DOS
:1; /*Enable/Disable output switching*/
91 u8 _DOD
:1; /*Enumerate all devices attached to display adapter*/
92 u8 _ROM
:1; /*Get ROM Data*/
93 u8 _GPD
:1; /*Get POST Device*/
94 u8 _SPD
:1; /*Set POST Device*/
95 u8 _VPO
:1; /*Video POST Options*/
99 struct acpi_video_device_attrib
{
100 u32 display_index
:4; /* A zero-based instance of the Display*/
101 u32 display_port_attachment
:4; /*This field differenates displays type*/
102 u32 display_type
:4; /*Describe the specific type in use*/
103 u32 vendor_specific
:4; /*Chipset Vendor Specifi*/
104 u32 bios_can_detect
:1; /*BIOS can detect the device*/
105 u32 depend_on_vga
:1; /*Non-VGA output device whose power is related to
107 u32 pipe_id
:3; /*For VGA multiple-head devices.*/
108 u32 reserved
:10; /*Must be 0*/
109 u32 device_id_scheme
:1; /*Device ID Scheme*/
112 struct acpi_video_enumerated_device
{
115 struct acpi_video_device_attrib attrib
;
117 struct acpi_video_device
*bind_info
;
120 struct acpi_video_bus
{
123 struct acpi_video_enumerated_device
*attached_array
;
125 struct acpi_video_bus_cap cap
;
126 struct acpi_video_bus_flags flags
;
127 struct semaphore sem
;
128 struct list_head video_device_list
;
129 struct proc_dir_entry
*dir
;
132 struct acpi_video_device_flags
{
141 struct acpi_video_device_cap
{
142 u8 _ADR
:1; /*Return the unique ID */
143 u8 _BCL
:1; /*Query list of brightness control levels supported*/
144 u8 _BCM
:1; /*Set the brightness level*/
145 u8 _DDC
:1; /*Return the EDID for this device*/
146 u8 _DCS
:1; /*Return status of output device*/
147 u8 _DGS
:1; /*Query graphics state*/
148 u8 _DSS
:1; /*Device state set*/
152 struct acpi_video_device_brightness
{
158 struct acpi_video_device
{
160 unsigned long device_id
;
161 struct acpi_video_device_flags flags
;
162 struct acpi_video_device_cap cap
;
163 struct list_head entry
;
164 struct acpi_video_bus
*video
;
165 struct acpi_device
*dev
;
166 struct acpi_video_device_brightness
*brightness
;
171 static int acpi_video_bus_info_open_fs(struct inode
*inode
, struct file
*file
);
172 static struct file_operations acpi_video_bus_info_fops
= {
173 .open
= acpi_video_bus_info_open_fs
,
176 .release
= single_release
,
179 static int acpi_video_bus_ROM_open_fs(struct inode
*inode
, struct file
*file
);
180 static struct file_operations acpi_video_bus_ROM_fops
= {
181 .open
= acpi_video_bus_ROM_open_fs
,
184 .release
= single_release
,
187 static int acpi_video_bus_POST_info_open_fs(struct inode
*inode
, struct file
*file
);
188 static struct file_operations acpi_video_bus_POST_info_fops
= {
189 .open
= acpi_video_bus_POST_info_open_fs
,
192 .release
= single_release
,
195 static int acpi_video_bus_POST_open_fs(struct inode
*inode
, struct file
*file
);
196 static struct file_operations acpi_video_bus_POST_fops
= {
197 .open
= acpi_video_bus_POST_open_fs
,
200 .release
= single_release
,
204 static int acpi_video_bus_DOS_open_fs(struct inode
*inode
, struct file
*file
);
205 static struct file_operations acpi_video_bus_DOS_fops
= {
206 .open
= acpi_video_bus_DOS_open_fs
,
209 .release
= single_release
,
213 static int acpi_video_device_info_open_fs(struct inode
*inode
, struct file
*file
);
214 static struct file_operations acpi_video_device_info_fops
= {
215 .open
= acpi_video_device_info_open_fs
,
218 .release
= single_release
,
221 static int acpi_video_device_state_open_fs(struct inode
*inode
, struct file
*file
);
222 static struct file_operations acpi_video_device_state_fops
= {
223 .open
= acpi_video_device_state_open_fs
,
226 .release
= single_release
,
229 static int acpi_video_device_brightness_open_fs(struct inode
*inode
, struct file
*file
);
230 static struct file_operations acpi_video_device_brightness_fops
= {
231 .open
= acpi_video_device_brightness_open_fs
,
234 .release
= single_release
,
237 static int acpi_video_device_EDID_open_fs(struct inode
*inode
, struct file
*file
);
238 static struct file_operations acpi_video_device_EDID_fops
= {
239 .open
= acpi_video_device_EDID_open_fs
,
242 .release
= single_release
,
245 static char device_decode
[][30] = {
246 "motherboard VGA device",
252 static void acpi_video_device_notify ( acpi_handle handle
, u32 event
, void *data
);
253 static void acpi_video_device_rebind( struct acpi_video_bus
*video
);
254 static void acpi_video_device_bind( struct acpi_video_bus
*video
, struct acpi_video_device
*device
);
255 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
);
256 static int acpi_video_switch_output( struct acpi_video_bus
*video
, int event
);
257 static int acpi_video_get_next_level( struct acpi_video_device
*device
, u32 level_current
,u32 event
);
258 static void acpi_video_switch_brightness ( struct acpi_video_device
*device
, int event
);
261 /* --------------------------------------------------------------------------
263 -------------------------------------------------------------------------- */
268 acpi_video_device_query (
269 struct acpi_video_device
*device
,
270 unsigned long *state
)
273 ACPI_FUNCTION_TRACE("acpi_video_device_query");
274 status
= acpi_evaluate_integer(device
->handle
, "_DGS", NULL
, state
);
276 return_VALUE(status
);
280 acpi_video_device_get_state (
281 struct acpi_video_device
*device
,
282 unsigned long *state
)
286 ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
288 status
= acpi_evaluate_integer(device
->handle
, "_DCS", NULL
, state
);
290 return_VALUE(status
);
294 acpi_video_device_set_state (
295 struct acpi_video_device
*device
,
299 union acpi_object arg0
= {ACPI_TYPE_INTEGER
};
300 struct acpi_object_list args
= {1, &arg0
};
302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
304 arg0
.integer
.value
= state
;
305 status
= acpi_evaluate_integer(device
->handle
, "_DSS", &args
, NULL
);
307 return_VALUE(status
);
311 acpi_video_device_lcd_query_levels (
312 struct acpi_video_device
*device
,
313 union acpi_object
**levels
)
316 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
, NULL
};
317 union acpi_object
*obj
;
320 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
324 status
= acpi_evaluate_object(device
->handle
, "_BCL", NULL
, &buffer
);
325 if (!ACPI_SUCCESS(status
))
326 return_VALUE(status
);
327 obj
= (union acpi_object
*) buffer
.pointer
;
328 if (!obj
&& (obj
->type
!= ACPI_TYPE_PACKAGE
)) {
329 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid _BCL data\n"));
340 kfree(buffer
.pointer
);
342 return_VALUE(status
);
346 acpi_video_device_lcd_set_level (
347 struct acpi_video_device
*device
,
351 union acpi_object arg0
= {ACPI_TYPE_INTEGER
};
352 struct acpi_object_list args
= {1, &arg0
};
354 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
356 arg0
.integer
.value
= level
;
357 status
= acpi_evaluate_object(device
->handle
, "_BCM", &args
, NULL
);
359 printk(KERN_DEBUG
"set_level status: %x\n", status
);
360 return_VALUE(status
);
364 acpi_video_device_lcd_get_level_current (
365 struct acpi_video_device
*device
,
366 unsigned long *level
)
369 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
371 status
= acpi_evaluate_integer(device
->handle
, "_BQC", NULL
, level
);
373 return_VALUE(status
);
377 acpi_video_device_EDID (
378 struct acpi_video_device
*device
,
379 union acpi_object
**edid
,
383 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
, NULL
};
384 union acpi_object
*obj
;
385 union acpi_object arg0
= {ACPI_TYPE_INTEGER
};
386 struct acpi_object_list args
= {1, &arg0
};
388 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
393 return_VALUE(-ENODEV
);
395 arg0
.integer
.value
= 1;
396 else if (length
== 256)
397 arg0
.integer
.value
= 2;
399 return_VALUE(-EINVAL
);
401 status
= acpi_evaluate_object(device
->handle
, "_DDC", &args
, &buffer
);
402 if (ACPI_FAILURE(status
))
403 return_VALUE(-ENODEV
);
405 obj
= (union acpi_object
*) buffer
.pointer
;
407 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
)
410 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid _DDC data\n"));
415 return_VALUE(status
);
422 acpi_video_bus_set_POST (
423 struct acpi_video_bus
*video
,
424 unsigned long option
)
428 union acpi_object arg0
= {ACPI_TYPE_INTEGER
};
429 struct acpi_object_list args
= {1, &arg0
};
431 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
433 arg0
.integer
.value
= option
;
435 status
= acpi_evaluate_integer(video
->handle
, "_SPD", &args
, &tmp
);
436 if (ACPI_SUCCESS(status
))
437 status
= tmp
? (-EINVAL
):(AE_OK
);
439 return_VALUE(status
);
443 acpi_video_bus_get_POST (
444 struct acpi_video_bus
*video
,
449 ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
451 status
= acpi_evaluate_integer(video
->handle
, "_GPD", NULL
, id
);
453 return_VALUE(status
);
457 acpi_video_bus_POST_options (
458 struct acpi_video_bus
*video
,
459 unsigned long *options
)
462 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
464 status
= acpi_evaluate_integer(video
->handle
, "_VPO", NULL
, options
);
467 return_VALUE(status
);
472 * video : video bus device pointer
474 * 0. The system BIOS should NOT automatically switch(toggle)
475 * the active display output.
476 * 1. The system BIOS should automatically switch (toggle) the
477 * active display output. No swich event.
478 * 2. The _DGS value should be locked.
479 * 3. The system BIOS should not automatically switch (toggle) the
480 * active display output, but instead generate the display switch
483 * 0. The system BIOS should automatically control the brightness level
484 * of the LCD, when the power changes from AC to DC
485 * 1. The system BIOS should NOT automatically control the brightness
486 * level of the LCD, when the power changes from AC to DC.
493 struct acpi_video_bus
*video
,
497 acpi_integer status
= 0;
498 union acpi_object arg0
= {ACPI_TYPE_INTEGER
};
499 struct acpi_object_list args
= {1, &arg0
};
501 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
503 if (bios_flag
< 0 || bios_flag
>3 || lcd_flag
< 0 || lcd_flag
> 1){
507 arg0
.integer
.value
= (lcd_flag
<< 2) | bios_flag
;
508 video
->dos_setting
= arg0
.integer
.value
;
509 acpi_evaluate_object(video
->handle
, "_DOS", &args
, NULL
);
512 return_VALUE(status
);
517 * device : video output device (LCD, CRT, ..)
522 * Find out all required AML method defined under the output
527 acpi_video_device_find_cap (struct acpi_video_device
*device
)
530 acpi_handle h_dummy1
;
532 union acpi_object
*obj
= NULL
;
533 struct acpi_video_device_brightness
*br
= NULL
;
535 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
537 memset( &device
->cap
, 0, 4);
539 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_ADR", &h_dummy1
))) {
540 device
->cap
._ADR
= 1;
542 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_BCL", &h_dummy1
))) {
545 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_BCM", &h_dummy1
))) {
548 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DDC", &h_dummy1
))) {
551 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DCS", &h_dummy1
))) {
552 device
->cap
._DCS
= 1;
554 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DGS", &h_dummy1
))) {
555 device
->cap
._DGS
= 1;
557 if( ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DSS", &h_dummy1
))) {
558 device
->cap
._DSS
= 1;
561 status
= acpi_video_device_lcd_query_levels(device
, &obj
);
563 if (obj
&& obj
->type
== ACPI_TYPE_PACKAGE
&& obj
->package
.count
>= 2) {
565 union acpi_object
*o
;
567 br
= kmalloc(sizeof &br
, GFP_KERNEL
);
569 printk(KERN_ERR
"can't allocate memory\n");
571 memset(br
, 0, sizeof &br
);
572 br
->levels
= kmalloc(obj
->package
.count
* sizeof &br
->levels
, GFP_KERNEL
);
576 for (i
= 0; i
< obj
->package
.count
; i
++) {
577 o
= (union acpi_object
*) &obj
->package
.elements
[i
];
578 if (o
->type
!= ACPI_TYPE_INTEGER
) {
579 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid data\n"));
582 br
->levels
[count
] = (u32
) o
->integer
.value
;
592 device
->brightness
= br
;
593 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "found %d brightness levels\n", count
));
606 * device : video output device (VGA)
611 * Find out all required AML method defined under the video bus device.
615 acpi_video_bus_find_cap (struct acpi_video_bus
*video
)
617 acpi_handle h_dummy1
;
619 memset(&video
->cap
,0, 4);
620 if( ACPI_SUCCESS(acpi_get_handle(video
->handle
, "_DOS", &h_dummy1
))) {
623 if( ACPI_SUCCESS(acpi_get_handle(video
->handle
, "_DOD", &h_dummy1
))) {
626 if( ACPI_SUCCESS(acpi_get_handle(video
->handle
, "_ROM", &h_dummy1
))) {
629 if( ACPI_SUCCESS(acpi_get_handle(video
->handle
, "_GPD", &h_dummy1
))) {
632 if( ACPI_SUCCESS(acpi_get_handle(video
->handle
, "_SPD", &h_dummy1
))) {
635 if( ACPI_SUCCESS(acpi_get_handle(video
->handle
, "_VPO", &h_dummy1
))) {
641 * Check whether the video bus device has required AML method to
642 * support the desired features
646 acpi_video_bus_check (
647 struct acpi_video_bus
*video
)
649 acpi_status status
= -ENOENT
;
652 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
655 return_VALUE(-EINVAL
);
657 /* Since there is no HID, CID and so on for VGA driver, we have
658 * to check well known required nodes.
661 /* Does this device able to support video switching ? */
663 video
->flags
.multihead
= 1;
667 /* Does this device able to retrieve a retrieve a video ROM ? */
669 video
->flags
.rom
= 1;
673 /* Does this device able to configure which video device to POST ? */
674 if(video
->cap
._GPD
&& video
->cap
._SPD
&& video
->cap
._VPO
){
675 video
->flags
.post
= 1;
679 return_VALUE(status
);
682 /* --------------------------------------------------------------------------
684 -------------------------------------------------------------------------- */
686 static struct proc_dir_entry
*acpi_video_dir
;
691 acpi_video_device_info_seq_show (
692 struct seq_file
*seq
,
695 struct acpi_video_device
*dev
= (struct acpi_video_device
*) seq
->private;
697 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
702 seq_printf(seq
, "device_id: 0x%04x\n", (u32
) dev
->device_id
);
703 seq_printf(seq
, "type: ");
705 seq_printf(seq
, "CRT\n");
706 else if (dev
->flags
.lcd
)
707 seq_printf(seq
, "LCD\n");
708 else if (dev
->flags
.tvout
)
709 seq_printf(seq
, "TVOUT\n");
711 seq_printf(seq
, "UNKNOWN\n");
713 seq_printf(seq
,"known by bios: %s\n",
714 dev
->flags
.bios
? "yes":"no");
721 acpi_video_device_info_open_fs (
725 return single_open(file
, acpi_video_device_info_seq_show
,
730 acpi_video_device_state_seq_show (
731 struct seq_file
*seq
,
735 struct acpi_video_device
*dev
= (struct acpi_video_device
*) seq
->private;
738 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
743 status
= acpi_video_device_get_state(dev
, &state
);
744 seq_printf(seq
, "state: ");
745 if (ACPI_SUCCESS(status
))
746 seq_printf(seq
, "0x%02lx\n", state
);
748 seq_printf(seq
, "<not supported>\n");
750 status
= acpi_video_device_query(dev
, &state
);
751 seq_printf(seq
, "query: ");
752 if (ACPI_SUCCESS(status
))
753 seq_printf(seq
, "0x%02lx\n", state
);
755 seq_printf(seq
, "<not supported>\n");
762 acpi_video_device_state_open_fs (
766 return single_open(file
, acpi_video_device_state_seq_show
,
771 acpi_video_device_write_state (
773 const char __user
*buffer
,
778 struct seq_file
*m
= (struct seq_file
*) file
->private_data
;
779 struct acpi_video_device
*dev
= (struct acpi_video_device
*) m
->private;
783 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
785 if (!dev
|| count
+ 1 > sizeof str
)
786 return_VALUE(-EINVAL
);
788 if (copy_from_user(str
, buffer
, count
))
789 return_VALUE(-EFAULT
);
792 state
= simple_strtoul(str
, NULL
, 0);
793 state
&= ((1ul<<31) | (1ul<<30) | (1ul<<0));
795 status
= acpi_video_device_set_state(dev
, state
);
798 return_VALUE(-EFAULT
);
804 acpi_video_device_brightness_seq_show (
805 struct seq_file
*seq
,
808 struct acpi_video_device
*dev
= (struct acpi_video_device
*) seq
->private;
811 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
813 if (!dev
|| !dev
->brightness
) {
814 seq_printf(seq
, "<not supported>\n");
818 seq_printf(seq
, "levels: ");
819 for (i
= 0; i
< dev
->brightness
->count
; i
++)
820 seq_printf(seq
, " %d", dev
->brightness
->levels
[i
]);
821 seq_printf(seq
, "\ncurrent: %d\n", dev
->brightness
->curr
);
827 acpi_video_device_brightness_open_fs (
831 return single_open(file
, acpi_video_device_brightness_seq_show
,
836 acpi_video_device_write_brightness (
838 const char __user
*buffer
,
842 struct seq_file
*m
= (struct seq_file
*) file
->private_data
;
843 struct acpi_video_device
*dev
= (struct acpi_video_device
*) m
->private;
845 unsigned int level
= 0;
848 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
850 if (!dev
|| count
+ 1 > sizeof str
)
851 return_VALUE(-EINVAL
);
853 if (copy_from_user(str
, buffer
, count
))
854 return_VALUE(-EFAULT
);
857 level
= simple_strtoul(str
, NULL
, 0);
860 return_VALUE(-EFAULT
);
862 /* validate though the list of available levels */
863 for (i
= 0; i
< dev
->brightness
->count
; i
++)
864 if (level
== dev
->brightness
->levels
[i
]) {
865 if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev
, level
)))
866 dev
->brightness
->curr
= level
;
874 acpi_video_device_EDID_seq_show (
875 struct seq_file
*seq
,
878 struct acpi_video_device
*dev
= (struct acpi_video_device
*) seq
->private;
881 union acpi_object
*edid
= NULL
;
883 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
888 status
= acpi_video_device_EDID (dev
, &edid
, 128);
889 if (ACPI_FAILURE(status
)) {
890 status
= acpi_video_device_EDID (dev
, &edid
, 256);
893 if (ACPI_FAILURE(status
)) {
897 if (edid
&& edid
->type
== ACPI_TYPE_BUFFER
) {
898 for (i
= 0; i
< edid
->buffer
.length
; i
++)
899 seq_putc(seq
, edid
->buffer
.pointer
[i
]);
904 seq_printf(seq
, "<not supported>\n");
912 acpi_video_device_EDID_open_fs (
916 return single_open(file
, acpi_video_device_EDID_seq_show
,
922 acpi_video_device_add_fs (
923 struct acpi_device
*device
)
925 struct proc_dir_entry
*entry
= NULL
;
926 struct acpi_video_device
*vid_dev
;
928 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
931 return_VALUE(-ENODEV
);
933 vid_dev
= (struct acpi_video_device
*) acpi_driver_data(device
);
935 return_VALUE(-ENODEV
);
937 if (!acpi_device_dir(device
)) {
938 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
939 vid_dev
->video
->dir
);
940 if (!acpi_device_dir(device
))
941 return_VALUE(-ENODEV
);
942 acpi_device_dir(device
)->owner
= THIS_MODULE
;
946 entry
= create_proc_entry("info", S_IRUGO
, acpi_device_dir(device
));
948 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
949 "Unable to create 'info' fs entry\n"));
951 entry
->proc_fops
= &acpi_video_device_info_fops
;
952 entry
->data
= acpi_driver_data(device
);
953 entry
->owner
= THIS_MODULE
;
957 entry
= create_proc_entry("state", S_IFREG
|S_IRUGO
|S_IWUSR
, acpi_device_dir(device
));
959 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
960 "Unable to create 'state' fs entry\n"));
962 entry
->proc_fops
= &acpi_video_device_state_fops
;
963 entry
->proc_fops
->write
= acpi_video_device_write_state
;
964 entry
->data
= acpi_driver_data(device
);
965 entry
->owner
= THIS_MODULE
;
968 /* 'brightness' [R/W] */
969 entry
= create_proc_entry("brightness", S_IFREG
|S_IRUGO
|S_IWUSR
, acpi_device_dir(device
));
971 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
972 "Unable to create 'brightness' fs entry\n"));
974 entry
->proc_fops
= &acpi_video_device_brightness_fops
;
975 entry
->proc_fops
->write
= acpi_video_device_write_brightness
;
976 entry
->data
= acpi_driver_data(device
);
977 entry
->owner
= THIS_MODULE
;
981 entry
= create_proc_entry("EDID", S_IRUGO
, acpi_device_dir(device
));
983 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
984 "Unable to create 'brightness' fs entry\n"));
986 entry
->proc_fops
= &acpi_video_device_EDID_fops
;
987 entry
->data
= acpi_driver_data(device
);
988 entry
->owner
= THIS_MODULE
;
995 acpi_video_device_remove_fs (
996 struct acpi_device
*device
)
998 struct acpi_video_device
*vid_dev
;
999 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
1001 vid_dev
= (struct acpi_video_device
*) acpi_driver_data(device
);
1002 if (!vid_dev
|| !vid_dev
->video
|| !vid_dev
->video
->dir
)
1003 return_VALUE(-ENODEV
);
1005 if (acpi_device_dir(device
)) {
1006 remove_proc_entry("info", acpi_device_dir(device
));
1007 remove_proc_entry("state", acpi_device_dir(device
));
1008 remove_proc_entry("brightness", acpi_device_dir(device
));
1009 remove_proc_entry("EDID", acpi_device_dir(device
));
1010 remove_proc_entry(acpi_device_bid(device
),
1011 vid_dev
->video
->dir
);
1012 acpi_device_dir(device
) = NULL
;
1021 acpi_video_bus_info_seq_show (
1022 struct seq_file
*seq
,
1025 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) seq
->private;
1027 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
1032 seq_printf(seq
, "Switching heads: %s\n",
1033 video
->flags
.multihead
? "yes":"no");
1034 seq_printf(seq
, "Video ROM: %s\n",
1035 video
->flags
.rom
? "yes":"no");
1036 seq_printf(seq
, "Device to be POSTed on boot: %s\n",
1037 video
->flags
.post
? "yes":"no");
1044 acpi_video_bus_info_open_fs (
1045 struct inode
*inode
,
1048 return single_open(file
, acpi_video_bus_info_seq_show
, PDE(inode
)->data
);
1052 acpi_video_bus_ROM_seq_show (
1053 struct seq_file
*seq
,
1056 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) seq
->private;
1058 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1063 printk(KERN_INFO PREFIX
"Please implement %s\n", __FUNCTION__
);
1064 seq_printf(seq
, "<TODO>\n");
1071 acpi_video_bus_ROM_open_fs (
1072 struct inode
*inode
,
1075 return single_open(file
, acpi_video_bus_ROM_seq_show
, PDE(inode
)->data
);
1079 acpi_video_bus_POST_info_seq_show (
1080 struct seq_file
*seq
,
1083 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) seq
->private;
1084 unsigned long options
;
1087 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1092 status
= acpi_video_bus_POST_options(video
, &options
);
1093 if (ACPI_SUCCESS(status
)) {
1094 if (!(options
& 1)) {
1095 printk(KERN_WARNING PREFIX
"The motherboard VGA device is not listed as a possible POST device.\n");
1096 printk(KERN_WARNING PREFIX
"This indicate a BIOS bug. Please contact the manufacturer.\n");
1098 printk("%lx\n", options
);
1099 seq_printf(seq
, "can POST: <intgrated video>");
1101 seq_printf(seq
, " <PCI video>");
1103 seq_printf(seq
, " <AGP video>");
1104 seq_putc(seq
, '\n');
1106 seq_printf(seq
, "<not supported>\n");
1112 acpi_video_bus_POST_info_open_fs (
1113 struct inode
*inode
,
1116 return single_open(file
, acpi_video_bus_POST_info_seq_show
, PDE(inode
)->data
);
1120 acpi_video_bus_POST_seq_show (
1121 struct seq_file
*seq
,
1124 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) seq
->private;
1128 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
1133 status
= acpi_video_bus_get_POST (video
, &id
);
1134 if (!ACPI_SUCCESS(status
)) {
1135 seq_printf(seq
, "<not supported>\n");
1138 seq_printf(seq
, "device posted is <%s>\n", device_decode
[id
& 3]);
1145 acpi_video_bus_DOS_seq_show (
1146 struct seq_file
*seq
,
1149 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) seq
->private;
1151 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
1153 seq_printf(seq
, "DOS setting: <%d>\n", video
->dos_setting
);
1159 acpi_video_bus_POST_open_fs (
1160 struct inode
*inode
,
1163 return single_open(file
, acpi_video_bus_POST_seq_show
, PDE(inode
)->data
);
1167 acpi_video_bus_DOS_open_fs (
1168 struct inode
*inode
,
1171 return single_open(file
, acpi_video_bus_DOS_seq_show
, PDE(inode
)->data
);
1175 acpi_video_bus_write_POST (
1177 const char __user
*buffer
,
1182 struct seq_file
*m
= (struct seq_file
*) file
->private_data
;
1183 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) m
->private;
1185 unsigned long opt
, options
;
1187 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
1190 if (!video
|| count
+ 1 > sizeof str
)
1191 return_VALUE(-EINVAL
);
1193 status
= acpi_video_bus_POST_options(video
, &options
);
1194 if (!ACPI_SUCCESS(status
))
1195 return_VALUE(-EINVAL
);
1197 if (copy_from_user(str
, buffer
, count
))
1198 return_VALUE(-EFAULT
);
1201 opt
= strtoul(str
, NULL
, 0);
1203 return_VALUE(-EFAULT
);
1205 /* just in case an OEM 'forget' the motherboard... */
1208 if (options
& (1ul << opt
)) {
1209 status
= acpi_video_bus_set_POST (video
, opt
);
1210 if (!ACPI_SUCCESS(status
))
1211 return_VALUE(-EFAULT
);
1216 return_VALUE(count
);
1220 acpi_video_bus_write_DOS (
1222 const char __user
*buffer
,
1227 struct seq_file
*m
= (struct seq_file
*) file
->private_data
;
1228 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) m
->private;
1232 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
1235 if (!video
|| count
+ 1 > sizeof str
)
1236 return_VALUE(-EINVAL
);
1238 if (copy_from_user(str
, buffer
, count
))
1239 return_VALUE(-EFAULT
);
1242 opt
= strtoul(str
, NULL
, 0);
1244 return_VALUE(-EFAULT
);
1246 status
= acpi_video_bus_DOS (video
, opt
& 0x3, (opt
& 0x4)>>2);
1248 if (!ACPI_SUCCESS(status
))
1249 return_VALUE(-EFAULT
);
1251 return_VALUE(count
);
1255 acpi_video_bus_add_fs (
1256 struct acpi_device
*device
)
1258 struct proc_dir_entry
*entry
= NULL
;
1259 struct acpi_video_bus
*video
;
1261 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
1263 video
= (struct acpi_video_bus
*) acpi_driver_data(device
);
1265 if (!acpi_device_dir(device
)) {
1266 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
1268 if (!acpi_device_dir(device
))
1269 return_VALUE(-ENODEV
);
1270 video
->dir
= acpi_device_dir(device
);
1271 acpi_device_dir(device
)->owner
= THIS_MODULE
;
1275 entry
= create_proc_entry("info", S_IRUGO
, acpi_device_dir(device
));
1277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to create 'info' fs entry\n"));
1279 entry
->proc_fops
= &acpi_video_bus_info_fops
;
1280 entry
->data
= acpi_driver_data(device
);
1281 entry
->owner
= THIS_MODULE
;
1285 entry
= create_proc_entry("ROM", S_IRUGO
, acpi_device_dir(device
));
1287 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to create 'ROM' fs entry\n"));
1289 entry
->proc_fops
= &acpi_video_bus_ROM_fops
;
1290 entry
->data
= acpi_driver_data(device
);
1291 entry
->owner
= THIS_MODULE
;
1294 /* 'POST_info' [R] */
1295 entry
= create_proc_entry("POST_info", S_IRUGO
, acpi_device_dir(device
));
1297 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to create 'POST_info' fs entry\n"));
1299 entry
->proc_fops
= &acpi_video_bus_POST_info_fops
;
1300 entry
->data
= acpi_driver_data(device
);
1301 entry
->owner
= THIS_MODULE
;
1305 entry
= create_proc_entry("POST", S_IFREG
|S_IRUGO
|S_IRUSR
, acpi_device_dir(device
));
1307 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to create 'POST' fs entry\n"));
1309 entry
->proc_fops
= &acpi_video_bus_POST_fops
;
1310 entry
->proc_fops
->write
= acpi_video_bus_write_POST
;
1311 entry
->data
= acpi_driver_data(device
);
1312 entry
->owner
= THIS_MODULE
;
1316 entry
= create_proc_entry("DOS", S_IFREG
|S_IRUGO
|S_IRUSR
, acpi_device_dir(device
));
1318 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to create 'DOS' fs entry\n"));
1320 entry
->proc_fops
= &acpi_video_bus_DOS_fops
;
1321 entry
->proc_fops
->write
= acpi_video_bus_write_DOS
;
1322 entry
->data
= acpi_driver_data(device
);
1323 entry
->owner
= THIS_MODULE
;
1330 acpi_video_bus_remove_fs (
1331 struct acpi_device
*device
)
1333 struct acpi_video_bus
*video
;
1335 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
1337 video
= (struct acpi_video_bus
*) acpi_driver_data(device
);
1339 if (acpi_device_dir(device
)) {
1340 remove_proc_entry("info", acpi_device_dir(device
));
1341 remove_proc_entry("ROM", acpi_device_dir(device
));
1342 remove_proc_entry("POST_info", acpi_device_dir(device
));
1343 remove_proc_entry("POST", acpi_device_dir(device
));
1344 remove_proc_entry("DOS", acpi_device_dir(device
));
1345 remove_proc_entry(acpi_device_bid(device
),
1347 acpi_device_dir(device
) = NULL
;
1353 /* --------------------------------------------------------------------------
1355 -------------------------------------------------------------------------- */
1357 /* device interface */
1360 acpi_video_bus_get_one_device (
1361 struct acpi_device
*device
,
1362 struct acpi_video_bus
*video
)
1364 unsigned long device_id
;
1366 struct acpi_video_device
*data
;
1368 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
1370 if (!device
|| !video
)
1371 return_VALUE(-EINVAL
);
1373 status
= acpi_evaluate_integer(device
->handle
, "_ADR", NULL
, &device_id
);
1374 if (ACPI_SUCCESS(status
)) {
1376 data
= kmalloc(sizeof(struct acpi_video_device
), GFP_KERNEL
);
1378 return_VALUE(-ENOMEM
);
1380 memset(data
, 0, sizeof(struct acpi_video_device
));
1382 data
->handle
= device
->handle
;
1383 strcpy(acpi_device_name(device
), ACPI_VIDEO_DEVICE_NAME
);
1384 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1385 acpi_driver_data(device
) = data
;
1387 data
->device_id
= device_id
;
1388 data
->video
= video
;
1391 switch (device_id
& 0xffff) {
1393 data
->flags
.crt
= 1;
1396 data
->flags
.lcd
= 1;
1399 data
->flags
.tvout
= 1;
1402 data
->flags
.unknown
= 1;
1406 acpi_video_device_bind(video
, data
);
1407 acpi_video_device_find_cap(data
);
1409 status
= acpi_install_notify_handler(data
->handle
,
1410 ACPI_DEVICE_NOTIFY
, acpi_video_device_notify
, data
);
1411 if (ACPI_FAILURE(status
)) {
1412 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1413 "Error installing notify handler\n"));
1419 list_add_tail(&data
->entry
, &video
->video_device_list
);
1422 acpi_video_device_add_fs(device
);
1428 return_VALUE(-ENOENT
);
1433 * video : video bus device
1438 * Enumerate the video device list of the video bus,
1439 * bind the ids with the corresponding video devices
1440 * under the video bus.
1444 acpi_video_device_rebind( struct acpi_video_bus
*video
)
1446 struct list_head
* node
, * next
;
1447 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1448 struct acpi_video_device
* dev
= container_of(node
, struct acpi_video_device
, entry
);
1449 acpi_video_device_bind( video
, dev
);
1455 * video : video bus device
1456 * device : video output device under the video
1462 * Bind the ids with the corresponding video devices
1463 * under the video bus.
1467 acpi_video_device_bind( struct acpi_video_bus
*video
,
1468 struct acpi_video_device
*device
)
1471 ACPI_FUNCTION_TRACE("acpi_video_device_bind");
1473 #define IDS_VAL(i) video->attached_array[i].value.int_val
1474 #define IDS_BIND(i) video->attached_array[i].bind_info
1476 for (i
= 0; IDS_VAL(i
) != ACPI_VIDEO_HEAD_INVALID
&&
1477 i
< video
->attached_count
; i
++) {
1478 if (device
->device_id
== (IDS_VAL(i
)& 0xffff)) {
1479 IDS_BIND(i
) = device
;
1480 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "device_bind %d\n", i
));
1489 * video : video bus device
1494 * Call _DOD to enumerate all devices attached to display adapter
1498 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
)
1503 struct acpi_video_enumerated_device
*active_device_list
;
1504 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
, NULL
};
1505 union acpi_object
*dod
= NULL
;
1506 union acpi_object
*obj
;
1508 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
1510 status
= acpi_evaluate_object(video
->handle
, "_DOD", NULL
, &buffer
);
1511 if (!ACPI_SUCCESS(status
)) {
1512 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Error evaluating _DOD\n"));
1513 return_VALUE(status
);
1516 dod
= (union acpi_object
*) buffer
.pointer
;
1517 if (!dod
|| (dod
->type
!= ACPI_TYPE_PACKAGE
)) {
1518 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid _DOD data\n"));
1523 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found %d video heads in _DOD\n",
1524 dod
->package
.count
));
1526 active_device_list
= kmalloc(
1527 (1+dod
->package
.count
)*sizeof(struct acpi_video_enumerated_device
),
1530 if (!active_device_list
) {
1536 for (i
= 0; i
< dod
->package
.count
; i
++) {
1537 obj
= (union acpi_object
*) &dod
->package
.elements
[i
];
1539 if (obj
->type
!= ACPI_TYPE_INTEGER
) {
1540 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid _DOD data\n"));
1541 active_device_list
[i
].value
.int_val
= ACPI_VIDEO_HEAD_INVALID
;
1543 active_device_list
[i
].value
.int_val
= obj
->integer
.value
;
1544 active_device_list
[i
].bind_info
= NULL
;
1545 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "dod element[%d] = %d\n", i
, (int) obj
->integer
.value
));
1548 active_device_list
[count
].value
.int_val
= ACPI_VIDEO_HEAD_END
;
1550 if(video
->attached_array
)
1551 kfree(video
->attached_array
);
1553 video
->attached_array
= active_device_list
;
1554 video
->attached_count
= count
;
1556 acpi_os_free(buffer
.pointer
);
1557 return_VALUE(status
);
1562 * video : video bus device
1563 * event : Nontify Event
1568 * 1. Find out the current active output device.
1569 * 2. Identify the next output device to switch
1570 * 3. call _DSS to do actual switch.
1574 acpi_video_switch_output(
1575 struct acpi_video_bus
*video
,
1578 struct list_head
* node
, * next
;
1579 struct acpi_video_device
*dev
=NULL
;
1580 struct acpi_video_device
*dev_next
=NULL
;
1581 struct acpi_video_device
*dev_prev
=NULL
;
1582 unsigned long state
;
1585 ACPI_FUNCTION_TRACE("acpi_video_switch_output");
1587 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1588 struct acpi_video_device
* dev
= container_of(node
, struct acpi_video_device
, entry
);
1589 status
= acpi_video_device_get_state(dev
, &state
);
1591 dev_next
= container_of(node
->next
, struct acpi_video_device
, entry
);
1592 dev_prev
= container_of(node
->prev
, struct acpi_video_device
, entry
);
1596 dev_next
= container_of(node
->next
, struct acpi_video_device
, entry
);
1597 dev_prev
= container_of(node
->prev
, struct acpi_video_device
, entry
);
1600 case ACPI_VIDEO_NOTIFY_CYCLE
:
1601 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
:
1602 acpi_video_device_set_state(dev
, 0);
1603 acpi_video_device_set_state(dev_next
, 0x80000001);
1605 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
:
1606 acpi_video_device_set_state(dev
, 0);
1607 acpi_video_device_set_state(dev_prev
, 0x80000001);
1612 return_VALUE(status
);
1616 acpi_video_get_next_level(
1617 struct acpi_video_device
*device
,
1622 return level_current
;
1627 acpi_video_switch_brightness (
1628 struct acpi_video_device
*device
,
1631 unsigned long level_current
, level_next
;
1632 acpi_video_device_lcd_get_level_current(device
, &level_current
);
1633 level_next
= acpi_video_get_next_level(device
, level_current
, event
);
1634 acpi_video_device_lcd_set_level(device
, level_next
);
1638 acpi_video_bus_get_devices (
1639 struct acpi_video_bus
*video
,
1640 struct acpi_device
*device
)
1643 struct list_head
*node
, *next
;
1645 ACPI_FUNCTION_TRACE("acpi_video_get_devices");
1647 acpi_video_device_enumerate(video
);
1649 list_for_each_safe(node
, next
, &device
->children
) {
1650 struct acpi_device
*dev
= list_entry(node
, struct acpi_device
, node
);
1655 status
= acpi_video_bus_get_one_device(dev
, video
);
1656 if (ACPI_FAILURE(status
)) {
1657 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Cant attach device\n"));
1662 return_VALUE(status
);
1666 acpi_video_bus_put_one_device(
1667 struct acpi_video_device
*device
)
1669 struct acpi_video_bus
*video
;
1671 ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
1673 if (!device
|| !device
->video
)
1674 return_VALUE(-ENOENT
);
1676 video
= device
->video
;
1679 list_del(&device
->entry
);
1681 acpi_video_device_remove_fs(device
->dev
);
1687 acpi_video_bus_put_devices (
1688 struct acpi_video_bus
*video
)
1691 struct list_head
*node
, *next
;
1693 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
1695 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1696 struct acpi_video_device
*data
= list_entry(node
, struct acpi_video_device
, entry
);
1700 status
= acpi_video_bus_put_one_device(data
);
1701 if(ACPI_FAILURE(status
))
1702 printk(KERN_WARNING PREFIX
"hhuuhhuu bug in acpi video driver.\n");
1704 if (data
->brightness
)
1705 kfree(data
->brightness
);
1713 /* acpi_video interface */
1716 acpi_video_bus_start_devices(
1717 struct acpi_video_bus
*video
)
1719 return acpi_video_bus_DOS(video
, 1, 0);
1723 acpi_video_bus_stop_devices(
1724 struct acpi_video_bus
*video
)
1726 return acpi_video_bus_DOS(video
, 0, 1);
1730 acpi_video_bus_notify (
1735 struct acpi_video_bus
*video
= (struct acpi_video_bus
*) data
;
1736 struct acpi_device
*device
= NULL
;
1738 ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
1739 printk("video bus notify\n");
1744 if (acpi_bus_get_device(handle
, &device
))
1748 case ACPI_VIDEO_NOTIFY_SWITCH
: /* User request that a switch occur,
1749 * most likely via hotkey. */
1750 acpi_bus_generate_event(device
, event
, 0);
1753 case ACPI_VIDEO_NOTIFY_PROBE
: /* User plug or remove a video
1755 acpi_video_device_enumerate(video
);
1756 acpi_video_device_rebind(video
);
1757 acpi_video_switch_output(video
, event
);
1758 acpi_bus_generate_event(device
, event
, 0);
1761 case ACPI_VIDEO_NOTIFY_CYCLE
: /* Cycle Display output hotkey pressed.*/
1762 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
: /* Next Display output hotkey pressed. */
1763 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
: /* previous Display output hotkey pressed. */
1764 acpi_video_switch_output(video
, event
);
1765 acpi_bus_generate_event(device
, event
, 0);
1769 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1770 "Unsupported event [0x%x]\n", event
));
1778 acpi_video_device_notify (
1783 struct acpi_video_device
*video_device
= (struct acpi_video_device
*) data
;
1784 struct acpi_device
*device
= NULL
;
1786 ACPI_FUNCTION_TRACE("acpi_video_device_notify");
1788 printk("video device notify\n");
1792 if (acpi_bus_get_device(handle
, &device
))
1796 case ACPI_VIDEO_NOTIFY_SWITCH
: /* change in status (cycle output device) */
1797 case ACPI_VIDEO_NOTIFY_PROBE
: /* change in status (output device status) */
1798 acpi_bus_generate_event(device
, event
, 0);
1800 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
: /* Cycle brightness */
1801 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
: /* Increase brightness */
1802 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
: /* Decrease brightness */
1803 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
: /* zero brightnesss */
1804 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
: /* display device off */
1805 acpi_video_switch_brightness (video_device
, event
);
1806 acpi_bus_generate_event(device
, event
, 0);
1809 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1810 "Unsupported event [0x%x]\n", event
));
1817 acpi_video_bus_add (
1818 struct acpi_device
*device
)
1821 acpi_status status
= 0;
1822 struct acpi_video_bus
*video
= NULL
;
1824 ACPI_FUNCTION_TRACE("acpi_video_bus_add");
1827 return_VALUE(-EINVAL
);
1829 video
= kmalloc(sizeof(struct acpi_video_bus
), GFP_KERNEL
);
1831 return_VALUE(-ENOMEM
);
1832 memset(video
, 0, sizeof(struct acpi_video_bus
));
1834 video
->handle
= device
->handle
;
1835 strcpy(acpi_device_name(device
), ACPI_VIDEO_BUS_NAME
);
1836 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1837 acpi_driver_data(device
) = video
;
1839 acpi_video_bus_find_cap(video
);
1840 result
= acpi_video_bus_check(video
);
1844 result
= acpi_video_bus_add_fs(device
);
1848 init_MUTEX(&video
->sem
);
1849 INIT_LIST_HEAD(&video
->video_device_list
);
1851 acpi_video_bus_get_devices(video
, device
);
1852 acpi_video_bus_start_devices(video
);
1854 status
= acpi_install_notify_handler(video
->handle
,
1855 ACPI_DEVICE_NOTIFY
, acpi_video_bus_notify
, video
);
1856 if (ACPI_FAILURE(status
)) {
1857 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1858 "Error installing notify handler\n"));
1863 printk(KERN_INFO PREFIX
"%s [%s] (multi-head: %s rom: %s post: %s)\n",
1864 ACPI_VIDEO_DEVICE_NAME
, acpi_device_bid(device
),
1865 video
->flags
.multihead
? "yes":"no",
1866 video
->flags
.rom
? "yes":"no",
1867 video
->flags
.post
? "yes":"no");
1871 acpi_video_bus_remove_fs(device
);
1875 return_VALUE(result
);
1879 acpi_video_bus_remove (
1880 struct acpi_device
*device
,
1883 acpi_status status
= 0;
1884 struct acpi_video_bus
*video
= NULL
;
1886 ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
1888 if (!device
|| !acpi_driver_data(device
))
1889 return_VALUE(-EINVAL
);
1891 video
= (struct acpi_video_bus
*) acpi_driver_data(device
);
1893 acpi_video_bus_stop_devices(video
);
1895 status
= acpi_remove_notify_handler(video
->handle
,
1896 ACPI_DEVICE_NOTIFY
, acpi_video_bus_notify
);
1897 if (ACPI_FAILURE(status
))
1898 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1899 "Error removing notify handler\n"));
1901 acpi_video_bus_put_devices(video
);
1902 acpi_video_bus_remove_fs(device
);
1904 if (video
->attached_array
)
1905 kfree(video
->attached_array
);
1913 acpi_video_bus_match (
1914 struct acpi_device
*device
,
1915 struct acpi_driver
*driver
)
1917 acpi_handle h_dummy1
;
1918 acpi_handle h_dummy2
;
1919 acpi_handle h_dummy3
;
1921 ACPI_FUNCTION_TRACE("acpi_video_bus_match");
1923 if (!device
|| !driver
)
1924 return_VALUE(-EINVAL
);
1926 /* Since there is no HID, CID for ACPI Video drivers, we have
1927 * to check well known required nodes for each feature we support.
1930 /* Does this device able to support video switching ? */
1931 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DOD", &h_dummy1
)) &&
1932 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_DOS", &h_dummy2
)))
1935 /* Does this device able to retrieve a video ROM ? */
1936 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_ROM", &h_dummy1
)))
1939 /* Does this device able to configure which video head to be POSTed ? */
1940 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_VPO", &h_dummy1
)) &&
1941 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_GPD", &h_dummy2
)) &&
1942 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "_SPD", &h_dummy3
)))
1946 return_VALUE(-ENODEV
);
1951 acpi_video_init (void)
1955 ACPI_FUNCTION_TRACE("acpi_video_init");
1958 acpi_dbg_level = 0xFFFFFFFF;
1959 acpi_dbg_layer = 0x08000000;
1962 acpi_video_dir
= proc_mkdir(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1963 if (!acpi_video_dir
)
1964 return_VALUE(-ENODEV
);
1965 acpi_video_dir
->owner
= THIS_MODULE
;
1967 result
= acpi_bus_register_driver(&acpi_video_bus
);
1969 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1970 return_VALUE(-ENODEV
);
1977 acpi_video_exit (void)
1979 ACPI_FUNCTION_TRACE("acpi_video_exit");
1981 acpi_bus_unregister_driver(&acpi_video_bus
);
1983 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1988 module_init(acpi_video_init
);
1989 module_exit(acpi_video_exit
);