Skip to content

Commit

Permalink
Add ImageDesign sensors (MIS)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimerr committed May 2, 2024
1 parent bdd7f81 commit 9c5286b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/hal/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum SENSORS {
SENSOR_GALAXYCORE,
SENSOR_SUPERPIX,
SENSOR_TECHPOINT,
SENSOR_IMAGEDESIGN,
};

typedef struct {
Expand Down
4 changes: 3 additions & 1 deletion src/hal/hisi/hal_hisi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ static unsigned char omni_addrs[] = {0x60, 0x6c, 0x42, 0};
static unsigned char gc_addrs[] = {0x6e, 0x52, 0x42, 0x78, 0};
static unsigned char superpix_addrs[] = {0x79, 0};
static unsigned char tp_addrs[] = {0x88, 0};
static unsigned char imagedesign_addrs[] = {0x60, 0};


static sensor_addr_t my_possible_i2c_addrs[] = {
{SENSOR_SONY, sony_addrs}, {SENSOR_SOI, soi_addrs},
{SENSOR_ONSEMI, onsemi_addrs}, {SENSOR_SMARTSENS, ssens_addrs},
{SENSOR_OMNIVISION, omni_addrs}, {SENSOR_GALAXYCORE, gc_addrs},
{SENSOR_SUPERPIX, superpix_addrs}, {SENSOR_TECHPOINT, tp_addrs},
{0, NULL}};
{SENSOR_IMAGEDESIGN, imagedesign_addrs}, {0, NULL}};

static float hisi_get_temp();

Expand Down
33 changes: 33 additions & 0 deletions src/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,35 @@ static int detect_techpoint_adc(sensor_ctx_t *ctx, int fd,
return res;
}

static int detect_imagedesign_sensor(sensor_ctx_t *ctx, int fd,
unsigned char i2c_addr) {
if (i2c_change_addr(fd, i2c_addr) < 0)
return false;

int msb = i2c_read_register(fd, i2c_addr, 0x3000, 2, 1);
if (msb == -1)
return false;

int lsb = i2c_read_register(fd, i2c_addr, 0x3001, 2, 1);
if (lsb == -1)
return false;

int res = msb << 8 | lsb;
switch (res) {
case 0x2006:
case 0x2008: // XM states 0x2008 is MIS2009, not going to believe that yet
sprintf(ctx->sensor_id, "MIS%04x", res);
return true;
case 0x1311:
sprintf(ctx->sensor_id, "MIS4001");
return true;
default:
SENSOR_ERR("ImageDesign", res);
return false;
}
// MIS40C1 0xce4 @ 3107-3108 ?
}

static int detect_possible_sensors(sensor_ctx_t *ctx, int fd,
int (*detect_fn)(sensor_ctx_t *ctx, int,
unsigned char),
Expand Down Expand Up @@ -958,6 +987,10 @@ static bool get_sensor_id_i2c(sensor_ctx_t *ctx) {
SENSOR_TECHPOINT)) {
strcpy(ctx->vendor, "TechPoint");
detected = true;
} else if (detect_possible_sensors(ctx, fd, detect_imagedesign_sensor,
SENSOR_IMAGEDESIGN)) {
strcpy(ctx->vendor, "ImageDesign");
detected = true;
}
exit:
close_sensor_fd(fd);
Expand Down

0 comments on commit 9c5286b

Please sign in to comment.