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

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Sep 2 16:22:39 CEST 2021


On 01/09/2021 15:37, Jacopo Mondi wrote:
> 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);
> +

Ok, I can see how this works now. Every serialize gets deserialized, and
at that point you know both sides have the same serial_.

So whichever side next calls serialize() will be the one that
increments, and the other side will then update accordingly when it has
it's deser...

Took me a longer time to realise than I liked - but it's actually simple
enough ;-)

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

>  	/*
>  	 * Use the ControlIdMap corresponding to the id map type. If the type
>  	 * references a globally defined id map (such as controls::controls
> 


More information about the libcamera-devel mailing list