Skip to content

About

Open-source sensor libraries for Fullhan IP camera SoCs, built from source (FH885x V100/V200)

Resources

Code of conduct

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

OpenFullhan

Sensor libraries for Fullhan IP camera SoCs, built from source, laid out like OpenHisilicon. Used by OpenIPC firmware, which otherwise ships the SDK's prebuilt lib<sensor>_mipi.so files.

Supported hardware

SoC family Chips Kernel SDK the sources come from
fh8852v100 FH8852, FH8856 (V100) 3.0.8 FH8856_IPC_V1.2.0_20200324
fh8852v200 FH8852V200/V210, FH8856V200/V210, FH8858V200/V210 4.9.129 FH885XV200_IPC_V1.1.0_20210716 + FH885XV200_IPC_V1.1.0.FP13_20211202

The family names are OpenIPC's OPENIPC_SOC_FAMILY.

Layout

libraries/
  include/<family>/        ISP, DSP and MIPI headers the drivers build against
  sensor/<family>/
    common/                the SDK's sensor_common (I2C, clock and register helpers)
    <vendor>_<sensor>/     one driver per directory
    sdk/                   the SDK's own sensor-build scripts, as shipped

Provenance

The first commit is the sensor sources Fullhan ships in its SDKs' media_support/tools/sensor-build, byte for byte; only their location changed. Each source still carries its BUILD VERSION: <SDK> @ <hash> line. The FH885xV200 base release ships the headers and build scripts, and its FP13 patch the isp/libs/sensor tree, so fh8852v200 is the base with FP13 over it, as the SDK intends.

SDK path (under media_support/tools/sensor-build/) Here (under libraries/)
isp/include/*, dsp/include/* include/<family>/
dsp/drivers/fh_std/include/* (V200) include/fh8852v200/fh_std/
isp/drivers/include/version.h include/<family>/version.h
isp/libs/mipi/mipi_ctrl.h include/<family>/mipi/mipi_ctrl.h
isp/libs/sensor/{Makefile,Sensor.make,*.py} sensor/<family>/
isp/libs/sensor/sensor_common/ sensor/<family>/common/
isp/libs/sensor/jxf22_mipi/ sensor/<family>/soi_jxf22/
isp/libs/sensor/ovos05_mipi/ sensor/<family>/omnivision_os05a/
README.txt, build.sh, setup_env.sh, isp/{Makefile,Rules.mk} sensor/<family>/sdk/

The SDKs ship sensor sources for these two sensors only. Every other sensor library in them is a prebuilt .so; drivers for other sensors are added here as source.

Sensors written here

Family Directory Sensor Sources of its register values
fh8852v100 galaxycore_gc4653 GalaxyCore GC4653, 2560x1440 at 15-30 fps, MIPI 2-lane RAW10 GalaxyCore's datasheet (V1.0), and for the PLL/analog start-up and gain steps the datasheet omits, sophgo/SensorSupportList (BSD-2-Clause, notice kept in gc4653_mipi.h)
fh8852v200 imagedesign_mis4001 MIS4001, 2560x1440 at 15, 20 and 25 fps, MIPI 2-lane RAW10 The library in the Tuya F1602-D2's stock firmware (see below)

Its ISP defaults are the SDK's JX-F22 tables and its .hex tuning the SDK's GC4633 files until the sensor is tuned on a camera, with two changes.

The SDK ships one GC4633 file as both its day and night tuning, and it is a night one: the 16-bit word at 0x78 is 0x0040, as in the stock PB1's own GC4653 night tuning, where every day tuning in the SDK, and the PB1's own GC4653 day tuning, has 0x0100. In gc4653_mipi_attr.hex that word is 0x0100, so the day file matches the SDK's day tunings; the night file keeps 0x0040. What the word controls is not known. The grey day picture first seen on a PB1 (OpenIPC/firmware#1610) was majestic's, not this word's: it went away with a majestic fix, and nobody has tested the old value since.

In both, offset 0x6e is 0x00, not GC4633's 0x02. Bit 1 there tells libispcore that the sensor applies white balance itself, through the driver's get_awb_gain. The GC4653 driver does not, so the ISP is left with zero gains and the white-balance loop divides by zero (SIGFPE in SetWbGain). Every other 2560x1440 tuning in the SDK (GC4623, OS05A) has 0x00 there.

In the day file, the saturation is lower than GC4633's: the level at 0x4a1 and the 12 gain steps at 0x4a4-0x4af are scaled by 42/50 (0x60 to 0x50; 48 48 44 40 40 30 28 20 18 12 10 10 to 3c 3c 39 35 35 28 21 1a 14 0f 0d 0d). On a PB1, GC4633's values gave colours its owner called "very saturated and unrealistic". With majestic's image.saturation, 42 matched red, green and blue test objects and a phone photo of the same scene. The file with those bytes scaled, under a majestic that does not apply image.saturation, looked the same (OpenIPC/firmware#1610). The SDK's JX-F22 night tuning zeroes the bytes at 0x4a0-0x4a1, which is how this block was found.

MIS4001 (fh8852v200/imagedesign_mis4001)

Written for the Tuya F1602-D2 (OpenIPC/builder#291), whose stock firmware (8.37.200, application dgiot, platform "HC1702") has a MIS4001 library the SDK does not. mis4001_mipi.h holds that library's register lists, picture attributes, white-balance presets and local-tone-mapping curves, read out of it; mis4001_mipi.c is written here on the SDK's common/ (the stock library was built on the same sensor_common, down to its version string) and keeps that library's behaviour, which a harness driving both builds through every interface slot against a simulated sensor shows register for register, except in these places:

  • Orientation (OpenIPC/majestic#416). The stock library wrote the orientation register, read it straight back, and moved only one of the two readout windows, chosen by what it read. A readback that still showed the previous orientation left a stale window and a magenta picture until the next switch. Here both windows are written from the orientation asked for, to the four states the stock library reached from a fresh start, which were checked on the camera. The Bayer table is the one measured there (OpenIPC/builder#292).
  • get_flipmirror reports both bits, as isp_sensor_if.h defines them; the stock library returned the flip bit alone.
  • The gain register is written only when its value changes. The stock library compared requests with a byte-wide copy of the last gain, so after a gain above 255 a request equal to its low byte was skipped and the sensor kept the old gain.
  • Before any format, or after a refused one, get_vi_attr and set_sns_frame_height return an error. The stock library read through a null table there and crashed.
  • AE limits. The AE is told the gain tops out at 15.75x (1008 in U.6), where the sensor does; the stock library said 0x7fff. Under slow shutter the line is stretched, and the AE is told the line rate that results; the stock library went on reporting the mode's own.
  • init sets the sensor clock before it probes, and fails when no MIS4001 answers or the clock or I2C cannot be set up. The stock library probed first and carried on regardless, at 0x60.

The tuning files came from the F1602-D2 builder profile, where they were made: the SDK's OVOS05 tuning (the stock MIS4001 tuning could not be recovered), with three changes measured on that camera.

  • Black level (0x2bc, 12 x u16): scaled to 50 %. The OVOS05 values are about 2x too high for this sensor and turned shadows green; checked on a ColorChecker shown on a monitor (dark greys neutral; 30 % goes magenta).
  • Colour matrices (0x238, 4 x 24 bytes, 3x3 int13 with rows summing to 512): a gentle fitted matrix, [[561, -76, 27], [-178, 721, -31], [-8, -26, 546]].
  • 3D noise reduction: the coefficient-index nibbles at 0x334 set to 0 and the strength curve at 0x33c halved, which removes the ghosting trails behind dark objects moving against a dark background.

Building

Each sensor directory has a self-contained Makefile; pass the toolchain:

make -C libraries/sensor/fh8852v100/galaxycore_gc4653 CC=arm-openipc-linux-musleabi-gcc
make -C libraries/sensor/fh8852v200/imagedesign_mis4001 CC=arm-openipc-linux-musleabi-gcc

Licence

GPL-3.0 (LICENSE) for the code written here. The SDK files keep their origin (see Provenance); the GC4653 register tables carry Sophgo's BSD-2-Clause notice.

About

Open-source sensor libraries for Fullhan IP camera SoCs, built from source (FH885x V100/V200)

Resources

Code of conduct

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages