diff --git a/src/sensors.c b/src/sensors.c index 2d3bef1..9d1e1ee 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -468,6 +468,17 @@ static int detect_onsemi_sensor(sensor_ctx_t *ctx, int fd, return sid; } +// SC1135 holds no ID in 0x3107/0x3108; it is told by 0x3008 = 0x60 and +// 0x3005 = 0x22. That is the pair the Xiongmai XM510 isp daemon accepts as an +// SC1135 once 0x3107/0x3108 matched none of its IDs: a sweep of every 0x3005 +// value with 0x3008 = 0x60 under emulation accepted 0x22 alone. The reads are +// 16-bit addressed, which an 8-bit device takes as a register write, so they +// are made only when 0x3107/0x3108 read empty. +static bool is_smartsens_sc1135(int fd, unsigned char i2c_addr) { + return i2c_read_register(fd, i2c_addr, 0x3008, 2, 1) == 0x60 && + i2c_read_register(fd, i2c_addr, 0x3005, 2, 1) == 0x22; +} + static int detect_smartsens_sensor(sensor_ctx_t *ctx, int fd, unsigned char i2c_addr) { if (i2c_change_addr(fd, i2c_addr) < 0) @@ -483,8 +494,6 @@ static int detect_smartsens_sensor(sensor_ctx_t *ctx, int fd, if (lower == -1) return false; - // check for SC1035, SC1145, SC1135 '0x3008' reg val is equal to 0x60 - int res = high << 8 | lower; switch (res) { case 0x0010: @@ -709,7 +718,11 @@ static int detect_smartsens_sensor(sensor_ctx_t *ctx, int fd, return true; case 0: case 0xffff: - // SC1135 catches here + // SC1135 has no ID here; only then are two more registers read + if (is_smartsens_sc1135(fd, i2c_addr)) { + strcpy(ctx->sensor_id, "SC1135"); + return true; + } return false; default: SENSOR_ERR("SmartSens", res); diff --git a/src/sensors_golden.txt b/src/sensors_golden.txt index 51b9f70..3accbc3 100644 --- a/src/sensors_golden.txt +++ b/src/sensors_golden.txt @@ -63,6 +63,7 @@ smartsens da23 SC1345 smartsens da4d SC1346 smartsens dc42 SC4336 smartsens eb2c SC2355 +smartsens-sc1135 6022 SC1135 soi 0500 JXK00 soi 0501 JXK01 soi 0502 JXK02 diff --git a/src/sensors_test.c b/src/sensors_test.c index b8fc6da..fb7082c 100644 --- a/src/sensors_test.c +++ b/src/sensors_test.c @@ -139,6 +139,14 @@ static void sc_smartsens(uint32_t id) { mock_set(0x3107, 2, 1, id >> 8); mock_set(0x3108, 2, 1, id & 0xff); } +/* SC1135 has no ID in 0x3107/0x3108: they read empty, and 0x3008/0x3005 + * name it. */ +static void sc_smartsens_sc1135(uint32_t id) { + mock_set(0x3107, 2, 1, 0x00); + mock_set(0x3108, 2, 1, 0x00); + mock_set(0x3008, 2, 1, id >> 8); + mock_set(0x3005, 2, 1, id & 0xff); +} static void sc_soi(uint32_t id) { mock_set(0x0a, 1, 1, id >> 8); mock_set(0x0b, 1, 1, id & 0xff); @@ -221,6 +229,7 @@ static void sc_techpoint(uint32_t id) { static const struct scenario scenarios[] = { {"smartsens", detect_smartsens_sensor, sc_smartsens}, + {"smartsens-sc1135", detect_smartsens_sensor, sc_smartsens_sc1135}, {"soi", detect_soi_sensor, sc_soi}, {"onsemi", detect_onsemi_sensor, sc_onsemi}, {"omni", detect_omni_sensor, sc_omni},