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_DRIVER_NAME "ACPI Video Driver"
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("acpi_video")
70 MODULE_AUTHOR("Bruno Ducrot");
71 MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME
);
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
= {
78 .name
= ACPI_VIDEO_DRIVER_NAME
,
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 differenates displays type */
107 u32 display_type
:4; /*Describe the specific type in use */
108 u32 vendor_specific
:4; /*Chipset Vendor Specifi */
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 backlight_properties
*data
;
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
,
278 /*backlight device sysfs support*/
279 static int acpi_video_get_brightness(struct backlight_device
*bd
)
281 unsigned long cur_level
;
282 struct acpi_video_device
*vd
=
283 (struct acpi_video_device
*)class_get_devdata(&bd
->class_dev
);
284 acpi_video_device_lcd_get_level_current(vd
, &cur_level
);
285 return (int) cur_level
;
288 static int acpi_video_set_brightness(struct backlight_device
*bd
)
290 int request_level
= bd
->props
->brightness
;
291 struct acpi_video_device
*vd
=
292 (struct acpi_video_device
*)class_get_devdata(&bd
->class_dev
);
293 acpi_video_device_lcd_set_level(vd
, request_level
);
297 /* --------------------------------------------------------------------------
299 -------------------------------------------------------------------------- */
304 acpi_video_device_query(struct acpi_video_device
*device
, unsigned long *state
)
308 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DGS", NULL
, state
);
314 acpi_video_device_get_state(struct acpi_video_device
*device
,
315 unsigned long *state
)
319 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DCS", NULL
, state
);
325 acpi_video_device_set_state(struct acpi_video_device
*device
, int state
)
328 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
329 struct acpi_object_list args
= { 1, &arg0
};
333 arg0
.integer
.value
= state
;
334 status
= acpi_evaluate_integer(device
->dev
->handle
, "_DSS", &args
, &ret
);
340 acpi_video_device_lcd_query_levels(struct acpi_video_device
*device
,
341 union acpi_object
**levels
)
344 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
345 union acpi_object
*obj
;
350 status
= acpi_evaluate_object(device
->dev
->handle
, "_BCL", NULL
, &buffer
);
351 if (!ACPI_SUCCESS(status
))
353 obj
= (union acpi_object
*)buffer
.pointer
;
354 if (!obj
|| (obj
->type
!= ACPI_TYPE_PACKAGE
)) {
355 printk(KERN_ERR PREFIX
"Invalid _BCL data\n");
365 kfree(buffer
.pointer
);
371 acpi_video_device_lcd_set_level(struct acpi_video_device
*device
, int level
)
374 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
375 struct acpi_object_list args
= { 1, &arg0
};
378 arg0
.integer
.value
= level
;
379 status
= acpi_evaluate_object(device
->dev
->handle
, "_BCM", &args
, NULL
);
381 printk(KERN_DEBUG
"set_level status: %x\n", status
);
386 acpi_video_device_lcd_get_level_current(struct acpi_video_device
*device
,
387 unsigned long *level
)
391 status
= acpi_evaluate_integer(device
->dev
->handle
, "_BQC", NULL
, level
);
397 acpi_video_device_EDID(struct acpi_video_device
*device
,
398 union acpi_object
**edid
, ssize_t length
)
401 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
402 union acpi_object
*obj
;
403 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
404 struct acpi_object_list args
= { 1, &arg0
};
412 arg0
.integer
.value
= 1;
413 else if (length
== 256)
414 arg0
.integer
.value
= 2;
418 status
= acpi_evaluate_object(device
->dev
->handle
, "_DDC", &args
, &buffer
);
419 if (ACPI_FAILURE(status
))
422 obj
= buffer
.pointer
;
424 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
)
427 printk(KERN_ERR PREFIX
"Invalid _DDC data\n");
438 acpi_video_bus_set_POST(struct acpi_video_bus
*video
, unsigned long option
)
442 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
443 struct acpi_object_list args
= { 1, &arg0
};
446 arg0
.integer
.value
= option
;
448 status
= acpi_evaluate_integer(video
->device
->handle
, "_SPD", &args
, &tmp
);
449 if (ACPI_SUCCESS(status
))
450 status
= tmp
? (-EINVAL
) : (AE_OK
);
456 acpi_video_bus_get_POST(struct acpi_video_bus
*video
, unsigned long *id
)
460 status
= acpi_evaluate_integer(video
->device
->handle
, "_GPD", NULL
, id
);
466 acpi_video_bus_POST_options(struct acpi_video_bus
*video
,
467 unsigned long *options
)
471 status
= acpi_evaluate_integer(video
->device
->handle
, "_VPO", NULL
, options
);
479 * video : video bus device pointer
481 * 0. The system BIOS should NOT automatically switch(toggle)
482 * the active display output.
483 * 1. The system BIOS should automatically switch (toggle) the
484 * active display output. No swich event.
485 * 2. The _DGS value should be locked.
486 * 3. The system BIOS should not automatically switch (toggle) the
487 * active display output, but instead generate the display switch
490 * 0. The system BIOS should automatically control the brightness level
491 * of the LCD, when the power changes from AC to DC
492 * 1. The system BIOS should NOT automatically control the brightness
493 * level of the LCD, when the power changes from AC to DC.
499 acpi_video_bus_DOS(struct acpi_video_bus
*video
, int bios_flag
, int lcd_flag
)
501 acpi_integer status
= 0;
502 union acpi_object arg0
= { ACPI_TYPE_INTEGER
};
503 struct acpi_object_list args
= { 1, &arg0
};
506 if (bios_flag
< 0 || bios_flag
> 3 || lcd_flag
< 0 || lcd_flag
> 1) {
510 arg0
.integer
.value
= (lcd_flag
<< 2) | bios_flag
;
511 video
->dos_setting
= arg0
.integer
.value
;
512 acpi_evaluate_object(video
->device
->handle
, "_DOS", &args
, NULL
);
520 * device : video output device (LCD, CRT, ..)
525 * Find out all required AML method defined under the output
529 static void acpi_video_device_find_cap(struct acpi_video_device
*device
)
532 acpi_handle h_dummy1
;
535 union acpi_object
*obj
= NULL
;
536 struct acpi_video_device_brightness
*br
= NULL
;
539 memset(&device
->cap
, 0, 4);
541 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_ADR", &h_dummy1
))) {
542 device
->cap
._ADR
= 1;
544 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCL", &h_dummy1
))) {
545 device
->cap
._BCL
= 1;
547 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_BCM", &h_dummy1
))) {
548 device
->cap
._BCM
= 1;
550 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
,"_BQC",&h_dummy1
)))
551 device
->cap
._BQC
= 1;
552 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DDC", &h_dummy1
))) {
553 device
->cap
._DDC
= 1;
555 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DCS", &h_dummy1
))) {
556 device
->cap
._DCS
= 1;
558 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DGS", &h_dummy1
))) {
559 device
->cap
._DGS
= 1;
561 if (ACPI_SUCCESS(acpi_get_handle(device
->dev
->handle
, "_DSS", &h_dummy1
))) {
562 device
->cap
._DSS
= 1;
565 status
= acpi_video_device_lcd_query_levels(device
, &obj
);
567 if (obj
&& obj
->type
== ACPI_TYPE_PACKAGE
&& obj
->package
.count
>= 2) {
569 union acpi_object
*o
;
571 br
= kzalloc(sizeof(*br
), GFP_KERNEL
);
573 printk(KERN_ERR
"can't allocate memory\n");
575 br
->levels
= kmalloc(obj
->package
.count
*
576 sizeof *(br
->levels
), GFP_KERNEL
);
580 for (i
= 0; i
< obj
->package
.count
; i
++) {
581 o
= (union acpi_object
*)&obj
->package
.
583 if (o
->type
!= ACPI_TYPE_INTEGER
) {
584 printk(KERN_ERR PREFIX
"Invalid data\n");
587 br
->levels
[count
] = (u32
) o
->integer
.value
;
588 if (br
->levels
[count
] > max_level
)
589 max_level
= br
->levels
[count
];
598 device
->brightness
= br
;
599 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
600 "found %d brightness levels\n",
608 if (device
->cap
._BCL
&& device
->cap
._BCM
&& device
->cap
._BQC
){
610 static int count
= 0;
612 struct backlight_properties
*acpi_video_data
;
614 name
= kzalloc(MAX_NAME_LEN
, GFP_KERNEL
);
618 acpi_video_data
= kzalloc(
619 sizeof(struct backlight_properties
),
621 if (!acpi_video_data
){
625 acpi_video_data
->owner
= THIS_MODULE
;
626 acpi_video_data
->get_brightness
=
627 acpi_video_get_brightness
;
628 acpi_video_data
->update_status
=
629 acpi_video_set_brightness
;
630 sprintf(name
, "acpi_video%d", count
++);
631 device
->data
= acpi_video_data
;
632 acpi_video_data
->max_brightness
= max_level
;
633 acpi_video_device_lcd_get_level_current(device
, &tmp
);
634 acpi_video_data
->brightness
= (int)tmp
;
635 device
->backlight
= backlight_device_register(name
,
636 NULL
, device
, acpi_video_data
);
644 * device : video output device (VGA)
649 * Find out all required AML method defined under the video bus device.
652 static void acpi_video_bus_find_cap(struct acpi_video_bus
*video
)
654 acpi_handle h_dummy1
;
656 memset(&video
->cap
, 0, 4);
657 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_DOS", &h_dummy1
))) {
660 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_DOD", &h_dummy1
))) {
663 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_ROM", &h_dummy1
))) {
666 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_GPD", &h_dummy1
))) {
669 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_SPD", &h_dummy1
))) {
672 if (ACPI_SUCCESS(acpi_get_handle(video
->device
->handle
, "_VPO", &h_dummy1
))) {
678 * Check whether the video bus device has required AML method to
679 * support the desired features
682 static int acpi_video_bus_check(struct acpi_video_bus
*video
)
684 acpi_status status
= -ENOENT
;
690 /* Since there is no HID, CID and so on for VGA driver, we have
691 * to check well known required nodes.
694 /* Does this device able to support video switching ? */
695 if (video
->cap
._DOS
) {
696 video
->flags
.multihead
= 1;
700 /* Does this device able to retrieve a retrieve a video ROM ? */
701 if (video
->cap
._ROM
) {
702 video
->flags
.rom
= 1;
706 /* Does this device able to configure which video device to POST ? */
707 if (video
->cap
._GPD
&& video
->cap
._SPD
&& video
->cap
._VPO
) {
708 video
->flags
.post
= 1;
715 /* --------------------------------------------------------------------------
717 -------------------------------------------------------------------------- */
719 static struct proc_dir_entry
*acpi_video_dir
;
723 static int acpi_video_device_info_seq_show(struct seq_file
*seq
, void *offset
)
725 struct acpi_video_device
*dev
= seq
->private;
731 seq_printf(seq
, "device_id: 0x%04x\n", (u32
) dev
->device_id
);
732 seq_printf(seq
, "type: ");
734 seq_printf(seq
, "CRT\n");
735 else if (dev
->flags
.lcd
)
736 seq_printf(seq
, "LCD\n");
737 else if (dev
->flags
.tvout
)
738 seq_printf(seq
, "TVOUT\n");
739 else if (dev
->flags
.dvi
)
740 seq_printf(seq
, "DVI\n");
742 seq_printf(seq
, "UNKNOWN\n");
744 seq_printf(seq
, "known by bios: %s\n", dev
->flags
.bios
? "yes" : "no");
751 acpi_video_device_info_open_fs(struct inode
*inode
, struct file
*file
)
753 return single_open(file
, acpi_video_device_info_seq_show
,
757 static int acpi_video_device_state_seq_show(struct seq_file
*seq
, void *offset
)
760 struct acpi_video_device
*dev
= seq
->private;
767 status
= acpi_video_device_get_state(dev
, &state
);
768 seq_printf(seq
, "state: ");
769 if (ACPI_SUCCESS(status
))
770 seq_printf(seq
, "0x%02lx\n", state
);
772 seq_printf(seq
, "<not supported>\n");
774 status
= acpi_video_device_query(dev
, &state
);
775 seq_printf(seq
, "query: ");
776 if (ACPI_SUCCESS(status
))
777 seq_printf(seq
, "0x%02lx\n", state
);
779 seq_printf(seq
, "<not supported>\n");
786 acpi_video_device_state_open_fs(struct inode
*inode
, struct file
*file
)
788 return single_open(file
, acpi_video_device_state_seq_show
,
793 acpi_video_device_write_state(struct file
*file
,
794 const char __user
* buffer
,
795 size_t count
, loff_t
* data
)
798 struct seq_file
*m
= file
->private_data
;
799 struct acpi_video_device
*dev
= m
->private;
800 char str
[12] = { 0 };
804 if (!dev
|| count
+ 1 > sizeof str
)
807 if (copy_from_user(str
, buffer
, count
))
811 state
= simple_strtoul(str
, NULL
, 0);
812 state
&= ((1ul << 31) | (1ul << 30) | (1ul << 0));
814 status
= acpi_video_device_set_state(dev
, state
);
823 acpi_video_device_brightness_seq_show(struct seq_file
*seq
, void *offset
)
825 struct acpi_video_device
*dev
= seq
->private;
829 if (!dev
|| !dev
->brightness
) {
830 seq_printf(seq
, "<not supported>\n");
834 seq_printf(seq
, "levels: ");
835 for (i
= 0; i
< dev
->brightness
->count
; i
++)
836 seq_printf(seq
, " %d", dev
->brightness
->levels
[i
]);
837 seq_printf(seq
, "\ncurrent: %d\n", dev
->brightness
->curr
);
843 acpi_video_device_brightness_open_fs(struct inode
*inode
, struct file
*file
)
845 return single_open(file
, acpi_video_device_brightness_seq_show
,
850 acpi_video_device_write_brightness(struct file
*file
,
851 const char __user
* buffer
,
852 size_t count
, loff_t
* data
)
854 struct seq_file
*m
= file
->private_data
;
855 struct acpi_video_device
*dev
= m
->private;
857 unsigned int level
= 0;
861 if (!dev
|| !dev
->brightness
|| count
+ 1 > sizeof str
)
864 if (copy_from_user(str
, buffer
, count
))
868 level
= simple_strtoul(str
, NULL
, 0);
873 /* validate though the list of available levels */
874 for (i
= 0; i
< dev
->brightness
->count
; i
++)
875 if (level
== dev
->brightness
->levels
[i
]) {
877 (acpi_video_device_lcd_set_level(dev
, level
)))
878 dev
->brightness
->curr
= level
;
885 static int acpi_video_device_EDID_seq_show(struct seq_file
*seq
, void *offset
)
887 struct acpi_video_device
*dev
= seq
->private;
890 union acpi_object
*edid
= NULL
;
896 status
= acpi_video_device_EDID(dev
, &edid
, 128);
897 if (ACPI_FAILURE(status
)) {
898 status
= acpi_video_device_EDID(dev
, &edid
, 256);
901 if (ACPI_FAILURE(status
)) {
905 if (edid
&& edid
->type
== ACPI_TYPE_BUFFER
) {
906 for (i
= 0; i
< edid
->buffer
.length
; i
++)
907 seq_putc(seq
, edid
->buffer
.pointer
[i
]);
912 seq_printf(seq
, "<not supported>\n");
920 acpi_video_device_EDID_open_fs(struct inode
*inode
, struct file
*file
)
922 return single_open(file
, acpi_video_device_EDID_seq_show
,
926 static int acpi_video_device_add_fs(struct acpi_device
*device
)
928 struct proc_dir_entry
*entry
= NULL
;
929 struct acpi_video_device
*vid_dev
;
935 vid_dev
= acpi_driver_data(device
);
939 if (!acpi_device_dir(device
)) {
940 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
941 vid_dev
->video
->dir
);
942 if (!acpi_device_dir(device
))
944 acpi_device_dir(device
)->owner
= THIS_MODULE
;
948 entry
= create_proc_entry("info", S_IRUGO
, acpi_device_dir(device
));
952 entry
->proc_fops
= &acpi_video_device_info_fops
;
953 entry
->data
= acpi_driver_data(device
);
954 entry
->owner
= THIS_MODULE
;
959 create_proc_entry("state", S_IFREG
| S_IRUGO
| S_IWUSR
,
960 acpi_device_dir(device
));
964 acpi_video_device_state_fops
.write
= acpi_video_device_write_state
;
965 entry
->proc_fops
= &acpi_video_device_state_fops
;
966 entry
->data
= acpi_driver_data(device
);
967 entry
->owner
= THIS_MODULE
;
970 /* 'brightness' [R/W] */
972 create_proc_entry("brightness", S_IFREG
| S_IRUGO
| S_IWUSR
,
973 acpi_device_dir(device
));
977 acpi_video_device_brightness_fops
.write
= acpi_video_device_write_brightness
;
978 entry
->proc_fops
= &acpi_video_device_brightness_fops
;
979 entry
->data
= acpi_driver_data(device
);
980 entry
->owner
= THIS_MODULE
;
984 entry
= create_proc_entry("EDID", S_IRUGO
, acpi_device_dir(device
));
988 entry
->proc_fops
= &acpi_video_device_EDID_fops
;
989 entry
->data
= acpi_driver_data(device
);
990 entry
->owner
= THIS_MODULE
;
996 static int acpi_video_device_remove_fs(struct acpi_device
*device
)
998 struct acpi_video_device
*vid_dev
;
1000 vid_dev
= acpi_driver_data(device
);
1001 if (!vid_dev
|| !vid_dev
->video
|| !vid_dev
->video
->dir
)
1004 if (acpi_device_dir(device
)) {
1005 remove_proc_entry("info", acpi_device_dir(device
));
1006 remove_proc_entry("state", acpi_device_dir(device
));
1007 remove_proc_entry("brightness", acpi_device_dir(device
));
1008 remove_proc_entry("EDID", acpi_device_dir(device
));
1009 remove_proc_entry(acpi_device_bid(device
), vid_dev
->video
->dir
);
1010 acpi_device_dir(device
) = NULL
;
1017 static int acpi_video_bus_info_seq_show(struct seq_file
*seq
, void *offset
)
1019 struct acpi_video_bus
*video
= seq
->private;
1025 seq_printf(seq
, "Switching heads: %s\n",
1026 video
->flags
.multihead
? "yes" : "no");
1027 seq_printf(seq
, "Video ROM: %s\n",
1028 video
->flags
.rom
? "yes" : "no");
1029 seq_printf(seq
, "Device to be POSTed on boot: %s\n",
1030 video
->flags
.post
? "yes" : "no");
1036 static int acpi_video_bus_info_open_fs(struct inode
*inode
, struct file
*file
)
1038 return single_open(file
, acpi_video_bus_info_seq_show
,
1042 static int acpi_video_bus_ROM_seq_show(struct seq_file
*seq
, void *offset
)
1044 struct acpi_video_bus
*video
= seq
->private;
1050 printk(KERN_INFO PREFIX
"Please implement %s\n", __FUNCTION__
);
1051 seq_printf(seq
, "<TODO>\n");
1057 static int acpi_video_bus_ROM_open_fs(struct inode
*inode
, struct file
*file
)
1059 return single_open(file
, acpi_video_bus_ROM_seq_show
, PDE(inode
)->data
);
1062 static int acpi_video_bus_POST_info_seq_show(struct seq_file
*seq
, void *offset
)
1064 struct acpi_video_bus
*video
= seq
->private;
1065 unsigned long options
;
1072 status
= acpi_video_bus_POST_options(video
, &options
);
1073 if (ACPI_SUCCESS(status
)) {
1074 if (!(options
& 1)) {
1075 printk(KERN_WARNING PREFIX
1076 "The motherboard VGA device is not listed as a possible POST device.\n");
1077 printk(KERN_WARNING PREFIX
1078 "This indicate a BIOS bug. Please contact the manufacturer.\n");
1080 printk("%lx\n", options
);
1081 seq_printf(seq
, "can POST: <intgrated video>");
1083 seq_printf(seq
, " <PCI video>");
1085 seq_printf(seq
, " <AGP video>");
1086 seq_putc(seq
, '\n');
1088 seq_printf(seq
, "<not supported>\n");
1094 acpi_video_bus_POST_info_open_fs(struct inode
*inode
, struct file
*file
)
1096 return single_open(file
, acpi_video_bus_POST_info_seq_show
,
1100 static int acpi_video_bus_POST_seq_show(struct seq_file
*seq
, void *offset
)
1102 struct acpi_video_bus
*video
= seq
->private;
1110 status
= acpi_video_bus_get_POST(video
, &id
);
1111 if (!ACPI_SUCCESS(status
)) {
1112 seq_printf(seq
, "<not supported>\n");
1115 seq_printf(seq
, "device posted is <%s>\n", device_decode
[id
& 3]);
1121 static int acpi_video_bus_DOS_seq_show(struct seq_file
*seq
, void *offset
)
1123 struct acpi_video_bus
*video
= seq
->private;
1126 seq_printf(seq
, "DOS setting: <%d>\n", video
->dos_setting
);
1131 static int acpi_video_bus_POST_open_fs(struct inode
*inode
, struct file
*file
)
1133 return single_open(file
, acpi_video_bus_POST_seq_show
,
1137 static int acpi_video_bus_DOS_open_fs(struct inode
*inode
, struct file
*file
)
1139 return single_open(file
, acpi_video_bus_DOS_seq_show
, PDE(inode
)->data
);
1143 acpi_video_bus_write_POST(struct file
*file
,
1144 const char __user
* buffer
,
1145 size_t count
, loff_t
* data
)
1148 struct seq_file
*m
= file
->private_data
;
1149 struct acpi_video_bus
*video
= m
->private;
1150 char str
[12] = { 0 };
1151 unsigned long opt
, options
;
1154 if (!video
|| count
+ 1 > sizeof str
)
1157 status
= acpi_video_bus_POST_options(video
, &options
);
1158 if (!ACPI_SUCCESS(status
))
1161 if (copy_from_user(str
, buffer
, count
))
1165 opt
= strtoul(str
, NULL
, 0);
1169 /* just in case an OEM 'forget' the motherboard... */
1172 if (options
& (1ul << opt
)) {
1173 status
= acpi_video_bus_set_POST(video
, opt
);
1174 if (!ACPI_SUCCESS(status
))
1183 acpi_video_bus_write_DOS(struct file
*file
,
1184 const char __user
* buffer
,
1185 size_t count
, loff_t
* data
)
1188 struct seq_file
*m
= file
->private_data
;
1189 struct acpi_video_bus
*video
= m
->private;
1190 char str
[12] = { 0 };
1194 if (!video
|| count
+ 1 > sizeof str
)
1197 if (copy_from_user(str
, buffer
, count
))
1201 opt
= strtoul(str
, NULL
, 0);
1205 status
= acpi_video_bus_DOS(video
, opt
& 0x3, (opt
& 0x4) >> 2);
1207 if (!ACPI_SUCCESS(status
))
1213 static int acpi_video_bus_add_fs(struct acpi_device
*device
)
1215 struct proc_dir_entry
*entry
= NULL
;
1216 struct acpi_video_bus
*video
;
1219 video
= acpi_driver_data(device
);
1221 if (!acpi_device_dir(device
)) {
1222 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
1224 if (!acpi_device_dir(device
))
1226 video
->dir
= acpi_device_dir(device
);
1227 acpi_device_dir(device
)->owner
= THIS_MODULE
;
1231 entry
= create_proc_entry("info", S_IRUGO
, acpi_device_dir(device
));
1235 entry
->proc_fops
= &acpi_video_bus_info_fops
;
1236 entry
->data
= acpi_driver_data(device
);
1237 entry
->owner
= THIS_MODULE
;
1241 entry
= create_proc_entry("ROM", S_IRUGO
, acpi_device_dir(device
));
1245 entry
->proc_fops
= &acpi_video_bus_ROM_fops
;
1246 entry
->data
= acpi_driver_data(device
);
1247 entry
->owner
= THIS_MODULE
;
1250 /* 'POST_info' [R] */
1252 create_proc_entry("POST_info", S_IRUGO
, acpi_device_dir(device
));
1256 entry
->proc_fops
= &acpi_video_bus_POST_info_fops
;
1257 entry
->data
= acpi_driver_data(device
);
1258 entry
->owner
= THIS_MODULE
;
1263 create_proc_entry("POST", S_IFREG
| S_IRUGO
| S_IRUSR
,
1264 acpi_device_dir(device
));
1268 acpi_video_bus_POST_fops
.write
= acpi_video_bus_write_POST
;
1269 entry
->proc_fops
= &acpi_video_bus_POST_fops
;
1270 entry
->data
= acpi_driver_data(device
);
1271 entry
->owner
= THIS_MODULE
;
1276 create_proc_entry("DOS", S_IFREG
| S_IRUGO
| S_IRUSR
,
1277 acpi_device_dir(device
));
1281 acpi_video_bus_DOS_fops
.write
= acpi_video_bus_write_DOS
;
1282 entry
->proc_fops
= &acpi_video_bus_DOS_fops
;
1283 entry
->data
= acpi_driver_data(device
);
1284 entry
->owner
= THIS_MODULE
;
1290 static int acpi_video_bus_remove_fs(struct acpi_device
*device
)
1292 struct acpi_video_bus
*video
;
1295 video
= acpi_driver_data(device
);
1297 if (acpi_device_dir(device
)) {
1298 remove_proc_entry("info", acpi_device_dir(device
));
1299 remove_proc_entry("ROM", acpi_device_dir(device
));
1300 remove_proc_entry("POST_info", acpi_device_dir(device
));
1301 remove_proc_entry("POST", acpi_device_dir(device
));
1302 remove_proc_entry("DOS", acpi_device_dir(device
));
1303 remove_proc_entry(acpi_device_bid(device
), acpi_video_dir
);
1304 acpi_device_dir(device
) = NULL
;
1310 /* --------------------------------------------------------------------------
1312 -------------------------------------------------------------------------- */
1314 /* device interface */
1315 static struct acpi_video_device_attrib
*
1316 acpi_video_get_device_attr(struct acpi_video_bus
*video
, unsigned long device_id
)
1320 for(count
= 0; count
< video
->attached_count
; count
++)
1321 if((video
->attached_array
[count
].value
.int_val
& 0xffff) == device_id
)
1322 return &(video
->attached_array
[count
].value
.attrib
);
1327 acpi_video_bus_get_one_device(struct acpi_device
*device
,
1328 struct acpi_video_bus
*video
)
1330 unsigned long device_id
;
1332 struct acpi_video_device
*data
;
1333 struct acpi_video_device_attrib
* attribute
;
1335 if (!device
|| !video
)
1339 acpi_evaluate_integer(device
->handle
, "_ADR", NULL
, &device_id
);
1340 if (ACPI_SUCCESS(status
)) {
1342 data
= kzalloc(sizeof(struct acpi_video_device
), GFP_KERNEL
);
1346 strcpy(acpi_device_name(device
), ACPI_VIDEO_DEVICE_NAME
);
1347 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1348 acpi_driver_data(device
) = data
;
1350 data
->device_id
= device_id
;
1351 data
->video
= video
;
1354 attribute
= acpi_video_get_device_attr(video
, device_id
);
1356 if((attribute
!= NULL
) && attribute
->device_id_scheme
) {
1357 switch (attribute
->display_type
) {
1358 case ACPI_VIDEO_DISPLAY_CRT
:
1359 data
->flags
.crt
= 1;
1361 case ACPI_VIDEO_DISPLAY_TV
:
1362 data
->flags
.tvout
= 1;
1364 case ACPI_VIDEO_DISPLAY_DVI
:
1365 data
->flags
.dvi
= 1;
1367 case ACPI_VIDEO_DISPLAY_LCD
:
1368 data
->flags
.lcd
= 1;
1371 data
->flags
.unknown
= 1;
1374 if(attribute
->bios_can_detect
)
1375 data
->flags
.bios
= 1;
1377 data
->flags
.unknown
= 1;
1379 acpi_video_device_bind(video
, data
);
1380 acpi_video_device_find_cap(data
);
1382 status
= acpi_install_notify_handler(device
->handle
,
1384 acpi_video_device_notify
,
1386 if (ACPI_FAILURE(status
)) {
1387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1388 "Error installing notify handler\n"));
1389 if(data
->brightness
)
1390 kfree(data
->brightness
->levels
);
1391 kfree(data
->brightness
);
1397 list_add_tail(&data
->entry
, &video
->video_device_list
);
1400 acpi_video_device_add_fs(device
);
1410 * video : video bus device
1415 * Enumerate the video device list of the video bus,
1416 * bind the ids with the corresponding video devices
1417 * under the video bus.
1420 static void acpi_video_device_rebind(struct acpi_video_bus
*video
)
1422 struct list_head
*node
, *next
;
1423 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1424 struct acpi_video_device
*dev
=
1425 container_of(node
, struct acpi_video_device
, entry
);
1426 acpi_video_device_bind(video
, dev
);
1432 * video : video bus device
1433 * device : video output device under the video
1439 * Bind the ids with the corresponding video devices
1440 * under the video bus.
1444 acpi_video_device_bind(struct acpi_video_bus
*video
,
1445 struct acpi_video_device
*device
)
1449 #define IDS_VAL(i) video->attached_array[i].value.int_val
1450 #define IDS_BIND(i) video->attached_array[i].bind_info
1452 for (i
= 0; IDS_VAL(i
) != ACPI_VIDEO_HEAD_INVALID
&&
1453 i
< video
->attached_count
; i
++) {
1454 if (device
->device_id
== (IDS_VAL(i
) & 0xffff)) {
1455 IDS_BIND(i
) = device
;
1456 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "device_bind %d\n", i
));
1465 * video : video bus device
1470 * Call _DOD to enumerate all devices attached to display adapter
1474 static int acpi_video_device_enumerate(struct acpi_video_bus
*video
)
1479 struct acpi_video_enumerated_device
*active_device_list
;
1480 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1481 union acpi_object
*dod
= NULL
;
1482 union acpi_object
*obj
;
1484 status
= acpi_evaluate_object(video
->device
->handle
, "_DOD", NULL
, &buffer
);
1485 if (!ACPI_SUCCESS(status
)) {
1486 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _DOD"));
1490 dod
= buffer
.pointer
;
1491 if (!dod
|| (dod
->type
!= ACPI_TYPE_PACKAGE
)) {
1492 ACPI_EXCEPTION((AE_INFO
, status
, "Invalid _DOD data"));
1497 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found %d video heads in _DOD\n",
1498 dod
->package
.count
));
1500 active_device_list
= kmalloc((1 +
1501 dod
->package
.count
) *
1503 acpi_video_enumerated_device
),
1506 if (!active_device_list
) {
1512 for (i
= 0; i
< dod
->package
.count
; i
++) {
1513 obj
= &dod
->package
.elements
[i
];
1515 if (obj
->type
!= ACPI_TYPE_INTEGER
) {
1516 printk(KERN_ERR PREFIX
"Invalid _DOD data\n");
1517 active_device_list
[i
].value
.int_val
=
1518 ACPI_VIDEO_HEAD_INVALID
;
1520 active_device_list
[i
].value
.int_val
= obj
->integer
.value
;
1521 active_device_list
[i
].bind_info
= NULL
;
1522 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "dod element[%d] = %d\n", i
,
1523 (int)obj
->integer
.value
));
1526 active_device_list
[count
].value
.int_val
= ACPI_VIDEO_HEAD_END
;
1528 kfree(video
->attached_array
);
1530 video
->attached_array
= active_device_list
;
1531 video
->attached_count
= count
;
1533 kfree(buffer
.pointer
);
1539 * video : video bus device
1540 * event : Nontify Event
1545 * 1. Find out the current active output device.
1546 * 2. Identify the next output device to switch
1547 * 3. call _DSS to do actual switch.
1550 static int acpi_video_switch_output(struct acpi_video_bus
*video
, int event
)
1552 struct list_head
*node
, *next
;
1553 struct acpi_video_device
*dev
= NULL
;
1554 struct acpi_video_device
*dev_next
= NULL
;
1555 struct acpi_video_device
*dev_prev
= NULL
;
1556 unsigned long state
;
1560 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1561 dev
= container_of(node
, struct acpi_video_device
, entry
);
1562 status
= acpi_video_device_get_state(dev
, &state
);
1565 container_of(node
->next
, struct acpi_video_device
,
1568 container_of(node
->prev
, struct acpi_video_device
,
1573 dev_next
= container_of(node
->next
, struct acpi_video_device
, entry
);
1574 dev_prev
= container_of(node
->prev
, struct acpi_video_device
, entry
);
1577 case ACPI_VIDEO_NOTIFY_CYCLE
:
1578 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
:
1579 acpi_video_device_set_state(dev
, 0);
1580 acpi_video_device_set_state(dev_next
, 0x80000001);
1582 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
:
1583 acpi_video_device_set_state(dev
, 0);
1584 acpi_video_device_set_state(dev_prev
, 0x80000001);
1593 acpi_video_get_next_level(struct acpi_video_device
*device
,
1594 u32 level_current
, u32 event
)
1596 int min
, max
, min_above
, max_below
, i
, l
;
1597 max
= max_below
= 0;
1598 min
= min_above
= 255;
1599 for (i
= 0; i
< device
->brightness
->count
; i
++) {
1600 l
= device
->brightness
->levels
[i
];
1605 if (l
< min_above
&& l
> level_current
)
1607 if (l
> max_below
&& l
< level_current
)
1612 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
:
1613 return (level_current
< max
) ? min_above
: min
;
1614 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
:
1615 return (level_current
< max
) ? min_above
: max
;
1616 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
:
1617 return (level_current
> min
) ? max_below
: min
;
1618 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
:
1619 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
:
1622 return level_current
;
1627 acpi_video_switch_brightness(struct acpi_video_device
*device
, int event
)
1629 unsigned long level_current
, level_next
;
1630 acpi_video_device_lcd_get_level_current(device
, &level_current
);
1631 level_next
= acpi_video_get_next_level(device
, level_current
, event
);
1632 acpi_video_device_lcd_set_level(device
, level_next
);
1636 acpi_video_bus_get_devices(struct acpi_video_bus
*video
,
1637 struct acpi_device
*device
)
1640 struct list_head
*node
, *next
;
1643 acpi_video_device_enumerate(video
);
1645 list_for_each_safe(node
, next
, &device
->children
) {
1646 struct acpi_device
*dev
=
1647 list_entry(node
, struct acpi_device
, node
);
1652 status
= acpi_video_bus_get_one_device(dev
, video
);
1653 if (ACPI_FAILURE(status
)) {
1654 ACPI_EXCEPTION((AE_INFO
, status
, "Cant attach device"));
1662 static int acpi_video_bus_put_one_device(struct acpi_video_device
*device
)
1665 struct acpi_video_bus
*video
;
1668 if (!device
|| !device
->video
)
1671 video
= device
->video
;
1674 list_del(&device
->entry
);
1676 acpi_video_device_remove_fs(device
->dev
);
1678 status
= acpi_remove_notify_handler(device
->dev
->handle
,
1680 acpi_video_device_notify
);
1681 if (device
->backlight
){
1682 backlight_device_unregister(device
->backlight
);
1683 kfree(device
->data
);
1688 static int acpi_video_bus_put_devices(struct acpi_video_bus
*video
)
1691 struct list_head
*node
, *next
;
1694 list_for_each_safe(node
, next
, &video
->video_device_list
) {
1695 struct acpi_video_device
*data
=
1696 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
1703 "hhuuhhuu bug in acpi video driver.\n");
1705 if (data
->brightness
)
1706 kfree(data
->brightness
->levels
);
1707 kfree(data
->brightness
);
1714 /* acpi_video interface */
1716 static int acpi_video_bus_start_devices(struct acpi_video_bus
*video
)
1718 return acpi_video_bus_DOS(video
, 1, 0);
1721 static int acpi_video_bus_stop_devices(struct acpi_video_bus
*video
)
1723 return acpi_video_bus_DOS(video
, 0, 1);
1726 static void acpi_video_bus_notify(acpi_handle handle
, u32 event
, void *data
)
1728 struct acpi_video_bus
*video
= data
;
1729 struct acpi_device
*device
= NULL
;
1731 printk("video bus notify\n");
1736 device
= video
->device
;
1739 case ACPI_VIDEO_NOTIFY_SWITCH
: /* User request that a switch occur,
1740 * most likely via hotkey. */
1741 acpi_bus_generate_event(device
, event
, 0);
1744 case ACPI_VIDEO_NOTIFY_PROBE
: /* User plug or remove a video
1746 acpi_video_device_enumerate(video
);
1747 acpi_video_device_rebind(video
);
1748 acpi_video_switch_output(video
, event
);
1749 acpi_bus_generate_event(device
, event
, 0);
1752 case ACPI_VIDEO_NOTIFY_CYCLE
: /* Cycle Display output hotkey pressed. */
1753 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT
: /* Next Display output hotkey pressed. */
1754 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT
: /* previous Display output hotkey pressed. */
1755 acpi_video_switch_output(video
, event
);
1756 acpi_bus_generate_event(device
, event
, 0);
1760 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1761 "Unsupported event [0x%x]\n", event
));
1768 static void acpi_video_device_notify(acpi_handle handle
, u32 event
, void *data
)
1770 struct acpi_video_device
*video_device
= data
;
1771 struct acpi_device
*device
= NULL
;
1776 device
= video_device
->dev
;
1779 case ACPI_VIDEO_NOTIFY_SWITCH
: /* change in status (cycle output device) */
1780 case ACPI_VIDEO_NOTIFY_PROBE
: /* change in status (output device status) */
1781 acpi_bus_generate_event(device
, event
, 0);
1783 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS
: /* Cycle brightness */
1784 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS
: /* Increase brightness */
1785 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS
: /* Decrease brightness */
1786 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS
: /* zero brightnesss */
1787 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF
: /* display device off */
1788 acpi_video_switch_brightness(video_device
, event
);
1789 acpi_bus_generate_event(device
, event
, 0);
1792 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1793 "Unsupported event [0x%x]\n", event
));
1799 static int acpi_video_bus_add(struct acpi_device
*device
)
1802 acpi_status status
= 0;
1803 struct acpi_video_bus
*video
= NULL
;
1809 video
= kzalloc(sizeof(struct acpi_video_bus
), GFP_KERNEL
);
1813 video
->device
= device
;
1814 strcpy(acpi_device_name(device
), ACPI_VIDEO_BUS_NAME
);
1815 strcpy(acpi_device_class(device
), ACPI_VIDEO_CLASS
);
1816 acpi_driver_data(device
) = video
;
1818 acpi_video_bus_find_cap(video
);
1819 result
= acpi_video_bus_check(video
);
1823 result
= acpi_video_bus_add_fs(device
);
1827 init_MUTEX(&video
->sem
);
1828 INIT_LIST_HEAD(&video
->video_device_list
);
1830 acpi_video_bus_get_devices(video
, device
);
1831 acpi_video_bus_start_devices(video
);
1833 status
= acpi_install_notify_handler(device
->handle
,
1835 acpi_video_bus_notify
, video
);
1836 if (ACPI_FAILURE(status
)) {
1837 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
1838 "Error installing notify handler\n"));
1839 acpi_video_bus_stop_devices(video
);
1840 acpi_video_bus_put_devices(video
);
1841 kfree(video
->attached_array
);
1842 acpi_video_bus_remove_fs(device
);
1847 printk(KERN_INFO PREFIX
"%s [%s] (multi-head: %s rom: %s post: %s)\n",
1848 ACPI_VIDEO_DEVICE_NAME
, acpi_device_bid(device
),
1849 video
->flags
.multihead
? "yes" : "no",
1850 video
->flags
.rom
? "yes" : "no",
1851 video
->flags
.post
? "yes" : "no");
1860 static int acpi_video_bus_remove(struct acpi_device
*device
, int type
)
1862 acpi_status status
= 0;
1863 struct acpi_video_bus
*video
= NULL
;
1866 if (!device
|| !acpi_driver_data(device
))
1869 video
= acpi_driver_data(device
);
1871 acpi_video_bus_stop_devices(video
);
1873 status
= acpi_remove_notify_handler(video
->device
->handle
,
1875 acpi_video_bus_notify
);
1877 acpi_video_bus_put_devices(video
);
1878 acpi_video_bus_remove_fs(device
);
1880 kfree(video
->attached_array
);
1886 static int __init
acpi_video_init(void)
1892 acpi_dbg_level = 0xFFFFFFFF;
1893 acpi_dbg_layer = 0x08000000;
1896 acpi_video_dir
= proc_mkdir(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1897 if (!acpi_video_dir
)
1899 acpi_video_dir
->owner
= THIS_MODULE
;
1901 result
= acpi_bus_register_driver(&acpi_video_bus
);
1903 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1910 static void __exit
acpi_video_exit(void)
1913 acpi_bus_unregister_driver(&acpi_video_bus
);
1915 remove_proc_entry(ACPI_VIDEO_CLASS
, acpi_root_dir
);
1920 module_init(acpi_video_init
);
1921 module_exit(acpi_video_exit
);