[libcamera-devel,RFC,v2,02/10] libcamera: ipa_data_serializer: Modify (de)serialization for offset
diff mbox series

Message ID 20210823131221.1034059-3-hiroh@chromium.org
State Superseded
Headers show
Series
  • Add offset to FrameBuffer::Plane
Related show

Commit Message

Hirokazu Honda Aug. 23, 2021, 1:12 p.m. UTC
The offset variable is added to FrameBuffer::Plane. This modifies
the serialization and deserialization code for the offset variable.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
---
 src/libcamera/ipa_data_serializer.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 23, 2021, 10:15 p.m. UTC | #1
Hi Hiro,

Thank you for the patch.

On Mon, Aug 23, 2021 at 10:12:13PM +0900, Hirokazu Honda wrote:
> The offset variable is added to FrameBuffer::Plane. This modifies
> the serialization and deserialization code for the offset variable.
> 
> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
> ---
>  src/libcamera/ipa_data_serializer.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp
> index 5b183c70..8d1ae4d2 100644
> --- a/src/libcamera/ipa_data_serializer.cpp
> +++ b/src/libcamera/ipa_data_serializer.cpp
> @@ -569,6 +569,7 @@ FileDescriptor IPADataSerializer<FileDescriptor>::deserialize(const std::vector<
>   * FrameBuffer::Plane is serialized as:
>   *
>   * 4 byte  - FileDescriptor
> + * 4 bytes - uint32_t Offset
>   * 4 bytes - uint32_t Length
>   */
>  template<>
> @@ -586,6 +587,7 @@ IPADataSerializer<FrameBuffer::Plane>::serialize(const FrameBuffer::Plane &data,
>  	dataVec.insert(dataVec.end(), fdBuf.begin(), fdBuf.end());
>  	fdsVec.insert(fdsVec.end(), fdFds.begin(), fdFds.end());
>  
> +	appendPOD<uint32_t>(dataVec, data.offset);
>  	appendPOD<uint32_t>(dataVec, data.length);
>  
>  	return { dataVec, fdsVec };
> @@ -603,7 +605,8 @@ IPADataSerializer<FrameBuffer::Plane>::deserialize(std::vector<uint8_t>::const_i
>  
>  	ret.fd = IPADataSerializer<FileDescriptor>::deserialize(dataBegin, dataBegin + 4,
>  								fdsBegin, fdsBegin + 1);
> -	ret.length = readPOD<uint32_t>(dataBegin, 4, dataEnd);
> +	ret.offset = readPOD<uint32_t>(dataBegin, 1, dataEnd);
> +	ret.length = readPOD<uint32_t>(dataBegin, 5, dataEnd);

This should be

	ret.offset = readPOD<uint32_t>(dataBegin, 4, dataEnd);
	ret.length = readPOD<uint32_t>(dataBegin, 8, dataEnd);

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  
>  	return ret;
>  }
Paul Elder Aug. 25, 2021, 2:22 a.m. UTC | #2
Hi Hiro,

On Tue, Aug 24, 2021 at 01:15:14AM +0300, Laurent Pinchart wrote:
> Hi Hiro,
> 
> Thank you for the patch.
> 
> On Mon, Aug 23, 2021 at 10:12:13PM +0900, Hirokazu Honda wrote:
> > The offset variable is added to FrameBuffer::Plane. This modifies
> > the serialization and deserialization code for the offset variable.
> > 
> > Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
> > ---
> >  src/libcamera/ipa_data_serializer.cpp | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp
> > index 5b183c70..8d1ae4d2 100644
> > --- a/src/libcamera/ipa_data_serializer.cpp
> > +++ b/src/libcamera/ipa_data_serializer.cpp
> > @@ -569,6 +569,7 @@ FileDescriptor IPADataSerializer<FileDescriptor>::deserialize(const std::vector<
> >   * FrameBuffer::Plane is serialized as:
> >   *
> >   * 4 byte  - FileDescriptor
> > + * 4 bytes - uint32_t Offset
> >   * 4 bytes - uint32_t Length
> >   */
> >  template<>
> > @@ -586,6 +587,7 @@ IPADataSerializer<FrameBuffer::Plane>::serialize(const FrameBuffer::Plane &data,
> >  	dataVec.insert(dataVec.end(), fdBuf.begin(), fdBuf.end());
> >  	fdsVec.insert(fdsVec.end(), fdFds.begin(), fdFds.end());
> >  
> > +	appendPOD<uint32_t>(dataVec, data.offset);
> >  	appendPOD<uint32_t>(dataVec, data.length);
> >  
> >  	return { dataVec, fdsVec };
> > @@ -603,7 +605,8 @@ IPADataSerializer<FrameBuffer::Plane>::deserialize(std::vector<uint8_t>::const_i
> >  
> >  	ret.fd = IPADataSerializer<FileDescriptor>::deserialize(dataBegin, dataBegin + 4,
> >  								fdsBegin, fdsBegin + 1);
> > -	ret.length = readPOD<uint32_t>(dataBegin, 4, dataEnd);
> > +	ret.offset = readPOD<uint32_t>(dataBegin, 1, dataEnd);
> > +	ret.length = readPOD<uint32_t>(dataBegin, 5, dataEnd);
> 
> This should be
> 
> 	ret.offset = readPOD<uint32_t>(dataBegin, 4, dataEnd);
> 	ret.length = readPOD<uint32_t>(dataBegin, 8, dataEnd);

Sorry about that, I pushed a change to FileDescriptor's serializer in
between your v1 and v2 :S

Also this needs to be squashed into 1/10, otherwise serialization (and
therefore isolation) will be broken between 1/10 and 2/10.


Paul

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> >  
> >  	return ret;
> >  }

Patch
diff mbox series

diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp
index 5b183c70..8d1ae4d2 100644
--- a/src/libcamera/ipa_data_serializer.cpp
+++ b/src/libcamera/ipa_data_serializer.cpp
@@ -569,6 +569,7 @@  FileDescriptor IPADataSerializer<FileDescriptor>::deserialize(const std::vector<
  * FrameBuffer::Plane is serialized as:
  *
  * 4 byte  - FileDescriptor
+ * 4 bytes - uint32_t Offset
  * 4 bytes - uint32_t Length
  */
 template<>
@@ -586,6 +587,7 @@  IPADataSerializer<FrameBuffer::Plane>::serialize(const FrameBuffer::Plane &data,
 	dataVec.insert(dataVec.end(), fdBuf.begin(), fdBuf.end());
 	fdsVec.insert(fdsVec.end(), fdFds.begin(), fdFds.end());
 
+	appendPOD<uint32_t>(dataVec, data.offset);
 	appendPOD<uint32_t>(dataVec, data.length);
 
 	return { dataVec, fdsVec };
@@ -603,7 +605,8 @@  IPADataSerializer<FrameBuffer::Plane>::deserialize(std::vector<uint8_t>::const_i
 
 	ret.fd = IPADataSerializer<FileDescriptor>::deserialize(dataBegin, dataBegin + 4,
 								fdsBegin, fdsBegin + 1);
-	ret.length = readPOD<uint32_t>(dataBegin, 4, dataEnd);
+	ret.offset = readPOD<uint32_t>(dataBegin, 1, dataEnd);
+	ret.length = readPOD<uint32_t>(dataBegin, 5, dataEnd);
 
 	return ret;
 }