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

Commit 954796e2 authored by John Bates's avatar John Bates
Browse files

Add shmem config buffer to libvrflinger

This allows VrCore to configure some tunable behaviors
of libvrflinger.

- Added dvrDisplayManagerDeleteNamedBuffer for testing config buffer
  creation.
- Added tests for named buffers, including one for the config buffer.
- Added IsValid to broadcast_ring to avoid tracking redundant state
  externally.

Bug: 38193993
Test: Run dvr_named_buffer-test
Change-Id: I52722dd314233b5bea1ca6377c14b5c856825746
parent d5398b92
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -348,6 +348,9 @@ class BroadcastRing {
    return Get(sequence, record);
  }

  // Returns true if this instance has been created or imported.
  bool is_valid() const { return !!data_.mmap; }

  uint32_t record_count() const { return record_count_internal(); }
  uint32_t record_size() const { return record_size_internal(); }
  static constexpr uint32_t mmap_alignment() { return alignof(Mmap); }
+14 −2
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ pdx::Status<std::unique_ptr<IonBuffer>> DisplayManagerClient::SetupGlobalBuffer(
  const int ret = native_buffer_handle.Import(ion_buffer.get());
  if (ret < 0) {
    ALOGE(
        "DisplayClient::GetGlobalBuffer: Failed to import global buffer: "
        "key=%d; error=%s",
        "DisplayManagerClient::GetGlobalBuffer: Failed to import global "
        "buffer: key=%d; error=%s",
        key, strerror(-ret));
    return ErrorStatus(-ret);
  }
@@ -58,6 +58,18 @@ pdx::Status<std::unique_ptr<IonBuffer>> DisplayManagerClient::SetupGlobalBuffer(
  return {std::move(ion_buffer)};
}

pdx::Status<void> DisplayManagerClient::DeleteGlobalBuffer(
    DvrGlobalBufferKey key) {
  auto status =
      InvokeRemoteMethod<DisplayManagerProtocol::DeleteGlobalBuffer>(key);
  if (!status) {
    ALOGE("DisplayManagerClient::DeleteGlobalBuffer Failed: %s",
          status.GetErrorMessage().c_str());
  }

  return status;
}

pdx::Status<std::string> DisplayManagerClient::GetConfigurationData(
    ConfigFileType config_type) {
  auto status =
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ class DisplayManagerClient : public pdx::ClientBase<DisplayManagerClient> {
  pdx::Status<std::vector<SurfaceState>> GetSurfaceState();
  pdx::Status<std::unique_ptr<IonBuffer>> SetupGlobalBuffer(
      DvrGlobalBufferKey key, size_t size, uint64_t usage);
  pdx::Status<void> DeleteGlobalBuffer(DvrGlobalBufferKey key);
  pdx::Status<std::unique_ptr<ConsumerQueue>> GetSurfaceQueue(int surface_id,
                                                              int queue_id);

+3 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ struct DisplayManagerProtocol {
    kOpGetSurfaceQueue,
    kOpSetupGlobalBuffer,
    kOpGetConfigurationData,
    kOpDeleteGlobalBuffer,
  };

  // Aliases.
@@ -251,6 +252,8 @@ struct DisplayManagerProtocol {
                                            uint64_t usage));
  PDX_REMOTE_METHOD(GetConfigurationData, kOpGetConfigurationData,
                    std::string(ConfigFileType config_type));
  PDX_REMOTE_METHOD(DeleteGlobalBuffer, kOpDeleteGlobalBuffer,
                    void(DvrGlobalBufferKey key));
};

struct VSyncSchedInfo {
+17 −0
Original line number Diff line number Diff line
@@ -133,6 +133,23 @@ int dvrDisplayManagerSetupGlobalBuffer(DvrDisplayManager* client,
  return 0;
}

int dvrDisplayManagerDeleteGlobalBuffer(DvrDisplayManager* client,
                                        DvrGlobalBufferKey key) {
  if (!client)
    return -EINVAL;

  auto buffer_status = client->client->DeleteGlobalBuffer(key);
  if (!buffer_status) {
    ALOGE(
        "dvrDisplayManagerDeleteGlobalBuffer: Failed to delete named buffer: "
        "%s",
        buffer_status.GetErrorMessage().c_str());
    return -buffer_status.error();
  }

  return 0;
}

int dvrConfigurationDataGet(DvrDisplayManager* client, int config_type,
                            uint8_t** data, size_t* data_size) {
  if (!client || !data || !data_size) {
Loading