Lines Matching refs:sensor
55 #define NANOHUB_LOCK_DIR "/data/vendor/sensor/nanohub_lock"
106 static bool isWakeEvent(int32_t sensor)
108 switch (sensor) {
281 // enable hall sensor for folio
315 // Set main thread to SCHED_FIFO to lower sensor event latency when system is under load
582 sensors_event_t *HubConnection::initEv(sensors_event_t *ev, uint64_t timestamp, uint32_t type, uint32_t sensor)
588 ev->sensor = sensor;
593 ssize_t HubConnection::decrementIfWakeEventLocked(int32_t sensor)
595 if (isWakeEvent(sensor)) {
599 ALOGW("%s: sensor=%d, unexpected count=%d, no-op",
600 __FUNCTION__, sensor, mWakeEventCount);
606 void HubConnection::protectIfWakeEventLocked(int32_t sensor)
608 if (isWakeEvent(sensor)) {
627 void HubConnection::processSample(uint64_t timestamp, uint32_t type, uint32_t sensor, struct OneAxisSample *sample, __attribute__((unused)) bool highAccuracy)
632 switch (sensor) {
645 mActivityEventHandler->OnActivityEvent(sensor, sample->idata & 0xff,
650 initEv(&nev[cnt++], timestamp, type, sensor)->pressure = sample->fdata;
653 initEv(&nev[cnt++], timestamp, type, sensor)->relative_humidity = sample->fdata;
656 initEv(&nev[cnt++], timestamp, type, sensor)->temperature = sample->fdata;
659 initEv(&nev[cnt++], timestamp, type, sensor)->temperature = sample->fdata;
662 initEv(&nev[cnt++], timestamp, type, sensor)->distance = sample->fdata;
665 initEv(&nev[cnt++], timestamp, type, sensor)->light = sample->fdata;
671 initEv(&nev[cnt++], timestamp, type, sensor)->u64.step_counter = mLastStepCount;
678 initEv(&nev[cnt++], timestamp, type, sensor)->data[0] = 1.0f;
685 initEv(&nev[cnt++], timestamp, type, sensor)->data[0] = sample->idata;
693 initEv(&nev[cnt++], timestamp, type, sensor)->data[0] = sample->idata;
720 void HubConnection::processSample(uint64_t timestamp, uint32_t type, uint32_t sensor, struct RawThreeAxisSample *sample, __attribute__((unused)) bool highAccuracy)
727 switch (sensor) {
729 sv = &initEv(&nev[cnt], timestamp, type, sensor)->acceleration;
736 if (mSensorState[sensor].enable && isSampleIntervalSatisfied(sensor, timestamp)) {
740 // https://source.android.com/devices/sensors/sensor-types.html
741 // "The bias and scale calibration must only be updated while the sensor is deactivated,
792 sv = &initEv(&nev[cnt], timestamp, type, sensor)->magnetic;
799 if (mSensorState[sensor].enable && isSampleIntervalSatisfied(sensor, timestamp)) {
826 void HubConnection::processSample(uint64_t timestamp, uint32_t type, uint32_t sensor, struct ThreeAxisSample *sample, bool highAccuracy)
836 switch (sensor) {
838 sv = &initEv(&nev[cnt], timestamp, type, sensor)->acceleration;
845 if (mSensorState[sensor].enable && isSampleIntervalSatisfied(sensor, timestamp)) {
878 sv = &initEv(&nev[cnt], timestamp, type, sensor)->gyro;
885 if (mSensorState[sensor].enable && isSampleIntervalSatisfied(sensor, timestamp)) {
930 sv = &initEv(&nev[cnt], timestamp, type, sensor)->magnetic;
937 if (mSensorState[sensor].enable && isSampleIntervalSatisfied(sensor, timestamp)) {
968 sv = &initEv(&nev[cnt++], timestamp, type, sensor)->orientation;
975 ev = initEv(&nev[cnt++], timestamp, type, sensor);
981 ev = initEv(&nev[cnt++], timestamp, type, sensor);
995 ev = initEv(&nev[cnt++], timestamp, type, sensor);
1052 ALOGV("restoring: sensor=%d, handle=%d, enable=%d, period=%" PRId64 ", latency=%" PRId64,
1058 ALOGW("failed to send config command to restore sensor %d\n", cmd.sensorType);
1067 ALOGW("failed to send flush command to sensor %d\n", cmd.sensorType);
1138 uint32_t type, sensor, bias, currSensor;
1159 sensor = COMMS_SENSOR_ACCEL;
1165 sensor = COMMS_SENSOR_ACCEL;
1170 sensor = COMMS_SENSOR_GYRO;
1176 sensor = COMMS_SENSOR_MAG;
1182 sensor = COMMS_SENSOR_MAG;
1187 sensor = COMMS_SENSOR_LIGHT;
1192 sensor = COMMS_SENSOR_PROXIMITY;
1197 sensor = COMMS_SENSOR_PRESSURE;
1202 sensor = COMMS_SENSOR_HUMIDITY;
1206 // nanohub only has one temperature sensor type, which is mapped to
1209 sensor = COMMS_SENSOR_TEMPERATURE;
1214 sensor = COMMS_SENSOR_AMBIENT_TEMPERATURE;
1219 sensor = COMMS_SENSOR_ORIENTATION;
1224 sensor = COMMS_SENSOR_WINDOW_ORIENTATION;
1229 sensor = COMMS_SENSOR_STEP_DETECTOR;
1234 sensor = COMMS_SENSOR_STEP_COUNTER;
1239 sensor = COMMS_SENSOR_SIGNIFICANT_MOTION;
1244 sensor = COMMS_SENSOR_GRAVITY;
1249 sensor = COMMS_SENSOR_LINEAR_ACCEL;
1254 sensor = COMMS_SENSOR_ROTATION_VECTOR;
1259 sensor = COMMS_SENSOR_GEO_MAG;
1264 sensor = COMMS_SENSOR_GAME_ROTATION_VECTOR;
1269 sensor = COMMS_SENSOR_HALL;
1274 sensor = COMMS_SENSOR_SYNC;
1279 sensor = COMMS_SENSOR_TILT;
1284 sensor = COMMS_SENSOR_GESTURE;
1289 sensor = COMMS_SENSOR_DOUBLE_TWIST;
1294 sensor = COMMS_SENSOR_DOUBLE_TAP;
1299 sensor = COMMS_SENSOR_WRIST_TILT;
1304 sensor = COMMS_SENSOR_DOUBLE_TOUCH;
1309 sensor = COMMS_SENSOR_ACTIVITY_IN_VEHICLE_START;
1314 sensor = COMMS_SENSOR_ACTIVITY_IN_VEHICLE_STOP;
1319 sensor = COMMS_SENSOR_ACTIVITY_ON_BICYCLE_START;
1324 sensor = COMMS_SENSOR_ACTIVITY_ON_BICYCLE_STOP;
1329 sensor = COMMS_SENSOR_ACTIVITY_WALKING_START;
1334 sensor = COMMS_SENSOR_ACTIVITY_WALKING_STOP;
1339 sensor = COMMS_SENSOR_ACTIVITY_RUNNING_START;
1344 sensor = COMMS_SENSOR_ACTIVITY_RUNNING_STOP;
1349 sensor = COMMS_SENSOR_ACTIVITY_STILL_START;
1354 sensor = COMMS_SENSOR_ACTIVITY_STILL_STOP;
1359 sensor = COMMS_SENSOR_ACTIVITY_TILTING;
1364 sensor = COMMS_SENSOR_GAZE;
1369 sensor = COMMS_SENSOR_UNGAZE;
1395 currSensor = sensor;
1399 ALOGW("sensor %d (one): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
1408 ALOGW("sensor %d (rawThree): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
1417 ALOGW("sensor %d (three): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
1425 ALOGW("sensor %d (unknown): cannot processSample\n", currSensor);
1433 // If no primary sensor type is specified,
1434 // then 'sensor' is the primary sensor type.
1435 primary = mSensorState[sensor].primary;
1436 primary = (primary ? primary : sensor);
1439 if (isActivitySensor(sensor) && mActivityEventHandler != NULL) {
1447 ev.sensor = 0;
1449 ev.meta_data.sensor = flush.handle;
1462 ALOGV("flushing %d", ev.meta_data.sensor);
1466 ALOGW("too little data for sensor %d: len=%zu\n", sensor, len);
1706 ALOGV("queueActivate: sensor=%d, handle=%d, enable=%d",
1710 ALOGW("queueActivate: failed to send command: sensor=%d, handle=%d, enable=%d",
1735 ALOGV("queueSetDelay: sensor=%d, handle=%d, period=%" PRId64,
1738 ALOGW("queueSetDelay: failed to send command: sensor=%d, handle=%d, period=%" PRId64,
1768 ALOGV("queueBatch: sensor=%d, handle=%d, period=%" PRId64 ", latency=%" PRId64,
1771 sensor=%d, handle=%d, period=%" PRId64 ", latency=%" PRId64,
1793 // If no primary sensor type is specified,
1794 // then 'handle' is the primary sensor type.
1813 ALOGV("queueFlush: sensor=%d, handle=%d",
1816 ALOGW("queueFlush: failed to send command: sensor=%d, handle=%d"
1836 ALOGV("queueData: sensor=%d, length=%zu",
1839 ALOGW("queueData: failed to send command: sensor=%d, length=%zu",
1917 decrementIfWakeEventLocked(ev[i].sensor);
1932 protectIfWakeEventLocked(ev[i].sensor);
2051 // no intention to block sensor delivery thread. when lock is needed ignore
2055 auto i = mSensorToChannel.find(nev->sensor);
2062 nev->sensor, j.second.rateLevel))) {
2139 // make sure no active sensor in this channel
2143 // sensor service is responsible for stop all sensors before remove direct
2181 // re-evaluate and send config for all sensor that need to be stopped
2303 // No sensor support VERY_FAST, fall through