Skip to content

opus-openipc: bake HiSilicon ot_opus_* shim into libopus (cv6xx)#2174

Merged
widgetii merged 1 commit into
masterfrom
cv6xx-opus-ot-shim
Jun 5, 2026
Merged

opus-openipc: bake HiSilicon ot_opus_* shim into libopus (cv6xx)#2174
widgetii merged 1 commit into
masterfrom
cv6xx-opus-ot-shim

Conversation

@widgetii

@widgetii widgetii commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds 6 open-source ot_opus_* shim wrappers (ot_opusenc_*, ot_opusdec_*) to libopus so the Hi3516CV6xx vendor MPP audio adapter (libss_mpi_audio_adp.so) can resolve them at runtime against the open opus build instead of the closed vendor libopus blob.
  • Gates the shim behind a new opt-in option BR2_PACKAGE_OPUS_OPENIPC_HISI_SHIM so other SoCs don't pay 6 dead symbols + host autotools deps.
  • Enables the option in hi3516cv6xx_ultimate_defconfig.

Background

After PR #2172 landed the cv6xx ultimate variant, sysupgrade onto live CV608 hardware boots fine (35 modules load, mmz hang gone), but majestic fails at relocation with:

Error relocating /usr/lib/libss_mpi_audio_adp.so: ot_opusdec_create: symbol not found
... (5 more ot_opus_* symbols)

libss_mpi_audio_adp.so (closed) needs 6 HiSilicon-only ot_opus_* wrappers whose source isn't shipped — vendor only ships them inside its prebuilt libopus.so. The osdrv .mk previously excluded that vendor blob on the assumption that BR2_PACKAGE_OPUS_OPENIPC covered the surface, but buildroot opus is upstream Opus and doesn't have the vendor wrappers.

Implementation

  • general/package/opus-openipc/src/ot_opus_shim.c — 6 thin shims against the public Opus API, error-code mapped to OT_ERR_OPUS{ENC,DEC}_*. Marked with __attribute__((visibility("default"))) because upstream Opus builds with -fvisibility=hidden.
  • general/package/opus-openipc/Config.in — new BR2_PACKAGE_OPUS_OPENIPC_HISI_SHIM switch, off by default.
  • general/package/opus-openipc/opus-openipc.mk — gated POST_EXTRACT_HOOKS copies the shim into src/ and seds Makefile.am to add it to libopus_la_SOURCES; gated AUTORECONF=YES so Makefile.in is regenerated from .am. Untouched for SoCs that don't enable the switch.
  • br-ext-chip-hisilicon/configs/hi3516cv6xx_ultimate_defconfig — turns the switch on.
  • general/package/hisilicon-osdrv-hi3516cv6xx/hisilicon-osdrv-hi3516cv6xx.mk — comment updated; libopus.so stays out of the vendor install set, now legitimately covered by the open opus build.

Signatures (from Hi3516CV610 SDK V1.0.2.0 public headers)

The shim implements:

  • ot_opus_encoder ot_opusenc_create(const ot_opusenc_config *)
  • void ot_opusenc_destroy(ot_opus_encoder)
  • int ot_opusenc_process_frame(ot_opus_encoder, short *, int, unsigned char *, unsigned int *)
  • ot_opus_decoder ot_opusdec_create(const ot_opusdec_config *)
  • void ot_opusdec_destroy(ot_opus_decoder)
  • int ot_opusdec_process_frame(ot_opus_decoder, unsigned char **, int *, short *, unsigned int *)

ot_opusdec_process_frame treats each call as one self-contained Opus packet (matching the consumer pattern in mpp/cbb/audio/adp/src/ot_audio_opus_adp.c) and advances *in_buf / *in_left_byte accordingly.

Test plan

  • make BOARD=hi3516cv6xx_ultimate br-opus-openipc-dirclean && br-opus-openipc — autoreconf runs, build clean
  • readelf --dyn-syms output/per-package/opus-openipc/target/usr/lib/libopus.so.0.8.0 | grep ot_opus — all 6 exported GLOBAL DEFAULT
  • unsquashfs output/images/rootfs.squashfs usr/lib/libopus.so.0.8.0 && readelf --dyn-syms ... | grep ot_opus — symbols present in the firmware image artifact
  • firmware repack succeeds at 10048 KB / 16384 KB budget
  • On-target: flash refreshed firmware to live CV608, confirm majestic relocates clean and serves RTSP
  • CI build-one passes for hi3516cv6xx-ultimate

🤖 Generated with Claude Code

The Hi3516CV6xx vendor MPP audio adapter libss_mpi_audio_adp.so calls
6 ot_opus_* wrapper functions (ot_opusenc_create/_destroy/_process_frame
and ot_opusdec_* counterparts) that ship only inside the closed vendor
libopus.so. Without those symbols majestic fails at relocation time
with "ot_opusdec_create: symbol not found" on cv6xx boards.

This adds an open-source equivalent of the wrappers (src/ot_opus_shim.c)
built into buildroot's libopus, gated behind a new opt-in option
BR2_PACKAGE_OPUS_OPENIPC_HISI_SHIM so SoCs that don't need the
ot_opus_* surface neither pay 6 dead symbols nor pull host autotools
deps. Enables the option in hi3516cv6xx_ultimate_defconfig so the
single open libopus satisfies both the standard libopus.so.0 SONAME
path and the vendor binary's unversioned libopus.so DT_NEEDED entry —
the vendor blob can stay out of the install set.

The shim wrappers map the public ot_opus* signatures from the
Hi3516CV610 SDK V1.0.2.0 headers (out/include/ot_opus{enc,dec}.h) onto
upstream Opus's standard API, including error-code translation to
OT_ERR_OPUS{ENC,DEC}_*. opus_*_create + OPUS_SET_BITRATE on the
encoder side; opus_*_create + opus_decode treating each call as one
self-contained packet on the decoder side (matching the consumer in
mpp/cbb/audio/adp/src/ot_audio_opus_adp.c).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit a5278f3 into master Jun 5, 2026
103 checks passed
@widgetii widgetii deleted the cv6xx-opus-ot-shim branch June 5, 2026 11:01
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