static int enable_disable_ls(struct sensors_control_context_t *dev, uint32_t active, uint32_t sensors, uint32_t mask) { int rc = 0; uint32_t now_active_ls_sensors; int fd = open_ls(dev); if (fd < 0) { LOGE("Couldn't open %s (%s)", LS_DEVICE_NAME, strerror(errno)); return 0; } LOGV("(before) ls sensors = %08x, real = %08x", sensors, read_ls_sensors_state(fd)); if (mask & SENSORS_LIGHT) { int flags = (sensors & SENSORS_LIGHT) ? 1 : 0; rc = ioctl(fd, LIGHTSENSOR_IOCTL_ENABLE, &flags); if (rc < 0) LOGE("LIGHTSENSOR_IOCTL_ENABLE error (%s)", strerror(errno)); } now_active_ls_sensors = read_ls_sensors_state(fd); LOGV("(after) ls sensors = %08x, real = %08x", sensors, now_active_ls_sensors); return now_active_ls_sensors; }
static int enable_disable_ls(struct sensors_control_context_t *dev, uint32_t active, uint32_t sensors, uint32_t mask) { int ret = 0; uint32_t now_active_ls_sensors; char buf[256]; int fd = open_ls(dev); LOGD("Enter enable_disable_ls, active:0x%x, sensors:0x%x, mask:0x%x", active& SENSORS_LIGHT, sensors& SENSORS_LIGHT, mask& SENSORS_LIGHT ); if (fd < 0) { LOGE("Couldn't open %s (%s)", LS_DEVICE_NAME, strerror(errno)); return 0; } LOGD("(before) ls sensors = %08x, real = %08x", sensors, read_ls_sensors_state(fd)); if (mask & SENSORS_LIGHT) { sprintf(buf, "%x", (sensors & SENSORS_LIGHT) ? 1 : 0); ret = write(fd, buf , strlen( buf ) + 1 ); if (ret < 0) LOGE("write to light sensor error (%s)", strerror(errno)); LOGD("write lightsensor(%s) return %d", buf, ret ); } now_active_ls_sensors = read_ls_sensors_state(fd); LOGD("(after) ls sensors = %08x, real = %08x", sensors, now_active_ls_sensors); return now_active_ls_sensors; }
static int enable_disable_ls(struct sensors_control_context_t *dev, uint32_t active, uint32_t sensors, uint32_t mask) { int rc = 0; uint32_t now_active_ls_sensors; int fd = open_ls(dev); if (fd < 0) { LOGE("Couldn't open %s (%s)", LS_DEVICE_NAME, strerror(errno)); return 0; } LOGV("(before) ls sensors = %08x, real = %08x", sensors, read_ls_sensors_state(fd,0)); int flags = 0; if (mask & SENSORS_LIGHT) { flags = (sensors & SENSORS_LIGHT) ? 1 : 0; if( flags == 1) { rc = ioctl(fd, L_IOC_POLLING_TIMER_SET); if (rc < 0) LOGE("L_IOC_POLLING_TIMER_SET error (%s)", strerror(errno)); } else { rc = ioctl(fd, L_IOC_POLLING_TIMER_CANCEL); if (rc < 0) LOGE("L_IOC_POLLING_TIMER_SET error (%s)", strerror(errno)); } } now_active_ls_sensors = read_ls_sensors_state(fd,flags); LOGV("(after) ls sensors = %08x, real = %08x", sensors, now_active_ls_sensors); return now_active_ls_sensors; }