Skip to content

gm: the GM8126 on a mainline kernel, and the OV7720/OV7725 - #293

Merged
dimerr merged 6 commits into
masterfrom
gm8126
Nov 24, 2026
Merged

dimerr merged 6 commits into
masterfrom
gm8126

Conversation

@dimerr

@dimerr dimerr commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

/proc/pmu exists only on the vendor kernel; on a mainline one the device tree's compatible names the chip. The OV77xx (0x42, one-byte registers) is tried only by the Grain Media HAL.

Nothing here has run on a camera: only under qemu-bench (-M gm8126).

/proc/pmu is the vendor kernel's; the device tree names the chip otherwise.
@qodo-free-for-open-source-projects

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

Copy link
Copy Markdown

PR Summary by Qodo

Detect GM8126 on mainline kernels and OV7720/OV7725 sensors

✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Detect Grain Media chips from device-tree compatibility when vendor-only /proc/pmu is
 unavailable.
• Add GM-only probing for OV7720 and OV7725 sensors at I²C address 0x42.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: camera hardware identification and reporting integration.
  • The changed detector feeds the existing generic CPU-detection table, which selects gm_setup_hal and supplies chip identity to the report initialization path.
  • This is one end-to-end platform-identification behavior rather than separate capabilities for the detector, HAL, and report consumer.
  • The address-table addition, protocol-specific probe, sensor context update, and existing report consumer form one sensor-identification/reporting behavior within the same bounded camera hardware-reporting integration.
  • They are implementation hops, not separate capabilities.
Sources

src/chipid.c[71-75]

#ifdef IPCHW_VENDOR_GM
    {"Grain", gm_detect_cpu, VENDOR_GM, gm_setup_hal},
#ifndef STANDALONE_LIBRARY
    {NULL /* Generic */, gm_dt_detect_cpu, VENDOR_GM, gm_setup_hal},
#endif
Behavioral complexity 🟡 Medium 🧩 Compatibility cases

  • Before: GM detection relied on the existing /proc/pmu/chipver path in gm_detect_cpu.
  • After: non-standalone builds add an alternate device-tree-compatible input and preserve the existing table-driven fallback.
  • New correctness condition: parse NUL-separated compatible strings, recognize the intended GrainMedia prefix, and derive the four-character chip suffix without changing the existing HAL-selection contract.
  • The implementation is a small compatibility case with no new concurrency, persistence, or coordinated-write protocol.
Sources

src/chipid.c[71-75]

#ifdef IPCHW_VENDOR_GM
    {"Grain", gm_detect_cpu, VENDOR_GM, gm_setup_hal},
#ifndef STANDALONE_LIBRARY
    {NULL /* Generic */, gm_dt_detect_cpu, VENDOR_GM, gm_setup_hal},
#endif
Potential damage 🟡 Medium 🩹 Temporary loss

  • Conditionally, if this newly supported detection behavior regresses on a matching device, getchipname() can fail to establish the GM platform and the normal hardware-reporting flow cannot initialize the corresponding HAL.
  • This is a capability-availability failure, not persistent-state corruption: the detector only reads procfs and writes in-memory identification state.
  • Re-running after restoring the binary or correcting the deployment restores the capability; no state repair or external compensation is required.
  • Revert or replace the binary and rerun detection.
  • No persistent state or external effect needs repair.
  • The consequence assumes the DT-compatible entry is the only available identification path for the affected mainline-kernel GM device.
Sources

src/chipid.c[71-75]

#ifdef IPCHW_VENDOR_GM
    {"Grain", gm_detect_cpu, VENDOR_GM, gm_setup_hal},
#ifndef STANDALONE_LIBRARY
    {NULL /* Generic */, gm_dt_detect_cpu, VENDOR_GM, gm_setup_hal},
#endif
Assessed commit 79df1de
Diagram

graph TD
  Detect["Chip detection"] --> PMU["Vendor PMU"] --> HAL["GM HAL"] --> Candidates["I2C candidates"] --> Probe["OV77xx probe"] --> Identity["Sensor identity"]
  Detect --> DT["DT compatible"] --> HAL
Loading
High-Level Assessment

The separate device-tree detector preserves vendor-kernel detection while using the existing generic fallback and GM HAL. Keeping address 0x42 in the GM candidate list limits the new probe to the intended platform; camera validation remains outstanding.

Files changed (4) +32 / -1

Enhancement (4) +32 / -1
chipid.cRegister a generic Grain Media device-tree fallback +1/-0

Register a generic Grain Media device-tree fallback

• Adds a Grain Media detector that can match without a Grain-specific CPU-info string. Successful detection selects the existing GM vendor identity and HAL.

src/chipid.c

gm.cRead GM chip identity from device tree and probe address 0x42 +13/-1

Read GM chip identity from device tree and probe address 0x42

• Adds detection from '/proc/device-tree/compatible' for kernels without '/proc/pmu'. Extends the GM OmniVision address list with 0x42.

src/hal/gm.c

gm.hDeclare the GM device-tree detector +1/-0

Declare the GM device-tree detector

• Exposes the new detector for registration in the chip identification table.

src/hal/gm.h

sensors.cIdentify OV7720 and OV7725 using one-byte registers +17/-0

Identify OV7720 and OV7725 using one-byte registers

• Adds an address-0x42 OmniVision probe that checks product and manufacturer registers, names the OV7720 or OV7725, and records one-byte register width. Other OmniVision addresses retain their existing probe path.

src/sensors.c

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Board-specific devices go unidentified ✓ Resolved
Description
gm_dt_detect_cpu() passes the NUL-separated device-tree compatible property to
line_from_file(), whose regex can inspect only the first compatible string. When a board-specific
string comes before grainmedia,gm8126, the detector misses the chip and getchipname() can return
NULL.


Remediation recommended

2. New detector call breaks the repo's clang-format alignment ⊘ Outdated
Description
The continuation line of the dts_items_by_regex( call in gm_dt_detect_cpu is indented to 24
spaces, while the opening parenthesis places the first argument at column 28, so .clang-format
would realign it. The src/hal/gm.c file is not in .clang-format-hook-exclude, so the format
check will flag this hunk.

3. Failed reads misidentify the camera ✓ Resolved
Description
detect_omni_sensor() treats every version-register result other than 0x21 as an OV7720,
including the reader's -1 error result. If the earlier identity reads succeed but the read of
register 0x0B fails, sensor detection still reports success with the wrong model; an unexpected
version is classified the same way.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@dimerr

dimerr commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Both fixed: every compatible is matched, and an unread or unknown version is no sensor.

@dimerr

dimerr commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

/agentic_review

@dimerr

dimerr commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Every compatible is matched, now without the regex helper, which had put the library over its size budget.

@dimerr

dimerr commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

The GM8126 and the OV77xx are now in ipctool only: ipcinfo does not grow at all (53707 to 53707 bytes with every vendor).

@dimerr
dimerr merged commit 62e0120 into master Nov 24, 2026
5 checks passed
@dimerr
dimerr deleted the gm8126 branch November 24, 2026 14:33
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