diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-09-21 22:07:21 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-09-21 22:07:21 +0000 |
commit | 340aebbd3cf63367f23dc6299d5a9ed352d324c5 (patch) | |
tree | 041e9e6dfdc6892044c81e6ead5f247cbb017e1e | |
parent | 2d4e83cc42e4d0ce36c172878adeb415d799b218 (diff) | |
parent | d8625365ec20038cb8fd0fc093b88dd461529d98 (diff) | |
download | libhardware-340aebbd3cf63367f23dc6299d5a9ed352d324c5.tar.gz |
Snap for 10843824 from d8625365ec20038cb8fd0fc093b88dd461529d98 to 24Q1-release
Change-Id: I104ca18341c1af644befd703711ee870aa2ed3c3
-rw-r--r-- | modules/gralloc/gr.h | 5 | ||||
-rw-r--r-- | modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp | 12 | ||||
-rw-r--r-- | modules/sensors/dynamic_sensor/HidRawSensorDevice.h | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/modules/gralloc/gr.h b/modules/gralloc/gr.h index 14fe6a05..fe66c9be 100644 --- a/modules/gralloc/gr.h +++ b/modules/gralloc/gr.h @@ -24,6 +24,7 @@ #include <hardware/gralloc.h> #include <pthread.h> #include <errno.h> +#include <unistd.h> #include <cutils/native_handle.h> @@ -32,8 +33,10 @@ struct private_module_t; struct private_handle_t; +static const size_t kPageSize = getpagesize(); + inline size_t roundUpToPageSize(size_t x) { - return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); + return (x + (kPageSize-1)) & ~(kPageSize-1); } int mapFrameBufferLocked(struct private_module_t* module, int format); diff --git a/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp b/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp index 8aa4cf92..5bc4abc2 100644 --- a/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp +++ b/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp @@ -35,6 +35,15 @@ using namespace Hid::Sensor::PropertyUsage; const std::unordered_set<unsigned int> HidRawSensorDevice::sInterested{ ACCELEROMETER_3D, GYROMETER_3D, COMPASS_3D, CUSTOM}; +void HidRawSensorDevice::enableSchedFifoMode() { + constexpr int kHidRawSensorPriority = 10; // Matches with sensor service priority + struct sched_param param = {0}; + param.sched_priority = kHidRawSensorPriority; + if (sched_setscheduler(getTid(), SCHED_FIFO | SCHED_RESET_ON_FORK, ¶m) != 0) { + ALOGE("Couldn't set SCHED_FIFO for HidRawSensor thread: %s", strerror(errno)); + } +} + sp<HidRawSensorDevice> HidRawSensorDevice::create(const std::string &devName) { sp<HidRawSensorDevice> device(new HidRawSensorDevice(devName)); // offset +1 strong count added by constructor @@ -74,7 +83,8 @@ HidRawSensorDevice::HidRawSensorDevice(const std::string &devName) return; } - run("HidRawSensor"); + run("HidRawSensor", PRIORITY_URGENT_DISPLAY); + enableSchedFifoMode(); mValid = true; } diff --git a/modules/sensors/dynamic_sensor/HidRawSensorDevice.h b/modules/sensors/dynamic_sensor/HidRawSensorDevice.h index 06d435e7..7818bf16 100644 --- a/modules/sensors/dynamic_sensor/HidRawSensorDevice.h +++ b/modules/sensors/dynamic_sensor/HidRawSensorDevice.h @@ -41,6 +41,7 @@ private: // constructor will result in +1 strong count explicit HidRawSensorDevice(const std::string &devName); + void enableSchedFifoMode(); // implement function of Thread virtual bool threadLoop() override; std::unordered_map<unsigned int/*reportId*/, sp<HidRawSensor>> mSensors; |