Skip to content

gk7205v500: build the V4 sensor drivers from their one source - #230

Merged
widgetii merged 2 commits into
mainfrom
sensor-single-source
Sep 25, 2026
Merged

widgetii merged 2 commits into
mainfrom
sensor-single-source

Conversation

@widgetii

Copy link
Copy Markdown
Member

#229 added libraries/sensor/gk7205v500/imagedesign_mis2008, a copy of the
hi3516ev200 MIS2008 driver with GK_* renamed to XMEDIA_*. That is the same
driver twice: the XMedia SPC020 sensor interface is the V4 one rebranded,
the same relationship HiSilicon's and Goke's already have and that
include/hicompat.h bridges for the V4 drivers.

So the copy goes, and CHIPARCH=gk7205v500 builds sensor/hi3516ev200 like
the other V4 targets. sensor/compat/xmedia maps the drivers' Goke names
onto the SDK:

  • xm_gk_compat.h: GK_/gk_ types and constants onto XMEDIA_*. Force-
    included: the drivers often get the Goke types only through the SDK
    headers, and those include their own type.h relative to themselves, so
    shadowing type.h on the include path cannot reach them;
  • gk_api_{isp,ae,awb}.h, hicompat.h: GK_API_* onto XMEDIA_API_*, with the
    SDK's own prototypes.

libraries/Makefile puts these and the SDK headers imported under kernel/
ahead of the V4 include/ the per-sensor Makefiles add; no driver or
per-sensor Makefile changes.

All 30 V4 sensor drivers now build for gk7205v500 (before: only MIS2008,
as the copy), with no warning the gk7205v200 build of the same sources
does not already have; gk7205v200 still builds all 30. On the GK7201V200 /
MIS2008 camera the shared-source libsns_mis2008.so initialises the sensor
and majestic streams 1080p25 H.264 with a correct image.

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

Copy link
Copy Markdown

PR Summary by Qodo

Build gk7205v500 V4 sensor drivers from shared sources

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Build all shared V4 sensor drivers for gk7205v500 through XMedia compatibility headers.
• Translate Goke types and ISP, AE, and AWB callbacks onto XMedia SDK APIs.
• Remove the duplicated XMedia-only MIS2008 driver implementation.
Diagram

graph TD
  A["gk7205v500 Build"] --> B["V4 Drivers"] --> C["Sensor Libraries"]
  A --> D["XMedia Flags"] --> E["Compat Headers"] --> F["XMedia SDK"]
  E --> B
Loading
High-Level Assessment

The compatibility-layer approach is the best fit because SPC020 is the V4 interface under different names. It preserves one source of truth for all 30 drivers and avoids either maintaining copied platform ports or adding XMedia conditionals throughout every sensor source and Makefile.

Files changed (6) +117 / -6

Enhancement (5) +101 / -0
gk_api_ae.hMap Goke AE callbacks to XMedia APIs +11/-0

Map Goke AE callbacks to XMedia APIs

• Provides the Goke AE header name expected by shared drivers while importing native XMedia declarations. Registration and unregistration calls are aliased to their XMedia equivalents.

libraries/sensor/compat/xmedia/gk_api_ae.h

gk_api_awb.hMap Goke AWB callbacks to XMedia APIs +11/-0

Map Goke AWB callbacks to XMedia APIs

• Provides the expected Goke AWB compatibility header and maps sensor registration callbacks onto the native XMedia AWB API.

libraries/sensor/compat/xmedia/gk_api_awb.h

gk_api_isp.hMap Goke ISP callbacks to XMedia APIs +12/-0

Map Goke ISP callbacks to XMedia APIs

• Adapts Goke ISP registration, unregistration, and module-parameter API names to the corresponding XMedia SDK functions while retaining native prototypes.

libraries/sensor/compat/xmedia/gk_api_isp.h

hicompat.hRoute shared driver compatibility includes through XMedia +13/-0

Route shared driver compatibility includes through XMedia

• Shadows the standard V4 compatibility header for XMedia builds. It aggregates the ISP, AE, and AWB adapters so existing driver includes resolve without source changes.

libraries/sensor/compat/xmedia/hicompat.h

xm_gk_compat.hTranslate Goke primitive types and constants to XMedia +54/-0

Translate Goke primitive types and constants to XMedia

• Defines the uppercase and lowercase Goke primitive types, status values, booleans, and null constant expected by V4 drivers. The header is designed for forced inclusion because SDK-relative type headers cannot be shadowed through include-path ordering.

libraries/sensor/compat/xmedia/xm_gk_compat.h

Other (1) +16 / -6
MakefileBuild shared V4 drivers with XMedia compatibility flags +16/-6

Build shared V4 drivers with XMedia compatibility flags

• Selects the hi3516ev200 V4 sensor directories for gk7205v500 instead of a target-specific sensor tree. It prepends compatibility and XMedia SDK include paths, force-includes the type adapter, and forwards those flags into each sensor build.

libraries/Makefile

@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 enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

#229 added libraries/sensor/gk7205v500/imagedesign_mis2008, a copy of the
hi3516ev200 MIS2008 driver with GK_* renamed to XMEDIA_*. That is the same
driver twice: the XMedia SPC020 sensor interface is the V4 one rebranded,
the same relationship HiSilicon's and Goke's already have and that
include/hicompat.h bridges for the V4 drivers.

So the copy goes, and CHIPARCH=gk7205v500 builds sensor/hi3516ev200 like
the other V4 targets. sensor/compat/xmedia maps the drivers' Goke names
onto the SDK:

- xm_gk_compat.h: GK_*/gk_* types and constants onto XMEDIA_*. Force-
  included: the drivers often get the Goke types only through the SDK
  headers, and those include their own type.h relative to themselves, so
  shadowing type.h on the include path cannot reach them;
- gk_api_{isp,ae,awb}.h, hicompat.h: GK_API_* onto XMEDIA_API_*, with the
  SDK's own prototypes.

libraries/Makefile puts these and the SDK headers imported under kernel/
ahead of the V4 include/ the per-sensor Makefiles add; no driver or
per-sensor Makefile changes.

All 30 V4 sensor drivers now build for gk7205v500 (before: only MIS2008,
as the copy), with no warning the gk7205v200 build of the same sources
does not already have; gk7205v200 still builds all 30. On the GK7201V200 /
MIS2008 camera the shared-source libsns_mis2008.so initialises the sensor
and majestic streams 1080p25 H.264 with a correct image.
@widgetii
widgetii force-pushed the sensor-single-source branch from c1f5344 to 83a3f48 Compare September 25, 2026 12:26
cmos_dgain_calc_table() used a hard-coded size of 255 for Dgain_table[],
which has 240 entries, so its saturation check read Dgain_table[254] --
whatever the linker put after the table -- and returned that as the
sensor digital gain. What that is depends on the build: an -O0 build
happened to get a large value and behaved, the optimised firmware build
of the same source gets 0. With a Dgain of 0 the AE's system gain is 0,
so it holds exposure short and makes the picture up with ~4x ISP digital
gain -- a noisy, yellow-cast image (seen on GK7201V200: Line 64, Again
1x, Dgain 0, IspDg 4176, ISO 0).

The size now comes from the table. Same camera, same scene, firmware
build: Line 2694, Again 8x, Dgain 1024, IspDg ~1x, ISO 843, clean image.
The bug is in the shared V4 driver, so hi3516ev200/gk7205v200 builds had
it too.
@widgetii

Copy link
Copy Markdown
Member Author

Added b1f1711: the shared V4 MIS2008 driver read Dgain_table with a hard-coded size of 255 (the table has 240 entries), so the Dgain saturation check read past the table and, in the optimised firmware build, returned a digital gain of 0 -- AE then ran on ~4x ISP gain and the image was noisy and yellow. Found while testing the gk7201v200_lite firmware build of this branch on the GK7201V200/MIS2008 camera; with the fix the same build and scene give Dgain 1024, ISO 843 and a clean image. The bug predates this PR and affects the hi3516ev200/gk7205v200 builds too.

@widgetii
widgetii merged commit 6eb7736 into main Sep 25, 2026
35 checks passed
@widgetii
widgetii deleted the sensor-single-source branch September 25, 2026 13:07
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