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.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index cd4fb7543a90..d7ff61c0d571 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -770,10 +770,12 @@ acpi_video_init_brightness(struct acpi_video_device *device)
770 * In this case, the first two elements in _BCL packages 770 * In this case, the first two elements in _BCL packages
771 * are also supported brightness levels that OS should take care of. 771 * are also supported brightness levels that OS should take care of.
772 */ 772 */
773 for (i = 2; i < count; i++) 773 for (i = 2; i < count; i++) {
774 if (br->levels[i] == br->levels[0] || 774 if (br->levels[i] == br->levels[0])
775 br->levels[i] == br->levels[1])
776 level_ac_battery++; 775 level_ac_battery++;
776 if (br->levels[i] == br->levels[1])
777 level_ac_battery++;
778 }
777 779
778 if (level_ac_battery < 2) { 780 if (level_ac_battery < 2) {
779 level_ac_battery = 2 - level_ac_battery; 781 level_ac_battery = 2 - level_ac_battery;
@@ -807,12 +809,19 @@ acpi_video_init_brightness(struct acpi_video_device *device)
807 br->flags._BCM_use_index = br->flags._BCL_use_index; 809 br->flags._BCM_use_index = br->flags._BCL_use_index;
808 810
809 /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ 811 /* _BQC uses INDEX while _BCL uses VALUE in some laptops */
810 br->curr = max_level; 812 br->curr = level_old = max_level;
813
814 if (!device->cap._BQC)
815 goto set_level;
816
811 result = acpi_video_device_lcd_get_level_current(device, &level_old); 817 result = acpi_video_device_lcd_get_level_current(device, &level_old);
812 if (result) 818 if (result)
813 goto out_free_levels; 819 goto out_free_levels;
814 820
815 result = acpi_video_device_lcd_set_level(device, br->curr); 821 /*
822 * Set the level to maximum and check if _BQC uses indexed value
823 */
824 result = acpi_video_device_lcd_set_level(device, max_level);
816 if (result) 825 if (result)
817 goto out_free_levels; 826 goto out_free_levels;
818 827
@@ -820,25 +829,19 @@ acpi_video_init_brightness(struct acpi_video_device *device)
820 if (result) 829 if (result)
821 goto out_free_levels; 830 goto out_free_levels;
822 831
823 if ((level != level_old) && !br->flags._BCM_use_index) { 832 br->flags._BQC_use_index = (level == max_level ? 0 : 1);
824 /* Note: 833
825 * This piece of code does not work correctly if the current 834 if (!br->flags._BQC_use_index)
826 * brightness levels is 0. 835 goto set_level;
827 * But I guess boxes that boot with such a dark screen are rare 836
828 * and no more code is needed to cover this specifial case. 837 if (br->flags._BCL_reversed)
829 */ 838 level_old = (br->count - 1) - level_old;
830 839 level_old = br->levels[level_old];
831 if (level_ac_battery != 2) { 840
832 /* 841set_level:
833 * For now, we don't support the _BCL like this: 842 result = acpi_video_device_lcd_set_level(device, level_old);
834 * 16, 15, 0, 1, 2, 3, ..., 14, 15, 16 843 if (result)
835 * because we may mess up the index returned by _BQC. 844 goto out_free_levels;
836 * Plus: we have not got a box like this.
837 */
838 ACPI_ERROR((AE_INFO, "_BCL not supported\n"));
839 }
840 br->flags._BQC_use_index = 1;
841 }
842 845
843 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 846 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
844 "found %d brightness levels\n", count - 2)); 847 "found %d brightness levels\n", count - 2));
@@ -2293,7 +2296,7 @@ static int __init acpi_video_init(void)
2293 return acpi_video_register(); 2296 return acpi_video_register();
2294} 2297}
2295 2298
2296static void __exit acpi_video_exit(void) 2299void __exit acpi_video_exit(void)
2297{ 2300{
2298 2301
2299 acpi_bus_unregister_driver(&acpi_video_bus); 2302 acpi_bus_unregister_driver(&acpi_video_bus);
@@ -2302,6 +2305,7 @@ static void __exit acpi_video_exit(void)
2302 2305
2303 return; 2306 return;
2304} 2307}
2308EXPORT_SYMBOL(acpi_video_exit);
2305 2309
2306module_init(acpi_video_init); 2310module_init(acpi_video_init);
2307module_exit(acpi_video_exit); 2311module_exit(acpi_video_exit);