static int ltr553_sensor_chip_readid(struct cavan_input_chip *chip) { int ret; u8 part_id; u8 manufac_id; ret = chip->read_register(chip, REG_PART_ID, &part_id); if (ret < 0) { pr_red_info("chip->read_data"); return ret; } pr_func_info("PART_ID = 0x%02x\n", part_id); if (part_id != 0x92) { pr_red_info("Invalid Part ID!"); return -EINVAL; } ret = chip->read_register(chip, REG_MANUFAC_ID, &manufac_id); if (ret < 0) { pr_red_info("chip->read_data"); return ret; } pr_func_info("MANUFAC_ID = 0x%02x\n", manufac_id); if (manufac_id != 0x05) { pr_red_info("Invalid Manufacturer ID!"); return -EINVAL; } return 0; }
static int adxl34x_sensor_chip_set_active(struct hua_input_chip *chip, bool enable) { int ret; u8 value; if (enable) { value = PCTL_AUTO_SLEEP | PCTL_LINK | PCTL_MEASURE; } else { value = 0; } pr_func_info("value = 0x%02x", value); ret = chip->write_register(chip, POWER_CTL, value); if (ret < 0) { pr_red_info("write_register POWER_CTL"); return ret; } return 0; }
struct sensors_event_t *hua_sensor_device_sync_event(struct hua_sensor_device *head, struct sensors_event_t *data, size_t data_size) { struct sensors_event_t *data_end; int64_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC); for (data_end = data + data_size; head; head = head->next) { if (head->updated) { #if HUA_SENSOR_DEVICE_DEBUG float *value = head->event.data; pr_func_info("%s(%d): [%f, %f, %f]", head->name, head->event.type, value[0], value[1], value[2]); #endif if (data < data_end) { head->updated = false; *data = head->event; data->timestamp = timestamp; } else { break; } data++; } } return data; }
static int cy8c242_proximity_set_enable(struct cavan_input_device *dev, bool enable) { u8 value = enable ? 1 : 0; struct cavan_input_chip *chip = dev->chip; pr_func_info("value = %d", value); return chip->write_register(chip, 0x12, value); }
static int lis3dh_acceleration_set_delay(struct cavan_input_device *dev, unsigned int delay) { struct cavan_input_chip *chip = dev->chip; u8 mask = lis3dh_delay2mask(lis3dh_delay_map, ARRAY_SIZE(lis3dh_delay_map), delay); pr_func_info("mask = 0x%02x", mask); return chip->write_register(chip, CTRL_REG1, LIS3DH_ACC_ENABLE_ALL_AXES | mask); }
static void test_mux_on_received(struct cavan_mux_link *link) { ssize_t rdlen; char buff[1024]; pr_func_info("link = %s", (char *) link->private_data); (void) buff; (void) rdlen; #if 0 rdlen = cavan_mux_link_recv(link, buff, sizeof(buff)); buff[rdlen] = 0; println("buff[%ld] = %s", rdlen, buff); #endif }
static int lis3dh_sensor_chip_set_active(struct cavan_input_chip *chip, bool enable) { int ret; u8 value; if (enable) { value = LIS3DH_ACC_ENABLE_ALL_AXES; } else { value = 0; } pr_func_info("value = 0x%02x", value); ret = chip->write_register(chip, CTRL_REG1, value); if (ret < 0) { pr_red_info("cavan_sensor_i2c_write_register"); return ret; } return 0; }