Skip to content

moontwister/kc110-mipi-shim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kc110-mipi-shim

2026-05-28 update — deprecated. Root cause turned out to be four wrong fields in cv200's ov2735_i2c_1080p.ini, not a majestic code bug. Master majestic (master+bcf6700 and later) constructs combo_dev_attr_t correctly from the .ini when those fields are right. This shim is kept here as a downstream workaround for users still on pre-master majestic builds. See "Deprecation path" below.

Buildroot package that builds libfixmipi.so — an LD_PRELOAD shim for OpenIPC's majestic streaming daemon on HiSilicon Hi3518EV200 (cv200 family) cameras with an OV2735 MIPI sensor. Workaround for OpenIPC/majestic#278 until the upstream fix lands.

The actual bug (now known)

The shim was forcing two ioctls into a correct state at runtime. Both HI_MIPI_SET_DEV_ATTR and VIU_DEV_ATTR_SET were receiving garbled values because the .ini was wrong, not because majestic was constructing the struct wrong. Master majestic now has a SET_DEV_ATTR: input_mode=N raw_data_type=N lanes=[…] diagnostic log + a fail-fast that compares [mode] input_mode against [vi_dev] Input_mod, which made it possible to walk through the failure modes step-by-step.

The four wrong fields in cv200's ov2735_i2c_1080p.ini (all fixed in OpenIPC/firmware#2155):

Field Was Now Why
[mode] input_mode 4 0 (INPUT_MODE_MIPI) 4 is unused; MIPI is 0.
[mipi] data_type 3 (RAW12) 2 (RAW10) OV2735 outputs RAW10.
[mipi] lane_id 0|1|2|3|... 0|1|-1|-1|... OV2735 cv200 = 2 lanes.
[vi_dev] Input_mod 2 (DIGITAL_CAMERA) 5 (MIPI) Must agree with [mode] input_mode per master majestic's new check.

Once those four fields are right, master majestic produces LaneNum=2 RAW10 MIPI in /proc/driver/hi_mipi, ISP/VENC IRQs climb, RTSP delivers clean H264 1080p — no shim needed. End-to-end verified on TP-Link Kasa KC110 (Hi3518EV200 + OV2735 2-lane RAW10).

The shim itself

libfixmipi.so intercepts ioctl() via LD_PRELOAD + RTLD_NEXT. When it sees HI_MIPI_SET_DEV_ATTR with input_mode == 0 (MIPI), it overwrites raw_data_type and lane_id[] with the correct values, then calls the real ioctl(). Same for VIU_DEV_ATTR_SET. Logs a one-liner to stderr on first patch so you can see it firing in dmesg / logread.

Source: src/libfixmipi.c — ~70 lines.

combo_dev_attr_t layout (32-bit ARM):

offset 0..3   : u32 input_mode_t input_mode
offset 4..7   : u32 mipi_dev_attr_t.raw_data_type
offset 8..23  : s16 mipi_dev_attr_t.lane_id[8]

Activation (if you still need it)

The shim must be wired in by exporting LD_PRELOAD=/usr/lib/libfixmipi.so from /etc/init.d/S95majestic before majestic starts:

export LD_PRELOAD=/usr/lib/libfixmipi.so

This package ships only the .so. The activation lives in your firmware overlay's S95majestic (a 7-line addition on top of the upstream version).

Building (downstream OpenIPC firmware)

  1. Drop this package under general/package/kc110-mipi-shim/ in your OpenIPC/firmware checkout.
  2. Add source "$BR2_EXTERNAL_GENERAL_PATH/package/kc110-mipi-shim/Config.in" to general/package/Config.in.
  3. Add BR2_PACKAGE_KC110_MIPI_SHIM=y to your board's _defconfig.
  4. Build as usual (make BOARD=<your-board>).

Cross-compiled with the OpenIPC musl toolchain (arm-openipc-linux-musleabi-gcc -O2 -fPIC -shared -ldl). The resulting libfixmipi.so is ~5 KB stripped.

Who still needs this

You need the shim if any of the below applies:

  • Your majestic binary is older than master+bcf6700 (2026-05-28) — master with the diagnostic log + fail-fast.
  • Your ov2735_i2c_1080p.ini doesn't have the four fields above set correctly.
  • You're using an OV2735 on cv200 hardware (Hi3518EV200, Hi3516CV200, etc.) AND not yet on a build that includes OpenIPC/firmware#2155.

If none of those apply, the shim does nothing useful — drop it.

Deprecation path

Once both of these land:

  1. OpenIPC/firmware#2155 merges (4-field cv200 .ini fix).
  2. BR2_PACKAGE_MAJESTIC fetches a build at or past master+bcf6700.

Then:

  1. Drop BR2_PACKAGE_KC110_MIPI_SHIM=y from your defconfig.
  2. Remove the LD_PRELOAD export from S95majestic.
  3. Verify majestic starts without the shim.
  4. Delete this package.
  5. This repo can be archived.

Hardware tested

  • TP-Link Kasa KC110 — Hi3518EV200 + OV2735 (MIPI 2-lane, RAW10) + RTL8188FU. Builder device entry at OpenIPC/builder#99.

Probably also affects any other cv200 board using an OV2735 sensor with a pre-fixed .ini, but only KC110 verified.

License

MIT.

About

LD_PRELOAD shim around majestic's MIPI ioctl construction on HiSilicon cv200 (workaround for OpenIPC/majestic#278)

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors