root/linux-2.6/trunk/brightness.patch

Revision 608, 2.8 kB (checked in by free, 6 months ago)

Added brightness patch

  • drivers/acpi/video.c

    commit 38531e6fe51ad5c7dfe72e0e066b5f54bc1921cd
    Author: Matthew Garrett <mjg59@srcf.ucam.org>
    Date:   Wed Dec 26 02:03:26 2007 +0000
    
        ACPI: video: Rationalise ACPI backlight implementation
        
        The sysfs backlight class provides no mechanism for querying the
        acceptable brightness for a backlight. The ACPI spec states that values
        are only valid if they are reported as available by the firmware. Since
        we can't provide that information to userspace, instead collapse the
        range to the number of actual values that can be set.
        
        http://bugzilla.kernel.org/show_bug.cgi?id=9277
        
        Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
        Acked-by: Zhang Rui <rui.zhang@intel.com>
        Signed-off-by: Len Brown <len.brown@intel.com>
    
    diff --git drivers/acpi/video.c drivers/acpi/video.c
    index bd77e81..59639c9 100644
     
    292292static int acpi_video_get_brightness(struct backlight_device *bd) 
    293293{ 
    294294        unsigned long cur_level; 
     295        int i; 
    295296        struct acpi_video_device *vd = 
    296297                (struct acpi_video_device *)bl_get_data(bd); 
    297298        acpi_video_device_lcd_get_level_current(vd, &cur_level); 
    298         return (int) cur_level; 
     299        for (i = 2; i < vd->brightness->count; i++) { 
     300                if (vd->brightness->levels[i] == cur_level) 
     301                        /* The first two entries are special - see page 575 
     302                           of the ACPI spec 3.0 */ 
     303                        return i-2; 
     304        } 
     305        return 0; 
    299306} 
    300307 
    301308static int acpi_video_set_brightness(struct backlight_device *bd) 
    302309{ 
    303         int request_level = bd->props.brightness; 
     310        int request_level = bd->props.brightness+2; 
    304311        struct acpi_video_device *vd = 
    305312                (struct acpi_video_device *)bl_get_data(bd); 
    306         acpi_video_device_lcd_set_level(vd, request_level); 
     313        acpi_video_device_lcd_set_level(vd, 
     314                                        vd->brightness->levels[request_level]); 
    307315        return 0; 
    308316} 
    309317 
     
    652660        kfree(obj); 
    653661 
    654662        if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){ 
    655                 unsigned long tmp; 
    656663                static int count = 0; 
    657664                char *name; 
    658665                name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); 
     
    660667                        return; 
    661668 
    662669                sprintf(name, "acpi_video%d", count++); 
    663                 acpi_video_device_lcd_get_level_current(device, &tmp); 
    664670                device->backlight = backlight_device_register(name, 
    665671                        NULL, device, &acpi_backlight_ops); 
    666                 device->backlight->props.max_brightness = max_level; 
    667                 device->backlight->props.brightness = (int)tmp; 
     672                device->backlight->props.max_brightness = device->brightness->count-3; 
     673                device->backlight->props.brightness = acpi_video_get_brightness(device->backlight); 
    668674                backlight_update_status(device->backlight); 
    669675 
    670676                kfree(name); 
Note: See TracBrowser for help on using the browser.