libcamera: framebuffer: Add offset to FrameBuffer::Plane

This adds offset to FrameBuffer::Plane. It enables representing frame
buffers that store planes in the same dmabuf at different offsets, as
for instance required by the V4L2 NV12 pixel format.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Hirokazu Honda
2021-08-30 18:08:02 +03:00
committed by Laurent Pinchart
parent a000a1f6e3
commit 86a47fdcd9
3 changed files with 22 additions and 8 deletions
+4 -1
View File
@@ -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, 4, dataEnd);
ret.length = readPOD<uint32_t>(dataBegin, 8, dataEnd);
return ret;
}