Skip to content

sensor: imx335 on hi3516cv6xx leaves mesh shading to the ISP default, as the vendor ships it - #300

Merged
openipc-ai merged 1 commit into
mainfrom
sensor-imx335-cv6xx-lsc-off
Nov 13, 2026
Merged

openipc-ai merged 1 commit into
mainfrom
sensor-imx335-cv6xx-lsc-off

Conversation

@openipc-ai

Copy link
Copy Markdown
Contributor

Fixes #299.

Problem

imx335_cmos.c on hi3516cv6xx set key.bit1_lsc = 1 with a mesh-shading table whose grid widths sum to 640x360 (16x40 / 9x40). That is a 2560x1440 geometry, and no IMX335 mode uses it. Modes 0/3 (2592x1944) would need 648/486, and mode 2 (1920x1080) would need 480/270.

From the vendor CV610 ISP source (firmware/arch/hi3516cv610/algorithms/isp_lsc.c, firmware/src/main/isp_param_check.c):

Vendor parity

The Hi3516CV610 SDK V1.0.2.0 ships bit1_lsc = 0 for all 15 of its CV610 sensor drivers, IMX335 included. Its IMX335 table has the same gain LUT as ours but a 16x45 / 9x45 grid (2880x1620), which matches no mode either, so the vendor ships the table switched off. In this tree IMX335 was the only cv6xx sensor with the flag on (from #270).

With the flag off, the ISP builds a geometric grid from the frame size with unity gains. That configuration is valid and leaves the image unchanged. isp_def->lsc still points at the table, as in the vendor driver.

Testing

Shading each mode properly would need a new flat-field calibration at every capture geometry. That is out of scope here.

… as the vendor ships it

The cv6xx IMX335 driver set key.bit1_lsc = 1 with a table whose grid sums to
640x360 (16x40 / 9x40), i.e. a 2560x1440 geometry that no IMX335 mode
captures. The CV610 ISP takes x/y_grid_width verbatim (lsc_image_size) and
requires sum == be_total_width/4, be_total_height/4, so every ISP init logged

  isp_mesh_shading_grid_width_check ... x_sum 640 != width / 4, y_sum 360 != height / 4!

and isp_lsc_init() returned before lsc_regs_initialize(): the LSC registers
were never programmed, which is why the A/B in #299 measured no difference.

The vendor Hi3516CV610 SDK ships bit1_lsc = 0 for all 15 of its CV610
sensors, IMX335 included. Its IMX335 table has the same gain LUT but a 16x45 /
9x45 grid (2880x1620), which matches no mode either, so the table is an unused
leftover upstream too. With the flag off the ISP builds a geometric grid from
the frame size with unity gains: valid, and no change to the image.

Fixes #299
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Disable invalid IMX335 mesh shading on hi3516cv6xx

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Disables the IMX335 shading table because its grid geometry matches no capture mode.
• Uses the vendor-default ISP behavior, avoiding mesh-validation errors while leaving the table
 available.
Diagram

graph TD
  A["IMX335 defaults"] --> B["LSC flag off"] --> C["ISP default grid"] --> D["Unity gains"]
  F["Frame dimensions"] --> C
  A -.->|retains| E["Unused LSC table"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Calibrate a shading mesh for each capture mode
  • ➕ Could provide actual lens-shading correction at each geometry.
  • ➖ Requires flat-field calibration and hardware validation for every mode; cannot safely reuse the existing table.

Recommendation: Disable the invalid table now, matching the vendor driver and allowing valid ISP initialization. Consider per-mode calibration separately if shading correction is needed.

Files changed (1) +7 / -1

Bug fix (1) +7 / -1
imx335_cmos.cDisable the incompatible IMX335 LSC table +7/-1

Disable the incompatible IMX335 LSC table

• Sets 'bit1_lsc' to zero so the ISP does not validate the table against capture modes it cannot match. Documents the geometry mismatch and retains the existing 'lsc' pointer, as in the vendor driver.

libraries/sensor/hi3516cv6xx/sony_imx335/imx335_cmos.c

@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 start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit 1b587c6 into main Nov 13, 2026
37 checks passed
@openipc-ai
openipc-ai deleted the sensor-imx335-cv6xx-lsc-off branch November 13, 2026 04:46
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.

sensor: imx335 on hi3516cv6xx: mesh-shading grid matches no selectable mode, and the correction measures inert

1 participant