diff --git a/src/hal/gm.c b/src/hal/gm.c index 737f5c7..d422d6a 100644 --- a/src/hal/gm.c +++ b/src/hal/gm.c @@ -17,7 +17,12 @@ static unsigned char omni_addrs[] = {0x6c, 0x42, 0}; #else static unsigned char omni_addrs[] = {0x6c, 0}; #endif +#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 static unsigned char gc_addrs[] = {0x6e, 0}; static sensor_addr_t gm_possible_i2c_addrs[] = { diff --git a/src/sensors.c b/src/sensors.c index d46b542..a620b99 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -456,6 +456,23 @@ static int detect_onsemi_sensor(sensor_ctx_t *ctx, int fd, // sensor_write_register(0x301A, 1); // msDelay(100); +#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; + } +#endif + int pid = i2c_read_register(fd, i2c_addr, 0x3000, 2, 2); int sid = 0;