Skip to content

Commit 9c5286b

Browse files
committed
Add ImageDesign sensors (MIS)
1 parent bdd7f81 commit 9c5286b

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/hal/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum SENSORS {
6060
SENSOR_GALAXYCORE,
6161
SENSOR_SUPERPIX,
6262
SENSOR_TECHPOINT,
63+
SENSOR_IMAGEDESIGN,
6364
};
6465

6566
typedef struct {

src/hal/hisi/hal_hisi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ static unsigned char omni_addrs[] = {0x60, 0x6c, 0x42, 0};
2828
static unsigned char gc_addrs[] = {0x6e, 0x52, 0x42, 0x78, 0};
2929
static unsigned char superpix_addrs[] = {0x79, 0};
3030
static unsigned char tp_addrs[] = {0x88, 0};
31+
static unsigned char imagedesign_addrs[] = {0x60, 0};
32+
3133

3234
static sensor_addr_t my_possible_i2c_addrs[] = {
3335
{SENSOR_SONY, sony_addrs}, {SENSOR_SOI, soi_addrs},
3436
{SENSOR_ONSEMI, onsemi_addrs}, {SENSOR_SMARTSENS, ssens_addrs},
3537
{SENSOR_OMNIVISION, omni_addrs}, {SENSOR_GALAXYCORE, gc_addrs},
3638
{SENSOR_SUPERPIX, superpix_addrs}, {SENSOR_TECHPOINT, tp_addrs},
37-
{0, NULL}};
39+
{SENSOR_IMAGEDESIGN, imagedesign_addrs}, {0, NULL}};
3840

3941
static float hisi_get_temp();
4042

src/sensors.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,35 @@ static int detect_techpoint_adc(sensor_ctx_t *ctx, int fd,
890890
return res;
891891
}
892892

893+
static int detect_imagedesign_sensor(sensor_ctx_t *ctx, int fd,
894+
unsigned char i2c_addr) {
895+
if (i2c_change_addr(fd, i2c_addr) < 0)
896+
return false;
897+
898+
int msb = i2c_read_register(fd, i2c_addr, 0x3000, 2, 1);
899+
if (msb == -1)
900+
return false;
901+
902+
int lsb = i2c_read_register(fd, i2c_addr, 0x3001, 2, 1);
903+
if (lsb == -1)
904+
return false;
905+
906+
int res = msb << 8 | lsb;
907+
switch (res) {
908+
case 0x2006:
909+
case 0x2008: // XM states 0x2008 is MIS2009, not going to believe that yet
910+
sprintf(ctx->sensor_id, "MIS%04x", res);
911+
return true;
912+
case 0x1311:
913+
sprintf(ctx->sensor_id, "MIS4001");
914+
return true;
915+
default:
916+
SENSOR_ERR("ImageDesign", res);
917+
return false;
918+
}
919+
// MIS40C1 0xce4 @ 3107-3108 ?
920+
}
921+
893922
static int detect_possible_sensors(sensor_ctx_t *ctx, int fd,
894923
int (*detect_fn)(sensor_ctx_t *ctx, int,
895924
unsigned char),
@@ -958,6 +987,10 @@ static bool get_sensor_id_i2c(sensor_ctx_t *ctx) {
958987
SENSOR_TECHPOINT)) {
959988
strcpy(ctx->vendor, "TechPoint");
960989
detected = true;
990+
} else if (detect_possible_sensors(ctx, fd, detect_imagedesign_sensor,
991+
SENSOR_IMAGEDESIGN)) {
992+
strcpy(ctx->vendor, "ImageDesign");
993+
detected = true;
961994
}
962995
exit:
963996
close_sensor_fd(fd);

0 commit comments

Comments
 (0)