Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7944b2a7 authored by Luke Song's avatar Luke Song
Browse files

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
parent f4fa8fb4
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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 <current> + <offset> 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
+1 −0
Original line number Diff line number Diff line
@@ -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
+15 −5
Original line number Diff line number Diff line
@@ -130,6 +130,16 @@ class PoseClient : public pdx::ClientBase<PoseClient> {
    return ReturnStatusOrError(status);
  }

  // Enables or disables all pose processing from sensors
  int EnableSensors(bool enabled) {
    Transaction trans{*this};
    Status<int> status = trans.Send<int>(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"