Repository navigation
media: apple: isp: apply per-module lens shading and DSC to setfile - #3902
RyanTheTide wants to merge 3 commits into
Conversation
Resample the cached per-module lens shading grid from sensor NVM onto setfile section 0xc003 using integer fixed-point math (non-uniform Bessel-Hermite bicubic interpolation in the interior, bilinear on border cells, against an ideal cos^4 illumination curve) before computing the SNF radial gains: - Average Gr (ch 0) and Gb (ch 3) shading tables and update their channel header maxima on legacy ISP generations. - Mark section 0x0a2a when present so firmware knows per-module shading was applied. - Multiply section 0xc003 by section 0xc021 (Q12 differential shading correction) when present after replacing 0xc003 with per-module gains. Add KUnit tests covering IEEE-754 coordinate conversion, 8-bit legacy and 10-bit H17 resampling, green averaging, DSC multiplication, and invalid grid rejection.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Additional live identical-scene A/B on J413 M2 Air (T8112, Legacy ABI,
|
|
6th and final lab Mac verified — live identical-scene A/B on MacBook Neo (J700) (T8140, H17 ABI,
|
Address review findings on malformed setfile or NVM inputs: - Require ideal_pct >= 10 so the cos^4 denominator stays well below 2^32. - Validate channel grid strides (1..1024) and pixel extent (<= 16384) before resampling so radius and bilinear arithmetic cannot overflow. - Require minimum knot spacing (LSC_ONE >> 10), mask 9..16-bit NVM samples to bit_depth bits, and clamp vertical cubic intermediates so non-uniform cubic interpolation cannot overflow s64. - Populate the 10-bit KUnit fixture with cpu_to_le16() for endianness safety.
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 6c28a3d7b279 (after #3901 merges and this PR retargets main)
Checked: Audited isp-cam.c and isp-cam-test.c for fixed-point overflow, setfile bounds validation, and interpolation math. isp_f32_to_q24() rejects negative/NaN/Inf/> 1.0f values and rounds without u32 overflow. isp_lsc_cubic() stays well within s64 bounds (|c3 * s| <= 2^61) given the LSC_ONE >> 10 minimum knot spacing and [0, 2 * LSC_ONE] vertical pass clamp; interior bicubic and border bilinear index ranges are strictly in bounds with x1 > x0 / y1 > y0 guards. isp_setfile_apply_lsc() validates all four channel records (sx,sy in 1..1024, gw,gh >= 2, table size within lsc_size, pixel extent <= 16384) before mutating the setfile, keeps r2 * k_q30 and denom * denom within u64 for ideal_pct in 10..100, averages Gr/Gb and updates channel maxima on legacy ABIs, and sets section 0x0a2a when flag_size >= 5. isp_setfile_apply_dsc() checks 0xc003/0xc021 count and sizes, avoids u32 overflow in DIV_ROUND_CLOSEST(a * b, SNF_ONE) even at (U16_MAX, U16_MAX), and recomputes all four channel maxima. pr-readiness CI is green on the stacked base, with exact-head J713 M4 Air verification at 6c28a3d7b279, 6-Mac identical-scene A/B (J413, J615, J713, J616s, J700, K114s), and ARM64 KUnit 55/55 PASS.
Evidence
- Checked fixed-point bounds: worst-case
ideal_pct = 10givesk_q30 < 2^32,r2 <= 2^31->r2 * k_q30 < 2^63;denom < 2^32->denom * denom < 2^64. - Checked
isp_setfile_apply_dsc():65535 * 65535 + 2048 = 0xfffe0801 <= 0xffffffff(nou32wrap). - Stacked on
#3901(camera-all/per-module-lsc-nvm): merge#3901first, then retargetmainso fullapple-build/host-tests/KUnitCI runs on the final merge head.
|
Local CI run (hosted CI doesn't run for this base, and is queued on #3901): host-tests fail at What fails: the same 5 host-test jobs as on #3901: The fix belongs in #3901 (or here, if the two land together). Nothing else failed.
The 2 KUnit failures on UML in every tree are On the #3900 conflict, the combined-tree resolution keeps #3900's |
|
Replaced by #3930 (same work, cleaned up: Signed-off-by on every commit, host-test fix, values limited to what our own measurements support). Closing this one. |
Replaced by #3930 (same work, cleaned up: Signed-off-by on every commit, host-test fix, values limited to what our own measurements support). Closing this one.