* [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 @ 2012-01-25 1:51 Kim, Milo 2012-01-25 7:52 ` Lars-Peter Clausen 0 siblings, 1 reply; 4+ messages in thread From: Kim, Milo @ 2012-01-25 1:51 UTC (permalink / raw) To: Linus Walleij, Lars-Peter Clausen Cc: shreshthakumar.sahu@stericsson.com, linux-kernel@vger.kernel.org, rpurdie@rpsys.net Only 7 bits are used for the brightness. (register address : A0h) So the max_brightness property of lm3530 should be set to 127. On initializing registers, maximum initial brightness is limited to 'max_brightness'. Division-by-two is removed on updating the value of brightness. This arithmetic is not necessary because the range of brightness is 0 ~ 127. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> --- drivers/leds/leds-lm3530.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index a7f24f7..7005a5f 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -153,11 +153,11 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) u8 als_imp_sel = 0; u8 brightness; u8 reg_val[LM3530_REG_MAX]; - struct lm3530_platform_data *pdata = drvdata->pdata; + struct lm3530_platform_data *pltfm = drvdata->pdata; struct i2c_client *client = drvdata->client; - gen_config = (pdata->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | - ((pdata->max_current & 7) << LM3530_MAX_CURR_SHIFT); + gen_config = (pltfm->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | + ((pltfm->max_current & 7) << LM3530_MAX_CURR_SHIFT); if (drvdata->mode == LM3530_BL_MODE_MANUAL || drvdata->mode == LM3530_BL_MODE_ALS) @@ -165,27 +165,27 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) if (drvdata->mode == LM3530_BL_MODE_ALS) { als_config = - (pdata->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | + (pltfm->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | (LM3530_ENABLE_ALS) | - (pdata->als_input_mode << LM3530_ALS_SEL_SHIFT); + (pltfm->als_input_mode << LM3530_ALS_SEL_SHIFT); als_imp_sel = - (pdata->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | - (pdata->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); + (pltfm->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | + (pltfm->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); } if (drvdata->mode == LM3530_BL_MODE_PWM) gen_config |= (LM3530_ENABLE_PWM) | - (pdata->pwm_pol_hi << LM3530_PWM_POL_SHIFT) | + (pltfm->pwm_pol_hi << LM3530_PWM_POL_SHIFT) | (LM3530_ENABLE_PWM_SIMPLE); - brt_ramp = (pdata->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) | - (pdata->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT); + brt_ramp = (pltfm->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) | + (pltfm->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT); if (drvdata->brightness) brightness = drvdata->brightness; else - brightness = drvdata->brightness = pdata->brt_val; + brightness = drvdata->brightness = pltfm->brt_val; if (brightness > drvdata->led_dev.max_brightness) brightness = drvdata->led_dev.max_brightness; -- 1.7.4.1 Best Regards, Milo (Woogyom) Kim Texas Instruments Incorporated ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 2012-01-25 1:51 [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 Kim, Milo @ 2012-01-25 7:52 ` Lars-Peter Clausen 2012-01-25 9:40 ` Kim, Milo 0 siblings, 1 reply; 4+ messages in thread From: Lars-Peter Clausen @ 2012-01-25 7:52 UTC (permalink / raw) To: Kim, Milo Cc: Linus Walleij, shreshthakumar.sahu@stericsson.com, linux-kernel@vger.kernel.org, rpurdie@rpsys.net On 01/25/2012 02:51 AM, Kim, Milo wrote: > Only 7 bits are used for the brightness. (register address : A0h) > So the max_brightness property of lm3530 should be set to 127. > > On initializing registers, maximum initial brightness is limited to 'max_brightness'. > > Division-by-two is removed on updating the value of brightness. > This arithmetic is not necessary because the range of brightness is 0 ~ 127. > > Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> > --- > drivers/leds/leds-lm3530.c | 22 +++++++++++----------- > 1 files changed, 11 insertions(+), 11 deletions(-) > Looks like something went wrong, this is the same patch as 2/2 > diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c > index a7f24f7..7005a5f 100644 > --- a/drivers/leds/leds-lm3530.c > +++ b/drivers/leds/leds-lm3530.c > @@ -153,11 +153,11 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) > u8 als_imp_sel = 0; > u8 brightness; > u8 reg_val[LM3530_REG_MAX]; > - struct lm3530_platform_data *pdata = drvdata->pdata; > + struct lm3530_platform_data *pltfm = drvdata->pdata; > struct i2c_client *client = drvdata->client; > > - gen_config = (pdata->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | > - ((pdata->max_current & 7) << LM3530_MAX_CURR_SHIFT); > + gen_config = (pltfm->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | > + ((pltfm->max_current & 7) << LM3530_MAX_CURR_SHIFT); > > if (drvdata->mode == LM3530_BL_MODE_MANUAL || > drvdata->mode == LM3530_BL_MODE_ALS) > @@ -165,27 +165,27 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) > > if (drvdata->mode == LM3530_BL_MODE_ALS) { > als_config = > - (pdata->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | > + (pltfm->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | > (LM3530_ENABLE_ALS) | > - (pdata->als_input_mode << LM3530_ALS_SEL_SHIFT); > + (pltfm->als_input_mode << LM3530_ALS_SEL_SHIFT); > > als_imp_sel = > - (pdata->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | > - (pdata->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); > + (pltfm->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | > + (pltfm->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); > } > > if (drvdata->mode == LM3530_BL_MODE_PWM) > gen_config |= (LM3530_ENABLE_PWM) | > - (pdata->pwm_pol_hi << LM3530_PWM_POL_SHIFT) | > + (pltfm->pwm_pol_hi << LM3530_PWM_POL_SHIFT) | > (LM3530_ENABLE_PWM_SIMPLE); > > - brt_ramp = (pdata->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) | > - (pdata->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT); > + brt_ramp = (pltfm->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) | > + (pltfm->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT); > > if (drvdata->brightness) > brightness = drvdata->brightness; > else > - brightness = drvdata->brightness = pdata->brt_val; > + brightness = drvdata->brightness = pltfm->brt_val; > > if (brightness > drvdata->led_dev.max_brightness) > brightness = drvdata->led_dev.max_brightness; ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 2012-01-25 7:52 ` Lars-Peter Clausen @ 2012-01-25 9:40 ` Kim, Milo 2012-01-26 11:53 ` Linus Walleij 0 siblings, 1 reply; 4+ messages in thread From: Kim, Milo @ 2012-01-25 9:40 UTC (permalink / raw) To: Lars-Peter Clausen Cc: Linus Walleij, shreshthakumar.sahu@stericsson.com, linux-kernel@vger.kernel.org, rpurdie@rpsys.net Only 7 bits are used for the brightness. (register address : A0h) So the max_brightness property of lm3530 should be set to 127. On initializing registers, maximum initial brightness is limited to 'max_brightness'. Division-by-two is removed on updating the value of brightness. This arithmetic is not necessary because the range of brightness is 0 ~ 127. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> --- drivers/leds/leds-lm3530.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index 4d7ce76..7005a5f 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -80,6 +80,9 @@ #define LM3530_DEF_ZT_3 (0x66) #define LM3530_DEF_ZT_4 (0x7F) +/* 7 bits are used for the brightness : LM3530_BRT_CTRL_REG */ +#define MAX_BRIGHTNESS (127) + struct lm3530_mode_map { const char *mode; enum lm3530_mode mode_val; @@ -184,6 +187,9 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) else brightness = drvdata->brightness = pltfm->brt_val; + if (brightness > drvdata->led_dev.max_brightness) + brightness = drvdata->led_dev.max_brightness; + reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */ reg_val[1] = als_config; /* LM3530_ALS_CONFIG */ reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */ @@ -241,12 +247,12 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev, /* set the brightness in brightness control register*/ err = i2c_smbus_write_byte_data(drvdata->client, - LM3530_BRT_CTRL_REG, brt_val / 2); + LM3530_BRT_CTRL_REG, brt_val); if (err) dev_err(&drvdata->client->dev, "Unable to set brightness: %d\n", err); else - drvdata->brightness = brt_val / 2; + drvdata->brightness = brt_val; if (brt_val == 0) { err = regulator_disable(drvdata->regulator); @@ -340,6 +346,7 @@ static int __devinit lm3530_probe(struct i2c_client *client, drvdata->enable = false; drvdata->led_dev.name = LM3530_LED_DEV; drvdata->led_dev.brightness_set = lm3530_brightness_set; + drvdata->led_dev.max_brightness = MAX_BRIGHTNESS; i2c_set_clientdata(client, drvdata); -- 1.7.4.1 Best Regards, Milo (Woogyom) Kim -----Original Message----- From: Lars-Peter Clausen [mailto:lars@metafoo.de] Sent: Wednesday, January 25, 2012 4:53 PM To: Kim, Milo Cc: Linus Walleij; shreshthakumar.sahu@stericsson.com; linux-kernel@vger.kernel.org; rpurdie@rpsys.net Subject: Re: [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 On 01/25/2012 02:51 AM, Kim, Milo wrote: >> Only 7 bits are used for the brightness. (register address : A0h) >> So the max_brightness property of lm3530 should be set to 127. >> >> On initializing registers, maximum initial brightness is limited to 'max_brightness'. >> >> Division-by-two is removed on updating the value of brightness. >> This arithmetic is not necessary because the range of brightness is 0 ~ 127. >> >> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> >> --- >> drivers/leds/leds-lm3530.c | 22 +++++++++++----------- >> 1 files changed, 11 insertions(+), 11 deletions(-) >> > Looks like something went wrong, this is the same patch as 2/2 Sorry for confusing you. Wrong patch was sent. Best Regards, Milo - ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 2012-01-25 9:40 ` Kim, Milo @ 2012-01-26 11:53 ` Linus Walleij 0 siblings, 0 replies; 4+ messages in thread From: Linus Walleij @ 2012-01-26 11:53 UTC (permalink / raw) To: Kim, Milo Cc: Lars-Peter Clausen, shreshthakumar.sahu@stericsson.com, linux-kernel@vger.kernel.org, rpurdie@rpsys.net On Wed, Jan 25, 2012 at 10:40 AM, Kim, Milo <Milo.Kim@ti.com> wrote: > Only 7 bits are used for the brightness. (register address : A0h) > So the max_brightness property of lm3530 should be set to 127. > > On initializing registers, maximum initial brightness is limited to 'max_brightness'. > > Division-by-two is removed on updating the value of brightness. > This arithmetic is not necessary because the range of brightness is 0 ~ 127. > > Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> On *this* exact patch. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-26 11:53 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-01-25 1:51 [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127 Kim, Milo 2012-01-25 7:52 ` Lars-Peter Clausen 2012-01-25 9:40 ` Kim, Milo 2012-01-26 11:53 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox