diff options
Diffstat (limited to 'modules/sensors/dynamic_sensor/HidRawSensor.cpp')
-rw-r--r-- | modules/sensors/dynamic_sensor/HidRawSensor.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/sensors/dynamic_sensor/HidRawSensor.cpp b/modules/sensors/dynamic_sensor/HidRawSensor.cpp index 4520ddaa..3759e7e9 100644 --- a/modules/sensors/dynamic_sensor/HidRawSensor.cpp +++ b/modules/sensors/dynamic_sensor/HidRawSensor.cpp @@ -891,10 +891,18 @@ bool HidRawSensor::findSensorControlUsage(const std::vector<HidParser::ReportPac mReportIntervalId = reportInterval->id; mReportIntervalBitOffset = reportInterval->bitOffset; mReportIntervalBitSize = reportInterval->bitSize; - - mFeatureInfo.minDelay = std::max(static_cast<int64_t>(1), reportInterval->minRaw) * 1000; - mFeatureInfo.maxDelay = std::min(static_cast<int64_t>(1000000), - reportInterval->maxRaw) * 1000; // maximum 1000 second + mReportIntervalScale = reportInterval->a; + mReportIntervalOffset = reportInterval->b; + + mFeatureInfo.minDelay = 1000000.0 + * (reportInterval->minRaw + reportInterval->b) + * reportInterval->a; + mFeatureInfo.minDelay = std::max(1000, mFeatureInfo.minDelay); + mFeatureInfo.maxDelay = 1000000.0 + * (reportInterval->maxRaw + reportInterval->b) + * reportInterval->a; + mFeatureInfo.maxDelay = std::min(static_cast<int64_t>(1000000000), + mFeatureInfo.maxDelay); } return true; return (mPowerStateId >= 0 || mReportingStateId >= 0) && mReportIntervalId >= 0; @@ -981,7 +989,9 @@ int HidRawSensor::batch(int64_t samplingPeriod, int64_t batchingPeriod) { if (device->getFeature(id, &buffer) && (8 * buffer.size()) >= (mReportIntervalBitOffset + mReportIntervalBitSize)) { - int64_t periodMs = samplingPeriod / 1000000; //ns -> ms + int64_t periodMs = + (((static_cast<double>(samplingPeriod)) / 1000000000.0) + / mReportIntervalScale) - mReportIntervalOffset; int64_t maxPeriodMs = (1LL << std::min(mReportIntervalBitSize, 63U)) - 1; periodMs = std::min(periodMs, maxPeriodMs); |