Skip to content

drm/panel: samsung-s6e3fc3: local high brightness mode for the Pixel 7's fingerprint sensor - #263

Open
angelrenefm wants to merge 6 commits into
derekross:omamobilefrom
angelrenefm:pr/s6e3fc3-lhbm-v2
Open

angelrenefm wants to merge 6 commits into
derekross:omamobilefrom
angelrenefm:pr/s6e3fc3-lhbm-v2

Conversation

@angelrenefm

@angelrenefm angelrenefm commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

As you suggested on omarchy-mobile#813: the local HBM commit from my fork's panther-lhbm, so the next kernel push
keeps it.

It adds local_hbm_mode and local_hbm_max_timeout to the S6E3FC3's backlight device, with the same interface as
the S6E3HC4 driver on the Pixel 7 Pro, so one fingerprint userspace drives both panels. Turning it on is refused
unless the allow_lhbm module parameter is set. The commands are from Google's GPL driver; the commit message
names each function.

It's stacked on #181. It needs that PR's "support sleep and a cold restart from KMS", so this branch carries
#181's five commits under the one commit for review. The diff that counts is the last commit only. Once #181
merges I'll rebase with --onto so it carries this commit alone.

Your two review points are folded into the one commit: remove() turns LHBM off under the lock and refuses it
from then on, and the timeout only turns off the session whose deadline has passed.

On #181's head it passes tools/kernel-pr-check --build OUT db288b74f: 1 commit signed off, checkpatch --strict
with 0 warnings, W=1 build of panel-samsung-s6e3fc3.c. This commit touches only the panel driver.

Tested on a Pixel 7 on 17 Nov with this commit's exact panel-samsung-s6e3fc3.c, as a module with
allow_lhbm=1: the circle lit over the sensor and went off by itself about 3.1 s later, three times running.
When the screen blanked mid-session the circle went off with it, and turning it on with the screen off was
refused (EPERM). Not tested: its timing against the fingerprint HAL.

I used AI help (Claude) to work on this.

Mark a panel taken over from the bootloader as prepared and enabled, so
drm_panel_disable() and drm_panel_unprepare() reach it, and track whether
it is out of reset and sleep. While it is not, backlight updates only
record the new state (drm_panel_enable() applies it through
backlight_enable()). prepare() leaves the display off, which the reset
does. Take the panel's lock in prepare/enable/disable/unprepare and in
backlight updates, so their command sequences don't interleave.

This follows the same change to the S6E3HC4 driver, for the Pixel 7
Pro, and lets gs-decon put the Pixel 7's panel to sleep with the screen
off.

Tested on a Pixel 7 from slot B (7.3.0-rc6), with gs-decon driving the
screen: with gs_decon.screen_off=2, DPMS off put the panel to sleep and
DPMS on woke it through the cold init (reset, the vendor init at 60 Hz,
TE2 and DSC) with the picture correct; the power key's lock turned the
screen off and a tap brought it back. No DSIM errors.

Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
Add the timers the Pixel 7's bootloader leaves on DSIM0 for its S6E3FC3
P10 panel at 60 Hz (UNDERRUN_CTRL 0x1cf8, CMD_TE_CTRL1 0x2a82306d, read
on the phone), so gs-decon gets the link and the panel and can put the
panel to sleep with the screen off. The set has no second rate: the
panel's 90 Hz has no timers yet, so the link is never switched.

Tested on a Pixel 7 from slot B (7.3.0-rc6): the driver logs "link
timers for 60 Hz", and gs-decon takes the link and puts the panel to
sleep and wakes it with the screen off.

Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
gs201 offered only the Pixel 7 Pro's 1440x3120 modes and refused to run
when the bootloader scanned out any other size. Give each SoC a list of
mode sets, one per panel, and pick the one whose first mode matches the
size the bootloader left, which the probe already reads. Add the Pixel
7's S6E3FC3 P10 at 1080x2400 and 60 Hz, with the timings of Google's
panel driver; its 90 Hz mode comes with the link timers for it.

Tested on a Pixel 7 from slot B (7.3.0-rc6), with the padded-row change
on top: gs-decon binds on the 1080x2400 set, counts frame starts at
60.02 Hz, and Hyprland runs on it at 1080x2400@60 with no flip
timeouts. The Pixel 6 Pro's, 7 Pro's, 8 Pro's and 9a's sets are
unchanged: one set each.

Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
gs-decon on gs201 took only framebuffers with the boot framebuffer's
pitch. On the Pixel 7, whose DECON0 the next commit enables,
Hyprland's buffers for the 1080x2400 panel have a 4352-byte pitch (1080
pixels padded to 64 bytes) where the boot framebuffer has 4320, so
every modeset failed the plane check with -EINVAL and the screen froze
on the boot console. The Pixel 7 Pro's 1440-pixel rows need no padding,
which is why it never showed there.

On gs201, DPP0 reads its source width as the row length in pixels,
padding included, as G4 does; gs201 packs the source height into the
upper half of the same register. This is measured on the Pixel 7, not
taken from Google's driver, which programs the source width from
fb->width and never scans out a padded stride: with 4352-byte rows and
the stride written as the source width, the desktop shows unsheared,
where an 8-pixel mismatch per row would shear every line. Set
padded_pitch for gs201, write the height back with the width, and cap
the width at the 16-bit field. With an unpadded buffer the register
gets the same value the bootloader left.

Tested on a Pixel 7 from slot B (7.3.0-rc6), with the next commit on
top: before this change every Hyprland modeset failed and the screen
froze on the boot console; with it the modesets pass, the desktop shows
at 1080x2400@60 and stays smooth, with 2624 flips in ten minutes, no
flip timeouts and no late flips (latency 8.9 ms on average, 16.8 ms at
most).

Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
Enable DECON0 with a pool for gs-decon's scanout buffers and the boot
framebuffer, as on the Pixel 7 Pro: gs-decon keeps the bootloader's
DECON, DSIM and DSC setup, flips DPP0 between buffers, and takes the
screen over from simpledrm. The pool has room for five 1080x2400
XRGB8888 buffers, below 4 GiB since DPP0 takes 32-bit addresses with
the DPU SysMMU bypassed, and is reusable.

Tested on a Pixel 7 from slot B (7.3.0-rc6): gs-decon allocates its
scanout buffers from the pool, takes the screen over from simpledrm, and
Hyprland flips on it at 60 Hz.

Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, Ángel, for putting this up so quickly. I went through it against Google's panel-samsung-s6e3fc3-p10.c on android-gs-pantah-5.10-android15-qpr1, and every sequence matches: the HS gamma read at 0xD8 offset 0x22 and its write with the 0x65 command in front, the three DVT1+ 0x66 writes, the box and the centre at x 0x21C, y 0x6B1 with size 0x63, and WRCTRLD with the LHBM bit on top of BCTRL. Your message says plainly what you left out (NS and AOD gamma, the revision gate, the refresh-rate and TE alignment), which made that easy to check. I also compared the blob you tested with this file: the only differences are the four hunks of your 60/90 Hz commit, with no LHBM line among them.

Our gate passes on #181's head: one commit, signed off, checkpatch clean, and the W=1 build of the panel driver. On today's omamobile it reports the conflict in gs201-panther.dts, which is #181's own, as you said, so this one waits for #181. Once #181 is merged, please rebase with git rebase --onto <your remote>/omamobile db288b74f 95788bb5d so it carries this commit alone, and once CI has run on that I'll take it.

Two small things you could look at while it waits, neither a condition:

  1. Unbinding with LHBM on. At unbind, devres cancels the timer first, then unregisters the backlight, and the attributes only go away with the backlight. A write of 1 in between would queue the timer again after it was cancelled, and an LHBM that's on at that moment is never turned off. Turning LHBM off under the lock in s6e3fc3_remove(), plus a flag that makes local_hbm_mode_store() refuse from then on, would close that. The 7 Pro's driver has the same layout, so this isn't something you introduced.
  2. A timeout racing a new touch. If the timer's work is already waiting for the mutex while LHBM goes off and on again, it then finds LHBM on and turns the new circle off straight away. A small generation counter would let it tell its own session from a new one.

When this lands I'll update panther's FINGERPRINT-PLAN, which still says the driver on omamobile has no local_hbm_mode.

The Pixel 7's under-display optical fingerprint sensor needs local high
brightness mode (LHBM): a bright circle over the sensor while a finger
is on it. Add it with the interface the S6E3HC4 driver (Pixel 7 Pro)
already has, so the same fingerprint userspace drives both panels:

- local_hbm_mode on the backlight device (0/1), named as in Google's
  driver; on is refused with EPERM unless the allow_lhbm module
  parameter is set and the panel is lit;
- local_hbm_max_timeout (ms, 1-3000, default 3000): LHBM switches
  itself off after that long;
- blanking, brightness 0, display off and sleep turn LHBM off first.

The commands are from Google's GPL driver (panel-samsung-s6e3fc3-p10.c,
android-gs-pantah-5.10-android15-qpr1):

- s6e3fc3_p10_lhbm_gamma_read(): the factory LHBM gamma at 0xd8 offset
  0x22, read once, on the first LHBM on. Only the HS gamma is kept, the
  one mode this driver runs; NS and AOD are left out. A failed read
  leaves the panel's own gamma, as the vendor driver does;
- s6e3fc3_p10_lhbm_gamma_write(): the gamma written to 0x65 and the
  DVT1+ fix for LHBM brightness with HBM, sent unconditionally since
  this driver has no panel revision read and phone panels are past
  DVT1;
- s6e3fc3_p10_send_lhbm_location_cmds(): the circle centred at x 0x21c,
  y 0x6b1 with size 0x63, in 10-bit offset mode (0xf2 0xcc);
- WRCTRLD (0x53) with the LHBM bit 0x10 on top of BCTRL; off is BCTRL
  alone.

The vendor driver sends the gamma and the location at each cold init.
Here they go with each LHBM on, which also covers a panel taken over
from the bootloader without a reset. Not reproduced from Google's
driver: switching to the peak refresh rate and aligning LHBM on to TE,
as for the S6E3HC4.

remove() turns LHBM off under the lock and marks the panel as going
away, so a write between devres cancelling the timeout and the backlight
going away can't light the circle with nothing left to turn it off. Each
on and re-enable sets the deadline it times out at, and the timeout work
turns LHBM off only once that deadline has passed, so a stale run can't
end a new session. Both from Derek Ross's review.

Tested on a Pixel 7, as a module on 7.3.0-rc6-omamobile-push1-g44048a9aa795
with allow_lhbm=1: writing 1 to local_hbm_mode read the gamma ("LHBM
gamma ..."), a bright circle lit over the fingerprint sensor, and it
went off by itself about 3.1 s later ("local HBM timed out"), three
times running. When the screen blanked during a session the circle went
off with it, and writing 1 with the screen off was refused with EPERM.
Not tested: its timing against the fingerprint HAL.

Assisted-by: LLM
Signed-off-by: Ángel René <17342133+angelrenefm@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, Ángel. Both points are in, and done the way I'd hoped:

  • remove() now turns LHBM off under the lock and sets a flag, and local_hbm_mode refuses an "on" with -ENODEV from then on, while an "off" still goes through.
  • The deadline is set on every on and every re-enable before the work is queued, and the work only acts once that deadline has passed. I walked through both orders: a run that was already waiting for the lock when a new session started finds the later deadline and leaves the new circle alone, and the new session's own timer can't fire before its deadline, so a real timeout is never skipped.

Nothing else in the commit changed; the sequences I compared with Google's driver last time are the same bytes.

One thing moved underneath you: #181 was rebased on the 16th (new head 3c2190791), and this branch still carries its previous head db288b74f. That is the conflict GitHub shows, and it isn't yours. I rebuilt your commit on #181's new head here: it applies cleanly, touches only the panel driver, and our gate passes on it (one commit, signed off, checkpatch clean, W=1 build clean).

So nothing is needed from you until #181 is merged; it is waiting on my Pixel 7 Pro run, not on you or its author. When it lands, please run

git rebase --onto <your remote>/omamobile db288b74f d7cca237a

(the old #181 head, since that is what your branch sits on), push, and once CI has run on the single commit I'll take it. If you'd like CI on it before then, git rebase --onto 3c2190791 db288b74f d7cca237a puts it on #181's current head, which merges cleanly, and the later rebase is then --onto <your remote>/omamobile 3c2190791. That's optional. If you have the blob id of the panel-samsung-s6e3fc3.c you tested on the 17th, add it to the description so the run is tied to this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants