summaryrefslogtreecommitdiffstats
path: root/libs/gui
diff options
context:
space:
mode:
authorAravind Akella <aakella@google.com>2013-09-03 17:43:44 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-03 17:43:44 -0700
commite29df8b929128621c8ef90091696d414eb235276 (patch)
tree68f1c419ed477b97c7b07ff9b7de8cd9f0bfaf07 /libs/gui
parent4de85b49b3c1ae6c27351a0e6fd8d6490fe4f0cc (diff)
parenta5552de96f0cff9fb1947d8d21556bfeccf9cd03 (diff)
downloadframeworks_native-e29df8b929128621c8ef90091696d414eb235276.zip
frameworks_native-e29df8b929128621c8ef90091696d414eb235276.tar.gz
frameworks_native-e29df8b929128621c8ef90091696d414eb235276.tar.bz2
am a5552de9: Merge "Sensor batching. Changes to the native code." into klp-dev
* commit 'a5552de96f0cff9fb1947d8d21556bfeccf9cd03': Sensor batching. Changes to the native code.
Diffstat (limited to 'libs/gui')
-rw-r--r--libs/gui/ISensorEventConnection.cpp30
-rw-r--r--libs/gui/Sensor.cpp29
-rw-r--r--libs/gui/SensorEventQueue.cpp20
3 files changed, 63 insertions, 16 deletions
diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/gui/ISensorEventConnection.cpp
index 0e51e8e..a80c661 100644
--- a/libs/gui/ISensorEventConnection.cpp
+++ b/libs/gui/ISensorEventConnection.cpp
@@ -33,7 +33,8 @@ namespace android {
enum {
GET_SENSOR_CHANNEL = IBinder::FIRST_CALL_TRANSACTION,
ENABLE_DISABLE,
- SET_EVENT_RATE
+ SET_EVENT_RATE,
+ FLUSH_SENSOR
};
class BpSensorEventConnection : public BpInterface<ISensorEventConnection>
@@ -52,12 +53,16 @@ public:
return new BitTube(reply);
}
- virtual status_t enableDisable(int handle, bool enabled)
+ virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
+ nsecs_t maxBatchReportLatencyNs, int reservedFlags)
{
Parcel data, reply;
data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
data.writeInt32(handle);
data.writeInt32(enabled);
+ data.writeInt64(samplingPeriodNs);
+ data.writeInt64(maxBatchReportLatencyNs);
+ data.writeInt32(reservedFlags);
remote()->transact(ENABLE_DISABLE, data, &reply);
return reply.readInt32();
}
@@ -71,6 +76,14 @@ public:
remote()->transact(SET_EVENT_RATE, data, &reply);
return reply.readInt32();
}
+
+ virtual status_t flushSensor(int handle) {
+ Parcel data, reply;
+ data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
+ data.writeInt32(handle);
+ remote()->transact(FLUSH_SENSOR, data, &reply);
+ return reply.readInt32();
+ }
};
IMPLEMENT_META_INTERFACE(SensorEventConnection, "android.gui.SensorEventConnection");
@@ -91,7 +104,11 @@ status_t BnSensorEventConnection::onTransact(
CHECK_INTERFACE(ISensorEventConnection, data, reply);
int handle = data.readInt32();
int enabled = data.readInt32();
- status_t result = enableDisable(handle, enabled);
+ nsecs_t samplingPeriodNs = data.readInt64();
+ nsecs_t maxBatchReportLatencyNs = data.readInt64();
+ int reservedFlags = data.readInt32();
+ status_t result = enableDisable(handle, enabled, samplingPeriodNs,
+ maxBatchReportLatencyNs, reservedFlags);
reply->writeInt32(result);
return NO_ERROR;
} break;
@@ -103,6 +120,13 @@ status_t BnSensorEventConnection::onTransact(
reply->writeInt32(result);
return NO_ERROR;
} break;
+ case FLUSH_SENSOR: {
+ CHECK_INTERFACE(ISensorEventConnection, data, reply);
+ int handle = data.readInt32();
+ status_t result = flushSensor(handle);
+ reply->writeInt32(result);
+ return NO_ERROR;
+ } break;
}
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/gui/Sensor.cpp b/libs/gui/Sensor.cpp
index d84c370..da6b0f9 100644
--- a/libs/gui/Sensor.cpp
+++ b/libs/gui/Sensor.cpp
@@ -32,11 +32,11 @@ namespace android {
Sensor::Sensor()
: mHandle(0), mType(0),
mMinValue(0), mMaxValue(0), mResolution(0),
- mPower(0), mMinDelay(0)
+ mPower(0), mMinDelay(0), mFifoReservedEventCount(0), mFifoMaxEventCount(0)
{
}
-Sensor::Sensor(struct sensor_t const* hwSensor)
+Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
{
mName = hwSensor->name;
mVendor = hwSensor->vendor;
@@ -48,6 +48,15 @@ Sensor::Sensor(struct sensor_t const* hwSensor)
mResolution = hwSensor->resolution;
mPower = hwSensor->power;
mMinDelay = hwSensor->minDelay;
+ // Set fifo event count zero for older devices which do not support batching. Fused
+ // sensors also have their fifo counts set to zero.
+ if (halVersion >= SENSORS_DEVICE_API_VERSION_1_1) {
+ mFifoReservedEventCount = hwSensor->fifoReservedEventCount;
+ mFifoMaxEventCount = hwSensor->fifoMaxEventCount;
+ } else {
+ mFifoReservedEventCount = 0;
+ mFifoMaxEventCount = 0;
+ }
}
Sensor::~Sensor()
@@ -98,12 +107,20 @@ int32_t Sensor::getVersion() const {
return mVersion;
}
+int32_t Sensor::getFifoReservedEventCount() const {
+ return mFifoReservedEventCount;
+}
+
+int32_t Sensor::getFifoMaxEventCount() const {
+ return mFifoMaxEventCount;
+}
+
size_t Sensor::getFlattenedSize() const
{
size_t fixedSize =
sizeof(int32_t) * 3 +
sizeof(float) * 4 +
- sizeof(int32_t);
+ sizeof(int32_t) * 3;
size_t variableSize =
sizeof(int32_t) + FlattenableUtils::align<4>(mName.length()) +
@@ -133,6 +150,8 @@ status_t Sensor::flatten(void* buffer, size_t size) const {
FlattenableUtils::write(buffer, size, mResolution);
FlattenableUtils::write(buffer, size, mPower);
FlattenableUtils::write(buffer, size, mMinDelay);
+ FlattenableUtils::write(buffer, size, mFifoReservedEventCount);
+ FlattenableUtils::write(buffer, size, mFifoMaxEventCount);
return NO_ERROR;
}
@@ -163,7 +182,7 @@ status_t Sensor::unflatten(void const* buffer, size_t size) {
size_t fixedSize =
sizeof(int32_t) * 3 +
sizeof(float) * 4 +
- sizeof(int32_t);
+ sizeof(int32_t) * 3;
if (size < fixedSize) {
return NO_MEMORY;
@@ -177,6 +196,8 @@ status_t Sensor::unflatten(void const* buffer, size_t size) {
FlattenableUtils::read(buffer, size, mResolution);
FlattenableUtils::read(buffer, size, mPower);
FlattenableUtils::read(buffer, size, mMinDelay);
+ FlattenableUtils::read(buffer, size, mFifoReservedEventCount);
+ FlattenableUtils::read(buffer, size, mFifoMaxEventCount);
return NO_ERROR;
}
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index 8a1bf41..08b8ac8 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -107,23 +107,25 @@ status_t SensorEventQueue::wake() const
}
status_t SensorEventQueue::enableSensor(Sensor const* sensor) const {
- return mSensorEventConnection->enableDisable(sensor->getHandle(), true);
+ return mSensorEventConnection->enableDisable(sensor->getHandle(), true, 0, 0, false);
}
status_t SensorEventQueue::disableSensor(Sensor const* sensor) const {
- return mSensorEventConnection->enableDisable(sensor->getHandle(), false);
+ return mSensorEventConnection->enableDisable(sensor->getHandle(), false, 0, 0, false);
}
-status_t SensorEventQueue::enableSensor(int32_t handle, int32_t us) const {
- status_t err = mSensorEventConnection->enableDisable(handle, true);
- if (err == NO_ERROR) {
- mSensorEventConnection->setEventRate(handle, us2ns(us));
- }
- return err;
+status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs,
+ int maxBatchReportLatencyUs, int reservedFlags) const {
+ return mSensorEventConnection->enableDisable(handle, true, us2ns(samplingPeriodUs),
+ us2ns(maxBatchReportLatencyUs), reservedFlags);
+}
+
+status_t SensorEventQueue::flushSensor(int32_t handle) const {
+ return mSensorEventConnection->flushSensor(handle);
}
status_t SensorEventQueue::disableSensor(int32_t handle) const {
- return mSensorEventConnection->enableDisable(handle, false);
+ return mSensorEventConnection->enableDisable(handle, false, 0, 0, false);
}
status_t SensorEventQueue::setEventRate(Sensor const* sensor, nsecs_t ns) const {