Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH v1 00/11] leds: st1202: Naming cleanups and pre-existing fixes
@ 2026-09-12 22:27 Manuel Fombuena
  2026-09-12 22:29 ` [PATCH v1 01/11] leds: st1202: Correct the name of the prescaler conversion helper Manuel Fombuena
                   ` (10 more replies)
  0 siblings, 11 replies; 23+ messages in thread
From: Manuel Fombuena @ 2026-09-12 22:27 UTC (permalink / raw)
  To: lee, pavel, vicentiu.galanopulo, linux-leds, linux-kernel

This series collects the issues identified during review of the two
previous ST1202 submissions, the pattern engine fix series and the
hardware-accelerated blink support:

https://lore.kernel.org/all/GV1PR08MB8497C0B898789BB73ACE6EE3C5F52@GV1PR08MB8497.eurprd08.prod.outlook.com/
https://lore.kernel.org/all/GV1PR08MB84974C7ACD911E66864C5008C5DA2@GV1PR08MB8497.eurprd08.prod.outlook.com/

Both left behind pre-existing problems that were out of scope at the
time and deferred to a follow-up. They are grouped here because they
share that origin, rather than being sent as a string of two and three
patch series.

Patches 1 to 4 are naming and readability only, with no functional
change; two of them address comments from the blink support review.
Patches 5 to 11 are fixes and carry Fixes tags.

Patch 5 is worth a note. The eight pattern duration registers are
chip-wide while the PWM registers are per-channel, so a channel can
inherit a sequencer timeline another channel programmed and then sit at
full brightness for the slots it never set up. It clears the channel's
own PWM for those slots rather than the shared durations, which would
have truncated a longer pattern still running elsewhere on the device.

Patches 6 and 7 belong together. Pattern brightness values were written
into the 12-bit PWM registers unscaled, so a step asking for full
brightness produced about 6% duty cycle; and the analog current register
was never programmed at all, so a channel whose current had been left at
zero stayed dark however bright the pattern. Together they make a
pattern step of N produce the same output as writing N to brightness,
which is what the documented hw_pattern range implies. Patch 7 takes the
current up in pattern_set() and releases it in pattern_clear(), so a
rejected hw_pattern write cannot leave a channel latched on, and a board
declaring a lower ceiling through max-brightness keeps it.

Patch 9 is the one worth the most attention. st1202_brightness_set()
takes a mutex and performs I2C transfers while installed as the
non-blocking brightness_set callback, so it can sleep in atomic context.
brightness_set_blocking is installed as well, but the core only falls
back to it when brightness_set is absent, and that callback ignored the
requested brightness in any case. Neither can be fixed without the other.

Patches 10 and 11 do for st1202_blink_set() what patches 5 and 7 do for
the pattern path.

blink_set() programs only the two slots its on and off cycle needs, and
leaves the other six at full scale. Those six are normally invisible
because their duration registers are zero. Durations are shared across
the chip, though, so another channel can set them again, and the
blinking channel then lights during steps it never programmed. This was
reproduced on hardware by blinking one channel and giving a second one a
four step pattern.

blink_set() also drives the current register to full scale, ignoring a
lower ceiling from the max-brightness property. Patch 11 makes it use
the same value the brightness and pattern paths already use.

Two points raised in earlier reviews are deliberately left alone:

  - brightness_set() programming every PWM slot to full scale, and so
    overriding a running pattern, is intended. It is what makes the
    brightness visible while the global sequencer runs, per
    commit 7cbe470366bd ("leds: st1202: Fix brightness having no effect
    while pattern mode is active"). Stopping the sequencer instead would
    halt the patterns of every other channel.

  - Only the pattern timing is shared; the per-channel PWM envelopes are
    independent, and running patterns on several channels at once is
    what the hardware is designed for. A channel whose pattern is
    shorter than the active timeline therefore keeps the longer period.
    Correcting that needs the driver to track sequencer usage across
    channels, which is outside the scope of this series.

Tested on LED1202 hardware over I2C, on a Linksys MX4200v2 router
running OpenWrt: brightness values reaching the current register, the
atomic-context path via the heartbeat trigger, hw_pattern on two
channels of one device with different pattern lengths, a pattern
programmed on a channel whose current had been left at zero, timer
trigger delay quantisation, and driver unbind/rebind cycles for the
firmware node reference counting. dmesg clean throughout.

Patch 6 was additionally checked at the register level with i2cget. Left
unscaled, a pattern step asking for full brightness programs 0x0FF of a
12-bit register, 6.25% duty cycle; with the patch it programs 0x0FFF.
The datasheet (DS12875 rev 2, Table 7) confirms the PWM register pair is
a plain little endian 12-bit value, low byte followed by the high
nibble. Its helper scales against max_brightness, clamps both ends of a
signed input, and guards the division, although the LED core never
registers a zero max_brightness.

Manuel Fombuena (11):
  leds: st1202: Correct the name of the prescaler conversion helper
  leds: st1202: Spell out the phase-shift configuration bit
  leds: st1202: Name pattern index variables consistently
  leds: st1202: Use u8 consistently for 8-bit values
  leds: st1202: Clear unused pattern slots in pattern_set()
  leds: st1202: Scale pattern brightness to the 12-bit PWM range
  leds: st1202: Program the channel current for hardware patterns
  leds: st1202: Take a reference on the LED firmware node
  leds: st1202: Do not set brightness from atomic context
  leds: st1202: Clear unused pattern slots in blink_set()
  leds: st1202: Honour max_brightness when blinking

 Documentation/leds/leds-st1202.rst |   3 +
 drivers/leds/leds-st1202.c         | 145 +++++++++++++++++++----------
 2 files changed, 101 insertions(+), 47 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-09-12 22:55 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-12 22:27 [PATCH v1 00/11] leds: st1202: Naming cleanups and pre-existing fixes Manuel Fombuena
2026-09-12 22:29 ` [PATCH v1 01/11] leds: st1202: Correct the name of the prescaler conversion helper Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:30 ` [PATCH v1 02/11] leds: st1202: Spell out the phase-shift configuration bit Manuel Fombuena
2026-09-12 22:50   ` sashiko-bot
2026-09-12 22:31 ` [PATCH v1 03/11] leds: st1202: Name pattern index variables consistently Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:32 ` [PATCH v1 04/11] leds: st1202: Use u8 consistently for 8-bit values Manuel Fombuena
2026-09-12 22:46   ` sashiko-bot
2026-09-12 22:34 ` [PATCH v1 05/11] leds: st1202: Clear unused pattern slots in pattern_set() Manuel Fombuena
2026-09-12 22:52   ` sashiko-bot
2026-09-12 22:35 ` [PATCH v1 06/11] leds: st1202: Scale pattern brightness to the 12-bit PWM range Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:36 ` [PATCH v1 07/11] leds: st1202: Program the channel current for hardware patterns Manuel Fombuena
2026-09-12 22:49   ` sashiko-bot
2026-09-12 22:37 ` [PATCH v1 08/11] leds: st1202: Take a reference on the LED firmware node Manuel Fombuena
2026-09-12 22:47   ` sashiko-bot
2026-09-12 22:38 ` [PATCH v1 09/11] leds: st1202: Do not set brightness from atomic context Manuel Fombuena
2026-09-12 22:46   ` sashiko-bot
2026-09-12 22:39 ` [PATCH v1 10/11] leds: st1202: Clear unused pattern slots in blink_set() Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:40 ` [PATCH v1 11/11] leds: st1202: Honour max_brightness when blinking Manuel Fombuena
2026-09-12 22:55   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox