Skip to content

Add Ingenic T23 V4L2/MC + Helix + ALSA support - #102

Open
difanz wants to merge 5 commits into
OpenIPC:masterfrom
difanz:ingenic-t23-v4l2
Open

difanz wants to merge 5 commits into
OpenIPC:masterfrom
difanz:ingenic-t23-v4l2

Conversation

@difanz

@difanz difanz commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds an opt-in Ingenic T23 backend (-DDIVINUS_T23) for OpenIPC's vendor-SDK-free T23 Linux 6.12 CIP port (OpenIPC/linux#261).

Unlike single-node V4L2 pipelines (#72), T23's in-kernel tx-isp pipeline is Media Controller-centric (V4L2_CAP_IO_MC), exposing a sensor → t23-isp-core0 → capture/MSCA/meta/OSD subdevice graph alongside the ingenic-helix stateful V4L2 M2M encoder.

What it adds

  • Media Controller & capture (src/hal/inge/t23_hal.c): Discovers the tx-isp graph via MEDIA_IOC_G_TOPOLOGY (walking upstream data links from t23-isp-core0 to the MEDIA_ENT_F_CAM_SENSOR subdevice over tx-isp's pre-enabled links and querying active sensor dimensions via VIDIOC_SUBDEV_G_FMT), allocates downscaled streams and snapshots across both "T23 scaled0" and "T23 scaled0.1" hardware MSCA scaler outputs so concurrent sub streams and snapshots match their encoder dimensions, honors requested snapshot width/height/quality with realloc buffer reuse, and recovers Helix M2M queues on encode timeouts or DQBUF errors.
  • Zero-copy Helix V4L2 M2M encoding: Exports capture buffers via VIDIOC_EXPBUF (V4L2_MEMORY_DMABUF) directly into ingenic-helix M2M instances for H.264 (with CBR/VBR/QP controls, IDR insertion, and runtime reconfiguration) and JPEG/MJPEG snapshots.
  • Audio: Captures PCM audio through ALSA (DIVINUS_ALSA_DEVICE, default hw:0,0) with exact sample-rate verification into Divinus's existing audio pipeline.
  • 3.10 header compatibility: Includes #ifndef fallbacks for post-3.10 Media Controller v2 and V4L2 stateful encoder UAPI definitions, and skips the 32-bit-offset compat.c mmap wrapper when DIVINUS_T23 is enabled so libasound uses libc off_t cleanly under OpenIPC's existing toolchain.ingenic-t31 musl toolchain.

Impact on other platforms

None when -DDIVINUS_T23 is not set: t23_hal.c compiles down to minimal stubs, hal_identify() on MIPS falls straight through to t31_system_identify(), and all existing CI targets (inge-t31 included) build unchanged without alsa-lib.

Commits

  1. build: honor LDFLAGS when linking divinus
  2. compat: avoid shadowing native uClibc symbols under -rdynamic
  3. media: unwind audio resources on audio startup failure
  4. rtsp: fix RTCP SR NTP timestamp, TCP rtcp_tick init, and client_fd cleanup (overlaps with Sending RTCP sender reports at the set interval on interleaved tracks #99 on TCP rtcp_tick; happy to rebase once Sending RTCP sender reports at the set interval on interleaved tracks #99 lands)
  5. hal: inge: add opt-in T23 V4L2/MC + Helix DMABUF + ALSA HAL

Testing

  • ./test.sh --all passes (8/8), and non-T23 MIPS builds (without -DDIVINUS_T23) compile cleanly with the #else stubs.
  • Built inside OpenIPC (-DDIVINUS_T23 -lasound against toolchain.ingenic-t31.tgz) and verified end-to-end in openipc-qemu-bench (qemu-system-mipsel -M t23,sensor=gc2053) with OpenIPC/linux#261 + t23-ipa:
    • Media Controller sensor/resolution discovery and 1920x1080 NV12 capture -> DMABUF -> Helix M2M encoding.
    • /image.jpg HTTP snapshots (1920x1080 JPEG).
    • RTSP/TCP H.264 streaming (/stream=0) decoded cleanly with ffmpeg -err_detect explode (0 errors) alongside ALSA audio capture (t23-audio).

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

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

Copy link
Copy Markdown

PR Summary by Qodo

Add opt-in Ingenic T23 capture, Helix encoding, and ALSA support

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

Grey Divider

AI Description

• Add an opt-in T23 backend for hardware-scaled capture, Helix encoding, JPEG snapshots, and ALSA
 audio.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 7 capabilities

  • 7 affected capabilities span independent functional scopes: Application audio lifecycle, RTSP connection lifecycle, RTSP media delivery integration, T23 audio capture integration, T23 camera media integration, T23 snapshot integration, Target build integration.
  • Camera discovery, capture nodes, Helix encoding, video callbacks, and MP4 timestamping form one end-to-end camera streaming integration; dispatch files are callers and consumers of that behavior.
  • ALSA initialization, capture threading, media callback registration, and MP3 consumption form one bounded audio delivery integration distinct from camera video.
  • Snapshot synchronization, scaler allocation, JPEG encoding, output ownership, and jpeg_get dispatch produce one distinct still-image outcome.
  • The changed helper is shared by audio shutdown and startup-failure branches, affecting one bounded audio lifecycle outcome across platform HALs and the MP3 encoder.
  • PLAY transport setup, RTP/RTCP polling, and sender-report timestamps are one end-to-end RTSP session behavior; UDP and TCP are delivery modes of that integration.
  • Accepting a client, creating read/write streams, adding it to the active list, and releasing it on partial failure are one bounded connection-admission behavior distinct from packet reporting.
  • The Makefile link invocation and compatibility shims jointly determine whether target binaries link with selected libc, vendor libraries, and target ABI; this is one bounded build capability.
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before, non-T23 MIPS targets used the existing HAL path.
  • After, T23 coordinates media-controller discovery, multiple capture nodes, DMABUF ownership, encoder queues, polling, callbacks, and shutdown.
  • New correctness conditions are that capture buffers remain valid across every encoder consumer, outputs are requeued after delivery, shared scaler nodes are not closed while referenced, and teardown does not race the poll thread.
Potential damage 🟡 Medium 🩹 Temporary loss

  • A regression can stop camera video or encoded output.
  • Reverting stops new failures, but an active stream must be restarted; no persistent media-state or external financial effect is shown.
  • Revert and restart can restore operation if device nodes and Helix are otherwise available; no stored video repair is required.
Assessed commit 6a51939
Diagram

graph TD
  Sensor["T23 sensor"] --> Capture["V4L2 capture"] --> HAL["T23 HAL"] --> Helix["Helix encoder"] --> Media["Media pipeline"] --> RTSP["RTSP clients"]
  ALSA["ALSA capture"] --> HAL
  HAL --> JPEG["JPEG snapshots"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use a media-controller helper library
  • ➕ Could centralize topology discovery, link configuration, and format propagation.
  • ➖ Adds a deployment dependency to an otherwise direct kernel-API backend.

Recommendation: Direct V4L2 and ALSA integration fits an opt-in embedded backend. Review the scope of the Media Controller claim before merging: this diff probes topology but does not enable links or propagate subdevice formats, so it appears to rely on an already configured pipeline.

Files changed (12) +1702 / -25

Enhancement (7) +1664 / -5
t23_hal.cImplement the opt-in T23 HAL +1529/-0

Implement the opt-in T23 HAL

• Adds T23 detection, media-topology probing, main and scaled V4L2 capture, DMABUF-fed Helix H.264/JPEG encoding, snapshots, and ALSA PCM capture. Provides failure stubs when T23 is not enabled.

src/hal/inge/t23_hal.c

t23_hal.hDeclare T23 HAL channels and lifecycle APIs +49/-0

Declare T23 HAL channels and lifecycle APIs

• Exposes the T23 platform functions, channel state, and audio/video callbacks used by shared dispatch code.

src/hal/inge/t23_hal.h

support.cIdentify T23 before the T31 fallback +3/-0

Identify T23 before the T31 fallback

• Adds conditional T23 detection on MIPS while retaining T31 identification when T23 is not detected.

src/hal/support.c

types.hAdd the T23 platform identifier +1/-0

Add the T23 platform identifier

• Adds HAL_PLATFORM_T23 for platform detection and media dispatch.

src/hal/types.h

jpeg.cRoute T23 snapshots through the JPEG module +9/-0

Route T23 snapshots through the JPEG module

• Treats T23 snapshots as provided by its HAL rather than creating a dedicated JPEG channel, and dispatches snapshot requests to T23.

src/jpeg.c

media.cConnect T23 to shared media lifecycle and controls +72/-4

Connect T23 to shared media lifecycle and controls

• Dispatches T23 channel, encoder, pipeline, audio, IDR, and grayscale operations through the existing media APIs. Sets audioOn before starting audio threads to prevent an immediate-exit race.

src/media.c

server.cUse T23 video timestamps for MP4 output +1/-1

Use T23 video timestamps for MP4 output

• Extends the platform check that sets MP4 timestamps from encoded packets to include T23.

src/server.c

Bug fix (3) +34 / -19
compat.cAvoid selected uClibc symbol overrides +10/-4

Avoid selected uClibc symbol overrides

• Guards compatibility symbols that could shadow native uClibc definitions. Disables the 32-bit-offset mmap wrapper for T23 builds.

src/compat.c

rtcp.hDerive RTCP sender-report timestamps from monotonic time +6/-4

Derive RTCP sender-report timestamps from monotonic time

• Replaces wall-clock sampling with CLOCK_MONOTONIC and computes the fractional timestamp using integer arithmetic.

src/rtsp/rtcp.h

rtsp.cInitialize TCP RTCP tracks and separate socket ownership +18/-11

Initialize TCP RTCP tracks and separate socket ownership

• Includes TCP-interleaved tracks in PLAY initialization without binding UDP sockets or sending an immediate sender report. Duplicates the client descriptor for read and write streams to avoid closing the same descriptor three times.

src/rtsp/rtsp.c

Other (2) +4 / -1
MakefileApply LDFLAGS at the final link step +1/-1

Apply LDFLAGS at the final link step

• Allows external builds to supply link-only options such as libasound without adding them to compilation commands.

src/Makefile

support.hConditionally expose the T23 HAL +3/-0

Conditionally expose the T23 HAL

• Includes T23 declarations only for MIPS builds with DIVINUS_T23 enabled.

src/hal/support.h

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

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Second downscaled stream is fed wrong-sized frames 🐞 Bug ≡ Correctness
Description
t23_video_create uses t23_cap_sub.width/height only when starting the shared sub-capture node,
leaving later use_sub encoders configured for their requested size even though the drain loop
feeds them buffers from that node. When MP4 and MJPEG request different scaled sizes, such as
1280x720 and 640x360 on a 1080p sensor, whichever starts second receives DMABUFs at the first
channel's resolution, causing corrupt output or QBUF bytesused and plane-size errors.
Code

src/hal/inge/t23_hal.c[R1267-1274]

+    if (c->use_sub && !t23_cap_sub.streaming) {
+        if (t23_cap_start(&t23_cap_sub, "T23 scaled0", w, h)) {
+            pthread_mutex_unlock(&t23_mtx);
+            return EXIT_FAILURE;
+        }
+        w = t23_cap_sub.width;
+        h = t23_cap_sub.height;
+    }
Evidence
t23_channel_create selects use_sub for requests smaller than the sensor and records each
channel's aligned size; MP4 and MJPEG each create channels with their own configured dimensions.
There is only one sub-capture node, and t23_video_create substitutes its actual width and height
only inside the branch that starts it when it is not already streaming. The drain loop then sends
that shared node's buffers to every channel using the sub scaler, including encoders opened with a
different requested size.

src/hal/inge/t23_hal.c[1167-1172]
src/hal/inge/t23_hal.c[1264-1279]
src/media.c[691-692]
src/media.c[785-786]
src/hal/inge/t23_hal.c[250-252]
src/hal/inge/t23_hal.c[938-950]

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

## Issue description
Multiple scaled channels share one T23 scaled0 capture format, but when that node is already streaming, `t23_video_create` can open a later channel's encoder at a different requested size from the DMABUFs it consumes.
## Fix Focus Areas
- src/hal/inge/t23_hal.c[938-950]
- src/hal/inge/t23_hal.c[1167-1172]
- src/hal/inge/t23_hal.c[1264-1279]
## Recommended Fix
Always configure a `use_sub` encoder from the actual `t23_cap_sub.width/height`, whether the node was just started or was already streaming, and update `c->width/height` to match. Handle a second channel requesting a different sub size explicitly: warn and adopt the existing sub-node size, fall back to the main node with `use_sub=0`, allocate an independent available scaler node, or reject the conflicting configuration before opening its encoder. In every case, keep the encoder dimensions consistent with the capture buffers it receives.

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



Remediation recommended

2. Audio startup failures leave resources open ✓ Resolved Bug Correctness
Description
media_audio_enable() now clears audioOn when either thread creation fails but continues startup
without unwinding the initialized audio resources or returning that failure. On a capture-thread
failure it also attempts the encoding thread, while a subsequent media_audio_disable() skips
cleanup because audioOn is already zero.

3. Audio can play at the wrong speed 🐞 Bug ≡ Correctness
Description
t23_audio_init() accepts the rate returned by snd_pcm_hw_params_set_rate_near() without checking
whether it still equals the requested samplerate. If the device negotiates another rate, the capture
callback forwards those samples unchanged while the MP3 encoder labels and sizes them using
app_config.audio_srate.
Code

src/hal/inge/t23_hal.c[R1067-1069]

+        (err = snd_pcm_hw_params_set_rate_near(t23_pcm, hw, &rate, 0)) < 0 ||
+        (err = snd_pcm_hw_params_set_periods_integer(t23_pcm, hw)) < 0 ||
+        (err = snd_pcm_hw_params_set_period_size_near(t23_pcm, hw, &t23_pcm_period, 0)) < 0 ||
Evidence
The negotiated rate is only logged; captured samples are forwarded directly, and media configures
MP3 from the original application rate.

src/hal/inge/t23_hal.c[1063-1089]
src/hal/inge/t23_hal.c[1118-1135]
src/media.c[606-623]

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

## Issue description
ALSA may negotiate a capture rate different from the rate used to encode the samples.
## Fix Focus Areas
- src/hal/inge/t23_hal.c[1067-1089]
## Recommended Fix
Reject a negotiated rate that differs from the configured encoder rate, or resample captured PCM and propagate the actual rate consistently through the audio pipeline.

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


4. T23 snapshots ignore requested settings ✓ Resolved Bug Correctness
Description
jpeg_get() dispatches T23 snapshots without passing its requested width, height or quality, and
the T23 snapshot encoder fixes its input to the main capture size and quality to 80. Image requests
and HTTP-post settings specifying different dimensions or quality therefore produce the same
configured snapshot format.

View review recommended (4)
5. Repeated posted snapshots leak memory ✓ Resolved Bug Correctness
Description
t23_video_snapshot_grab() assigns a new allocation to jpeg->data without releasing its previous
value. The HTTP-post thread repeatedly passes the same JPEG object and frees only its final pointer,
so each earlier successful T23 snapshot allocation remains allocated.

6. The reported sensor can be the VIC ✓ Resolved Bug Correctness
Description
t23_probe_mc_sensor() follows only the enabled link into the ISP sink and treats that link's
source entity as the sensor. In the described sensor-to-CSI-to-VIC-to-ISP graph, that immediate
upstream entity is the VIC, so the reported sensor name and queried subdevice format do not come
from the sensor.

7. One encoder timeout leaves video a frame behind 🐞 Bug ☼ Reliability
Description
t23_enc_encode_dmabuf() returns on a poll timeout or dequeue error without releasing the queued
OUTPUT buffer or resynchronizing the encoder queues. When t23_drain_node re-queues that DMABUF to
the ISP and continues, the ISP can overwrite input still being encoded, a later packet can receive
the next frame’s timestamp, or a queue mismatch can stall subsequent encoding; snapshots use the
same failure path.
Code

src/hal/inge/t23_hal.c[R836-842]

+    do {
+        prc = poll(&pfd, 1, 2000);
+    } while (prc < 0 && errno == EINTR);
+    if (prc <= 0) {
+        HAL_DANGER("t23_venc", "Helix poll timeout/err: rc=%d errno=%d\n", prc, errno);
+        return -1;
+    }
Evidence
The failure returns leave an OUTPUT QBUF outstanding, while the caller has no recovery branch and
re-queues the capture DMABUF regardless of the encoder result; stream-off occurs only during encoder
close. On a subsequent call, poll can report the earlier pending result, causing the older
CAPTURE/OUTPUT pair to be emitted with the current ts_us, while the capture buffer may already be
back with the ISP. The same encoder failure path is used for snapshots.

src/hal/inge/t23_hal.c[828-864]
src/hal/inge/t23_hal.c[949-953]
src/hal/inge/t23_hal.c[997-998]
src/hal/inge/t23_hal.c[820-859]
src/hal/inge/t23_hal.c[615-648]
src/hal/inge/t23_hal.c[945-953]
src/hal/inge/t23_hal.c[969-989]

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

## Issue description
An encode failure after OUTPUT QBUF can leave a buffer pending while the caller returns its DMABUF to the ISP and continues using the encoder. This can desynchronize frames and timestamps, permit the ISP to overwrite input still in use, or stall later encoding, including snapshots.
## Fix Focus Areas
- src/hal/inge/t23_hal.c[836-859]
- src/hal/inge/t23_hal.c[945-953]
- src/hal/inge/t23_hal.c[973-989]
## Recommended Fix
On a poll timeout or DQBUF failure after OUTPUT QBUF, recover the encoder before accepting another frame: reset and reinitialize both V4L2 queues with STREAMOFF/STREAMON, or close and recreate the encoder. Do not re-queue the capture DMABUF to the ISP until the encoder has released it. Apply the recovery to both stream and snapshot encoders.

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


8. Failed RTSP accepts leak the client socket ✓ Resolved Bug Correctness
Description
The new error path in __connection_list_add replaced __connection_reset with bufpool_detach,
so the accepted fd (already stored in p->client_fd) is never closed. If the second fdopen
fails, the already-opened p->fp_tcp_read stream leaks as well. The caller __accept_handler just
returns FAILURE, so every failure (for example dup hitting EMFILE) permanently leaks descriptors
and leaves the client connection hanging.


Informational

9. Audio default device differs from the documented one 🐞 Bug ≡ Correctness
Description
t23_audio_init falls back to hw:0,0 when DIVINUS_ALSA_DEVICE is unset, but the PR description
documents the default as default. Because of the hw: plugin there is no rate or format
conversion, so on boards where card 0 is not the mic, or where the codec cannot do mono S16
natively, audio init fails unless the variable is set by hand.
Code

src/hal/inge/t23_hal.c[R1044-1045]

+    if (!device || !device[0])
+        device = "hw:0,0";
Evidence
The code hardcodes device = "hw:0,0" as the fallback, which contradicts the stated
DIVINUS_ALSA_DEVICE default of default.

src/hal/inge/t23_hal.c[1035-1060]

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 ALSA fallback device is `hw:0,0`, but the documentation says `default`.
## Fix Focus Areas
- src/hal/inge/t23_hal.c[1044-1045]
## Recommended Fix
Either change the fallback to `"default"` (which lets ALSA plugins convert format and rate), or update the PR and docs to say the default is `hw:0,0`.

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


10. Stream sender reports carry 1900-era wall times ✓ Resolved Bug Correctness
Description
__rtcp_send_sr() treats CLOCK_MONOTONIC seconds since boot as Unix time and adds the Unix-to-NTP
epoch offset, producing an NTP timestamp near January 1900 rather than the current wall-clock time.
Every periodically transmitted sender report carries this value on every platform, leaving receivers
unable to correlate RTP with wall-clock time and giving recorders and clients such as ffmpeg
meaningless absolute timestamps.

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

@difanz

difanz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR commits (e55bbad → 47259be) to address the AI review findings:

  1. Multi-substream MSCA scaling & encoder matching (src/hal/inge/t23_hal.c): Added support for both tx-isp MSCA sub-scaler outputs ("T23 scaled0" and "T23 scaled0.1") and ensured t23_video_create() aligns encoder dimensions to the selected scaler node (or shares/falls back to the closest active node when both MSCA nodes are occupied). Also locked t23_mtx before polling/DQBUF state validation so closing sub nodes cannot race t23_video_thread().
  2. Audio startup unwind (src/media.c): Extracted media_audio_hal_deinit() / media_audio_cleanup() so partial initialization (audRing, HAL audio backend, mp3Enc, thread attributes) is torn down if HAL init, Shine setup, or pthread_create() fails prior to HAL_ERROR returning.
  3. ALSA sample rate check (src/hal/inge/t23_hal.c): Verified snd_pcm_hw_params_set_rate_near() negotiates the exact requested req_rate and fail cleanly on mismatch.
  4. Snapshot settings & buffer reuse (src/jpeg.c, src/hal/inge/t23_hal.{c,h}): Updated t23_video_snapshot_grab(width, height, quality, jpeg) to pass requested dimensions/quality (selecting/starting a matching MSCA sub node when downscaled and updating V4L2_CID_JPEG_COMPRESSION_QUALITY) and reuse caller-owned jpeg->data via realloc.
  5. Multi-hop MC sensor walk (src/hal/inge/t23_hal.c): Updated t23_probe_mc_sensor() to walk upstream MEDIA_LNK_FL_DATA_LINK hops from t23-isp-core0 until reaching a MEDIA_ENT_F_CAM_SENSOR entity (with entity-list fallback).
  6. Helix M2M timeout/DQBUF recovery (src/hal/inge/t23_hal.c): Added t23_enc_recover() (STREAMOFF + re-QBUF + STREAMON across both queues) on poll timeout or DQBUF failure so no capture DMABUF remains queued inside Helix.
  7. RTSP accept cleanup (src/rtsp/rtsp.c) & RTCP SR wall clock (src/rtsp/rtcp.h, src/rtsp/rtp.c): Closed fd on early bufpool_get_free / head == NULL errors, routed list_add failure through bufpool_detach -> __connection_reset(), kept unsetup-track skipping in __rtcp_poll(), and switched __rtcp_send_sr() back to CLOCK_REALTIME (retaining integer tv_nsec math) so NTP wall-clock timestamps are RFC 3550 compliant.
  8. PR description: Fixed the documented DIVINUS_ALSA_DEVICE default (hw:0,0) and updated the tx-isp MC topology description (sensor -> t23-isp-core0).

Verification:

  • ./test.sh --all passes (6/6).
  • Non-T23 MIPS build (without -DDIVINUS_T23) passes with 0 warnings in t23_hal.c/rtsp.c/compat.c.
  • Rebuilt inside OpenIPC BOARD=t23_lite and passed full QEMU -M t23,sensor=gc2053 E2E verification (ALL E2E CHECKS PASSED!: 1920x1080 /image.jpg JPEG snapshot and 15-frame RTSP TCP H.264 decode with 0 errors).

Allow external build systems such as Buildroot to pass link-only libraries (e.g. -lasound) via LDFLAGS without passing them to compile-only steps.

Signed-off-by: Difan Zhang <alex@osqdu.org>
Linking divinus with -rdynamic exports compat stubs into the dynamic symbol table. On uClibc targets, stubs like __assert, __ctype_b, __ctype_tolower, __pthread_register_cancel, __pthread_unregister_cancel, and __fgetc_unlocked shadow uClibc's own symbols in dynamically linked libraries.

Signed-off-by: Difan Zhang <alex@osqdu.org>
Unwind partially initialized audio resources (audRing, HAL audio backend, shine MP3 encoder, and thread attributes) if audio init, shine setup, or pthread_create fails before HAL_ERROR returns.

Signed-off-by: Difan Zhang <alex@osqdu.org>
…eanup

Use integer tv_nsec math from CLOCK_REALTIME for RFC 3550 RTCP SR NTP wall-clock timestamps, initialize rtcp_tick/rtcp_tick_org for TCP-interleaved tracks in PLAY without binding UDP sockets or sending a premature SR, skip unsetup tracks in __rtcp_poll, and dup() client_fd for fp_tcp_read/fp_tcp_write with full error-path descriptor cleanup.

Signed-off-by: Difan Zhang <alex@osqdu.org>
@difanz

difanz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto master (1bb2d6d) to resolve the merge conflicts and clean up the remaining review items (head d5e7045):

  • Rebase onto 1bb2d6d: Kept upstream's audioOn = 1 placement while preserving media_audio_cleanup() resource unwinding on init/shine/pthread_create failures in src/media.c, and merged upstream's RTSP socket hardening in __connection_list_add() (src/rtsp/rtsp.c) with dup(fd) + bufpool_detach() cleanup.
  • Sub-stream / snapshot MSCA scaler sizing (Update README.md #1): Already addressed via t23_select_sub_node_locked() across both scaled0 and scaled0.1, with t23_video_create() adopting the selected capture node's actual width/height.
  • ALSA rate check & default device (Update build script #3, Add compatibility for ini files #9): t23_audio_init() rejects a negotiated sample rate that does not match req_rate and closes the PCM handle cleanly; the fallback remains "hw:0,0" (minimal embedded ALSA rootfs without plug/default PCM config, overridable via DIVINUS_ALSA_DEVICE), and the PR description accurately documents hw:0,0.
  • Helix M2M timeout / DQBUF recovery (Support mipsel #7): t23_enc_encode_dmabuf() calls t23_enc_recover() (STREAMOFF + CAPTURE re-QBUF + STREAMON) on poll timeouts and DQBUF failures, and t23_drain_node() now also re-queues snapshot capture buffers even when jlen == 0 and calls t23_enc_recover() if capture re-QBUF fails.

./test.sh --all passes (8/8).

@difanz

difanz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@wberube - can you take a look at this CL?

@wberube

wberube commented Nov 30, 2026

Copy link
Copy Markdown
Member

Hi Mr. Zhang,

Thank you for your patience. Because I currently develop and maintain Divinus on my own, review times can be long—and I take full responsibility for that. The project has reached a point where clear contributor guidelines are needed, and I haven't put those in place yet.

When a pull request spans multiple subsystems—especially shared code across platforms—I have to be extra cautious with integration, as is the case with the T23 changes. Too often, changes to components like compatibility shims are written with a single platform in mind, which ends up introducing regressions and breaking support for other targets. As for the RTSP server, everyone has their own approach, and reconciling them quickly becomes a burden.

Combined with the rise of AI-assisted submissions, reviewing and keeping the codebase cohesive has become increasingly difficult to manage. Going forward, I would strongly prefer PRs to be scoped to one component at a time—for instance, keeping a HAL platform integration separate from unrelated or unrequested changes to shared code.

Ultimately, however, licensing is currently a hard blocker: Divinus is MIT-licensed, and your contribution is GPL-2.0, so I am unable to integrate it as-is. That said, if the licensing can be changed to MIT, I would be able to accept it.

Thank you very much for your understanding, and kudos for the V4L2 integration, this is really something we needed!

@difanz

difanz commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

I totally understand the burdens (as I am basically on the same boat). The license can definitely be changed to MIT.

Going forward, I will try to keep the CL's scoped for easier review and integration.

Will update the codebase soon to reflect the license updates.

Add an opt-in HAL for Ingenic T23 boards running mainline-style V4L2/Media Controller ISP capture, zero-copy Helix DMABUF video encoding (H.264/JPEG/MJPEG), and ALSA audio capture.

Walk upstream Media Controller links from t23-isp-core0 until locating the CAMERA_SENSOR entity, assign independent MSCA scaler capture nodes (scaled0 / scaled0.1) so concurrent downscaled streams and snapshots match their Helix encoder dimensions, pass snapshot dimensions and quality with realloc buffer reuse, verify exact ALSA sample-rate negotiation, and recover Helix M2M queues on encode timeouts or DQBUF errors.

Guard the backend under -DDIVINUS_T23 so standard builds (including inge-t31 in CI) compile minimal stubs with no ALSA or post-3.10 UAPI header dependencies.

Signed-off-by: Difan Zhang <alex@osqdu.org>
@difanz

difanz commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

@wberube Updated src/hal/inge/t23_hal.c and src/hal/inge/t23_hal.h from SPDX-License-Identifier: GPL-2.0 to SPDX-License-Identifier: MIT (amended commit d5e7045 → 6a51939, with no functional changes). Thanks for taking a look!

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.

2 participants