Skip to content

Infinity3: a working HAL on the vendor MI library - #106

Open
HeytalePazguato wants to merge 1 commit into
OpenIPC:masterfrom
HeytalePazguato:infinity3-hal
Open

HeytalePazguato wants to merge 1 commit into
OpenIPC:masterfrom
HeytalePazguato:infinity3-hal

Conversation

@HeytalePazguato

Copy link
Copy Markdown

The current Infinity3 HAL doesn't match the vendor libmi and never produces a picture. This replaces it with one verified on an Imou LOOC 2 (MSC316DC, OV2735) on OpenIPC:

  • Video: H.264/H.265 (CBR/VBR), IDR, JPEG snapshots with the requested quality, MJPEG
  • Audio capture into the existing MP3/PCM path
  • Night grayscale through the ISP

Also needed for this board: PIN_MAX 127 (IR-cut is on GPIO 96/97), and with GLIBC_COMPAT compat.c leaves a few symbols and mmap to musl and the glibc-compat shim (since a903df9 the 32-bit mmap broke the shim's calls and Divinus crashed at start).

Tested on the camera: RTSP 1080p with audio, snapshot, MP4, night on/off. Builds for all 12 CI targets; ./test.sh --all passes.

This is the first part of #64, split into small PRs as suggested. The rest (Opus audio for browsers, exposure-based day/night, recorder, system login, sub-stream, web page) will follow one at a time.

Replaces the Infinity3 HAL, whose structures and call order did not match
the vendor libmi and never produced a picture, with one verified on an
Imou LOOC 2 (MSC316DC, OV2735) running OpenIPC:

- Video: VI -> VENC H.264/H.265 with CBR or VBR, IDR requests, JPEG
  snapshots with the requested quality, MJPEG
- Audio capture (MI_AI) into the existing MP3/PCM path
- Night grayscale through the ISP
- media.c and jpeg.c route the Infinity3 cases to it

Also needed on this board:
- PIN_MAX goes to 127: Infinity3 has GPIOs up to 109, the IR-cut is on
  96/97
- With GLIBC_COMPAT (infinity3 on OpenIPC's musl base, which links the
  glibc-compat shim for the glibc-built vendor libraries) compat.c leaves
  backtrace, __ctype_*, the pthread cancel hooks and mmap to musl and the
  shim; the stubs here would be found first and break the vendor
  libraries. The shim's mm32 calls mmap with musl's 64-bit off_t, so the
  32-bit mmap from a903df9 must not override it there.
- The encoder configs are zeroed before they are filled, so fields a
  backend reads but the caller does not set are not stack garbage
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Replace broken Infinity3 HAL with working vendor MI integration

🐞 Bug fix ✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Replace broken Infinity3 bindings with working H.264/H.265, MJPEG, JPEG snapshot, and
 night-grayscale paths.
• Add TinyALSA audio capture, speaker APIs, and software-blended overlays to the HAL.
• Resolve OpenIPC glibc-compat conflicts and allow the board’s IR-cut GPIO pins.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 4 capabilities

  • 4 affected capabilities span independent functional scopes: Infinity3 audio I/O integration, Infinity3 imaging controls, Infinity3 live video integration, Infinity3 still-image integration.
  • The pipeline, VI channels, VENC channels, stream worker, media dispatch, and callback consumer jointly implement the live video behavior; these are technical hops of one bounded integration, not separate capabilities.
  • Capture, callback delivery, queued speaker playback, mixer controls, and amplifier sequencing form one bounded Infinity3 audio integration with separate input and output stages.
  • JPEG module lifecycle, snapshot request serialization, MJPEG encoder configuration, temporary binding, and returned JPEG data implement one still-image outcome.
  • Grayscale, exposure telemetry, overlay rendering, and night-mode GPIO acceptance are distinct user-visible imaging controls within one bounded Infinity3 imaging subsystem; they share the same visual-control integration but not merely a technical helper.
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before, audio used the vendor MI frame API and synchronous device/channel lifecycle.
  • After, capture uses ALSA buffers while playback introduces a producer-consumer ring, a worker thread, lazy PCM open/close, idle shutdown, and an amplifier pulse sequence.
  • New correctness conditions are synchronized head/fill accounting, safe shutdown and join ordering, correct sample-rate/frame sizing, and ordering DAC output before amplifier enable and amplifier disable after playback drains or idles.
  • The mutex and retry calls are not themselves the complexity; the new concurrent state and hardware ordering are.
Potential damage 🟡 Medium 🩹 Temporary loss

  • If the changed Infinity3 video behavior regresses, live encoded streams can stop or become unusable.
  • The source shows per-channel polling containment, but shared initialization or ABI failures can prevent all Infinity3 video.
  • Reverting code stops new failures; no persistent application data is changed, although clients lose video until restart or redeployment.
  • A code revert or corrected runtime library can restore the capability after restarting the media pipeline; no stored-state repair is indicated.
Assessed commit 23bc981
Diagram

graph TD
  Media["Media and JPEG"] --> HAL["Infinity3 HAL"] --> MI["Vendor libmi"] --> VI["Video input"] --> VENC["Video encoder"] --> Media
  HAL --> ALSA["TinyALSA audio"] --> Media
  MI --> ISP["ISP grayscale"] --> VI
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use MI_AI for capture
  • ➕ Would keep audio capture within the vendor MI API.
  • ➖ The PR reports that channel startup requires undocumented vendor setup, while ALSA capture works on the tested board.
2. Run a property service
  • ➕ Would provide the vendor libraries with their expected property interface.
  • ➖ Adds a service and deployment dependency where the HAL can supply the needed properties directly.

Recommendation: Keep the hardware-verified MI video path and TinyALSA capture: they address the reported failure without introducing an undocumented MI_AI startup dependency. Review the recovered ABI layouts, property-store writes, direct amplifier-register access, and teardown paths particularly closely.

Files changed (6) +843 / -711

Enhancement (1) +26 / -19
i3_hal.hExpose the rebuilt Infinity3 HAL interfaces +26/-19

Expose the rebuilt Infinity3 HAL interfaces

• Removes dependencies on the retired subsystem headers and declares the active video, audio, region, speaker, property, and exposure interfaces used by the implementation.

src/hal/star/i3_hal.h

Bug fix (4) +816 / -691
compat.cAvoid overriding working glibc-compat symbols +12/-2

Avoid overriding working glibc-compat symbols

• Under GLIBC_COMPAT, stops supplying selected backtrace, ctype, pthread-cancellation, and 32-bit mmap replacements. This leaves musl and the OpenIPC compatibility shim to resolve calls used by the vendor libraries.

src/compat.c

i3_hal.cRebuild the Infinity3 HAL around verified vendor calls +780/-689

Rebuild the Infinity3 HAL around verified vendor calls

• Replaces the previous bindings and inactive pipeline with vendor-compatible VI/VENC initialization, encoded-stream delivery, JPEG quality control, audio capture, and ISP grayscale. Also adds property provisioning, TinyALSA speaker APIs, software-blended OSD widgets, and an ISP exposure-query API.

src/hal/star/i3_hal.c

jpeg.cRoute Infinity3 snapshots through the new encoder +4/-0

Route Infinity3 snapshots through the new encoder

• Adds Infinity3 snapshot creation, capture, and destruction to the existing JPEG dispatch. Zero-initializes the encoder configuration before setting snapshot options.

src/jpeg.c

media.cConnect Infinity3 video and audio to media lifecycle +20/-0

Connect Infinity3 video and audio to media lifecycle

• Adds Infinity3 dispatch for channel and pipeline lifecycle, H.264/H.265 and MJPEG encoding, IDR requests, grayscale, and audio capture. Registers the HAL’s stream callbacks and zero-initializes encoder configurations before use.

src/media.c

Other (1) +1 / -1
app_config.cPermit Infinity3 IR-cut GPIO pins +1/-1

Permit Infinity3 IR-cut GPIO pins

• Raises the night-mode pin limit from 95 to 127 so configurations can use the board’s IR-cut pins at GPIO 96 and 97.

src/app_config.c

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (12) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. A slow stream stalls the faster stream 🐞 Bug ➹ Performance
Description
i3_video_thread() reads each active encoder sequentially with a 200 ms blocking timeout. When a
low-frame-rate MJPEG channel runs alongside a faster H.264 or H.265 channel, waiting for MJPEG
prevents the thread from draining the faster channel at its configured rate.
Code

src/hal/star/i3_hal.c[R859-862]

+            memset(stream, 0, sizeof(stream));
+            // A channel that is being restarted fails at once instead of
+            // waiting out the timeout; don't spin on it.
+            if (i3.vencGet(i, stream, 200)) { usleep(10000); continue; }
Evidence
The new loop visits all enabled channels and performs a blocking read before advancing. The
application can enable MP4 and MJPEG together with separately configured frame rates.

src/hal/star/i3_hal.c[853-862]
src/media.c[674-703]
src/media.c[763-798]
src/app_config.c[541-544]
src/app_config.c[600-608]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The video thread waits up to 200 ms on each encoder in sequence, so a low-frame-rate channel delays delivery from faster channels.
## Fix Focus Areas
- src/hal/star/i3_hal.c[849-905]
## Recommended Fix
Use readiness notification, independent readers, or nonblocking reads with appropriate scheduling so an idle channel cannot hold up another channel. Test simultaneous channels at substantially different frame rates.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Infinity3 streams never show overlays 🐞 Bug ≡ Correctness
Description
The new i3_region_* functions are not dispatched by region_thread() for the Infinity3 platform.
When on-screen display is enabled, text and image updates still pass through switch statements
without an Infinity3 case, so the widget creation and update code is never called.
Code

src/hal/star/i3_hal.c[R560-563]

+int i3_region_setbitmap(int handle, hal_bitmap *bitmap)
+{
+    int (*create)(void**, int, void*, unsigned int, i3_osd_pos*, unsigned int, unsigned int) =
+        dlsym(i3.handle, "MI_OSD_CreateYuvWidget");
Evidence
Infinity3 identifies itself as its own platform and defines the widget functions, while the region
thread's initialization, update, destruction, and deinitialization switches omit that platform.

src/hal/star/i3_hal.c[532-563]
src/hal/star/i3_hal.c[950-964]
src/region.c[349-358]
src/region.c[399-425]
src/region.c[552-590]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Infinity3 implements region widgets, but the application's on-screen display dispatcher never invokes them.
## Fix Focus Areas
- src/region.c[349-358]
- src/region.c[399-425]
- src/region.c[552-590]
- src/hal/star/i3_hal.c[532-560]
## Recommended Fix
Add Infinity3 cases for region initialization, text and image creation and bitmap updates, destruction, and deinitialization. Exercise overlay updates and teardown on an active Infinity3 stream.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Selected video rate modes become VBR 🐞 Bug ≡ Correctness
Description
i3_video_create() maps every non-CBR video mode to vendor VBR mode 1 instead of handling or
rejecting the selected mode. Selecting QP, ABR, or AVBR in the accepted MP4 configuration therefore
produces a VBR encoder without telling the user that the requested behavior was not applied.
Code

src/hal/star/i3_hal.c[R744-746]

+    } else {
+        channel.rate.mode = 1;
+        channel.rate.vbr.gop = config->gop;
Evidence
The parser exposes five named MP4 modes, the MP4 setup passes the selected enum to the HAL, and the
new encoder branch distinguishes only CBR from all other values.

src/app_config.c[525-537]
src/hal/types.h[42-48]
src/media.c[783-795]
src/hal/star/i3_hal.c[736-754]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
MP4 configuration accepts QP, ABR, and AVBR, but Infinity3 silently treats all three as VBR.
## Fix Focus Areas
- src/hal/star/i3_hal.c[736-754]
- src/app_config.c[525-537]
## Recommended Fix
Switch explicitly on the requested rate mode. Implement vendor-supported modes with their proper parameters, and return a clear unsupported-mode error for modes Infinity3 cannot provide.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. MJPEG bitrate settings have no effect 🐞 Bug ≡ Correctness
Description
i3_video_create() forces JPEG and MJPEG into its CBR branch but assigns the JPEG encoder rate mode
0, which its own description identifies as no rate control. When a user configures MJPEG CBR or VBR
with a target bitrate, the encoder instead runs at the selected fixed JPEG quality regardless of
that bitrate.
Code

src/hal/star/i3_hal.c[R722-725]

+        channel.attrib.pad[0] = config->maxQual ? MIN(config->maxQual, 100) :
+            config->codec == HAL_VIDCODEC_JPG ? 85 : 50;
+        config->mode = HAL_VIDMODE_CBR;
+        if (!config->bitrate) config->bitrate = 4096;
Evidence
The parser accepts MJPEG CBR and VBR and requires a bitrate; the new path overwrites the mode, then
selects vendor rate mode 0 for JPEG while still filling a bitrate field.

src/app_config.c[590-609]
src/media.c[690-700]
src/hal/star/i3_hal.c[19-23]
src/hal/star/i3_hal.c[718-740]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Infinity3 accepts MJPEG bitrate-controlled settings but runs JPEG encoding without rate control, silently ignoring the requested bitrate.
## Fix Focus Areas
- src/hal/star/i3_hal.c[718-740]
- src/app_config.c[590-609]
## Recommended Fix
Use a supported vendor rate-control mechanism if available. Otherwise reject bitrate-controlled MJPEG modes explicitly and expose fixed-quality encoding as the supported choice rather than silently changing the configured mode.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. A large snapshot can crash on low memory 🐞 Bug ☼ Reliability
Description
i3_video_snapshot_grab() assigns realloc() directly to jpeg->data and calls memcpy() without
checking the result. If growing the snapshot buffer fails, the original pointer is lost and the
capture path copies JPEG data through a null pointer before releasing the vendor stream.
Code

src/hal/star/i3_hal.c[R829-833]

+            if (length > jpeg->length) {
+                jpeg->data = realloc(jpeg->data, length);
+                jpeg->length = length;
            }
+            memcpy(jpeg->data, data, length);
Evidence
The changed capture path grows the caller-owned JPEG buffer without checking allocation before
copying into it.

src/hal/star/i3_hal.c[820-844]
src/hal/types.h[95-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed snapshot-buffer reallocation is assigned to the live pointer and then dereferenced.
## Fix Focus Areas
- src/hal/star/i3_hal.c[820-844]
## Recommended Fix
Reallocate into a temporary pointer, update the JPEG buffer and capacity only on success, and on failure release the acquired vendor stream, unbind the channel, and return an error.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View review recommended (3)
6. Additional video units corrupt recordings 🐞 Bug ≡ Correctness
Description
i3_video_thread() stops finding start codes after seven NAL units, then assigns the rest of the
buffer to the seventh unit's length. When a frame contains eight or more units, the recording and
HTTP paths receive merged NAL metadata rather than the actual units, so they cannot process that
frame correctly.
Code

src/hal/star/i3_hal.c[R879-880]

+                while (h26x && n < 7 &&
+                       (sc = nal_find_startcode(data, scanOff, length)) < length) {
Evidence
The new parser caps its scan at seven while using the following slot as an end sentinel; both
recording and HTTP iterate only the reported NAL count.

src/hal/star/i3_hal.c[876-893]
src/hal/types.h[114-121]
src/record.c[349-366]
src/server.c[178-198]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Infinity3 parser has room for seven NAL units plus a sentinel and merges any subsequent units into the last reported unit.
## Fix Focus Areas
- src/hal/star/i3_hal.c[876-893]
- src/hal/types.h[114-121]
## Recommended Fix
Support the complete set of NAL units in a frame, for example by using storage sized to the parsed count with a safe limit. Preserve each unit's type, offset, and length for downstream consumers.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. A trailing start code reads past a frame 🐞 Bug ☼ Reliability
Description
i3_video_thread() reads data[sc + scLen] for the NAL type without checking that a header byte
follows the detected start code. If an encoder buffer ends in a three- or four-byte start code,
nal_find_startcode() still returns its offset and this read crosses the buffer boundary.
Code

src/hal/star/i3_hal.c[R881-884]

+                    unsigned int scLen = (data[sc + 2] == 1) ? 3 : 4;
+                    outPack[0].nalu[n].type = i3_state[i].payload == HAL_VIDCODEC_H264
+                        ? (data[sc + scLen] & 0x1F)
+                        : ((data[sc + scLen] & 0x7E) >> 1);
Evidence
The shared finder requires only that the start-code bytes fit; the changed Infinity3 parser
additionally reads the following byte without a length check.

src/fmt/nal.h[50-64]
src/hal/star/i3_hal.c[879-887]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Infinity3 NAL parser reads a header byte even when a start code appears at the very end of a buffer.
## Fix Focus Areas
- src/hal/star/i3_hal.c[879-887]
- src/fmt/nal.h[50-64]
## Recommended Fix
Before reading the NAL type, verify that the complete start code and at least one header byte fit within `length`. Skip or reject a trailing start code while retaining valid preceding units.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. High-profile H.265 config reaches the encoder unclamped 🐞 Bug ≡ Correctness
Description
i3_video_create sets channel.attrib.h26x.profile = MIN(config->profile, 2) for both H.264 and
H.265. The old HAL clamped H.265 to MIN(1, profile), and the header this PR deletes said H.265
only supports profile 0. With mp4.profile: HP (or MP) and mp4.codecH265: true, an unsupported
profile value goes to MI_VENC_CreateChn, and the main stream can fail to start.
Code

src/hal/star/i3_hal.c[R728-729]

+    } else
+        channel.attrib.h26x.profile = MIN(config->profile, 2);
Evidence
app_config.c accepts profile values 0..2 for the mp4 stream regardless of codec, and
media_mp4_enable passes app_config.mp4_profile through as config.profile. The removed
i3_venc.h said 'H.265 only supports 0 (BP)', and the removed code clamped H.265 to 1 at most. The
new code uses one clamp of 2 for both codecs.

src/app_config.c[546-558]
src/media.c[783-794]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
For H.265, i3_video_create passes profile values up to 2 to the encoder. The vendor's H.265 encoder only supports the baseline/main profile.

## Fix Focus Areas
- src/hal/star/i3_hal.c[728-729]

## Recommended Fix
Clamp per codec: `channel.attrib.h26x.profile = config->codec == HAL_VIDCODEC_H265 ? 0 : MIN(config->profile, 2);` Use 1 instead of 0 if hardware testing confirms Main is accepted.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

9. Mirror and flip settings have no effect on Infinity3 🐞 Bug ≡ Correctness
Description
i3_pipeline_create accepts mirror and flip but initializes i3_vi_dev with only the camera
source and frame rate, while i3_channel_create no longer accepts those settings. When sdk_start
passes app_config.mirror or app_config.flip, neither is applied elsewhere in the HAL, leaving
video and snapshots unchanged on cameras that need image orientation adjusted.
Code

src/hal/star/i3_hal.c[R676-683]

+int i3_pipeline_create(char sensor, short width, short height, char mirror, char flip, char framerate)
{
-    i3_rgn_bmp nativeBmp = { .data = bitmap->data, .pixFmt = I3_RGN_PIXFMT_ARGB1555,
-        .size.height = bitmap->dim.height, .size.width = bitmap->dim.width };
+    i3_vi_dev device;
+    memset(&device, 0, sizeof(device));
+    device.source = I3_VI_SRC_CAMERA;
+    device.srcFps = (float)framerate;

-    return i3_rgn.fnSetBitmap(handle, &nativeBmp);
+    return i3.viSetDev(&device);
Evidence
sdk_start passes app_config.mirror and app_config.flip to i3_pipeline_create alongside
width, height and frame rate. The pipeline implementation never reads either setting, and no other
code in this HAL applies them, so both configured values are dropped before they can affect camera
output.

src/hal/star/i3_hal.c[676-684]
src/media.c[989-990]
src/app_config.c[408-413]
src/media.c[986-990]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Infinity3 receives the configured mirror and flip settings but does not apply them during camera setup.

## Fix Focus Areas
- src/hal/star/i3_hal.c[676-684]
- src/media.c[986-990]

## Recommended Fix
Apply mirror and flip through supported Infinity3 camera or channel controls, resolving the appropriate vendor API if needed. Propagate an error if applying a requested setting fails; if no supported control exists, log `HAL_WARNING` when mirror or flip is requested so users know the setting is unsupported.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Sensor config file is silently ignored 🐞 Bug ◔ Observability
Description
i3_config_load() returns EXIT_SUCCESS without using its path argument, replacing the previous
HAL call to MI_ISP_Load_ISPCmdBinFile. When an existing app_config.sensor_config file is
configured, sdk_start() calls this stub after starting the pipeline, so the tuning is not applied
and the user is not told.
Code

src/hal/star/i3_hal.c[674]

+int i3_config_load(char *path) { return EXIT_SUCCESS; }
Evidence
src/media.c calls i3_config_load(app_config.sensor_config) when the configured file exists,
while the replacement implementation in src/hal/star/i3_hal.c unconditionally reports success
without using the supplied path. Together, those paths show that startup accepts the configuration
file but does not apply it.

src/media.c[1074-1080]
src/hal/star/i3_hal.c[674-674]
src/app_config.c[310-310]
src/media.c[1073-1081]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`i3_config_load()` reports success without applying the configured sensor/ISP file or telling the user it was ignored.

## Fix Focus Areas
- src/hal/star/i3_hal.c[674-674]
- src/media.c[1073-1081]

## Recommended Fix
Resolve `MI_ISP_Load_ISPCmdBinFile` with `dlsym(RTLD_DEFAULT)` and call it with the configured path when available. If the interface or file format is unsupported, emit `HAL_WARNING("i3_hal", "Sensor config %s is not supported, ignoring\n", path)` and return or surface a meaningful error instead of reporting success.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


11. Repo builds never enable the mmap crash fix 🐞 Bug ☼ Reliability
Description
The #ifndef GLIBC_COMPAT guards in compat.c only take effect when GLIBC_COMPAT is defined, and
nothing in the repository defines it: no build.sh target or CMake flag sets it. A binary built from
this repo for Infinity3 (armhf-musl/star6) still gets the 32-bit mmap override and the empty
backtrace/__ctype_*/pthread-cancel stubs, so it hits the startup crash the PR says it fixes.
Code

src/compat.c[R64-68]

+// With GLIBC_COMPAT (infinity3 on musl) the vendor libraries' 32-bit mmap
+// calls go through the shim's mm32, which calls mmap with musl's 64-bit off_t,
+// so musl's own mmap has to stay in place there.
+#ifndef GLIBC_COMPAT
void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
Evidence
A repo-wide search for GLIBC_COMPAT finds only the new #if/#ifndef lines in compat.c. build.sh's
armhf-musl/star6 target passes no such define.

src/compat.c[38-71]
build.sh[47-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
compat.c relies on a GLIBC_COMPAT define that no in-repo build sets, so the Infinity3 fix is inactive unless an external package adds -DGLIBC_COMPAT.

## Fix Focus Areas
- src/compat.c[38-71]
- build.sh[47-50]

## Recommended Fix
Add a build option or target (e.g. `star3`/`infinity3`) that passes `-DGLIBC_COMPAT`. At a minimum, document in the README/build.sh that OpenIPC's infinity3 package must define it.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View optional (1)
12. Unwired code pokes board registers via /dev/mem 🐞 Bug ⚙ Maintainability
Description
i3_speaker_amp maps physical 0x1F207000 through /dev/mem and toggles PAD_FUART_CTS bits, a
sequence specific to the Imou LOOC 2. It sits beside the property-store writer
(/dev/__properties__), the OSD widgets and i3_exposure_info, none of which any caller in this PR
uses. Once a later change wires up i3_speaker_write, any other Infinity3 board gets an unrelated
pad driven by a hardcoded register write, and in the meantime reviewers have to vet roughly 400
lines that do nothing.
Code

src/hal/star/i3_hal.c[R291-298]

+static void i3_speaker_amp(char on)
{
-    int ret;
+    int fd = open("/dev/mem", O_RDWR | O_SYNC);
+    if (fd < 0) return;
+    void *map = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x1F207000);
+    close(fd);
+    if (map == MAP_FAILED) return;
+    volatile unsigned short *reg = (volatile unsigned short*)((char*)map + 0x858);
Evidence
A search of src/*.c for i3_ callers finds only media.c/jpeg.c calls to the video/audio/channel
functions. Nothing calls i3_speaker_write, i3_speaker_volume, i3_region_*, i3_exposure_info or
i3_property_set, and the PR description defers those features to follow-ups.

src/hal/star/i3_hal.c[281-307]
src/hal/star/i3_hal.c[96-147]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The HAL ships speaker (with raw /dev/mem register writes for one specific board), OSD, exposure and property-store code that nothing calls yet.

## Fix Focus Areas
- src/hal/star/i3_hal.c[96-147]
- src/hal/star/i3_hal.c[273-399]
- src/hal/star/i3_hal.c[511-660]

## Recommended Fix
Remove the unused code from this PR and add it with the follow-up PRs that wire it in. When the speaker amp lands, gate the GPIO/register sequence behind a config option (e.g. an amp pin setting) rather than hardcoding the LOOC 2 pad address.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: Auto: 🧠 Deep: Large hardware HAL rewrite spans many independent, failure-prone runtime paths.

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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