Skip to content

sensor: imx662 on hi3516cv6xx runs the stock firmware's day white balance - #298

Merged
openipc-ai merged 1 commit into
mainfrom
sensor-imx662-vendor-day-awb
Nov 12, 2026
Merged

openipc-ai merged 1 commit into
mainfrom
sensor-imx662-vendor-day-awb

Conversation

@openipc-ai

Copy link
Copy Markdown
Contributor

The IMX662 driver on hi3516cv6xx (#296) carries the AWB calibration and colour matrices from the stock firmware's cmos defaults. The SIP-K662C6S module never runs those: once its ISP is up, the stock firmware's day scene (IMX662_ISP_SetAWBAttr, scene 0) writes its own AWB curve, reference gains and colour-matrix table over them. With the defaults, the picture on the module was green and the sky cyan (OpenIPC/majestic#370).

The driver now carries the day scene's values:

  • AWB curve: -86, 342, 0, 199146, 128, -148048.
  • Reference gains: 418/545 at 4950 K.
  • Colour matrices at 7500, 6500, 4800 and 2600 K. The table is now written out as values instead of a byte image.

Measured on the module, with the same majestic and IQ profile, on the delivered JPEG (R/G / B/G of neutral surfaces):

driver defaults day scene
grey pavement, overcast 0.62 / 0.55–0.59 0.78–0.80 / 0.89
sky, overcast 0.79 / 0.88 0.84 / 1.03
white fascia, sun – 1.01–1.03 / 0.94–0.97

The overcast rows are an A/B/A/B swap of the sensor library at about 11:25 UTC. In sun, raw frames show AWB landing within 0–5% of the neutral red gain and 4–7% short of the neutral blue gain.

The matrix bytes of this build match the library tested on the camera.

Not covered:

  • Under an overcast sky the picture stays slightly cool. That case has not been measured against raw.
  • The stock firmware's other scenes (1–4) are not carried.
  • Its black level of 820 is not carried either; this driver uses 800.

The camera owner has seen the result on their camera and agreed to make it the default.

…ance

The driver carried the AWB calibration and colour matrices of the stock
firmware's cmos defaults. Those are never what the SIP-K662C6S module runs:
once its ISP is up, the stock firmware's day scene (IMX662_ISP_SetAWBAttr,
scene 0) writes its own AWB curve, reference gains and a four-temperature
colour matrix table over them. On the module the defaults gave a green
picture and a cyan sky.

The driver now carries the day scene's values: curve -86, 342, 0, 199146,
128, -148048, reference gains 418/545 at 4950 K, and matrices at 7500,
6500, 4800 and 2600 K. The matrix table is written out as values rather
than a byte image.

Measured on the module, with the same host program and IQ profile:
- Overcast: grey pavement went from R/G 0.62, B/G 0.55-0.59 to 0.78-0.80
  and 0.89; the sky went from B/G 0.88 to 1.03.
- Sun: a white fascia reads R/G 1.01-1.03, B/G 0.94-0.97. Against raw
  frames AWB lands within 0-5% of the neutral red gain and 4-7% short of
  the blue.

An overcast sky still leaves the picture slightly cool. That has not been
measured against raw.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Use stock day-scene white balance for hi3516cv6xx IMX662

🐞 Bug fix 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Replace IMX662 AWB defaults with stock day-scene calibration to reduce the green and cyan cast.
• Set four day-scene colour matrices as typed values rather than a byte image.
• Document on-camera measurements and the remaining overcast and scene-coverage limitations.
Diagram

graph TD
  A["AWB calibration"] --> C["AWB defaults callback"] --> D["ISP white balance"] --> E["Output image"]
  B["Day colour matrices"] --> C
Loading
High-Level Assessment

Using the day-scene values as sensor defaults matches the stock firmware's effective configuration without adding runtime scene handling. Keeping the other scenes and black-level change out of scope is appropriate given the stated measurements.

Files changed (3) +62 / -11

Bug fix (2) +35 / -11
imx662_cmos.hApply day-scene AWB gains and curve +13/-7

Apply day-scene AWB gains and curve

• Changes the reference red and blue gains and AWB curve coefficients to stock day-scene values while retaining the 4950 K reference temperature. Comments identify the superseded firmware-driver defaults.

libraries/sensor/hi3516cv6xx/sony_imx662/imx662_cmos.h

imx662_cmos_param.hReplace CCM byte image with day-scene matrix values +22/-4

Replace CCM byte image with day-scene matrix values

• Replaces the previous byte-backed CCM with a typed four-temperature table at 7500, 6500, 4800, and 2600 K. The existing AWB callback continues to copy this table into ISP defaults.

libraries/sensor/hi3516cv6xx/sony_imx662/imx662_cmos_param.h

Documentation (1) +27 / -0
README.mdDocument day-scene white balance and camera measurements +27/-0

Document day-scene white balance and camera measurements

• Explains why stock day-scene AWB differs from the firmware driver's defaults and records JPEG colour-ratio measurements. Notes the unmeasured overcast residual, omitted scenes, and unchanged black level.

libraries/sensor/hi3516cv6xx/sony_imx662/README.md

@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 open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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.

1 participant