Currently, all LED LPG devices will call lpg_{set,clear}_pbs_trigger()
when setting brightness regardless of if they support PPG and have PBS
triggers. Check if device supports PPG before setting/clearing PBS
triggers.
Fixes: 6ab1f766a80a ("leds: rgb: leds-qcom-lpg: Add support for PPG through single SDAM")
Fixes: 5e9ff626861a ("leds: rgb: leds-qcom-lpg: Include support for PPG with dedicated LUT SDAM")
Signed-off-by: Anjelique Melendez <[email protected]>
---
drivers/leds/rgb/leds-qcom-lpg.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index 9467c796bd04..e74b2ceed1c2 100644
--- a/drivers/leds/rgb/leds-qcom-lpg.c
+++ b/drivers/leds/rgb/leds-qcom-lpg.c
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2017-2022 Linaro Ltd
* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/bits.h>
#include <linux/bitfield.h>
@@ -254,6 +254,9 @@ static int lpg_clear_pbs_trigger(struct lpg *lpg, unsigned int lut_mask)
u8 val = 0;
int rc;
+ if (!lpg->lpg_chan_sdam)
+ return 0;
+
lpg->pbs_en_bitmap &= (~lut_mask);
if (!lpg->pbs_en_bitmap) {
rc = nvmem_device_write(lpg->lpg_chan_sdam, SDAM_REG_PBS_SEQ_EN, 1, &val);
@@ -276,6 +279,9 @@ static int lpg_set_pbs_trigger(struct lpg *lpg, unsigned int lut_mask)
u8 val = PBS_SW_TRIG_BIT;
int rc;
+ if (!lpg->lpg_chan_sdam)
+ return 0;
+
if (!lpg->pbs_en_bitmap) {
rc = nvmem_device_write(lpg->lpg_chan_sdam, SDAM_REG_PBS_SEQ_EN, 1, &val);
if (rc < 0)
--
2.34.1
Fix line wrapping style issues introduced in previous patches.
Signed-off-by: Anjelique Melendez <[email protected]>
---
drivers/leds/rgb/leds-qcom-lpg.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index e74b2ceed1c2..7c35b3ba09a3 100644
--- a/drivers/leds/rgb/leds-qcom-lpg.c
+++ b/drivers/leds/rgb/leds-qcom-lpg.c
@@ -620,6 +620,7 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
u8 val = 0, conf = 0, lut_offset = 0;
unsigned int hi_pause, lo_pause;
struct lpg *lpg = chan->lpg;
+ u16 addr;
if (!chan->ramp_enabled || chan->pattern_lo_idx == chan->pattern_hi_idx)
return;
@@ -640,17 +641,23 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
lo_idx += lut_offset;
}
- nvmem_device_write(lpg_chan_sdam, SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset, 1, &val);
- nvmem_device_write(lpg_chan_sdam, SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset, 1, &conf);
- nvmem_device_write(lpg_chan_sdam, SDAM_END_INDEX_OFFSET + chan->sdam_offset, 1, &hi_idx);
- nvmem_device_write(lpg_chan_sdam, SDAM_START_INDEX_OFFSET + chan->sdam_offset, 1, &lo_idx);
+ addr = SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset;
+ nvmem_device_write(lpg_chan_sdam, addr, 1, &val);
+ addr = SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset;
+ nvmem_device_write(lpg_chan_sdam, addr, 1, &conf);
+ addr = SDAM_END_INDEX_OFFSET + chan->sdam_offset;
+ nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_idx);
+ addr = SDAM_START_INDEX_OFFSET + chan->sdam_offset;
+ nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_idx);
val = RAMP_STEP_DURATION(chan->ramp_tick_ms);
nvmem_device_write(lpg_chan_sdam, SDAM_REG_RAMP_STEP_DURATION, 1, &val);
if (lpg->lut_sdam) {
- nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &hi_pause);
- nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &lo_pause);
+ addr = SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset;
+ nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_pause);
+ addr = SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset;
+ nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_pause);
}
}
--
2.34.1
On Thu, Jun 06, 2024 at 05:52:52PM -0700, Anjelique Melendez wrote:
> Fix line wrapping style issues introduced in previous patches.
I'd say this reduces readability of the patch.
>
> Signed-off-by: Anjelique Melendez <[email protected]>
> ---
> drivers/leds/rgb/leds-qcom-lpg.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index e74b2ceed1c2..7c35b3ba09a3 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -620,6 +620,7 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
> u8 val = 0, conf = 0, lut_offset = 0;
> unsigned int hi_pause, lo_pause;
> struct lpg *lpg = chan->lpg;
> + u16 addr;
>
> if (!chan->ramp_enabled || chan->pattern_lo_idx == chan->pattern_hi_idx)
> return;
> @@ -640,17 +641,23 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
> lo_idx += lut_offset;
> }
>
> - nvmem_device_write(lpg_chan_sdam, SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset, 1, &val);
> - nvmem_device_write(lpg_chan_sdam, SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset, 1, &conf);
> - nvmem_device_write(lpg_chan_sdam, SDAM_END_INDEX_OFFSET + chan->sdam_offset, 1, &hi_idx);
> - nvmem_device_write(lpg_chan_sdam, SDAM_START_INDEX_OFFSET + chan->sdam_offset, 1, &lo_idx);
> + addr = SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &val);
> + addr = SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &conf);
> + addr = SDAM_END_INDEX_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_idx);
> + addr = SDAM_START_INDEX_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_idx);
>
> val = RAMP_STEP_DURATION(chan->ramp_tick_ms);
> nvmem_device_write(lpg_chan_sdam, SDAM_REG_RAMP_STEP_DURATION, 1, &val);
>
> if (lpg->lut_sdam) {
> - nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &hi_pause);
> - nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &lo_pause);
> + addr = SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_pause);
> + addr = SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_pause);
> }
>
> }
> --
> 2.34.1
>
--
With best wishes
Dmitry
On Thu, Jun 06, 2024 at 05:52:52PM GMT, Anjelique Melendez wrote:
> Fix line wrapping style issues introduced in previous patches.
Bending the line length guidelines is okay when it results in easier to
read code. I find the existing code easier to read...
Regards,
Bjorn
>
> Signed-off-by: Anjelique Melendez <[email protected]>
> ---
> drivers/leds/rgb/leds-qcom-lpg.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index e74b2ceed1c2..7c35b3ba09a3 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -620,6 +620,7 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
> u8 val = 0, conf = 0, lut_offset = 0;
> unsigned int hi_pause, lo_pause;
> struct lpg *lpg = chan->lpg;
> + u16 addr;
>
> if (!chan->ramp_enabled || chan->pattern_lo_idx == chan->pattern_hi_idx)
> return;
> @@ -640,17 +641,23 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
> lo_idx += lut_offset;
> }
>
> - nvmem_device_write(lpg_chan_sdam, SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset, 1, &val);
> - nvmem_device_write(lpg_chan_sdam, SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset, 1, &conf);
> - nvmem_device_write(lpg_chan_sdam, SDAM_END_INDEX_OFFSET + chan->sdam_offset, 1, &hi_idx);
> - nvmem_device_write(lpg_chan_sdam, SDAM_START_INDEX_OFFSET + chan->sdam_offset, 1, &lo_idx);
> + addr = SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &val);
> + addr = SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &conf);
> + addr = SDAM_END_INDEX_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_idx);
> + addr = SDAM_START_INDEX_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_idx);
>
> val = RAMP_STEP_DURATION(chan->ramp_tick_ms);
> nvmem_device_write(lpg_chan_sdam, SDAM_REG_RAMP_STEP_DURATION, 1, &val);
>
> if (lpg->lut_sdam) {
> - nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &hi_pause);
> - nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &lo_pause);
> + addr = SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_pause);
> + addr = SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset;
> + nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_pause);
> }
>
> }
> --
> 2.34.1
>
On Thu, Jun 06, 2024 at 05:52:50PM GMT, Anjelique Melendez wrote:
> Currently, all LED LPG devices will call lpg_{set,clear}_pbs_trigger()
> when setting brightness regardless of if they support PPG and have PBS
> triggers. Check if device supports PPG before setting/clearing PBS
> triggers.
>
> Fixes: 6ab1f766a80a ("leds: rgb: leds-qcom-lpg: Add support for PPG through single SDAM")
> Fixes: 5e9ff626861a ("leds: rgb: leds-qcom-lpg: Include support for PPG with dedicated LUT SDAM")
> Signed-off-by: Anjelique Melendez <[email protected]>
Looks to align with sdam code paths.
Reviewed-by: Bjorn Andersson <[email protected]>
Regards,
Bjorn
> ---
> drivers/leds/rgb/leds-qcom-lpg.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 9467c796bd04..e74b2ceed1c2 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -2,7 +2,7 @@
> /*
> * Copyright (c) 2017-2022 Linaro Ltd
> * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
> - * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
> + * Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved.
> */
> #include <linux/bits.h>
> #include <linux/bitfield.h>
> @@ -254,6 +254,9 @@ static int lpg_clear_pbs_trigger(struct lpg *lpg, unsigned int lut_mask)
> u8 val = 0;
> int rc;
>
> + if (!lpg->lpg_chan_sdam)
> + return 0;
> +
> lpg->pbs_en_bitmap &= (~lut_mask);
> if (!lpg->pbs_en_bitmap) {
> rc = nvmem_device_write(lpg->lpg_chan_sdam, SDAM_REG_PBS_SEQ_EN, 1, &val);
> @@ -276,6 +279,9 @@ static int lpg_set_pbs_trigger(struct lpg *lpg, unsigned int lut_mask)
> u8 val = PBS_SW_TRIG_BIT;
> int rc;
>
> + if (!lpg->lpg_chan_sdam)
> + return 0;
> +
> if (!lpg->pbs_en_bitmap) {
> rc = nvmem_device_write(lpg->lpg_chan_sdam, SDAM_REG_PBS_SEQ_EN, 1, &val);
> if (rc < 0)
> --
> 2.34.1
>
On Fri, 07 Jun 2024, Bjorn Andersson wrote:
> On Thu, Jun 06, 2024 at 05:52:52PM GMT, Anjelique Melendez wrote:
> > Fix line wrapping style issues introduced in previous patches.
>
> Bending the line length guidelines is okay when it results in easier to
> read code. I find the existing code easier to read...
Agree. This patch is not going to be accepted.
> > Signed-off-by: Anjelique Melendez <[email protected]>
> > ---
> > drivers/leds/rgb/leds-qcom-lpg.c | 19 +++++++++++++------
> > 1 file changed, 13 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> > index e74b2ceed1c2..7c35b3ba09a3 100644
> > --- a/drivers/leds/rgb/leds-qcom-lpg.c
> > +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> > @@ -620,6 +620,7 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
> > u8 val = 0, conf = 0, lut_offset = 0;
> > unsigned int hi_pause, lo_pause;
> > struct lpg *lpg = chan->lpg;
> > + u16 addr;
> >
> > if (!chan->ramp_enabled || chan->pattern_lo_idx == chan->pattern_hi_idx)
> > return;
> > @@ -640,17 +641,23 @@ static void lpg_sdam_apply_lut_control(struct lpg_channel *chan)
> > lo_idx += lut_offset;
> > }
> >
> > - nvmem_device_write(lpg_chan_sdam, SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset, 1, &val);
> > - nvmem_device_write(lpg_chan_sdam, SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset, 1, &conf);
> > - nvmem_device_write(lpg_chan_sdam, SDAM_END_INDEX_OFFSET + chan->sdam_offset, 1, &hi_idx);
> > - nvmem_device_write(lpg_chan_sdam, SDAM_START_INDEX_OFFSET + chan->sdam_offset, 1, &lo_idx);
> > + addr = SDAM_PBS_SCRATCH_LUT_COUNTER_OFFSET + chan->sdam_offset;
> > + nvmem_device_write(lpg_chan_sdam, addr, 1, &val);
> > + addr = SDAM_PATTERN_CONFIG_OFFSET + chan->sdam_offset;
> > + nvmem_device_write(lpg_chan_sdam, addr, 1, &conf);
> > + addr = SDAM_END_INDEX_OFFSET + chan->sdam_offset;
> > + nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_idx);
> > + addr = SDAM_START_INDEX_OFFSET + chan->sdam_offset;
> > + nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_idx);
> >
> > val = RAMP_STEP_DURATION(chan->ramp_tick_ms);
> > nvmem_device_write(lpg_chan_sdam, SDAM_REG_RAMP_STEP_DURATION, 1, &val);
> >
> > if (lpg->lut_sdam) {
> > - nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &hi_pause);
> > - nvmem_device_write(lpg_chan_sdam, SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset, 1, &lo_pause);
> > + addr = SDAM_PAUSE_HI_MULTIPLIER_OFFSET + chan->sdam_offset;
> > + nvmem_device_write(lpg_chan_sdam, addr, 1, &hi_pause);
> > + addr = SDAM_PAUSE_LO_MULTIPLIER_OFFSET + chan->sdam_offset;
> > + nvmem_device_write(lpg_chan_sdam, addr, 1, &lo_pause);
> > }
> >
> > }
> > --
> > 2.34.1
> >
--
Lee Jones [李琼斯]
On Thu, 06 Jun 2024 17:52:50 -0700, Anjelique Melendez wrote:
> Currently, all LED LPG devices will call lpg_{set,clear}_pbs_trigger()
> when setting brightness regardless of if they support PPG and have PBS
> triggers. Check if device supports PPG before setting/clearing PBS
> triggers.
>
>
Applied, thanks!
[1/2] leds: rgb: leds-qcom-lpg: Add PPG check for setting/clearing PBS triggers
commit: bdd39a590cec198d4208ef4dd375971dbd079b5e
--
Lee Jones [李琼斯]