Source
/*
* Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
* PCF50633 backlight device driver
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
struct pcf50633_bl {
struct pcf50633 *pcf;
struct backlight_device *bl;
unsigned int brightness;
unsigned int brightness_limit;
};
/*
* pcf50633_bl_set_brightness_limit
*
* Update the brightness limit for the pc50633 backlight. The actual brightness
* will not go above the limit. This is useful to limit power drain for example
* on low battery.
*
* @dev: Pointer to a pcf50633 device
* @limit: The brightness limit. Valid values are 0-63
*/
int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit)
{
struct pcf50633_bl *pcf_bl = platform_get_drvdata(pcf->bl_pdev);
if (!pcf_bl)
return -ENODEV;
pcf_bl->brightness_limit = limit & 0x3f;
backlight_update_status(pcf_bl->bl);
return 0;
}
static int pcf50633_bl_update_status(struct backlight_device *bl)
{
struct pcf50633_bl *pcf_bl = bl_get_data(bl);
unsigned int new_brightness;