() Sometimes the ueventd has a hard time keeping up with all
the uevents. It causes the permissions of the IIO sysfs nodes
to remain unchanged. This causes the sensor HAL initialization
to fail. Need to retry a few more times.
() There is a quirk with some sensor hubs, where you have to
enable/disable/enable for it to start sending any events.
This adds the code to "jump-start" the hub.
Issue: AXIA-1451
Change-Id: Iecfbf8589637eb16a8b80364b47c2527a69d7cd3
Depends-Change-Id: Ibfff2a60c5223b2018c106237365967471e00e89
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
50000.0f, 1.0f, 0.75f, 0, {}
,
};
50000.0f, 1.0f, 0.75f, 0, {}
,
};
-const int retry_cnt = 5;
+const int retry_cnt = 10;
ALSSensor::ALSSensor(): SensorIIODev("als", "in_intensity_scale", "in_intensity_offset", "in_intensity_", retry_cnt){
ALOGV(">>ALSSensor 3D: constructor!");
ALSSensor::ALSSensor(): SensorIIODev("als", "in_intensity_scale", "in_intensity_offset", "in_intensity_", retry_cnt){
ALOGV(">>ALSSensor 3D: constructor!");
const long HID_USAGE_SENSOR_UNITS_G = 0x1A;
const long HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD = (0x11, 0xE0);
const long HID_USAGE_SENSOR_UNITS_G = 0x1A;
const long HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD = (0x11, 0xE0);
-const int retry_cnt = 5;
+const int retry_cnt = 10;
AccelSensor::AccelSensor(): SensorIIODev("accel_3d", "in_accel_scale", "in_accel_offset", "in_accel_", retry_cnt){
ALOGV(">>AccelSensor 3D: constructor!");
AccelSensor::AccelSensor(): SensorIIODev("accel_3d", "in_accel_scale", "in_accel_offset", "in_accel_", retry_cnt){
ALOGV(">>AccelSensor 3D: constructor!");
"HID_SENSOR Compass 3D", "Intel", 1, SENSORS_MAGNETIC_FIELD_HANDLE,
SENSOR_TYPE_MAGNETIC_FIELD, RANGE_M, RESOLUTION_M, 0.1f, 23000, {}
};
"HID_SENSOR Compass 3D", "Intel", 1, SENSORS_MAGNETIC_FIELD_HANDLE,
SENSOR_TYPE_MAGNETIC_FIELD, RANGE_M, RESOLUTION_M, 0.1f, 23000, {}
};
-const int retry_cnt = 5;
+const int retry_cnt = 10;
CompassSensor::CompassSensor(): SensorIIODev("magn_3d", "in_magn_scale", "in_magn_offset", "in_magn_", retry_cnt){
ALOGV(">>ComassSensor 3D: constructor!");
CompassSensor::CompassSensor(): SensorIIODev("magn_3d", "in_magn_scale", "in_magn_offset", "in_magn_", retry_cnt){
ALOGV(">>ComassSensor 3D: constructor!");
};
const int HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND = 0x15;
const int HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND = 0xF012;
};
const int HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND = 0x15;
const int HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND = 0xF012;
-const int retry_cnt = 5;
+const int retry_cnt = 10;
GyroSensor::GyroSensor(): SensorIIODev("gyro_3d", "in_anglvel_scale", "in_anglvel_offset", "in_anglvel_", retry_cnt){
ALOGV("GyroSensor: constructor\n");
GyroSensor::GyroSensor(): SensorIIODev("gyro_3d", "in_anglvel_scale", "in_anglvel_offset", "in_anglvel_", retry_cnt){
ALOGV("GyroSensor: constructor\n");
return 0;
}
if (enabled){
return 0;
}
if (enabled){
+ // QUIRK: some sensor hubs need to be turned on and off and on
+ // before sending any information. So we turn it on and off first
+ // before enabling again later in this function.
+ EnableBuffer(1);
+ EnableBuffer(0);
+
if (ReadHIDExponentValue(&unit_expo_value) < 0)
goto err_ret;
if (ReadHIDMeasurmentUnit(&units_value) < 0)
if (ReadHIDExponentValue(&unit_expo_value) < 0)
goto err_ret;
if (ReadHIDMeasurmentUnit(&units_value) < 0)
ret = EnableChannels();
if (ret < 0){
ALOGE("ParseIIODirectory Failed due Enable Channels failed\n");
ret = EnableChannels();
if (ret < 0){
ALOGE("ParseIIODirectory Failed due Enable Channels failed\n");
+ if (ret == -EACCES) {
+ // EACCES means the nodes do not have current owner.
+ // Need to retry, or else sensors won't power on.
+ // Other errors can be ignored, as these nodes are
+ // set once, and will return error when set again.
+ return ret;
+ }
}
// Parse the channels and build a list
}
// Parse the channels and build a list