libcamera: camera_sensor: getFormat(): Use span
The function takes a const std::vector reference, but it does not actually need an `std::vector`. So use a `libcamera::Span` instead to avoid forcing the caller to construct a vector. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -54,7 +54,7 @@ public:
|
||||
virtual Size resolution() const = 0;
|
||||
|
||||
virtual V4L2SubdeviceFormat
|
||||
getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
getFormat(Span<const unsigned int> mbusCodes,
|
||||
const Size &size, const Size maxSize = Size()) const = 0;
|
||||
virtual int setFormat(V4L2SubdeviceFormat *format,
|
||||
Transform transform = Transform::Identity) = 0;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "rkisp1_path.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <linux/media-bus-format.h>
|
||||
|
||||
#include <libcamera/formats.h>
|
||||
@@ -341,7 +343,7 @@ RkISP1Path::validate(const CameraSensor *sensor,
|
||||
: cfg->size;
|
||||
|
||||
V4L2SubdeviceFormat sensorFormat =
|
||||
sensor->getFormat({ mbusCode }, rawSize);
|
||||
sensor->getFormat(std::array{ mbusCode }, rawSize);
|
||||
|
||||
if (sensorConfig &&
|
||||
sensorConfig->outputSize != sensorFormat.size)
|
||||
@@ -362,7 +364,7 @@ RkISP1Path::validate(const CameraSensor *sensor,
|
||||
|
||||
uint32_t mbusCode = formatToMediaBus.at(rawFormat);
|
||||
V4L2SubdeviceFormat sensorFormat =
|
||||
sensor->getFormat({ mbusCode }, sensorSize);
|
||||
sensor->getFormat(std::array{ mbusCode }, sensorSize);
|
||||
|
||||
if (sensorFormat.size != sensorSize)
|
||||
return CameraConfiguration::Invalid;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
std::vector<Size> sizes(unsigned int mbusCode) const override;
|
||||
Size resolution() const override;
|
||||
|
||||
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
V4L2SubdeviceFormat getFormat(Span<const unsigned int> mbusCodes,
|
||||
const Size &size,
|
||||
const Size maxSize) const override;
|
||||
int setFormat(V4L2SubdeviceFormat *format,
|
||||
@@ -699,7 +699,7 @@ Size CameraSensorLegacy::resolution() const
|
||||
}
|
||||
|
||||
V4L2SubdeviceFormat
|
||||
CameraSensorLegacy::getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
CameraSensorLegacy::getFormat(Span<const unsigned int> mbusCodes,
|
||||
const Size &size, Size maxSize) const
|
||||
{
|
||||
unsigned int desiredArea = size.width * size.height;
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
std::vector<Size> sizes(unsigned int mbusCode) const override;
|
||||
Size resolution() const override;
|
||||
|
||||
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
V4L2SubdeviceFormat getFormat(Span<const unsigned int> mbusCodes,
|
||||
const Size &size,
|
||||
const Size maxSize) const override;
|
||||
int setFormat(V4L2SubdeviceFormat *format,
|
||||
@@ -757,7 +757,7 @@ Size CameraSensorRaw::resolution() const
|
||||
}
|
||||
|
||||
V4L2SubdeviceFormat
|
||||
CameraSensorRaw::getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
CameraSensorRaw::getFormat(Span<const unsigned int> mbusCodes,
|
||||
const Size &size, Size maxSize) const
|
||||
{
|
||||
unsigned int desiredArea = size.width * size.height;
|
||||
|
||||
@@ -96,10 +96,13 @@ protected:
|
||||
}
|
||||
|
||||
/* Use an invalid format and make sure it's not selected. */
|
||||
V4L2SubdeviceFormat format = sensor_->getFormat({ 0xdeadbeef,
|
||||
MEDIA_BUS_FMT_SBGGR10_1X10,
|
||||
MEDIA_BUS_FMT_BGR888_1X24 },
|
||||
Size(1024, 768));
|
||||
static constexpr uint32_t mbusCodes[] = {
|
||||
0xdeadbeef,
|
||||
MEDIA_BUS_FMT_SBGGR10_1X10,
|
||||
MEDIA_BUS_FMT_BGR888_1X24,
|
||||
};
|
||||
|
||||
V4L2SubdeviceFormat format = sensor_->getFormat(mbusCodes, Size(1024, 768));
|
||||
if (format.code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
|
||||
format.size != Size(4096, 2160)) {
|
||||
cerr << "Failed to get a suitable format, expected 4096x2160-0x"
|
||||
|
||||
Reference in New Issue
Block a user