libcamera: framebuffer: Add assertion to detect offset is unfilled

The offset variable is introduced to FrameBuffer::Plane. In order to
detect that the plane is used while the offset is not set, this adds
the assertion to FrameBuffer::planes(). It should be removed in the
future.

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-26 20:25:39 +09:00 committed by Laurent Pinchart
parent dde91916f1
commit 887dbdb439
2 changed files with 16 additions and 2 deletions

View file

@ -7,6 +7,8 @@
#ifndef __LIBCAMERA_FRAMEBUFFER_H__ #ifndef __LIBCAMERA_FRAMEBUFFER_H__
#define __LIBCAMERA_FRAMEBUFFER_H__ #define __LIBCAMERA_FRAMEBUFFER_H__
#include <assert.h>
#include <limits>
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>
@ -41,14 +43,21 @@ class FrameBuffer final : public Extensible
public: public:
struct Plane { struct Plane {
static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();
FileDescriptor fd; FileDescriptor fd;
unsigned int offset; unsigned int offset = kInvalidOffset;
unsigned int length; unsigned int length;
}; };
FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0); FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
const std::vector<Plane> &planes() const { return planes_; } const std::vector<Plane> &planes() const
{
/* \todo Remove the assertions after sufficient testing */
for (const auto &plane : planes_)
assert(plane.offset != Plane::kInvalidOffset);
return planes_;
}
Request *request() const; Request *request() const;
const FrameMetadata &metadata() const { return metadata_; } const FrameMetadata &metadata() const { return metadata_; }

View file

@ -170,6 +170,11 @@ FrameBuffer::Private::Private()
* multiple dmabufs, based on the camera requirements. * multiple dmabufs, based on the camera requirements.
*/ */
/**
* \var FrameBuffer::Plane::kInvalidOffset
* \brief Invalid offset value, to identify uninitialized planes
*/
/** /**
* \var FrameBuffer::Plane::fd * \var FrameBuffer::Plane::fd
* \brief The dmabuf file descriptor * \brief The dmabuf file descriptor