aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c100
1 files changed, 61 insertions, 39 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 56666a982476..eb5141f9ef8f 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org> 5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
6 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
6 * 7 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * 9 *
@@ -47,11 +48,11 @@
47#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 48#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
48#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 49#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
49 50
50#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82 51#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
51#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83 52#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
52#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84 53#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
53#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85 54#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
54#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86 55#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
55 56
56#define ACPI_VIDEO_HEAD_INVALID (~0u - 1) 57#define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
57#define ACPI_VIDEO_HEAD_END (~0u) 58#define ACPI_VIDEO_HEAD_END (~0u)
@@ -386,7 +387,7 @@ acpi_video_device_EDID(struct acpi_video_device *device,
386 if (ACPI_FAILURE(status)) 387 if (ACPI_FAILURE(status))
387 return -ENODEV; 388 return -ENODEV;
388 389
389 obj = (union acpi_object *)buffer.pointer; 390 obj = buffer.pointer;
390 391
391 if (obj && obj->type == ACPI_TYPE_BUFFER) 392 if (obj && obj->type == ACPI_TYPE_BUFFER)
392 *edid = obj; 393 *edid = obj;
@@ -654,8 +655,7 @@ static struct proc_dir_entry *acpi_video_dir;
654 655
655static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) 656static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
656{ 657{
657 struct acpi_video_device *dev = 658 struct acpi_video_device *dev = seq->private;
658 (struct acpi_video_device *)seq->private;
659 659
660 660
661 if (!dev) 661 if (!dev)
@@ -688,8 +688,7 @@ acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
688static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) 688static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
689{ 689{
690 int status; 690 int status;
691 struct acpi_video_device *dev = 691 struct acpi_video_device *dev = seq->private;
692 (struct acpi_video_device *)seq->private;
693 unsigned long state; 692 unsigned long state;
694 693
695 694
@@ -727,8 +726,8 @@ acpi_video_device_write_state(struct file *file,
727 size_t count, loff_t * data) 726 size_t count, loff_t * data)
728{ 727{
729 int status; 728 int status;
730 struct seq_file *m = (struct seq_file *)file->private_data; 729 struct seq_file *m = file->private_data;
731 struct acpi_video_device *dev = (struct acpi_video_device *)m->private; 730 struct acpi_video_device *dev = m->private;
732 char str[12] = { 0 }; 731 char str[12] = { 0 };
733 u32 state = 0; 732 u32 state = 0;
734 733
@@ -754,8 +753,7 @@ acpi_video_device_write_state(struct file *file,
754static int 753static int
755acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) 754acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
756{ 755{
757 struct acpi_video_device *dev = 756 struct acpi_video_device *dev = seq->private;
758 (struct acpi_video_device *)seq->private;
759 int i; 757 int i;
760 758
761 759
@@ -784,8 +782,8 @@ acpi_video_device_write_brightness(struct file *file,
784 const char __user * buffer, 782 const char __user * buffer,
785 size_t count, loff_t * data) 783 size_t count, loff_t * data)
786{ 784{
787 struct seq_file *m = (struct seq_file *)file->private_data; 785 struct seq_file *m = file->private_data;
788 struct acpi_video_device *dev = (struct acpi_video_device *)m->private; 786 struct acpi_video_device *dev = m->private;
789 char str[4] = { 0 }; 787 char str[4] = { 0 };
790 unsigned int level = 0; 788 unsigned int level = 0;
791 int i; 789 int i;
@@ -817,8 +815,7 @@ acpi_video_device_write_brightness(struct file *file,
817 815
818static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) 816static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
819{ 817{
820 struct acpi_video_device *dev = 818 struct acpi_video_device *dev = seq->private;
821 (struct acpi_video_device *)seq->private;
822 int status; 819 int status;
823 int i; 820 int i;
824 union acpi_object *edid = NULL; 821 union acpi_object *edid = NULL;
@@ -866,7 +863,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
866 if (!device) 863 if (!device)
867 return -ENODEV; 864 return -ENODEV;
868 865
869 vid_dev = (struct acpi_video_device *)acpi_driver_data(device); 866 vid_dev = acpi_driver_data(device);
870 if (!vid_dev) 867 if (!vid_dev)
871 return -ENODEV; 868 return -ENODEV;
872 869
@@ -931,7 +928,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
931{ 928{
932 struct acpi_video_device *vid_dev; 929 struct acpi_video_device *vid_dev;
933 930
934 vid_dev = (struct acpi_video_device *)acpi_driver_data(device); 931 vid_dev = acpi_driver_data(device);
935 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) 932 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
936 return -ENODEV; 933 return -ENODEV;
937 934
@@ -950,7 +947,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
950/* video bus */ 947/* video bus */
951static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset) 948static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
952{ 949{
953 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 950 struct acpi_video_bus *video = seq->private;
954 951
955 952
956 if (!video) 953 if (!video)
@@ -975,7 +972,7 @@ static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
975 972
976static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset) 973static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
977{ 974{
978 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 975 struct acpi_video_bus *video = seq->private;
979 976
980 977
981 if (!video) 978 if (!video)
@@ -995,7 +992,7 @@ static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
995 992
996static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) 993static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
997{ 994{
998 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 995 struct acpi_video_bus *video = seq->private;
999 unsigned long options; 996 unsigned long options;
1000 int status; 997 int status;
1001 998
@@ -1033,7 +1030,7 @@ acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1033 1030
1034static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) 1031static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1035{ 1032{
1036 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 1033 struct acpi_video_bus *video = seq->private;
1037 int status; 1034 int status;
1038 unsigned long id; 1035 unsigned long id;
1039 1036
@@ -1054,7 +1051,7 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1054 1051
1055static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) 1052static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1056{ 1053{
1057 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 1054 struct acpi_video_bus *video = seq->private;
1058 1055
1059 1056
1060 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); 1057 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
@@ -1079,8 +1076,8 @@ acpi_video_bus_write_POST(struct file *file,
1079 size_t count, loff_t * data) 1076 size_t count, loff_t * data)
1080{ 1077{
1081 int status; 1078 int status;
1082 struct seq_file *m = (struct seq_file *)file->private_data; 1079 struct seq_file *m = file->private_data;
1083 struct acpi_video_bus *video = (struct acpi_video_bus *)m->private; 1080 struct acpi_video_bus *video = m->private;
1084 char str[12] = { 0 }; 1081 char str[12] = { 0 };
1085 unsigned long opt, options; 1082 unsigned long opt, options;
1086 1083
@@ -1119,8 +1116,8 @@ acpi_video_bus_write_DOS(struct file *file,
1119 size_t count, loff_t * data) 1116 size_t count, loff_t * data)
1120{ 1117{
1121 int status; 1118 int status;
1122 struct seq_file *m = (struct seq_file *)file->private_data; 1119 struct seq_file *m = file->private_data;
1123 struct acpi_video_bus *video = (struct acpi_video_bus *)m->private; 1120 struct acpi_video_bus *video = m->private;
1124 char str[12] = { 0 }; 1121 char str[12] = { 0 };
1125 unsigned long opt; 1122 unsigned long opt;
1126 1123
@@ -1150,7 +1147,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1150 struct acpi_video_bus *video; 1147 struct acpi_video_bus *video;
1151 1148
1152 1149
1153 video = (struct acpi_video_bus *)acpi_driver_data(device); 1150 video = acpi_driver_data(device);
1154 1151
1155 if (!acpi_device_dir(device)) { 1152 if (!acpi_device_dir(device)) {
1156 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1153 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
@@ -1226,7 +1223,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device)
1226 struct acpi_video_bus *video; 1223 struct acpi_video_bus *video;
1227 1224
1228 1225
1229 video = (struct acpi_video_bus *)acpi_driver_data(device); 1226 video = acpi_driver_data(device);
1230 1227
1231 if (acpi_device_dir(device)) { 1228 if (acpi_device_dir(device)) {
1232 remove_proc_entry("info", acpi_device_dir(device)); 1229 remove_proc_entry("info", acpi_device_dir(device));
@@ -1403,7 +1400,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1403 return status; 1400 return status;
1404 } 1401 }
1405 1402
1406 dod = (union acpi_object *)buffer.pointer; 1403 dod = buffer.pointer;
1407 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { 1404 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1408 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data")); 1405 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
1409 status = -EFAULT; 1406 status = -EFAULT;
@@ -1426,7 +1423,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1426 1423
1427 count = 0; 1424 count = 0;
1428 for (i = 0; i < dod->package.count; i++) { 1425 for (i = 0; i < dod->package.count; i++) {
1429 obj = (union acpi_object *)&dod->package.elements[i]; 1426 obj = &dod->package.elements[i];
1430 1427
1431 if (obj->type != ACPI_TYPE_INTEGER) { 1428 if (obj->type != ACPI_TYPE_INTEGER) {
1432 printk(KERN_ERR PREFIX "Invalid _DOD data\n"); 1429 printk(KERN_ERR PREFIX "Invalid _DOD data\n");
@@ -1509,8 +1506,34 @@ static int
1509acpi_video_get_next_level(struct acpi_video_device *device, 1506acpi_video_get_next_level(struct acpi_video_device *device,
1510 u32 level_current, u32 event) 1507 u32 level_current, u32 event)
1511{ 1508{
1512 /*Fix me */ 1509 int min, max, min_above, max_below, i, l;
1513 return level_current; 1510 max = max_below = 0;
1511 min = min_above = 255;
1512 for (i = 0; i < device->brightness->count; i++) {
1513 l = device->brightness->levels[i];
1514 if (l < min)
1515 min = l;
1516 if (l > max)
1517 max = l;
1518 if (l < min_above && l > level_current)
1519 min_above = l;
1520 if (l > max_below && l < level_current)
1521 max_below = l;
1522 }
1523
1524 switch (event) {
1525 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
1526 return (level_current < max) ? min_above : min;
1527 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
1528 return (level_current < max) ? min_above : max;
1529 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
1530 return (level_current > min) ? max_below : min;
1531 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
1532 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
1533 return 0;
1534 default:
1535 return level_current;
1536 }
1514} 1537}
1515 1538
1516static void 1539static void
@@ -1612,7 +1635,7 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1612 1635
1613static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) 1636static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1614{ 1637{
1615 struct acpi_video_bus *video = (struct acpi_video_bus *)data; 1638 struct acpi_video_bus *video = data;
1616 struct acpi_device *device = NULL; 1639 struct acpi_device *device = NULL;
1617 1640
1618 printk("video bus notify\n"); 1641 printk("video bus notify\n");
@@ -1654,8 +1677,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1654 1677
1655static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) 1678static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1656{ 1679{
1657 struct acpi_video_device *video_device = 1680 struct acpi_video_device *video_device = data;
1658 (struct acpi_video_device *)data;
1659 struct acpi_device *device = NULL; 1681 struct acpi_device *device = NULL;
1660 1682
1661 1683
@@ -1757,7 +1779,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1757 if (!device || !acpi_driver_data(device)) 1779 if (!device || !acpi_driver_data(device))
1758 return -EINVAL; 1780 return -EINVAL;
1759 1781
1760 video = (struct acpi_video_bus *)acpi_driver_data(device); 1782 video = acpi_driver_data(device);
1761 1783
1762 acpi_video_bus_stop_devices(video); 1784 acpi_video_bus_stop_devices(video);
1763 1785