Skip to content

drm: google: gs-dsim-cmd: Support DCS reads, and tg4c checks the panel ID with them - #125

Merged
derekross merged 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-dsim-read
Nov 1, 2026
Merged

derekross merged 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-dsim-read

Conversation

@W4HO-ham

@W4HO-ham W4HO-ham commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

gs-dsim-cmd returned -EOPNOTSUPP for every read. This adds reads, following Google's dsim_read_data(): set the maximum return packet size, send the request with the PKTHDR bus-turnaround bit (24), poll RX_DATA_DONE, then parse the RX FIFO. The BTA bit is the part that matters: without it the panel never answers. The RX FIFO is drained before each request as well as after, so a late answer to a timed-out read can't be taken for the next one.

The user is the second commit: tg4c reads the panel's ID (0xDA, 0xDB, 0xDC, 0xA1, as Google's gs_panel does) and sends no commands to a panel whose ID1 and ID3 aren't the TG4C's. That answers the point on omarchy-mobile#74 about TG4A, TG4B and TG4C. Google's sources don't carry TG4A's and TG4B's IDs, so the check accepts the TG4C's own ID rather than refusing a list.

Two commits on omamobile (#88 is in now):

  1. drm: google: gs-dsim-cmd: Support DCS reads
  2. drm/panel: google-tg4c: Send no commands to a panel that is not a TG4C

Tested on the palmtop with both (7.3.0-rc6-omamobile-push1-g88a7314c6409): panel ID 04 80 00 2d (the bootloader's google-tg4c.2d008004, last byte first) before the first command. Brightness, DPMS off and on, and 120 Hz to 60 Hz and back all worked, and tools/phone-smoke passed every required row. An earlier build of the reads, with a test panel driver, read tg4c's five LHBM bands; LHBM in #126 doesn't need them. No read has timed out with this code, so the recovery after a timeout is untested. checkpatch --strict and W=1 are clean.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

A correction to my description: tg4c's LHBM turned out not to need these reads. #126 keeps the panel's own bands and matches without them. The reason that still stands is reading the panel ID to tell TG4A, TG4B and TG4C apart (your point on #74).

@derekross

Copy link
Copy Markdown
Owner

Thank you for this. Reads are the piece gs-dsim-cmd has been missing, and the code follows Google's dsim_read_data() closely. Using the PKTHDR turnaround bit and polling RX_DATA_DONE instead of adding an interrupt handler keeps it small, and I like that reads go through the same allow_tx gate, the same lock and the same packet-go check as writes. gs-dsim-cmd also drives my Pixel 7 Pro's panel every day, so I went through it closely.

What I checked:

  • Registers. Every offset and bit you use matches Google's cal_9845/regs-dsim.h (gs201) and cal_9865/regs-dsim.h (zumapro), and the two are the same here: DSIM_TIMEOUT 0x28 (BTA timeout in [31:16], LP RX timeout in [15:0]), INTSRC/INTMSK bit 18 for RX_DATA_DONE, PKTHDR bit 24 for the turnaround (DSIM_PKTHDR_BTA_TYPE), RXFIFO 0x60 and FIFOCTRL bit 12 for EMPTY_RX. 0xff/0xffff is what dsim_reg_set_timeout() writes, and 100 ms is MIPI_RD_TIMEOUT. The CAL helpers you're following (dsim_reg_wr_tx_header, dsim_reg_get_rx_fifo, dsim_reg_rx_fifo_is_empty, dsim_reg_clear_int) are identical in the two CALs.
  • Power. The DSIM has no power domain or runtime PM in our tree, and reads touch the same block the write path already uses, under the same mutex. If a read goes to a sleeping panel it just times out after 100 ms of polling. It can't abort the bus.
  • Checks. kernel-pr-check --build --merge on today's omamobile merges cleanly, has your sign-offs, prefixes and checkpatch --strict with nothing to read, and W=1 builds of both files are clean. CI is green. The gs-dsim-cmd.c you tested (f84c53346fea) is exactly this head's file.
  • The Pixel 7 Pro. I built gs-dsim-cmd.o at drm: google: 120 Hz on the Pixel 9a (per-panel DSIM timers, gs-decon on zumapro) #88's head and at yours and compared them function by function. Only gs_dsim_transfer changes (gs_dsim_read is inlined into it). The write path's source is untouched, and the new branch runs only for a message with rx_len set. The 7 Pro's S6E3HC4 driver issues no reads, either on omamobile or on my integration branch, so by reading nothing changes there. The function still compiles differently, though, and it carries every panel command on my phone. I'm already running drm: google: 120 Hz on the Pixel 9a (per-panel DSIM timers, gs-decon on zumapro) #88 on the 7 Pro before merging it, so I'll run this commit in the same boot.

Two things I'd like changed before merging:

  1. What the reads are for. The message and the PR description say tg4c's LHBM starts from brightness bands read from the panel, and that the panel side using these reads comes as a separate PR. drm/panel: google-tg4c: Add local high brightness mode #126 is that PR, and it reads nothing: its message says the circle keeps the panel's own per-band values, and every DSI call in it is a write. So as it stands, nothing in any public tree calls this code, and the reads in your test (LHBM brightness[0]: 23 c4 20 48 28 de …) came from a panel driver I can't see. Could you either
    • add the user here, for example a read of the panel ID in tg4c, which would let the driver tell TG4A, TG4B and TG4C apart (my point on device-tegu 0.1.1: public-kernel boot, native display and guarded touch omarchy-mobile#74). That's the case I'd most like to see these reads serve; or
    • push the panel code you tested with to a branch or a draft PR, give its panel-google-tg4c.c blob id, and reword the message so it gives the real reason (panel identification, and LHBM only if it still needs the reads)?
  2. Stale data after a timeout. If a read times out, gs_dsim_read() returns before its drain loop. A panel that answers late then leaves its response in the RX FIFO, and the next read parses that response as its own header. Google has the same gap, but for a read that might pick a panel's command set it matters. Moving the drain into a small helper and calling it before the request is sent (as well as at the end) would close it.

Smaller things, none blocking:

  • A one-byte short response with rx_len 2 returns 2 and leaves rx_buf[1] as it was. Returning the bytes actually received (1 or 2) would be more accurate.
  • An acknowledge-and-error report with no error bits set is "no error" in Google's dsim_reg_rx_err_handler() (the read returns 0), and an EoTp response is accepted there too. Both are -EIO here. That's fine if you prefer it strict; maybe just say so in a comment.
  • DSIM_MAX_RX_FIFO (64) is a read-length limit you chose, not the FIFO's size: the FIFO holds 64 words, and Google allows 252 bytes. A name like DSIM_MAX_RX_LEN with a comment would keep the next reader from mixing the two up.
  • The file's header comment still describes the driver as sending DCS commands only. Worth a line about reads.
  • A question: have you seen a read time out on the 9a, and if so, did scanout carry on afterwards? If the panel never turns the bus around, I'd like to know the link comes back on its own, since we have nothing like Google's recovery path.

Merge order: this goes in after #88 (its two commits sit under yours), and #126 goes after this one if it ends up using reads. It also conflicts with #116 (the Pixel 6 Pro display) in gs-dsim-cmd.c, because #116 splits gs_dsim_transfer into a wrapper and gs_dsim_transfer_packet. Whichever lands second needs a rebase: the read branch moves into gs_dsim_transfer_packet, since the wrapper only looks at writes. I'll sort out the order when we get there.

Thanks again. I'll report the Pixel 7 Pro run in this thread.

Panel drivers need reads: a read of the panel's ID would let the tg4c
driver tell the Pixel 9a's three panels (TG4A, TG4B, TG4C) apart. Reads
returned -EOPNOTSUPP until now.

Do them as Google's dsim_read_data() does: set the maximum return
packet size, send the read request with the PKTHDR bus-turnaround bit
(24), wait for RX_DATA_DONE, then parse the short or long response from
the RX FIFO. Without the BTA bit the panel never answers and the read
times out. RX_DATA_DONE is polled: it is unmasked in INTMSK only for the
read, so it latches in INTSRC, and the mask is put back afterwards. If
the bootloader left DSIM_TIMEOUT at zero, it gets the vendor driver's
BTA and LP RX timeouts. Reads take the same lock and the same packet-go
check as writes.

The RX FIFO is emptied before the request as well as after the
response, so a panel that answers after its read timed out can't have
that answer taken for the next read's. A short response returns the
number of bytes it carried. An acknowledge-and-error report and an EoTp
packet fail the read with -EIO, which is stricter than the vendor
driver.

Tested on the Pixel 9a with a tg4c build that reads its five LHBM
brightness bands (six bytes each) at every boot: the reads succeed, and
the desktop and 120 Hz are unaffected.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham
W4HO-ham force-pushed the tegu-dsim-read branch 3 times, most recently from 5e0e520 to 081d98a Compare November 1, 2026 22:47
@W4HO-ham

W4HO-ham commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for going through it this closely. Both items and the smaller points are in (head 081d98a, rebased onto omamobile now that #88 is in, so only my two commits are left).

  1. The user is here now, as a second commit: "drm/panel: google-tg4c: Send no commands to a panel that is not a TG4C". It reads the panel's ID the way Google's gs_panel does (_gs_panel_read_extinfo(): one byte each from 0xDA, 0xDB, 0xDC and 0xA1) and logs it once. Then it compares ID1 and ID3 with the TG4C's. The bootloader passes the same four bytes, last first, as the suffix of panel_name, so google-tg4c.2d008004 on my 9a is ID1 0x04, ID2 0x80 (Google's PVT build code) and ID3 0x00. A panel with a different ID1 or ID3 gets no commands at all: brightness, LHBM, the rate switch, display on/off and sleep all return -ENODEV, so it keeps the bootloader's picture at 60 Hz. ID2 isn't compared, since it changes with the panel's build. The device package turns allow_tx on after the panel has probed, so if gs-dsim-cmd refuses the read at probe, the driver reads the ID before its first command instead.

    One limit, said plainly: Google's kernel never compares these bytes itself. It takes the panel the bootloader names, and TG4A's and TG4B's IDs aren't in the GPL sources. So the check is against the TG4C's own ID, not a list of the other two. If a TG4C turned up with a different ID, it would lose its commands and say so in dmesg, rather than a TG4B getting the TG4C's commands. The reads commit's message now gives panel identification as the reason. The LHBM band reads were only in my test build, and drm/panel: google-tg4c: Add local high brightness mode #126 doesn't use them.

  2. Stale data: the RX FIFO is drained by a helper before the request is sent, as well as after the response.

Smaller points: a short response returns the bytes it actually carried (1 or 2). A comment at the error-report and EoTp cases says the strictness is on purpose. The limit is DSIM_MAX_RX_LEN now, with a comment saying it's our read-length limit, not the FIFO's 64 words, and that Google allows 252 bytes. The header comment mentions reads.

Boot of both commits on the palmtop (7.3.0-rc6-omamobile-push1-g88a7314c6409, omamobile plus these two): panel-google-tg4c 19440000.dsi.0: panel ID 04 80 00 2d 11 s into the boot, before the first command, right before gs-decon's switch to 120 Hz. Brightness writes (900, 2400, back to 1829) took effect, DPMS off and on came back, and the rate went 120 Hz to 60 Hz and back to 120 Hz. There was no "staying at 60 Hz" and no "panel sleep failed", and tools/phone-smoke passed every required row. On your question about timeouts: I haven't seen a read time out with this code, in this boot or before. The only failed reads were in bring-up, before I set the BTA bit, and I didn't keep that log, so I can't say whether scanout carried on, and I haven't tested recovery from one.

checkpatch --strict and W=1 are clean on both files. The reads commit is signed off; the panel commit waits for its sign-off.

@W4HO-ham W4HO-ham changed the title drm: google: gs-dsim-cmd: Support DCS reads drm: google: gs-dsim-cmd: Support DCS reads, and tg4c checks the panel ID with them Nov 1, 2026
The Pixel 9a comes with one of three panels. Google's tegu device tree
lists TG4A, TG4B and TG4C, each with its own driver, and their commands
differ: TG4B's rate switch, for one, sends more than TG4C's, so TG4C's
commands would leave a TG4B half switched.

Read the panel's ID as Google's gs_panel does: one byte each from 0xDA,
0xDB, 0xDC and 0xA1, the MIPI DCS ID1 to ID3 and the start of the device
descriptor block. The bootloader passes the same four bytes, last first,
in exynos_drm.panel_name, and Google's get_panel_rev() finds the panel's
build in the 0xDB byte in both orders. Our Pixel 9a reports
google-tg4c.2d008004: ID1 0x04, ID2 0x80 (Google's PVT build) and ID3
0x00.

A panel whose ID1 (the module's manufacturer, whose low nibble Google's
gs_panel_model_init() takes as the vendor) or ID3 (the module ID)
differs from those gets no commands: brightness, LHBM, the rate switch,
display on/off and sleep all fail with -ENODEV, so it keeps the
bootloader's picture at 60 Hz, as with gs_dsim_cmd.allow_tx off. ID2
changes with the build and is not compared.

The ID is read at probe, and if gs-dsim-cmd refuses the read there
(-EPERM: allow_tx is off; the Pixel 9a's device package turns it on
from a start script, which can run after the panel has probed), before
the first command instead. A read that fails
any other way leaves the panel driven as before.

Google's kernel never compares these bytes itself: it takes the panel
the bootloader names, and TG4A's and TG4B's IDs are not in its sources.
So the check is against TG4C's own ID, not a list of the others'.

Google sources, android-gs-tegu-6.1-android16:
- kernel/google-modules/display/common e34756e6205a:
  gs_panel/gs_panel.c (ext_info_regs, _gs_panel_read_extinfo(),
  gs_panel_first_enable_helper()), gs_drm/gs_drm_connector.c
  (dsim_get_panel_id()), gs_panel/gs_panel_funcs_defaults.c
  (gs_panel_model_init())
- kernel/google-modules/display/panels/tegu e3a801fb038f:
  panel-gs-tg4a.c, panel-gs-tg4b.c (tg4b_change_frequency()),
  panel-gs-tg4c.c (tg4c_change_frequency(), tg4c_get_panel_rev())
- kernel/devices/google/tegu 6276884d9940:
  dts/zuma-tegu-connector.dtsi (the three panel nodes)

Tested on the Pixel 9a (7.3.0-rc6-omamobile-push1-g88a7314c6409,
this commit on the reads commit, bootloader panel_name
google-tg4c.2d008004): the ID was read 11 s into the boot, before
the first command, and logged as "panel ID 04 80 00 2d". Brightness
writes, DPMS off and on, and 120 Hz to 60 Hz and back all worked as
before, with no "staying at 60 Hz" line.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. The panel ID check is the user I hoped these reads would get, and thank you for saying plainly what it can and can't tell apart.

What I checked on 912a7e5c2060:

  • Both items are in. The panel commit reads 0xDA, 0xDB, 0xDC and 0xA1 one byte at a time and compares ID1 and ID3. "panel ID 04 80 00 2d" matches your bootloader's google-tg4c.2d008004 read backwards. A panel that isn't a TG4C gets -ENODEV from prepare, enable, disable, unprepare, the rate switch, the backlight and the LHBM attribute, so nothing is sent to it. gs_dsim_drain_rx() now runs before the request as well as after the response, so a late answer to a timed-out read can't be taken as the next read's header.
  • The smaller points. A short response returns the bytes it carried. The strict error-report and EoTp handling has its comment, the limit is DSIM_MAX_RX_LEN with a comment, and the header mentions reads. Thank you for answering the timeout question honestly too.
  • Gate on today's omamobile: a clean merge, both commits signed off, checkpatch --strict with nothing to read, and W=1 builds of both files. CI is green on this head.
  • The Pixel 7 Pro. Since my first review, gs_dsim_transfer()'s write path has no changes, and the read branch runs only for a message with rx_len. None of the 7 Pro's panel drivers on omamobile (S6E3HC4 and the BOE NT37290 that just landed) issues a read, so nothing new runs there.

One small thing, not a blocker. If a read at probe comes back -EBUSY (packet go left on, which nothing in our tree sets, so only the bootloader could), or times out, tg4c_check_id() records the panel as a TG4C for the rest of the boot. Retrying an -EBUSY read before the next command, as you already do for -EPERM, would keep that case from skipping the check. Your choice. A one-off log line would do too.

On merge order, this goes in before #116, which then needs a rebase: its split of gs_dsim_transfer() has to take this read branch into gs_dsim_transfer_packet(). I'll rebase-merge this one.

@derekross
derekross merged commit 77ea6af into derekross:omamobile Nov 1, 2026
1 check passed
@derekross

Copy link
Copy Markdown
Owner

Merged. Thanks, @W4HO-ham.

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