Skip to content

superpix_sp2305: analog gain to 31.9x, and the module maker's colour defaults - #262

Merged
widgetii merged 1 commit into
mainfrom
sp2305-vendor-equivalent
Oct 14, 2026
Merged

widgetii merged 1 commit into
mainfrom
sp2305-vendor-equivalent

Conversation

@widgetii

Copy link
Copy Markdown
Member

The SP2305/OV2735 driver for hi3516ev200/ev300 now does what the module maker's library does in the places an IQ profile depends on, while keeping its own timing and black level.

Analog gain: 15.5x → 31.9x

The analog gain is a 9-bit code in sixteenths. The low byte goes in P1:0x24 and bit 8 in bit 0 of P1:0x38. The driver wrote only 0x24.

  • 0x38 is now in the per-frame register list, ahead of the trigger.
  • The again table now runs to 511/16 = 31.94x.

Measured in RAW on an hi3516ev300 + SP2305 at a fixed exposure:

step result
0x24 0x10 → 0x20 → 0x40 → 0x80 signal ×2.05, ×2.00, ×1.95
0x38 bit 0 set under 0x24 = 0x10 ×17.1 (code 0x110), pedestal unchanged
AE in a dark room again 32704, 0x38 = 1, ISO 13673 (the maker's camera: 13379)
pedestal at 31.9x 65–67 DN in all four channels, no zeros

White balance, colour matrices and saturation: the maker's

These now match the maker's library for this board. The IQ profile's matrices are written against this curve's colour-temperature scale.

Grey neutrality on one camera and profile, with the maker's camera beside it as the control (max−min over mean of the chart's greys, lower is better):

light chart fit from #248 this curve
3000 K 0.16 0.08
3000 K + 6000 K 0.56 0.32
6000 K 0.41 0.45

Swapping this library for the maker's on the same camera at the same moment moves these numbers by no more than run-to-run scatter. That is why I'm calling it functionally equivalent.

Not changed

  • The 24 MHz timing.
  • The 0x40 black-level target written to P1:0xF0–0xF3, and the 0x100 the ISP subtracts.

The maker's library drops that target. Its pedestal sits near zero and the sensor clips its own noise there, so a profile tuned on that library needs a different black level. That doesn't apply to this one.

The firmware IQ profile that goes with this follows in OpenIPC/firmware.

…defaults

The analog gain is a 9-bit code in sixteenths: the low byte in P1:0x24
and bit 8 in bit 0 of P1:0x38. The driver wrote only 0x24 and stopped at
15.5x, half of what the sensor has. 0x38 now rides in the per-frame
register list ahead of the trigger, and the again table runs on to
511/16 = 31.94x.

Measured on an hi3516ev300 + SP2305 module in RAW at a fixed exposure:

  0x24 0x10 -> 0x20 -> 0x40 -> 0x80   signal x2.05, x2.00, x1.95
  0x38 bit 0 set under 0x24 = 0x10    x17.1 (code 0x110), pedestal unchanged
  AE in a dark room                   again 32704, 0x38 = 1, ISO 13673
                                      (the maker's camera: 13379)

The black pedestal holds at 65-67 DN in all four channels at 31.9x, so
the 0x100 black level stays right; nothing clips at zero.

The white-balance curve, colour matrices and saturation table are now
the ones the module maker's library carries for this board. Its curve
places lights on the colour-temperature scale an IQ profile's matrices
are written against, and on one camera and profile, beside the maker's
camera as the control, it left the chart's greys about twice as close
to neutral as the chart fit from #248 under a 3000 K lamp (0.16 -> 0.08,
max-min over mean) and a 3000 K + 6000 K mix (0.56 -> 0.32), and the
same under 6000 K (0.41 -> 0.45). Swapping this library for the maker's
on the same camera, at the same moment, moves those numbers by no more
than run-to-run scatter.

Left as they were: the 24 MHz timing, the 0x40 black-level target the
init writes to P1:0xF0-0xF3, and the 0x100 the ISP subtracts. The
maker's library drops that target, so its pedestal is near zero and the
sensor clips its own noise there.
@openipc-ai

Copy link
Copy Markdown
Contributor

/review

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@widgetii
widgetii merged commit 6408b71 into main Oct 14, 2026
35 checks passed
widgetii added a commit to OpenIPC/firmware that referenced this pull request Oct 14, 2026
widgetii added a commit to OpenIPC/firmware that referenced this pull request Oct 14, 2026
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