Skip to content

drm/panel: google-tg4c: Add local high brightness mode - #126

Merged
derekross merged 1 commit into
derekross:omamobilefrom
W4HO-ham:tegu-tg4c-lhbm
Oct 30, 2026
Merged

derekross merged 1 commit into
derekross:omamobilefrom
W4HO-ham:tegu-tg4c-lhbm

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

This adds the fingerprint circle to the Pixel 9a's panel. Local high brightness mode is set up the way Google's panel-gs-tg4c.c does it (CMD2 page 2, the LHBM gamma for the current brightness, then 0x87 0x05). It's exposed through local_hbm_mode and local_hbm_max_timeout on the backlight device, which the fingerprint HAL uses, and the new ABI file documents both. It's off unless allow_lhbm is set, and it's refused unless the panel is on at 120 Hz. It turns off after 3 s, when the panel turns off, and before a switch away from 120 Hz.

One finding is in the message: Google overdrives the circle only for its first frames and then goes back to the panel's own bands. Keeping the overdrive on gave captures too poor to match. With the panel's own bands, matching works. So this version doesn't overdrive at all, and it doesn't need DCS reads (#125).

Tested on the palmtop on 2026-10-29: the enrolled finger matches and a different finger is refused, through the HAL and through fprintd, and the lock screen unlocks by fingerprint. The userspace side is in derekross/omarchy-mobile#135. checkpatch --strict is clean, and the file builds W=1 clean against the integration tree.

W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Oct 29, 2026
…was masked

Review: the status says it works on the owner's integration kernel, with LHBM open as derekross/linux-omarchy-mobile#126 and the DSI reads as derekross#125, and the fprintd mask came from the palmtop's private bring-up root. The G3 next step is on the charger.
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. A working fingerprint unlock on the 9a is a big step. The patch is easy to check against Google's file. I compared it with panel-gs-tg4c.c at the commit you link: the CMD2 page 2 select, 0x6F 0x07, the four gamma sets with Google's thresholds (3628, 2774 and 2186, compared with > as Google does), 0x87 0x05 on and 0x87 0x00 off, and turning LHBM off before a switch away from 120 Hz all match. Dropping the first-stage overdrive is a real finding, and the message explains it well. It's off unless allow_lhbm is set, the same pattern the Pixel 7 Pro's panel uses, which I like.

The checks pass on today's omamobile: a clean merge, the sign-off, the prefix, checkpatch --strict, the W=1 build, and CI. Only the 9a's panel driver and MAINTAINERS change, so nothing changes on the Pixel 7 Pro.

Two fixes to the timer, and one question about evidence:

  1. A timer from an earlier circle can cut a new one short. Turning LHBM off doesn't cancel lhbm_off, and turning it on uses schedule_delayed_work(), which does nothing while the work is still pending. So if the HAL turns the circle off and on again within 3 s, as it may between capture attempts, the first circle's timer turns the second one off early. Please cancel the work when LHBM goes off (cancel_delayed_work() under the lock is enough, since the work function takes the same lock), and use mod_delayed_work() when it goes on.

  2. Unbinding with the circle lit. tg4c_remove() detaches from DSI, cancels the timer, then removes the attributes. If LHBM is on at that point, nothing turns it off: the circle stays lit at full LHBM brightness and the timer that would end it is gone. And a write to local_hbm_mode between the cancel and the removal can queue the work again after cancel_delayed_work_sync(), and the work would then run on freed memory. Please reverse the order: remove the attributes first, then turn LHBM off under the lock, then cancel_delayed_work_sync(), then detach. devm_delayed_work_autocancel() at probe would cover the cancel part.

  3. The tested file. The message says the tested panel-google-tg4c.c was blob 9ed30eea72b0, and that it differs from this one only in the include order, a comment and the named thresholds. That blob isn't in any tree I can fetch, so I can't check the claim. After the two fixes above, could you re-run the match and refuse tests with the file from this branch and post its blob id (git rev-parse HEAD:drivers/gpu/drm/panel/panel-google-tg4c.c)? Please include the release and a tools/phone-smoke report from that boot.

One thing for later, not for this PR: nothing in the omarchy-mobile packages sets options panel_google_tg4c allow_lhbm=1 yet. Cheetah's is in omamobile-fingerprint's omamobile-fingerprint-lhbm.conf, so the 9a's line can sit next to it once derekross/omarchy-mobile#135 or its follow-up is ready. Until then the kernel side is safely off by default, so it doesn't hold up this PR.

Thanks again. The overdrive finding alone will save whoever brings up the next Google panel some time.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Thanks, both timer points were real. Fixed at 798fcb4 (force-pushed, one commit):

  1. A stale timer: turning LHBM on now uses mod_delayed_work(), so the timer belongs to the current circle, and turning it off cancels it (cancel_delayed_work() under the lock; the work takes the same lock).
  2. Remove with the circle lit: the attributes go first, then the circle is turned off under the lock, then cancel_delayed_work_sync(), then the DSI detach and the panel removal.

Checked on the palmtop with this head's module (built out of tree against the running kernel, blob d591bc3d1bf1, installed under /lib/modules/$(uname -r)/updates/panel/, so it is the boot panel driver): on, off after 1 s, on again, then local_hbm_mode still reads 1 at 2.5 s after the second on (the old code would have turned it off at 2 s, when the first circle's timer fired) and 0 at 3.5 s; on, then off after 0.5 s, stays 0. No panel errors in dmesg, and the display came up normally on that boot.

  1. The tested file: the match and refuse tests with this blob need the owner's finger, which is away for a few hours; I'll post the result, the release and the smoke report from that boot here when it's done, and update the message's blob id. Until then the message says what was tested on which blob (9ed30eea72b0, and what differs).

For the record, the boot in question: release 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, tools/phone-smoke 19 of 19 ok.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. Both timer fixes are right, and the test you ran shows each one: the second circle survived past the point where the first circle's timer used to end it, and turned off at 3.5 s.

I read the new head against my two points:

  1. The stale timer. mod_delayed_work() when the circle goes on and cancel_delayed_work() under the lock when it goes off. The timer now belongs to the current circle.
  2. tg4c_remove(). The attributes go first, so no write can come in after that. Then the circle is turned off while the DSI host is still attached, so the off command can still reach the panel. Then the timer is cancelled for good, then the detach. A timer that was already waiting on the lock finds the circle off and does nothing. That's exactly the order I hoped for.

The checks pass on today's omamobile (clean merge, sign-off, checkpatch --strict with nothing to read, W=1, and CI), and the module you tested, d591bc3d1bf1, is this head's file.

What's left is the run you mentioned: the match and refuse tests with this head's file, the release, and a tools/phone-smoke report from that boot. Please also update the message's tested blob to d591bc3d1bf1. I'll merge once that's posted. No code changes needed.

Thanks again. This was a quick and clean turnaround.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

The one-minute repeat on the rebuilt panel module (updates/panel, blob d591bc3d1bf1, release 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty), 2026-10-30 morning on the palmtop: locked with the power key, the enrolled finger lit the LHBM circle and unlocked on the first press; locked again, three presses of a wrong finger each lit the circle and were refused (the HAL's dismatch with image quality 24, valid area 100), then the right finger matched on one press. The bridge's FINGER DOWN / ACQUIRED / FINGER UP sequence ran cleanly every time and local_hbm_mode read 0 again afterwards.

One thing found on the way, not this driver's fault: after the shell's power-key off-and-on, the backlight device stayed in its blank state (bl_power 4, and the core's FBBLANK bit even after bl_power was set back to 0) while the panel was lit, so local_hbm_mode refused with EPERM (the allow_lhbm/brightness check reads brightness as 0 while blank) and no circle came. A DPMS off/on through Hyprland cleared it and everything above ran. I'll take that to the shell's power-key path on the omarchy-mobile side.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. The match and the three refusals with d591bc3d1bf1, which is this head's file, are exactly what I asked for. One small thing before I merge: the message still says the tested file was 9ed30eea72b0 and lists how it differs. I'll replace that sentence with the new blob on your branch, keeping your sign-off, and merge, then derekross/omarchy-mobile#155 right after. The backlight staying blanked after the power key is a good catch; the driver refusing LHBM there is the safe behaviour, and the fix belongs on the shell side, as you say.

The Pixel 9a's under-display fingerprint sensor needs the panel to light
the finger: local high brightness mode (LHBM), a bright circle over the
sensor. Add it as Google's panel-gs-tg4c.c does it, and expose it as
their panels do, through local_hbm_mode and local_hbm_max_timeout on
the backlight device, which the fingerprint HAL uses.

Turning it on selects CMD2 page 2, sets the LHBM gamma for the current
brightness (0x6F 0x07, then 0x87 0x01-0x04 by Google's thresholds) and
writes 0x87 0x05; 0x87 0x00 turns it off. The circle keeps the panel's
own per-band LHBM brightness. Google raises those by an overdrive
offset for the first frames and then writes the panel's values back;
with the overdrive kept on, the sensor's captures were too poor to
match, and with the panel's values they match.

LHBM needs the panel on and at 120 Hz, as on stock, so it is refused
otherwise, turned off before a switch away from 120 Hz or the panel
turning off, and turned off by a timer after 3 s. The timer belongs to
the current circle: turning LHBM on restarts it and turning it off
cancels it, so an earlier circle's timer can't cut a new one short. On
remove the attributes go first, then the circle is turned off and the
timer stopped, so nothing can queue it afterwards. It is off unless the
allow_lhbm module parameter is set.

Tested on the Pixel 9a: with the fingerprint stack running, the
enrolled finger matches and a different finger is refused, and the lock
screen unlocks by fingerprint. The tested panel-google-tg4c.c is this
commit's file (blob d591bc3).

Link: https://android.googlesource.com/kernel/google-modules/display/panels/tegu/+/e3a801fb038fdd1bbaec36d387f27bd99f10757a/panel-gs-tg4c.c
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross
derekross merged commit 38b6fc0 into derekross:omamobile Oct 30, 2026
1 check passed
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.

2 participants