Skip to content

gm: the Aptina MT9P006 at 0xBA - #308

Merged
openipc-ai merged 1 commit into
masterfrom
gm-mt9p006
Dec 3, 2026
Merged

openipc-ai merged 1 commit into
masterfrom
gm-mt9p006

Conversation

@openipc-ai

Copy link
Copy Markdown
Contributor

For #305: with #306 and #307 in, the reporter's GM8128 is named, but its sensor isn't found (comment). The reporter measured it themselves:

  • i2cdetect finds a device at 0xba.
  • i2cdump 0xba 0x00 0x01 reads 18 01.
  • The camera's firmware calls the part mt9p006 and loads isp_mt9p031.cfg for it.

The Aptina (now onsemi) MT9P0xx use one-byte register addresses with two-byte data, and keep CHIP_VERSION at 0x00. That register reads 0x1801 on the MT9P001, MT9P031 and MT9P006 alike (Linux's mt9p031 driver handles all three with the one ID), so the register can't tell them apart. The report says MT9P006, the name this camera's firmware uses.

The probe is part of the onsemi probe, runs only at 0xBA, and makes only reads. 0xBA is added to the Grain Media HAL's onsemi address list. Like the rest of the GM8126 support, this is in ipctool only: ipcinfo is byte-identical (153852 bytes on arm32).

Tested

I booted qemu-bench's gm8126 machine with the GM8128 chip ID and a stand-in sensor at 0x5D (0xBA in ipctool's 8-bit form): an 8-bit-register model that holds 0x1801 at 0x00. The stand-in was a temporary entry in my local build only, not committed to qemu-bench. It reads 18 01 through i2cdump, as the reporter's sensor does.

  • master: No sensor detected, as on the reporter's camera.
  • This branch: model: MT9P006, addr: 0xba, bus 0.

The native unit tests pass.

The GM8128 camera of #305 carries an MT9P006: CHIP_VERSION 0x1801 at
register 0x00, with one-byte register addresses and two-byte data. The
MT9P001 and MT9P031 read the same value, so the name is the camera's own
(its firmware loads isp_mt9p031.cfg for the part). ipctool only.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

gm: detect the Aptina MT9P006 sensor at 0xBA on GM8128

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Adds 0xBA to the Grain Media onsemi address list, for GM8128 cameras.
• Identifies the MT9P006 by reading CHIP_VERSION 0x1801 at register 0x00.
• Probe runs only at 0xBA, only reads, and is excluded from the standalone library.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed address nomination and detection branch form one bounded sensor-identification behavior.
  • The resulting sensor_id and register-width metadata flow to the command-line identity output and diagnostic monitor; these are consumers of the same detection capability, not independent technical capabilities.
Sources

src/hal/gm.c[20-25]

#ifndef STANDALONE_LIBRARY
/* 0xBA: the Aptina MT9P006, on GM8128 cameras */
static unsigned char onsemi_addrs[] = {0x20, 0xba, 0};
#else
static unsigned char onsemi_addrs[] = {0x20, 0};
#endif

src/sensors.c[459-472]

#if defined(IPCHW_VENDOR_GM) && !defined(STANDALONE_LIBRARY)
    /* The Aptina MT9P0xx have one-byte register addresses and two-byte data,
     * and CHIP_VERSION at 0x00: 0x1801 on the MT9P001, MT9P031 and MT9P006
     * alike, so the register cannot tell them apart. The GM8128 camera of
     * #305 runs an MT9P006 (its firmware loads isp_mt9p031.cfg for it) at
     * 0xBA. The second value is the same reading with the bytes swapped, as
     * the universal reader assembles two bytes. */
    if (i2c_addr == 0xBA) {
        int ver = i2c_read_register(fd, i2c_addr, 0x00, 1, 2);
        if (ver != 0x1801 && ver != 0x0118)
            return false;
        strcpy(ctx->sensor_id, "MT9P006");
        ctx->reg_width = 1;
        return true;
Behavioral complexity 🟡 Medium 🧩 Compatibility cases

  • Before: the ON Semiconductor probe used the existing two-byte register-address path beginning at 0x3000.
  • After: a GM-only 0xBA case uses a one-byte register address, two-byte data, and accepts either byte ordering of the version value.
  • New correctness conditions are that the special path applies only to 0xBA in non-standalone GM builds, preserves the existing 0x20 and other vendor probes, and interprets both returned byte orders consistently.
  • The source also introduces an unavoidable compatibility ambiguity because three Aptina models share the accepted signature.
Sources

src/hal/gm.c[20-25]

#ifndef STANDALONE_LIBRARY
/* 0xBA: the Aptina MT9P006, on GM8128 cameras */
static unsigned char onsemi_addrs[] = {0x20, 0xba, 0};
#else
static unsigned char onsemi_addrs[] = {0x20, 0};
#endif

src/sensors.c[459-472]

#if defined(IPCHW_VENDOR_GM) && !defined(STANDALONE_LIBRARY)
    /* The Aptina MT9P0xx have one-byte register addresses and two-byte data,
     * and CHIP_VERSION at 0x00: 0x1801 on the MT9P001, MT9P031 and MT9P006
     * alike, so the register cannot tell them apart. The GM8128 camera of
     * #305 runs an MT9P006 (its firmware loads isp_mt9p031.cfg for it) at
     * 0xBA. The second value is the same reading with the bytes swapped, as
     * the universal reader assembles two bytes. */
    if (i2c_addr == 0xBA) {
        int ver = i2c_read_register(fd, i2c_addr, 0x00, 1, 2);
        if (ver != 0x1801 && ver != 0x0118)
            return false;
        strcpy(ctx->sensor_id, "MT9P006");
        ctx->reg_width = 1;
        return true;
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the shared signature matches a different Aptina model at 0xBA, the tool can report MT9P006 incorrectly and diagnostic selection can be wrong or unsupported.
  • The effect is limited to this sensor-identification capability; no persistent writes or external state changes are performed.
  • Rebuild or revert to remove the new probe.
  • The incorrect diagnostic result is transient and does not require persistent-state repair; any operator action based on a wrong report would need separate correction.
Sources

src/sensors.c[459-472]

#if defined(IPCHW_VENDOR_GM) && !defined(STANDALONE_LIBRARY)
    /* The Aptina MT9P0xx have one-byte register addresses and two-byte data,
     * and CHIP_VERSION at 0x00: 0x1801 on the MT9P001, MT9P031 and MT9P006
     * alike, so the register cannot tell them apart. The GM8128 camera of
     * #305 runs an MT9P006 (its firmware loads isp_mt9p031.cfg for it) at
     * 0xBA. The second value is the same reading with the bytes swapped, as
     * the universal reader assembles two bytes. */
    if (i2c_addr == 0xBA) {
        int ver = i2c_read_register(fd, i2c_addr, 0x00, 1, 2);
        if (ver != 0x1801 && ver != 0x0118)
            return false;
        strcpy(ctx->sensor_id, "MT9P006");
        ctx->reg_width = 1;
        return true;
Assessed commit 110669f
Diagram

graph TD
  A["gm.c: onsemi_addrs"] --> B["detect_onsemi_sensor"] --> C{"addr == 0xBA?"}
  C -->|yes| D["Read reg 0x00, 1-byte addr"] --> E{"0x1801 or 0x0118?"}
  E -->|yes| F["sensor_id = MT9P006"]
  E -->|no| G["Return not found"]
  C -->|no| H["Existing onsemi probe"]
Loading
High-Level Assessment

The PR's approach is appropriate. The MT9P001, MT9P031 and MT9P006 all return the same CHIP_VERSION, so no register read can tell them apart, and the name comes from the reporter's firmware rather than the probe. A separate probe at 0xBA keeps the change narrow and read-only. Using the existing generic 0x3000 PID path would not work, since these parts use one-byte register addresses. Detection by address alone would be too broad, so the value check stays.

Files changed (2) +22 / -0

Enhancement (2) +22 / -0
gm.cAdd 0xBA to the Grain Media onsemi address list +5/-0

Add 0xBA to the Grain Media onsemi address list

• Adds 0xBA to onsemi_addrs in the non-standalone build, with a comment naming the MT9P006 on GM8128 cameras. The standalone build keeps the original list.

src/hal/gm.c

sensors.cProbe MT9P006 at 0xBA by its CHIP_VERSION register +17/-0

Probe MT9P006 at 0xBA by its CHIP_VERSION register

• Adds an early branch to detect_onsemi_sensor, compiled only for GM non-standalone builds, that runs only at 0xBA. It reads register 0x00 with a 1-byte address and 2-byte data, accepts 0x1801 or the byte-swapped 0x0118, and sets the sensor ID to MT9P006 with 1-byte register width. All other addresses fall through to the existing probe.

src/sensors.c

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit acec0a7 into master Dec 3, 2026
5 checks passed
@openipc-ai
openipc-ai deleted the gm-mt9p006 branch December 3, 2026 10:33
@openipc-ai openipc-ai mentioned this pull request Dec 3, 2026
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