From 7944b2a7f835490de2bcde60de011feaad30e333 Mon Sep 17 00:00:00 2001 From: Luke Song Date: Mon, 15 May 2017 14:17:42 -0700 Subject: [PATCH] Sensor enable/disable added to dvr api In order to manage power usage when system isn't being used. Bug: None Test: None Change-Id: I64f9c3064cc75c1522fef0adef9a5fc156f336b0 --- libs/vr/libvrsensor/include/dvr/pose_client.h | 12 +++++++++--- libs/vr/libvrsensor/include/private/dvr/pose-ipc.h | 1 + libs/vr/libvrsensor/pose_client.cpp | 20 +++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libs/vr/libvrsensor/include/dvr/pose_client.h b/libs/vr/libvrsensor/include/dvr/pose_client.h index 43a8e74246..d684ddcc57 100644 --- a/libs/vr/libvrsensor/include/dvr/pose_client.h +++ b/libs/vr/libvrsensor/include/dvr/pose_client.h @@ -119,7 +119,7 @@ int dvrPoseClientPoll(DvrPoseClient* client, DvrPose* state); // Freezes the pose to the provided state. // // Future poll operations will return this state until a different state is -// frozen or dvrPoseSetMode() is called with a different mode. The timestamp is +// frozen or dvrPoseClientModeSet() is called with a different mode. The timestamp is // not frozen. // // @param client Pointer to the pose client. @@ -131,13 +131,13 @@ int dvrPoseClientFreeze(DvrPoseClient* client, const DvrPose* frozen_state); // // @param mode The requested pose mode. // @return Zero on success, negative error code on failure. -int dvrPoseClientSetMode(DvrPoseClient* client, DvrPoseMode mode); +int dvrPoseClientModeSet(DvrPoseClient* client, DvrPoseMode mode); // Gets the pose service mode. // // @param mode Return value for the current pose mode. // @return Zero on success, negative error code on failure. -int dvrPoseClientGetMode(DvrPoseClient* client, DvrPoseMode* mode); +int dvrPoseClientModeGet(DvrPoseClient* client, DvrPoseMode* mode); // Get access to the shared memory pose ring buffer. // A future pose at vsync + is accessed at index: @@ -151,6 +151,12 @@ int dvrPoseClientGetMode(DvrPoseClient* client, DvrPoseMode* mode); int dvrPoseClientGetRingBuffer(DvrPoseClient* client, DvrPoseRingBufferInfo* out_info); +// Sets enabled state for sensors pose processing. +// +// @param enabled Whether sensors are enabled or disabled. +// @return Zero on success +int dvrPoseClientSensorsEnable(DvrPoseClient* client, bool enabled); + #ifdef __cplusplus } // extern "C" #endif diff --git a/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h b/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h index 9603f1b40f..e4455f1840 100644 --- a/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h +++ b/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h @@ -16,6 +16,7 @@ enum { DVR_POSE_GET_MODE, DVR_POSE_GET_CONTROLLER_RING_BUFFER, DVR_POSE_LOG_CONTROLLER, + DVR_POSE_SENSORS_ENABLE, }; #ifdef __cplusplus diff --git a/libs/vr/libvrsensor/pose_client.cpp b/libs/vr/libvrsensor/pose_client.cpp index 21665972dc..b21c7cf572 100644 --- a/libs/vr/libvrsensor/pose_client.cpp +++ b/libs/vr/libvrsensor/pose_client.cpp @@ -130,6 +130,16 @@ class PoseClient : public pdx::ClientBase { return ReturnStatusOrError(status); } + // Enables or disables all pose processing from sensors + int EnableSensors(bool enabled) { + Transaction trans{*this}; + Status status = trans.Send(DVR_POSE_SENSORS_ENABLE, &enabled, + sizeof(enabled), nullptr, 0); + ALOGE_IF(!status, "Pose EnableSensors() failed because: %s\n", + status.GetErrorMessage().c_str()); + return ReturnStatusOrError(status); + } + int GetRingBuffer(DvrPoseRingBufferInfo* out_info) { // First time mapping the buffer? const auto vsync_buffer = GetVsyncBuffer(); @@ -277,17 +287,17 @@ int dvrPoseClientFreeze(DvrPoseClient* client, const DvrPose* frozen_state) { return PoseClient::FromC(client)->Freeze(*frozen_state); } -int dvrPoseClientSetMode(DvrPoseClient* client, DvrPoseMode mode) { +int dvrPoseClientModeSet(DvrPoseClient* client, DvrPoseMode mode) { return PoseClient::FromC(client)->SetMode(mode); } -int dvrPoseClientGetMode(DvrPoseClient* client, DvrPoseMode* mode) { +int dvrPoseClientModeGet(DvrPoseClient* client, DvrPoseMode* mode) { return PoseClient::FromC(client)->GetMode(mode); } -int dvrPoseClientGetRingBuffer(DvrPoseClient* client, - DvrPoseRingBufferInfo* out_info) { - return PoseClient::FromC(client)->GetRingBuffer(out_info); + +int dvrPoseClientSensorsEnable(DvrPoseClient* client, bool enabled) { + return PoseClient::FromC(client)->EnableSensors(enabled); } } // extern "C" -- 2.11.0