Merge "DispSync: don't compensate for wakeup latency" into klp-dev
diff --git a/include/gui/ISensorEventConnection.h b/include/gui/ISensorEventConnection.h
index 00eecc4..f64c6b8 100644
--- a/include/gui/ISensorEventConnection.h
+++ b/include/gui/ISensorEventConnection.h
@@ -39,7 +39,7 @@
virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
nsecs_t maxBatchReportLatencyNs, int reservedFlags) = 0;
virtual status_t setEventRate(int handle, nsecs_t ns) = 0;
- virtual status_t flushSensor(int handle) = 0;
+ virtual status_t flush() = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/SensorEventQueue.h b/include/gui/SensorEventQueue.h
index a3a9daa..0bfc7a0 100644
--- a/include/gui/SensorEventQueue.h
+++ b/include/gui/SensorEventQueue.h
@@ -74,7 +74,7 @@
status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs,
int reservedFlags) const;
status_t disableSensor(int32_t handle) const;
- status_t flushSensor(int32_t handle) const;
+ status_t flush() const;
private:
sp<Looper> getLooper() const;
diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/gui/ISensorEventConnection.cpp
index a80c661..28fcb53 100644
--- a/libs/gui/ISensorEventConnection.cpp
+++ b/libs/gui/ISensorEventConnection.cpp
@@ -77,10 +77,9 @@
return reply.readInt32();
}
- virtual status_t flushSensor(int handle) {
+ virtual status_t flush() {
Parcel data, reply;
data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
- data.writeInt32(handle);
remote()->transact(FLUSH_SENSOR, data, &reply);
return reply.readInt32();
}
@@ -122,8 +121,7 @@
} break;
case FLUSH_SENSOR: {
CHECK_INTERFACE(ISensorEventConnection, data, reply);
- int handle = data.readInt32();
- status_t result = flushSensor(handle);
+ status_t result = flush();
reply->writeInt32(result);
return NO_ERROR;
} break;
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index ab50c1d..c365671 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -132,8 +132,8 @@
us2ns(maxBatchReportLatencyUs), reservedFlags);
}
-status_t SensorEventQueue::flushSensor(int32_t handle) const {
- return mSensorEventConnection->flushSensor(handle);
+status_t SensorEventQueue::flush() const {
+ return mSensorEventConnection->flush();
}
status_t SensorEventQueue::disableSensor(int32_t handle) const {
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index d6507f4..9bd7fc6 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -376,13 +376,13 @@
bool InputConsumer::isTouchResamplingEnabled() {
char value[PROPERTY_VALUE_MAX];
- int length = property_get("debug.inputconsumer.resample", value, NULL);
+ int length = property_get("ro.input.noresample", value, NULL);
if (length > 0) {
- if (!strcmp("0", value)) {
+ if (!strcmp("1", value)) {
return false;
}
- if (strcmp("1", value)) {
- ALOGD("Unrecognized property value for 'debug.inputconsumer.resample'. "
+ if (strcmp("0", value)) {
+ ALOGD("Unrecognized property value for 'ro.input.noresample'. "
"Use '1' or '0'.");
}
}
@@ -511,7 +511,7 @@
status_t result;
for (size_t i = mBatches.size(); i-- > 0; ) {
Batch& batch = mBatches.editItemAt(i);
- if (frameTime < 0) {
+ if (frameTime < 0 || !mResampleTouch) {
result = consumeSamples(factory, batch, batch.samples.size(),
outSeq, outEvent);
mBatches.removeAt(i);
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index b26e572..af605de 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -679,8 +679,12 @@
int handle) {
if (mInitCheck != NO_ERROR) return mInitCheck;
SensorInterface* sensor = mSensorMap.valueFor(handle);
- if (sensor == NULL) {
- return BAD_VALUE;
+ if (sensor == NULL) {
+ return BAD_VALUE;
+ }
+ if (sensor->getSensor().getType() == SENSOR_TYPE_SIGNIFICANT_MOTION) {
+ ALOGE("flush called on Significant Motion sensor");
+ return INVALID_OPERATION;
}
SensorDevice& dev(SensorDevice::getInstance());
@@ -934,8 +938,18 @@
return mService->setEventRate(this, handle, samplingPeriodNs);
}
-status_t SensorService::SensorEventConnection::flushSensor(int handle) {
- return mService->flushSensor(this, handle);
+status_t SensorService::SensorEventConnection::flush() {
+ Mutex::Autolock _l(mConnectionLock);
+ status_t err(NO_ERROR);
+ for (size_t i = 0; i < mSensorInfo.size(); ++i) {
+ const int handle = mSensorInfo.keyAt(i);
+ status_t err_flush = mService->flushSensor(this, handle);
+ if (err_flush != NO_ERROR) {
+ ALOGE("Flush error handle=%d %s", handle, strerror(-err_flush));
+ }
+ err = (err_flush != NO_ERROR) ? err_flush : err;
+ }
+ return err;
}
// ---------------------------------------------------------------------------
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index 2311bff..2d40071 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -79,7 +79,7 @@
virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
nsecs_t maxBatchReportLatencyNs, int reservedFlags);
virtual status_t setEventRate(int handle, nsecs_t samplingPeriodNs);
- virtual status_t flushSensor(int handle);
+ virtual status_t flush();
// Count the number of flush complete events which are about to be dropped in the buffer.
// Increment mPendingFlushEventsToSend in mSensorInfo. These flush complete events will be
// sent separately before the next batch of events.
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index bff304e..167c6f0 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -397,6 +397,7 @@
Mutex::Autolock lock(mMutex);
mPeriod = period;
mPhase = 0;
+ mThread->updateModel(mPeriod, mPhase);
}
void DispSync::updateModelLocked() {
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
index 1cd8cb3..521a5d2 100644
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
@@ -46,7 +46,7 @@
}
} pack565;
- const uint16_t protTexData[] = { pack565(0x03, 0x03, 0x03) };
+ const uint16_t protTexData[] = { 0 };
glGenTextures(1, &mProtectedTexName);
glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
index 7112ca8..a2a6270 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
@@ -50,7 +50,7 @@
}
} pack565;
- const uint16_t protTexData[] = { pack565(0x03, 0x03, 0x03) };
+ const uint16_t protTexData[] = { 0 };
glGenTextures(1, &mProtectedTexName);
glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3733ede..4a1373e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2982,6 +2982,27 @@
renderScreenImplLocked(hw, reqWidth, reqHeight,
minLayerZ, maxLayerZ, true);
+ // Create a sync point and wait on it, so we know the buffer is
+ // ready before we pass it along. We can't trivially call glFlush(),
+ // so we use a wait flag instead.
+ // TODO: pass a sync fd to queueBuffer() and let the consumer wait.
+ EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, NULL);
+ if (sync != EGL_NO_SYNC_KHR) {
+ EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync,
+ EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 2000000000 /*2 sec*/);
+ EGLint eglErr = eglGetError();
+ eglDestroySyncKHR(mEGLDisplay, sync);
+ if (result == EGL_TIMEOUT_EXPIRED_KHR) {
+ ALOGW("captureScreen: fence wait timed out");
+ } else {
+ ALOGW_IF(eglErr != EGL_SUCCESS,
+ "captureScreen: error waiting on EGL fence: %#x", eglErr);
+ }
+ } else {
+ ALOGW("captureScreen: error creating EGL fence: %#x", eglGetError());
+ // not fatal
+ }
+
if (DEBUG_SCREENSHOTS) {
uint32_t* pixels = new uint32_t[reqWidth*reqHeight];
getRenderEngine().readPixels(0, 0, reqWidth, reqHeight, pixels);