Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 346384
b: refs/heads/master
c: 8cc9764
h: refs/heads/master
v: v3
  • Loading branch information
Kim, Milo authored and Linus Torvalds committed Dec 18, 2012
1 parent 75a14e0 commit ef50dbb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 05a5d4d2640dfe934ec78ba577dd21baccb11aa6
refs/heads/master: 8cc9764c9c7d01a6e2c3ddac8f0ac7716be01868
10 changes: 2 additions & 8 deletions trunk/Documentation/backlight/lp855x-driver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ For supporting platform specific data, the lp855x platform data can be used.
* mode : Brightness control mode. PWM or register based.
* device_control : Value of DEVICE CONTROL register.
* initial_brightness : Initial value of backlight brightness.
* pwm_data : Platform specific pwm generation functions.
* period_ns : Platform specific PWM period value. unit is nano.
Only valid when brightness is pwm input mode.
Functions should be implemented by PWM driver.
- pwm_set_intensity() : set duty of PWM
- pwm_get_intensity() : get current duty of PWM
* load_new_rom_data :
0 : use default configuration data
1 : update values of eeprom or eprom registers on loading driver
Expand Down Expand Up @@ -71,8 +68,5 @@ static struct lp855x_platform_data lp8556_pdata = {
.mode = PWM_BASED,
.device_control = PWM_CONFIG(LP8556),
.initial_brightness = INITIAL_BRT,
.pwm_data = {
.pwm_set_intensity = platform_pwm_set_intensity,
.pwm_get_intensity = platform_pwm_get_intensity,
},
.period_ns = 1000000,
};
37 changes: 26 additions & 11 deletions trunk/drivers/video/backlight/lp855x_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/platform_data/lp855x.h>
#include <linux/pwm.h>

/* Registers */
#define BRIGHTNESS_CTRL 0x00
Expand All @@ -36,6 +37,7 @@ struct lp855x {
struct device *dev;
struct mutex xfer_lock;
struct lp855x_platform_data *pdata;
struct pwm_device *pwm;
};

static int lp855x_read_byte(struct lp855x *lp, u8 reg, u8 *data)
Expand Down Expand Up @@ -121,6 +123,28 @@ static int lp855x_init_registers(struct lp855x *lp)
return ret;
}

static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
{
unsigned int period = lp->pdata->period_ns;
unsigned int duty = br * period / max_br;
struct pwm_device *pwm;

/* request pwm device with the consumer name */
if (!lp->pwm) {
pwm = devm_pwm_get(lp->dev, lp->chipname);
if (IS_ERR(pwm))
return;

lp->pwm = pwm;
}

pwm_config(lp->pwm, duty, period);
if (duty)
pwm_enable(lp->pwm);
else
pwm_disable(lp->pwm);
}

static int lp855x_bl_update_status(struct backlight_device *bl)
{
struct lp855x *lp = bl_get_data(bl);
Expand All @@ -130,12 +154,10 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
bl->props.brightness = 0;

if (mode == PWM_BASED) {
struct lp855x_pwm_data *pd = &lp->pdata->pwm_data;
int br = bl->props.brightness;
int max_br = bl->props.max_brightness;

if (pd->pwm_set_intensity)
pd->pwm_set_intensity(br, max_br);
lp855x_pwm_ctrl(lp, br, max_br);

} else if (mode == REGISTER_BASED) {
u8 val = bl->props.brightness;
Expand All @@ -150,14 +172,7 @@ static int lp855x_bl_get_brightness(struct backlight_device *bl)
struct lp855x *lp = bl_get_data(bl);
enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;

if (mode == PWM_BASED) {
struct lp855x_pwm_data *pd = &lp->pdata->pwm_data;
int max_br = bl->props.max_brightness;

if (pd->pwm_get_intensity)
bl->props.brightness = pd->pwm_get_intensity(max_br);

} else if (mode == REGISTER_BASED) {
if (mode == REGISTER_BASED) {
u8 val = 0;

lp855x_read_byte(lp, BRIGHTNESS_CTRL, &val);
Expand Down
9 changes: 2 additions & 7 deletions trunk/include/linux/platform_data/lp855x.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ enum lp8556_brightness_source {
LP8556_COMBINED2, /* pwm + i2c after the shaper block */
};

struct lp855x_pwm_data {
void (*pwm_set_intensity) (int brightness, int max_brightness);
int (*pwm_get_intensity) (int max_brightness);
};

struct lp855x_rom_data {
u8 addr;
u8 val;
Expand All @@ -105,7 +100,7 @@ struct lp855x_rom_data {
* @mode : brightness control by pwm or lp855x register
* @device_control : value of DEVICE CONTROL register
* @initial_brightness : initial value of backlight brightness
* @pwm_data : platform specific pwm generation functions.
* @period_ns : platform specific pwm period value. unit is nano.
Only valid when mode is PWM_BASED.
* @load_new_rom_data :
0 : use default configuration data
Expand All @@ -118,7 +113,7 @@ struct lp855x_platform_data {
enum lp855x_brightness_ctrl_mode mode;
u8 device_control;
int initial_brightness;
struct lp855x_pwm_data pwm_data;
unsigned int period_ns;
u8 load_new_rom_data;
int size_program;
struct lp855x_rom_data *rom_data;
Expand Down

0 comments on commit ef50dbb

Please sign in to comment.