summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2020-06-25 08:28:44 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-25 17:47:51 +0300
commit0396380614fb0b77e91d469f5845291910c8f8d5 (patch)
treee54da655e74c5345079eef94a145aea39c528936
parent23e15e72f9745d4a11f41b366ff3c9e3dca51bf0 (diff)
libcamera: pipeline: raspberrypi: Add StreamFormats to StreamConfiguration
In generateConfiguration(), add the device node specific formats to the StreamConfiguration for each StreamRole requested. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp52
1 files changed, 36 insertions, 16 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 60985b71..dcd737a1 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -518,41 +518,45 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
RPiCameraData *data = cameraData(camera);
CameraConfiguration *config = new RPiCameraConfiguration(data);
V4L2DeviceFormat sensorFormat;
+ unsigned int bufferCount;
+ PixelFormat pixelFormat;
V4L2PixFmtMap fmts;
+ Size size;
if (roles.empty())
return config;
for (const StreamRole role : roles) {
- StreamConfiguration cfg{};
-
switch (role) {
case StreamRole::StillCaptureRaw:
- cfg.size = data->sensor_->resolution();
+ size = data->sensor_->resolution();
fmts = data->unicam_[Unicam::Image].dev()->formats();
- sensorFormat = findBestMode(fmts, cfg.size);
- cfg.pixelFormat = sensorFormat.fourcc.toPixelFormat();
- ASSERT(cfg.pixelFormat.isValid());
- cfg.bufferCount = 1;
+ sensorFormat = findBestMode(fmts, size);
+ pixelFormat = sensorFormat.fourcc.toPixelFormat();
+ ASSERT(pixelFormat.isValid());
+ bufferCount = 1;
break;
case StreamRole::StillCapture:
- cfg.pixelFormat = formats::NV12;
+ fmts = data->isp_[Isp::Output0].dev()->formats();
+ pixelFormat = formats::NV12;
/* Return the largest sensor resolution. */
- cfg.size = data->sensor_->resolution();
- cfg.bufferCount = 1;
+ size = data->sensor_->resolution();
+ bufferCount = 1;
break;
case StreamRole::VideoRecording:
- cfg.pixelFormat = formats::NV12;
- cfg.size = { 1920, 1080 };
- cfg.bufferCount = 4;
+ fmts = data->isp_[Isp::Output0].dev()->formats();
+ pixelFormat = formats::NV12;
+ size = { 1920, 1080 };
+ bufferCount = 4;
break;
case StreamRole::Viewfinder:
- cfg.pixelFormat = formats::ARGB8888;
- cfg.size = { 800, 600 };
- cfg.bufferCount = 4;
+ fmts = data->isp_[Isp::Output0].dev()->formats();
+ pixelFormat = formats::ARGB8888;
+ size = { 800, 600 };
+ bufferCount = 4;
break;
default:
@@ -561,6 +565,22 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
break;
}
+ /* Translate the V4L2PixelFormat to PixelFormat. */
+ std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
+ std::transform(fmts.begin(), fmts.end(), std::inserter(deviceFormats, deviceFormats.end()),
+ [&](const decltype(fmts)::value_type &format) {
+ return decltype(deviceFormats)::value_type{
+ format.first.toPixelFormat(),
+ format.second
+ };
+ });
+
+ /* Add the stream format based on the device node used for the use case. */
+ StreamFormats formats(deviceFormats);
+ StreamConfiguration cfg(formats);
+ cfg.size = size;
+ cfg.pixelFormat = pixelFormat;
+ cfg.bufferCount = bufferCount;
config->addConfiguration(cfg);
}