Skip to content

feat(gc573): overhaul JSON-RPC IPC with jsmn parser and expand unit tests - #56

Merged
Everlite merged 2 commits into
Everlite:devfrom
PolygonPrincess:pr/gc573-ipc-jsmn
Nov 10, 2026
Merged

Everlite merged 2 commits into
Everlite:devfrom
PolygonPrincess:pr/gc573-ipc-jsmn

Conversation

@PolygonPrincess

Copy link
Copy Markdown
Contributor

Summary

Replaces the hand-rolled string-scanning JSON parser in gc573_user_ipc.c with the fast, MIT-licensed jsmn parser:

  • Specification Compliance: Fully conforms to JSON-RPC 2.0; supports both numeric integer and string request IDs via JSON_GET_RAW.
  • Validation: Enforces device path validation (/dev/video[0-9]+) and prevents malformed token buffer overruns.
  • Unit Testing: Introduces tests/test_ipc_json.c covering normal RPC operations, numeric IDs, malformed JSON, truncated buffers, and NULL-pointer negative edge cases.

This needs testing on GC573 as this is a GC573 improvement and I do not have the hardware to test for this myself.

PolygonPrincess and others added 2 commits November 9, 2026 04:03
…er handlers

- Enforce object key validation in json_token_find_key to prevent matching string values
- Prioritize root object keys before searching nested parameter objects
- Wire streamer handling in apply_ipc_command for TOAST, EDID, HOTPLUG, and HDR_EV
- Add toast_render OSD overlay for centered toast notifications
- Implement gc573_user_it6664_pulse_hpd for HDMI source re-sync
- Avoid resetting active HDR exposure on hdr.passthrough calls
- Add unit test coverage for duplicate key-value string collisions
@Everlite

Everlite commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thank you so much for this PR and the clean jsmn parser refactor!

We tested this locally on real GC573 hardware and verified everything. While testing, we found and fixed a small edge case in the tokenizer and completed the streamer wiring:

  1. Object Key Validation (json_token_find_key): In jsmn, string values also carry JSMN_STRING. We added a check for tokens[tokens[i].parent].type == JSMN_OBJECT and a two-pass lookup (root keys first, then nested params) so string values matching a key name (e.g. {"title":"mode","mode":"wave"}) don't get mistakenly treated as keys.
  2. Streamer Command Wiring: Implemented the apply_ipc_command() handlers for the new commands:
    • toast.show: Displays a clean on-screen toast notification matching the native OSD style.
    • edid.set: Programs the requested profile into IT6805 DDC RAM and synchronizes IT6664 upstream EDID.
    • hotplug: Pulses HDMI RX HPD for 150 ms via gc573_user_it6664_pulse_hpd() to trigger a source re-sync.
    • hdr.exposure: Applies live EV tonemapping exposure bias without resetting on passthrough toggles.
  3. Unit Tests: Added test cases for key-vs-value string collisions in tests/test_ipc_json.c (all 30 tests passing cleanly).

Everything compiled without any warnings and ran smoothly in our local hardware tests. We pushed these fixes directly to your branch so you have them right away. Thank you again for the great work!

@PolygonPrincess
PolygonPrincess marked this pull request as ready for review November 10, 2026 00:01
@PolygonPrincess

Copy link
Copy Markdown
Contributor Author

@Everlite Marked this as ready for review, thanks for testing this and providing these fixes and completing the streamer wiring!

@Everlite
Everlite merged commit e4b03f4 into Everlite:dev Nov 10, 2026
1 check passed
@PolygonPrincess
PolygonPrincess deleted the pr/gc573-ipc-jsmn branch November 10, 2026 19:19
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