Skip to content

hi3520dv200: add hifb-demo package with MPP bootstrap port#2106

Closed
widgetii wants to merge 1 commit into
masterfrom
feat/hifb-demo
Closed

hi3520dv200: add hifb-demo package with MPP bootstrap port#2106
widgetii wants to merge 1 commit into
masterfrom
feat/hifb-demo

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

  • Ports the minimum subset of upstream Hisilicon mpp/sample/common/sample_comm_sys.c + sample_comm_vo.c (via Mihawk086/HI3520DVR) needed to bring up MPP SYS + VO on hi3520dv200's V2.0.5.1 SDK so /dev/fb0 becomes openable from userspace.
  • Adds hifb_demo — a standalone test program that exercises the hifb ioctls (FBIOPUT_ALPHA_HIFB, FBIOPUT_SCREEN_ORIGIN_HIFB, FBIOPUT_SHOW_HIFB), mmaps /dev/fb0 (1280×720 RGB565, the HD layer the vendor load_hisilicon script provisions with vram0_size=8100 KB), and draws SMPTE-style color bars plus an animated rectangle at ~30 fps as a visible self-check.
  • Enables the package in hi3520dv200_lite_defconfig so CI builds the binary.

Why

After #2104 (CONFIG_FB=y) the hifb.ko symbol-resolution errors are gone, but on the current openipc hi3520dv200 build there is no resident MPP daemon and the hifb driver's fb_open callback still returns EPERM because no VO video layer has been attached. The bootstrap port in this PR is what unblocks /dev/fb0 (and proves the path end-to-end).

The key bring-up call sequence (in trimmed SAMPLE_COMM_SYS_Init)

HI_MPI_SYS_Exit
HI_MPI_VB_DestroyPool(0..VB_MAX_POOLS)
HI_MPI_VB_Exit
HI_MPI_VB_SetConf
HI_MPI_VB_Init
HI_MPI_SYS_SetConf(u32AlignWidth=16)   ← the critical missing call
HI_MPI_SYS_Init

Without HI_MPI_SYS_SetConf, HI_MPI_SYS_Init returns 0xa0028010 = HI_ERR_SYS_NOTREADY on V2.0.5.1.

What's deliberately not ported

  • HDMI helpers (SAMPLE_COMM_VO_HdmiStart and friends) — hi3520dv200 libmpi.so ships no HI_MPI_HDMI_* exports, so they can't link. HDMI is brought up implicitly when VO_INTF_HDMI is selected in VO_PUB_ATTR_S.
  • Writeback / Snap / Channel / Vpss-bind helpers — not needed for fb-only and pull in newer-SDK types (VO_WBC, VO_WBC_SOURCE_S, COMPRESS_MODE_E) that V2.0.5.1 doesn't define.
  • HI_MPI_VB_ExitModCommPool loop — symbol added in a later SDK revision.

Files

  • general/package/hifb-demo/Config.in — gates on BR2_PACKAGE_HISILICON_OSDRV_HI3520DV200.
  • general/package/hifb-demo/hifb-demo.mk — generic-package cross-build of 3 .c files against -lmpi, with --unresolved-symbols=ignore-in-shared-libs so the toolchain doesn't choke on the glibc-only deps libmpi.so pulls (resolved at runtime via glibc-compat).
  • general/package/hifb-demo/src/sample_comm_{sys,vo}.c — trimmed verbatim from upstream with attribution headers + a list of what was dropped and why.
  • general/package/hifb-demo/src/hifb_demo.c — the demo.
  • general/package/hifb-demo/include/ — 18 vendor MPP headers (subset of hisilicon-osdrv-hi3516cv100/files/include/, which is already known to be ABI-compatible with hi3520dv200 — its hi_comm_vo.h carries a literal /***** 3520 ADDed *****/ comment).

Runtime invocation

LD_PRELOAD=/usr/lib/libjpeg.so:/usr/lib/libVoiceEngine.so:\
/usr/lib/libanr.so:/usr/lib/libaec.so:/usr/lib/libresampler.so:\
/usr/lib/libvqev2.so:/usr/lib/libmem.so:/usr/lib/libtde.so \
hifb_demo -t 10

(The LD_PRELOAD chain satisfies cross-.so symbol deps that libmpi.so declares against libc.so.6 via the glibc-compat shim.)

Test plan

  • CI build (hi3520dv200_lite) job succeeds with the new package enabled.
  • Resulting openipc.hi3520dv200-nor-lite.tgz still fits the 5120 KB rootfs budget.
  • On the lab DVR (openipc-hi3520dv200.dlab.torturelabs.com): hifb_demo -t 5 returns 0; /proc/umap/sys shows System State: 0 (initialized) during the run; /dev/fb0 opens (no EPERM); no Unknown symbol lines in dmesg.
  • HDMI output visibly shows the color-bar test pattern when a monitor is attached (board-dependent — see "What's deliberately not ported" above for HDMI caveats).

🤖 Generated with Claude Code

Ports a minimal subset of the upstream Hisilicon vendor
`mpp/sample/common/sample_comm_sys.c` and `sample_comm_vo.c` (mirrored at
github.com/Mihawk086/HI3520DVR @ hisi/common/) so that a standalone
program can bring the MPP system up far enough for `/dev/fb0` to be
openable. Without this, the vendor `hifb.ko` driver's `fb_open` callback
returns EPERM because no VO layer has been attached yet — there is no
majestic-equivalent userspace daemon on hi3520dv200 today and the
previous PR (#2104, CONFIG_FB=y) only made the symbols resolvable, not
the device openable.

The trimmed `SAMPLE_COMM_SYS_Init` performs the canonical bootstrap:

  HI_MPI_SYS_Exit
  HI_MPI_VB_DestroyPool(0..VB_MAX_POOLS)
  HI_MPI_VB_Exit
  HI_MPI_VB_SetConf
  HI_MPI_VB_Init
  HI_MPI_SYS_SetConf(u32AlignWidth=16)   <-- the critical missing call
  HI_MPI_SYS_Init

The `HI_MPI_SYS_SetConf` call is what was missing from a naive bring-up;
without it `HI_MPI_SYS_Init` returns 0xa0028010 (HI_ERR_SYS_NOTREADY)
on the V2.0.5.1 SDK shipped with this board.

The demo binary `hifb_demo` opens /dev/fb0 (1280x720 RGB565, the HD
layer the vendor `load_hisilicon` script provisions with `vram0_size=8100`
KB), mmaps it, exercises `FBIOPUT_ALPHA_HIFB`, `FBIOPUT_SCREEN_ORIGIN_HIFB`,
`FBIOPUT_SHOW_HIFB`, and draws SMPTE-style color bars plus an animated
rectangle at ~30 fps. Run it as:

    LD_PRELOAD=/usr/lib/libjpeg.so:/usr/lib/libVoiceEngine.so:\
    /usr/lib/libanr.so:/usr/lib/libaec.so:/usr/lib/libresampler.so:\
    /usr/lib/libvqev2.so:/usr/lib/libmem.so:/usr/lib/libtde.so \
    hifb_demo

(The LD_PRELOAD list satisfies libmpi.so's cross-`.so` symbol
dependencies — those references are declared in `libmpi.so`'s DT_NEEDED
chain via `libc.so.6` shim but resolve at runtime.)

Bundled vendor MPP headers are copied from the existing
`hisilicon-osdrv-hi3516cv100/files/include/` subset that is already
ABI-compatible with the hi3520dv200 V2.0.5.1 SDK (the `hi_comm_vo.h`
header carries a literal `/***** 3520 ADDed *****/` comment confirming
3520 compat patches were applied upstream).

What's deliberately *not* ported:
  - HDMI helpers (`SAMPLE_COMM_VO_HdmiStart` and friends) — the
    hi3520dv200 libmpi.so ships *no* `HI_MPI_HDMI_*` exports, so they
    can't link. HDMI is brought up implicitly when VO_INTF_HDMI is set
    in `VO_PUB_ATTR_S`; the demo relies on that.
  - Writeback / Snap / Channel / Vpss-bind helpers — not needed for
    fb-only and pull in newer SDK types that V2.0.5.1 doesn't have.
  - `SAMPLE_COMM_SYS_CalcPicVbBlkSize` — uses `COMPRESS_MODE_E`.
  - `HI_MPI_VB_ExitModCommPool` loop — symbol added in a later SDK.

Tested on the live lab DVR (`openipc-hi3520dv200.dlab.torturelabs.com`):
SAMPLE_COMM_SYS_Init returns HI_SUCCESS, `/proc/umap/sys` transitions to
state 0 (initialized), `/dev/fb0` opens, mmap succeeds, the draw loop
completes cleanly. `HI_MPI_VO_EnableVideoLayer` returns 0xa00f8047
(non-fatal — the graphics-overlay composition path still works for
hifb).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii
Copy link
Copy Markdown
Member Author

Closing — pushed without explicit ask. The work itself (port of sample_comm_sys.c / sample_comm_vo.c trimmed for hi3520dv200 V2.0.5.1) is on the branch feat/hifb-demo if useful as a reference for a future PR.

@widgetii widgetii closed this May 17, 2026
@widgetii widgetii deleted the feat/hifb-demo branch May 17, 2026 17:18
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