Skip to content

T32: add all-C source recovery compile baseline - #15

Open
matteius wants to merge 1 commit into
apertofrom
feat/t32-recovered-driver
Open

matteius wants to merge 1 commit into
apertofrom
feat/t32-recovered-driver

Conversation

@matteius

@matteius matteius commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Adds a buildable, all-C T32 ISP recovery baseline for review and continued bring-up. The original match-source whole-driver output failed to compile and included truncated implementations and placeholder state despite reporting zero fallback stubs.

The branch implements all 1,591 distinct OEM function entry addresses: 1,382 mechanical MIPS/MXU2-to-C translations and 209 retained or reviewed C candidates/wrappers. The export's other 337 entries are interior code fragments covered by their enclosing functions. All 13 MXU2 routines have scalar C implementations; no assembly function fallbacks or executable OEM blobs are linked.

The integration restores shared data layout and 893 data relocations, all 33 OEM exports, and 21 module parameters. It also fixes module lifetime annotations, variadic logging/module requests, and the IRQ-request calling convention. Source inventories, provenance, reproducibility tools, and handoff notes are included.

Validation:

  • Clean module build and final rebuild passed against the prepared T32 Linux 4.4.94 kernel with GCC 16.2.
  • All 143 kernel imports resolve; all 33 OEM exports and 21 module parameters pass interface checks.
  • 17,100 MXU2 boundary, randomized, and overlapping-register cases passed with UBSan enabled.
  • Integer translation checks passed for delay slots, branch-likely annulment, jumps into delay slots, division edge cases, unaligned accesses, split stack frames, and atomic counter loops.
  • All 1,382 mechanical function bodies reproduce exactly from the hash-checked OEM input.

This is a compile/source-recovery baseline, not a device-validated driver. Most implementations remain register-level C. Hardware behavior, image-processing parity, callback/variadic ABIs, performance, and nested stack usage still need review. The build retains recovered-C diagnostic relaxations and reports stack frames up to 2,320 bytes. No camera was loaded or flashed.

Handoff notes and build instructions · Recorded verification

Integrate all 1591 distinct OEM function entries and restore module exports, parameters, and relocated data. Replace incomplete recovery candidates with decoded MIPS/MXU2 C translations, including scalar vector operations. Add reproducibility, instruction semantics, and module interface checks with explicit device-validation and stack-use limitations.
@matteius
matteius requested a review from Lu-Fi November 7, 2026 10:17
@Lu-Fi

Lu-Fi commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks a lot, Matt, this is a huge piece of work. We have pulled the branch unchanged into our fork as Lu-Fi/open-tx-isp:t32/recovered-baseline, with your authorship intact, and will evaluate it there.

As in the rest of the project, we'd love to grow this step by step into real, readable C functions, and your translations will be a great reference to check each one bit-exact against the vendor.

Plan:

  • a build check against our T32 kernel/toolchain;
  • a function-by-function comparison with our own T32 work in driver/t32;
  • a T32 device test.

Anything we take over keeps your commit via merge, and derived commits carry a Co-authored-by trailer. We will report back here with what we find.

@matteius

matteius commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@Lu-Fi sounds good -- ill be kicking off the openimp side soon for t32 next.

Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
…checked

Zero first threshold (section +4) is no longer refused. Oracle also calls the
vendor interp_by_ev at ~105000 exposures; 0 mismatches, 20/20 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
…table fixed

t32_top_oracle: 20000 random + 804 bin cases bit-exact, 10/10 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
…alk confirmed

Vendor memory compared per section and payload table: 3000 generated bins and
all 67 T32 bins, 0 mismatches, 9/9 mutations. No driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
20000 random + 67 bin sections, 0 mismatches, 10/10 mutations. Shared env
(csc/csccr data objects, ref copies for both chains) is added here.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
15645 random + 63 bin sections compared, 0 mismatches, 9/9 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
…vision

t32_gib_oracle: 19364 random + 2077 bin cases (67 bins x 32 Bayer indices),
0 mismatches, 11/11 mutations. Ours now builds the per-pattern pointer table
(0..3, 12..14, 16..19; 15 refused) and avoids C division by zero in the slope.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
10000 random + 134 bin cases, 0 mismatches, 11/11 mutations; no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
10000 random + 67 bin cases, 0 mismatches, 12/12 mutations; no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
10000 random + 67 bin cases, 0 mismatches, 13/13 mutations; no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 7, 2026
10000 random + 67 bin cases, 0 mismatches, 14/14 mutations; no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…bits

5812 random + 67 bin cases, 0 mismatches, 15/15 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
18741 random + 65 bin cases, 0 mismatches, 16/16 mutations; no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…ange bit-exact

2516 random + 67 bin cases, 0 mismatches, 16/16 mutations. The blend range between two zones
disagrees with the recovered vendor code (signed table byte compare at 0x8a6d8) and is
documented as open. No driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
5812 random + 66 bin cases, 0 mismatches, 15/15 mutations; no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…d range in the oracle

Disassembly of tisp_clm_ct_interp (0x8a6e4: lb of the zone's first table byte) confirms the
recovered C; ours now matches (unsigned compares, byte test, blend, unchanged tables).
t32_clm_oracle: 2498 random + 67 bin cases, 0 mismatches, 22/22 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
t32_bcsh_oracle builds and runs; on real bins only register 0xf064 differs: the vendor leaves
the hue matrix zero because tisp_bcsh_interp_by_ct (not forced at init) does not fill the CCM
the way ours assumes. Not in CHECK_TARGETS until ours follows the vendor branches
(sec bytes 0x493/0x494, API flag at ctx[16]+4).
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…heck

CSC data from the vendor's mode table, interp_by_ct does not update at init (hue matrix zero),
no refusal of the CCM block id or CSC path bytes (43 of 67 bins were refused).
t32_bcsh_oracle: 67 bins + perturbed + random, 0 mismatches, 16/16 mutations; .ko frame size ok.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…div-by-zero fixed

6000 random + 201 bin cases, 0 mismatches, 15/15 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…kernel table

30000 size pairs x 3 sets, all taps bit-exact, 12/12 mutations. The computed table differed from
tisp_sin's data table (data.c bfc40) in 58 entries by 1; now the vendor table.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…he hardware setup

Vendor AWB block writes (0x16xxx) vs t32_awb_stats_init: 4000 random + 134 bin cases, 0
mismatches, 15/15 mutations (112 of 134 bin cases differed before: ours used raw section bytes
the vendor rewrites from the sensor size). t32_awb_stats_init takes width/height.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…-exact

4000 random + 134 bin cases vs the vendor writes to 0x17xxx, 0 mismatches, 14/14 mutations;
no driver logic change.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
Env for the vendor tisp_lsc_init closure (27 functions): LSC state blocks, completion/mutex
stubs, shadow writers rebuilt from the disassembly (Matt's tisp_single_lsc_reg_write /
_reg_lut_write lost the load of the shadow base pointer). t32_lsc_oracle.c dumps the vendor
output for one bin; it is not built by make check.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…, vendor cell count rule

t32_lsc_oracle: 1500 random + 67 bins x 3 sizes x plain/IR Bayer, 0 mismatches, 17 mutations.
t32_lsc_cell_count: byte 65 ? (IR ? 1152 : 576) : rows*cols*2; the stream-on list carries that many
cells (was always 1152). Mesh words reported, not yet compared (step 2).
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…tags

The vendor selects the mesh tables by the u16 colour temperature tag at the start of each table,
not by the section's breakpoints; ours now blends them (Q12 weight, truncating), about 80 % of the
vendor's mesh values. Rest: tisp_lsc_mesh_itp shifts / hysteresis path, open. Unit test updated.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…ct / mesh_itp

Tags, hysteresis (p[48] limited to a quarter of the smallest tag distance), first/last table
sticking, band stick, pair weight ((ct - lo - h) << 12) / (hi - lo - 2h), 16-bit element blend.
Mesh words now equal outside the vendor's radial correction (byte 65 clear, 0x44460) and the ring
path (byte 65 set). Unit test updated; oracle diagnostics (T32O_DIAG) added.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
…exact

Port of the vendor's radial correction (section byte 65 clear: per-cell r^2 vs squared thresholds,
gains p[77/85/93+k], pull to the black level) and of the ring format (byte 65 set: first payload,
577-element planes, tisp_lsc_ring_itp, own two-block cell packing); hysteresis distance loop runs one
step past the last table as the vendor's. t32_lsc_oracle: 1491 random + 67 bins x 3 sizes x 2 Bayer,
mesh words compared too, 0 mismatches, 35/35 mutations.
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 8, 2026
… work planes kept

t32_lsc_oracle runs tisp_lsc_ct_update (non-forced, threshold u32 p[12]) and tisp_lsc_tgain_update
after the init and compares the full shadow image: 26820 random + 16608 bin steps, 0 mismatches,
mutations detected. Ours keeps the work planes between updates (struct t32_lsc_work, t32_lsc_update).
Reference: Matt Davis' recovered C (opensensor/open-tx-isp PR opensensor#15).

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 9, 2026
Ports tisp_gib_dn_params_refresh and tisp_gib_wake_up (Matt Davis'
recovered C, PR opensensor#15 @ 2e2e06b), starting from the failed port-loop
attempt (audit/t32pr/ds/failed-gib).

The earlier mismatches came from the port, plus two oracle setup bugs:
- Port: interp_by_again(_s) is not the init-only simplification. The
  vendor holds the black levels in a block at ctx +16 (u16 flag, 5
  levels at +2 / +14). sec[0x220]/sec[0x221] select the held levels,
  and sec[0x223] == 1 with sec[0x220] 2 (or 0 and sec[0x221] 2)
  writes them back. interp_by_again also sets cp[0x80] (register
  0x3068). Now one t32_gib_interp_set(); t32_gib_ctx gains .hold.
- Oracle: the gain words at ctx +4 are values, not pointers (the old
  setup dereferenced them). The hold block is now randomised and
  compared. sec[0x220/0x221/0x223] and the hold flag get small values
  so every branch is reached.

t32_gibf_oracle: 5925 compared (171 Bayer-15 refused), 0 mismatches,
22/22 mutations detected; t32_gib_oracle PASS 11/11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

(cherry picked from commit dfb96c0, Makefile registration redone)
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 9, 2026
…(openimp #234)

Ports tisp_ae_short_expt, tisp_ae_short_ev_alloc and
tisp_ae_long_ev_alloc (Matt Davis' recovered C, PR opensensor#15 @ 2e2e06b).
The starting point is the failed port-loop attempt
(audit/t32pr/ds/failed-ae). Only its new block is taken over; the rest
of that header was an older base.

The attempt failed because of the oracle, not the port:
- The mult3_32 / mult2_32 hooks called the reference fix_point_*
  directly instead of through t32o_call, which crashed.
- The env event counters were not reset between the vendor and the
  port run.
- One mutation used "\|" (an alternation in GNU sed BRE), so it did not
  build.
Oracle additions: an ascending table case whose x lies in the last
bracket (13), and a full event log. env.c's tisp_event_push now keeps
every event of a run (t32o_evlog, first 16), not only the last, so
earlier events are compared too.

t32_aee_oracle: 4500 cases (1500 per function), 0 mismatches, 16/16
mutations detected. t32_ae / aes / aew / awbi oracles still PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8748b0e)
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 12, 2026
…mp #389)

Copied unchanged with git show from origin/claude/t32-ds-batch:
tx_isp_t32_awb.h, awbct.h, awbdet.h, awblong.h, awbproc.h, awbinit.h
(the T32 port of tisp_awb_* checked against the recovered vendor C of
PR opensensor#15). tx_isp_t32_stats.h gets the five helpers they use
(t32_awb_div, t32_awb_params_refresh, t32_ld32, t32_wr32, t32_wr16),
same text as on ds-batch. No T32 build change: no T32 object includes
the headers (tx-isp-t32.ko byte size unchanged); ds-batch is not merged.

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 12, 2026
…p #389)

Copied unchanged with git show from origin/claude/t32-ds-batch:
tx_isp_t32_aechain.h, aefu.h, aeinfo.h, aeinit.h, aemath.h, aev.h,
api_ag.h, fixp.h, log2.h, aesns.h, libwrap.h (the T32 port of the
vendor AE chain, checked against the recovered vendor C of PR opensensor#15).
tx_isp_t32_aestats.h holds the AE part of ds-batch's tx_isp_t32_stats.h
(its lines 303..2353, unchanged, without the t32_ld32 / t32_wr32 /
t32_wr16 this branch's stats.h already has). No T32 object includes
the headers (tx-isp-t32.ko code unchanged); ds-batch is not merged.

Co-authored-by: Matt Davis <matteius@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lu-Fi added a commit to Lu-Fi/open-tx-isp that referenced this pull request Nov 13, 2026
…hout it

tests/t32_oracle/ref/ (functions copied from the still-open upstream PR opensensor#15)
stays on claude/t32-ds-batch until that PR lands. run.sh prints SKIP and exits 0
(2 with T40_ORACLE_STRICT=1) when ref/ is missing; t32_tmotab_check and
t32_rdnstab_check skip the same way when commit 2e2e06b is not available.
CHANGELOG + tests/README.oracles.md note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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