[libcamera-devel] [PATCH 3/6] libcamera: control_serializer: Keep handles in sync

Jacopo Mondi jacopo at jmondi.org
Wed Sep 1 16:37:57 CEST 2021


When running the IPA in isolated mode, each side of the IPC boundary
has an instance of the ControlSerializer class.

Each serializer instance tags with a numerical id (handle) each
ControlInfoMap instance it serializes, to be capable of associating
ControlList with it at serialization and deserialization time, and
increments the numerical counter for each newly serialized control info
map.

Having two instances of the ControlSerializer class running in two
different process spaces, each instance increments its own counter,
preventing from maintaining a globally shared state where each
ControlInfoMap instance is reference by a unique identifier.

Fix this by advancing the serial_ counter at ControlInfoMap
de-serialization time, so that each newly serialized map will have a
globally unique identifier.

Fixes: 2c5f0ad23aa4 ("libcamera: Add controls serializer")
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 src/libcamera/control_serializer.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp
index 27360526f9eb..08cfecca3078 100644
--- a/src/libcamera/control_serializer.cpp
+++ b/src/libcamera/control_serializer.cpp
@@ -380,6 +380,9 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &
 		return {};
 	}
 
+	/* Keep the info map handles in sync between the two sides of IPC. */
+	serial_ = std::max(serial_, hdr->handle);
+
 	/*
 	 * Use the ControlIdMap corresponding to the id map type. If the type
 	 * references a globally defined id map (such as controls::controls
-- 
2.32.0



More information about the libcamera-devel mailing list