Repository navigation
Conversation
…less
cmos_gains_update() encodes the analogue gain one increment low. The OV2710
codes gain as 16 * linear in the 9-bit 0x350a/0x350b pair, so 1x is 0x10, but
the code computed ((1 << index) - 1) << 4:
gain before after
1x 0x000 0x010
2x 0x010 0x020
4x 0x030 0x040
8x 0x070 0x080
16x 0x0f0 0x100
32x 0x1f0 0x1ff (clamped)
Measured on a VStarcam C23S-class Hi3518EV200 board, OV2710 over MIPI: the
ISP reported Again = 1024 (1x Q10) while the sensor held 0x350b = 0x00, below
its own documented minimum, and the register's own init table writes 0x10.
The 32x entry needs the clamp as well: 0x200 shifted right by 8 gives 2, and
the high byte is masked with & 0x1, so 0x200 truncated back to 0x000 - the very
value this change removes. Clamping at 0x1ff keeps the pair inside the 9 bits
the sensor implements.
Verified: /usr/lib/sensors/libsns_ov2710.so rebuilt with
arm-linux-musleabi-cross (gcc 11.2.1, -march=armv5te), exported symbols
identical to the shipped library, NEEDED libc.so (musl), no VFP ABI tag, and
0x350b now reads 0x10 with the same Again = 1x reported by the ISP. The stream
is unaffected.
This does not fix the remaining noise on that board: the AE still pins the
integration time at 2 lines while reporting Exp = 2049, and the noise is
invariant to exposure and gain, so the figure is added downstream (DRC and a
capped 3DNR are the suspects). Sent on its own because the gain encoding is a
defect against the sensor's own encoding and is independent of that.
1cd04a9 to
f9f2867
Compare
PR Summary by QodoFix OV2710 analogue gain encoding and clamp to 9 bits
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. 32x gain is programmed as 31.9x without a note
|
|
I was wrong, and this PR should not be merged. The formula it replaces is correct. Two independent drivers settle the encoding, and both agree with the code in
Carrying
So Measured on the board, with everything else unchanged: Darker with more noise, which is what a doubled analogue gain looks like. I Closing. The part of the investigation that still stands is on Thanks to whoever looks at this - the cross-check against a second driver is |
cmos_gains_update()encodes the analogue gain one step low. The OV2710 codes gain as16 * linearin the 9-bit0x350a/0x350bpair, so 1x is0x10, but the code computes((1 << index) - 1) << 4:0x0000x0100x0100x0200x0300x0400x0700x0800x0f00x1000x1f00x1ff(clamped)The sensor's own init table in the same driver writes
0x350b = 0x10, so0x000at 1x is below its documented minimum.The 32x entry needed a second half.
0x200shifted right by 8 gives 2, andcmos_get_sns_regs_info()declares the high byte of the pair; the value is stored with& 0x1, so0x200truncated straight back to0x000- the exact value this change removes. The clamp keeps the pair inside the 9 bits the sensor implements.Measured on hardware
A VStarcam C23S-class Hi3518EV200 board, OV2710 wired to MIPI, running the shipped
libsns_ov2710.sofrom thehi3516cv200package:With the sensor handed its own AE (
0x3503 = 0x00) it asks for0x350b = 0x12and 1098 of 1104 lines, which is a sane request - so the sensor side is fine and this is purely the encoding in the driver.Built
arm-linux-musleabi-cross(gcc 11.2.1),-march=armv5te, against the headers the Makefile expects. ABI checked against the shipped library before deploying:nm -D --defined-onlysymbolsreadelf -dNEEDEDlibc.solibc.soTag_CPU_archTag_ABI_VFP_argsWhat this does not fix
The picture on that board stays noisy, and it is not this bug: the AE pins the integration time at 2 lines (
0x3501 = 0x00,0x3502 = 0x20) while the ISP reportsExp = 2049, and the noise is invariant to both exposure (550 vs 1098 lines) and gain. The figure is added downstream -[DRC]runs withDRCStrengthTarget = 128/Stretch = 54, and the 3DNR temporal strength is capped atTFStrMax = 14, which cannot smooth temporal noise. Sent separately because the gain encoding is a defect against the sensor's own encoding.Also worth knowing for anyone bringing this sensor up: in
OpenIPC/firmware,ov2710_mipi_1080p.iniselects the parallel interface (input_mode = 4,[vi_dev] Input_mod = 2), so the VI stays in DC andIntCntstays 0. Reported separately on OpenIPC/firmware#2243.