* [PATCH RESEND v6] backlight: lp855x: Switch to atomic PWM API
@ 2022-07-14 21:53 ` Maíra Canal
0 siblings, 0 replies; 4+ messages in thread
From: Maíra Canal @ 2022-07-14 21:53 UTC (permalink / raw)
To: daniel.thompson, lee.jones, jingoohan1, thierry.reding, u.kleine-koenig
Cc: dri-devel, linux-fbdev, linux-kernel, linux-pwm, Maíra Canal
Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
replace it for the atomic PWM API.
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
---
V1 -> V2: Initialize variable and simplify conditional loop
V2 -> V3: Fix assignment of NULL variable
V3 -> V4: Replace division for pwm_set_relative_duty_cycle
V4 -> V5: Fix overwrite of state.period
V5 -> V6: Fix duty cycle rounding and set period outside conditional loop
---
drivers/video/backlight/lp855x_bl.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 2b9e2bbbb03e..fc02c5c16055 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -218,9 +218,8 @@ static int lp855x_configure(struct lp855x *lp)
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;
+ struct pwm_state state;
/* request pwm device with the consumer name */
if (!lp->pwm) {
@@ -230,18 +229,16 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
lp->pwm = pwm;
- /*
- * FIXME: pwm_apply_args() should be removed when switching to
- * the atomic PWM API.
- */
- pwm_apply_args(pwm);
+ pwm_init_state(lp->pwm, &state);
+ } else {
+ pwm_get_state(lp->pwm, &state);
}
- pwm_config(lp->pwm, duty, period);
- if (duty)
- pwm_enable(lp->pwm);
- else
- pwm_disable(lp->pwm);
+ state.period = lp->pdata->period_ns;
+ state.duty_cycle = div_u64(br * state.period, max_br);
+ state.enabled = state.duty_cycle;
+
+ pwm_apply_state(lp->pwm, &state);
}
static int lp855x_bl_update_status(struct backlight_device *bl)
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH RESEND v6] backlight: lp855x: Switch to atomic PWM API
@ 2022-07-14 21:53 ` Maíra Canal
0 siblings, 0 replies; 4+ messages in thread
From: Maíra Canal @ 2022-07-14 21:53 UTC (permalink / raw)
To: daniel.thompson, lee.jones, jingoohan1, thierry.reding, u.kleine-koenig
Cc: linux-pwm, linux-fbdev, linux-kernel, dri-devel, Maíra Canal
Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
replace it for the atomic PWM API.
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
---
V1 -> V2: Initialize variable and simplify conditional loop
V2 -> V3: Fix assignment of NULL variable
V3 -> V4: Replace division for pwm_set_relative_duty_cycle
V4 -> V5: Fix overwrite of state.period
V5 -> V6: Fix duty cycle rounding and set period outside conditional loop
---
drivers/video/backlight/lp855x_bl.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 2b9e2bbbb03e..fc02c5c16055 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -218,9 +218,8 @@ static int lp855x_configure(struct lp855x *lp)
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;
+ struct pwm_state state;
/* request pwm device with the consumer name */
if (!lp->pwm) {
@@ -230,18 +229,16 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
lp->pwm = pwm;
- /*
- * FIXME: pwm_apply_args() should be removed when switching to
- * the atomic PWM API.
- */
- pwm_apply_args(pwm);
+ pwm_init_state(lp->pwm, &state);
+ } else {
+ pwm_get_state(lp->pwm, &state);
}
- pwm_config(lp->pwm, duty, period);
- if (duty)
- pwm_enable(lp->pwm);
- else
- pwm_disable(lp->pwm);
+ state.period = lp->pdata->period_ns;
+ state.duty_cycle = div_u64(br * state.period, max_br);
+ state.enabled = state.duty_cycle;
+
+ pwm_apply_state(lp->pwm, &state);
}
static int lp855x_bl_update_status(struct backlight_device *bl)
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND v6] backlight: lp855x: Switch to atomic PWM API
2022-07-14 21:53 ` Maíra Canal
@ 2022-07-18 8:29 ` Lee Jones
-1 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2022-07-18 8:29 UTC (permalink / raw)
To: Maíra Canal
Cc: daniel.thompson, jingoohan1, thierry.reding, u.kleine-koenig,
dri-devel, linux-fbdev, linux-kernel, linux-pwm
On Thu, 14 Jul 2022, Maíra Canal wrote:
> Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
> replace it for the atomic PWM API.
>
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
> Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Nit: This should be chronological.
> ---
> V1 -> V2: Initialize variable and simplify conditional loop
> V2 -> V3: Fix assignment of NULL variable
> V3 -> V4: Replace division for pwm_set_relative_duty_cycle
> V4 -> V5: Fix overwrite of state.period
> V5 -> V6: Fix duty cycle rounding and set period outside conditional loop
> ---
> drivers/video/backlight/lp855x_bl.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
Applied, thanks.
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND v6] backlight: lp855x: Switch to atomic PWM API
@ 2022-07-18 8:29 ` Lee Jones
0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2022-07-18 8:29 UTC (permalink / raw)
To: Maíra Canal
Cc: linux-pwm, daniel.thompson, jingoohan1, linux-fbdev, dri-devel,
linux-kernel, thierry.reding, u.kleine-koenig
On Thu, 14 Jul 2022, Maíra Canal wrote:
> Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
> replace it for the atomic PWM API.
>
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
> Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Nit: This should be chronological.
> ---
> V1 -> V2: Initialize variable and simplify conditional loop
> V2 -> V3: Fix assignment of NULL variable
> V3 -> V4: Replace division for pwm_set_relative_duty_cycle
> V4 -> V5: Fix overwrite of state.period
> V5 -> V6: Fix duty cycle rounding and set period outside conditional loop
> ---
> drivers/video/backlight/lp855x_bl.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
Applied, thanks.
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-18 8:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 21:53 [PATCH RESEND v6] backlight: lp855x: Switch to atomic PWM API Maíra Canal
2022-07-14 21:53 ` Maíra Canal
2022-07-18 8:29 ` Lee Jones
2022-07-18 8:29 ` Lee Jones
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.