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
diff --git a/libs/vr/libvrflinger/hardware_composer.h b/libs/vr/libvrflinger/hardware_composer.h
index 8ba72ab..c182bf9 100644
--- a/libs/vr/libvrflinger/hardware_composer.h
+++ b/libs/vr/libvrflinger/hardware_composer.h
@@ -16,6 +16,7 @@
#include <tuple>
#include <vector>
+#include <dvr/dvr_vrflinger_config_buffer.h>
#include <dvr/pose_client.h>
#include <pdx/file_handle.h>
#include <pdx/rpc/variant.h>
@@ -284,6 +285,9 @@
void SetDisplaySurfaces(
std::vector<std::shared_ptr<DirectDisplaySurface>> surfaces);
+ int OnNewGlobalBuffer(DvrGlobalBufferKey key, IonBuffer& ion_buffer);
+ void OnDeletedGlobalBuffer(DvrGlobalBufferKey key);
+
void OnHardwareComposerRefresh();
private:
@@ -365,6 +369,13 @@
// Called on the post thread when the post thread is paused or quits.
void OnPostThreadPaused();
+ // Map the given shared memory buffer to our broadcast ring to track updates
+ // to the config parameters.
+ int MapConfigBuffer(IonBuffer& ion_buffer);
+ void ConfigBufferDeleted();
+ // Poll for config udpates.
+ void UpdateConfigBuffer();
+
bool initialized_;
// Hardware composer HAL device from SurfaceFlinger. VrFlinger does not own
@@ -439,6 +450,13 @@
// out to display frame boundaries, so we need to tell it about vsyncs.
DvrPose* pose_client_ = nullptr;
+ // Broadcast ring for receiving config data from the DisplayManager.
+ DvrVrFlingerConfigRing shared_config_ring_;
+ uint32_t shared_config_ring_sequence_{0};
+ // Config buffer for reading from the post thread.
+ DvrVrFlingerConfigBuffer post_thread_config_;
+ std::mutex shared_config_mutex_;
+
static constexpr int kPostThreadInterrupted = 1;
static void HwcRefresh(hwc2_callback_data_t data, hwc2_display_t display);