Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 296857
b: refs/heads/master
c: 1efc158
h: refs/heads/master
i:
  296855: 65cae13
v: v3
  • Loading branch information
Jett.Zhou authored and Samuel Ortiz committed Mar 6, 2012
1 parent b5cf3d8 commit 0c8ca0a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 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: 78258064747a5d4570400955b1ad55d5d13909e4
refs/heads/master: 1efc15812d8ce5d9096bb8af400f51a85b5f5af0
49 changes: 28 additions & 21 deletions trunk/drivers/video/backlight/88pm860x_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ static inline int wled_idc(int port)
return ret;
}

static int backlight_power_set(struct pm860x_chip *chip, int port,
int on)
{
int ret = -EINVAL;

switch (port) {
case PM8606_BACKLIGHT1:
ret = on ? pm8606_osc_enable(chip, WLED1_DUTY) :
pm8606_osc_disable(chip, WLED1_DUTY);
break;
case PM8606_BACKLIGHT2:
ret = on ? pm8606_osc_enable(chip, WLED2_DUTY) :
pm8606_osc_disable(chip, WLED2_DUTY);
break;
case PM8606_BACKLIGHT3:
ret = on ? pm8606_osc_enable(chip, WLED3_DUTY) :
pm8606_osc_disable(chip, WLED3_DUTY);
break;
}
return ret;
}

static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
{
struct pm860x_backlight_data *data = bl_get_data(bl);
Expand All @@ -79,6 +101,9 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
else
value = brightness;

if (brightness)
backlight_power_set(chip, data->port, 1);

ret = pm860x_reg_write(data->i2c, wled_a(data->port), value);
if (ret < 0)
goto out;
Expand Down Expand Up @@ -115,6 +140,9 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
if (ret < 0)
goto out;

if (brightness == 0)
backlight_power_set(chip, data->port, 0);

dev_dbg(chip->dev, "set brightness %d\n", value);
data->current_brightness = value;
return 0;
Expand Down Expand Up @@ -170,7 +198,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
struct backlight_device *bl;
struct resource *res;
struct backlight_properties props;
unsigned char value;
char name[MFD_NAME_SIZE];
int ret;

Expand Down Expand Up @@ -218,26 +245,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, bl);

/* Enable reference VSYS */
ret = pm860x_reg_read(data->i2c, PM8606_VSYS);
if (ret < 0)
goto out;
if ((ret & PM8606_VSYS_EN) == 0) {
value = ret | PM8606_VSYS_EN;
ret = pm860x_reg_write(data->i2c, PM8606_VSYS, value);
if (ret < 0)
goto out;
}
/* Enable reference OSC */
ret = pm860x_reg_read(data->i2c, PM8606_MISC);
if (ret < 0)
goto out;
if ((ret & PM8606_MISC_OSC_EN) == 0) {
value = ret | PM8606_MISC_OSC_EN;
ret = pm860x_reg_write(data->i2c, PM8606_MISC, value);
if (ret < 0)
goto out;
}
/* read current backlight */
ret = pm860x_backlight_get_brightness(bl);
if (ret < 0)
Expand Down

0 comments on commit 0c8ca0a

Please sign in to comment.