From f448af72136f7ecdadbe3ed44fabbab66349a296 Mon Sep 17 00:00:00 2001 From: Dmitry Ermakov <7954832+dimerr@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:52:08 +0000 Subject: [PATCH] sensors: detect Sony IMX662 (Starvis 2) detect_sony_sensor() had no IMX662 entry, so a camera carrying one came back "no sensor detected" -- e.g. a Hi3516CV610, where the probe path already reaches the sensor (0x34>>1 = 0x1a on /dev/i2c-0) and only the decision tree was missing a leaf. Key on 0x3B00: 0x41 at power-on reset -- the state at boot-time auto-detection -- and 0x39 after the standard init ("Set to 39h", IMX662 Standard Register Setting v2.0); both distinct from IMX415's 0x2E/0x28 ruled out just above. 0x341C=0x01 (IMX334 reads 0x47 there) confirms and holds in either state. Verified on a live IMX662 on a Hi3516CV610 in both reset and configured states; the unit test covers both 0x3B00 values. --- src/sensors.c | 11 +++++++++++ src/sensors_test.c | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/sensors.c b/src/sensors.c index dcf5976..90db816 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -230,6 +230,17 @@ static int detect_sony_sensor(sensor_ctx_t *ctx, int fd, return true; } + // Sony IMX662 (Starvis 2). 0x3B00 reads 0x41 at power-on reset -- the + // state at boot-time auto-detection -- and the standard init sets it to + // 0x39 ("Set to 39h", IMX662 Standard Register Setting v2.0); both are + // distinct from IMX415's 0x2E/0x28 ruled out just above. 0x341C=0x01 + // (IMX334 reads 0x47 there) holds in either state and guards a stray + // 0x3B00 match. Verified on a live IMX662 on a Hi3516CV610. + if ((r3B00 == 0x41 || r3B00 == 0x39) && READ(0x41C) == 0x01) { + sprintf(ctx->sensor_id, "IMX662"); + return true; + } + // HINT: possible check 0x3015 == 0x3c int r33B4 = READ(0x3B4); if (r33B4 == 0x96 || r33B4 == 0xFE) { diff --git a/src/sensors_test.c b/src/sensors_test.c index fef25c1..ec40914 100644 --- a/src/sensors_test.c +++ b/src/sensors_test.c @@ -369,6 +369,29 @@ static void check_sony(void) { mock_set(0x316a, 2, 1, 0x7e); mock_set(0x3b00, 2, 1, -1); CHECK(!detect_sony_sensor(&ctx, 0, mock_addr)); + + /* IMX662 (Starvis 2): 0x3b00 is 0x41 at power-on reset -- what boot-time + * auto-detection sees -- and the standard init sets it to 0x39; both are + * distinct from IMX415's 0x2e/0x28. 0x341c=0x01 (IMX334 reads 0x47) + * confirms, and 0x316a=0x00 keeps the IMX335 path from firing. */ + memset(&ctx, 0, sizeof(ctx)); + mock_clear(); + mock_set(0x316a, 2, 1, 0x00); + mock_set(0x3b00, 2, 1, 0x41); + mock_set(0x341c, 2, 1, 0x01); + CHECK(detect_sony_sensor(&ctx, 0, mock_addr)); + CHECK(!strcmp(ctx.sensor_id, "IMX662")); + if (strcmp(ctx.sensor_id, "IMX662")) + fprintf(stderr, " (IMX662 reset default: got \"%s\")\n", + ctx.sensor_id); + + memset(&ctx, 0, sizeof(ctx)); + mock_clear(); + mock_set(0x316a, 2, 1, 0x00); + mock_set(0x3b00, 2, 1, 0x39); + mock_set(0x341c, 2, 1, 0x01); + CHECK(detect_sony_sensor(&ctx, 0, mock_addr)); + CHECK(!strcmp(ctx.sensor_id, "IMX662")); } /* TechPoint is a rule, not a table: it whitelists nothing and turns any