mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manuel Fombuena <fombuena@outlook.com>
To: lee@kernel.org, pavel@kernel.org,
	vicentiu.galanopulo@remote-tech.co.uk,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 4/9] leds: st1202: restore Pattern0 PWM to full on after clearing pattern
Date: Thu, 18 Jun 2026 21:35:39 +0100	[thread overview]
Message-ID: <GV1PR08MB8497BE987FFEFFD1EFB0BA36C5E32@GV1PR08MB8497.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <GV1PR08MB8497ABC8E6AEFF8AAA1AF883C5E32@GV1PR08MB8497.eurprd08.prod.outlook.com>

When PATS is cleared the LED output is the product of the ILED analog
current register and the Pattern0 PWM duty cycle. brightness_set only
writes the ILED register, so if Pattern0 PWM is zero the LED remains
dark regardless of the brightness value set.

pattern_clear zeros all pattern PWM registers including Pattern0, which
means any subsequent brightness_set call has no visible effect until a
new pattern is programmed.

Restore Pattern0 PWM to full duty cycle after clearing so that ILED
alone controls brightness in static mode.

Signed-off-by: Manuel Fombuena <fombuena@outlook.com>
Assisted-by: Claude:claude-sonnet-4-6
---
 drivers/leds/leds-st1202.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index b4adade49898..b32d8e716372 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -35,6 +35,7 @@
 #define ST1202_MILLIS_PATTERN_DUR_MIN      22
 #define ST1202_PATTERN_DUR                 0x16
 #define ST1202_PATTERN_PWM                 0x1E
+#define ST1202_PATTERN_PWM_FULL            0x0FFF
 #define ST1202_PATTERN_REP                 0x15
 
 struct st1202_led {
@@ -204,7 +205,15 @@ static int st1202_led_pattern_clear(struct led_classdev *ldev)
 	if (ret != 0)
 		return ret;
 
-	for (int patt = 0; patt < ST1202_MAX_PATTERNS; patt++) {
+	ret = st1202_pwm_pattern_write(chip, led->led_num, 0, ST1202_PATTERN_PWM_FULL);
+	if (ret != 0)
+		return ret;
+
+	ret = st1202_write_reg(chip, ST1202_PATTERN_DUR, 0);
+	if (ret != 0)
+		return ret;
+
+	for (int patt = 1; patt < ST1202_MAX_PATTERNS; patt++) {
 		ret = st1202_pwm_pattern_write(chip, led->led_num, patt, LED_OFF);
 		if (ret != 0)
 			return ret;
-- 
2.54.0


  parent reply	other threads:[~2026-06-18 20:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 20:28 [PATCH v5 0/9] leds: st1202: fix multiple bugs in pattern engine and brightness handling Manuel Fombuena
2026-06-18 20:31 ` [PATCH v5 1/9] leds: st1202: stop pattern sequence before reprogramming Manuel Fombuena
2026-06-18 20:32 ` [PATCH v5 2/9] leds: st1202: validate pattern input before stopping the sequence Manuel Fombuena
2026-06-18 20:34 ` [PATCH v5 3/9] leds: st1202: fix pattern duration prescaler and pattern_clear skip marker Manuel Fombuena
2026-06-18 20:35 ` Manuel Fombuena [this message]
2026-06-18 20:37 ` [PATCH v5 5/9] leds: st1202: fix spurious pattern sequence start in setup Manuel Fombuena
2026-06-18 20:38 ` [PATCH v5 6/9] leds: st1202: fix brightness having no effect while pattern mode is active Manuel Fombuena
2026-06-18 20:39 ` [PATCH v5 7/9] leds: st1202: disable channel when brightness is set to zero Manuel Fombuena
2026-06-18 20:40 ` [PATCH v5 8/9] leds: st1202: validate LED reg property against channel count Manuel Fombuena
2026-06-18 20:42 ` [PATCH v5 9/9] leds: st1202: correct and extend hw_pattern documentation Manuel Fombuena
2026-07-02 13:56 ` [PATCH v5 0/9] leds: st1202: fix multiple bugs in pattern engine and brightness handling Lee Jones
2026-07-02 17:51   ` Manuel Fombuena

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=GV1PR08MB8497BE987FFEFFD1EFB0BA36C5E32@GV1PR08MB8497.eurprd08.prod.outlook.com \
    --to=fombuena@outlook.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=vicentiu.galanopulo@remote-tech.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox