From 4438c6e167d0efc8b617509e43f69be733478094 Mon Sep 17 00:00:00 2001 From: Dmitry Ilyin Date: Sun, 28 Jan 2024 19:34:19 +0300 Subject: [PATCH] Refactor IMX664, IMX662, IMX675, IMX482 sensors detection --- src/sensors.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/sensors.c b/src/sensors.c index 8f0afca..0a723f8 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -320,28 +320,32 @@ static int detect_sony_sensor(sensor_ctx_t *ctx, int fd, } int r30A4 = READ(0xA4); + switch (r30A4 & 0xF0) { + case 0xA0: + if (READ(0xC44) == 6) { + sprintf(ctx->sensor_id, "IMX664"); + return true; + } - if (((r30A4 & 0xF0) == 0xA0) && (READ(0xC44) == 6)) { - sprintf(ctx->sensor_id, "IMX664"); - return true; - } - - // TODO: not tested yet - if (((r30A4 & 0xF0) == 0xA0) && (READ(0xC40) == 5)) { - sprintf(ctx->sensor_id, "IMX662"); - return true; - } + // TODO: not tested yet + if (READ(0xC40) == 5) { + sprintf(ctx->sensor_id, "IMX662"); + return true; + } - // TODO: not tested yet - if (((r30A4 & 0xF0) == 0xA0) && (READ(0xC7C) == 0x16)) { - sprintf(ctx->sensor_id, "IMX675"); - return true; - } + // TODO: not tested yet + if (READ(0xC7C) == 0x16) { + sprintf(ctx->sensor_id, "IMX675"); + return true; + } + break; - // TODO: not tested yet - if (((r30A4 & 0xF0) == 0x20) && (READ(0x152) == 0x1E)) { - sprintf(ctx->sensor_id, "IMX482"); - return true; + case 0x20: + // TODO: not tested yet + if (READ(0x152) == 0x1E) { + sprintf(ctx->sensor_id, "IMX482"); + return true; + } } return false;