diff options
author | Iliyan Malchev <malchev@google.com> | 2017-04-12 23:21:35 -0700 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2017-04-12 23:21:35 -0700 |
commit | ecb97cfc3c565760fa32b4bec79f822a06798972 (patch) | |
tree | fa43a8e136a7cf9d55a3aebcab82d0f46b67b75f | |
parent | e6076e6104fc13ac559b5fd914ba2b82e4ca27a7 (diff) | |
download | contexthub-ecb97cfc3c565760fa32b4bec79f822a06798972.tar.gz |
hubconnection: revert ot old behavior for legacy devices
The old behavior needs to be maintained for non-Treble devices.
b/30105910 Unexplained 2-4ms MTP VR latency on Sailfish and Marlin
Test: angler, marlin
Change-Id: I7a5468ec9a95586ef2c55652526f643f63fad3e8
Signed-off-by: Iliyan Malchev <malchev@google.com>
-rw-r--r-- | sensorhal/Android.mk | 3 | ||||
-rw-r--r-- | sensorhal/hubconnection.cpp | 15 | ||||
-rw-r--r-- | sensorhal/hubconnection.h | 4 |
3 files changed, 22 insertions, 0 deletions
diff --git a/sensorhal/Android.mk b/sensorhal/Android.mk index e410ed19..1f35410d 100644 --- a/sensorhal/Android.mk +++ b/sensorhal/Android.mk @@ -128,6 +128,9 @@ LOCAL_MODULE_OWNER := google LOCAL_PROPRIETARY_MODULE := true LOCAL_CFLAGS += $(COMMON_CFLAGS) +ifeq ($(PRODUCT_FULL_TREBLE),true) +LOCAL_CFLAGS += -DUSE_SENSORSERVICE_TO_GET_FIFO +endif ifeq ($(NANOHUB_SENSORHAL_LID_STATE_ENABLED), true) LOCAL_CFLAGS += -DLID_STATE_REPORTING_ENABLED diff --git a/sensorhal/hubconnection.cpp b/sensorhal/hubconnection.cpp index 0db52c03..ec10a0ab 100644 --- a/sensorhal/hubconnection.cpp +++ b/sensorhal/hubconnection.cpp @@ -85,9 +85,11 @@ static const uint32_t delta_time_shift_table[2] = {9, 0}; // flip this system property on to use newly defined data structure for sending sensor configuration const char USE_NEW_CFG_PROPERTY[] = "sensor.hubconnection.new_cfg"; +#ifdef USE_SENSORSERVICE_TO_GET_FIFO // TODO(b/35219747): retain sched_fifo before eval is done to avoid // performance regression. const char SCHED_FIFO_PRIOIRTY[] = "sensor.hubconnection.sched_fifo"; +#endif namespace android { @@ -270,14 +272,19 @@ HubConnection::~HubConnection() void HubConnection::onFirstRef() { run("HubConnection", PRIORITY_URGENT_DISPLAY); +#ifdef USE_SENSORSERVICE_TO_GET_FIFO if (property_get_bool(SCHED_FIFO_PRIOIRTY, true)) { ALOGI("Try activate sched-fifo priority for HubConnection thread"); mEnableSchedFifoThread = std::thread(enableSchedFifoMode, this); } +#else + enableSchedFifoMode(this); +#endif } // Set main thread to SCHED_FIFO to lower sensor event latency when system is under load void HubConnection::enableSchedFifoMode(sp<HubConnection> hub) { +#ifdef USE_SENSORSERVICE_TO_GET_FIFO using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService; using ::android::hardware::Return; @@ -300,6 +307,14 @@ void HubConnection::enableSchedFifoMode(sp<HubConnection> hub) { ALOGI("Enabled sched fifo thread mode (prio %d)", static_cast<int32_t>(max)); } } +#else +#define HUBCONNECTION_SCHED_FIFO_PRIORITY 10 + struct sched_param param = {0}; + param.sched_priority = HUBCONNECTION_SCHED_FIFO_PRIORITY; + if (sched_setscheduler(hub->getTid(), SCHED_FIFO | SCHED_RESET_ON_FORK, ¶m) != 0) { + ALOGE("Couldn't set SCHED_FIFO for HubConnection thread"); + } +#endif } status_t HubConnection::initCheck() const diff --git a/sensorhal/hubconnection.h b/sensorhal/hubconnection.h index 8e6bda66..ce358775 100644 --- a/sensorhal/hubconnection.h +++ b/sensorhal/hubconnection.h @@ -34,7 +34,9 @@ #include "hubdefs.h" #include "ring.h" +#ifdef USE_SENSORSERVICE_TO_GET_FIFO #include <thread> +#endif #include <unordered_map> #define WAKELOCK_NAME "sensorHal" @@ -266,8 +268,10 @@ private: void restoreSensorState(); void sendCalibrationOffsets(); +#ifdef USE_SENSORSERVICE_TO_GET_FIFO // Enable SCHED_FIFO priority for main thread std::thread mEnableSchedFifoThread; +#endif static void enableSchedFifoMode(sp<HubConnection> hub); #ifdef LID_STATE_REPORTING_ENABLED |