summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-07-04 17:55:57 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-07-10 16:11:26 +0900
commit7ed827e0a09bffabf4b2c4bc2a506e9563207a93 (patch)
treeb77438a47cabc0440b309cd2669c6f5788516022
parent3a9c574ed9fd17e7bfec41abf09ada08ec8872aa (diff)
libcamera: raspberrypi: Fill stride and frameSize at config validation
Fill the stride and frameSize fields of the StreamConfiguration at configuration validation time instead of at camera configuration time. This allows applications to get the stride when trying a configuration without modifying the active configuration of the camera. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 1822ac90..a08ad6a8 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -427,6 +427,10 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
*/
V4L2PixFmtMap fmts = data_->unicam_[Unicam::Image].dev()->formats();
V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size);
+ int ret = data_->unicam_[Unicam::Image].dev()->tryFormat(&sensorFormat);
+ if (ret)
+ return Invalid;
+
PixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat();
if (cfg.size != sensorFormat.size ||
cfg.pixelFormat != sensorPixFormat) {
@@ -434,6 +438,10 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
cfg.pixelFormat = sensorPixFormat;
status = Adjusted;
}
+
+ cfg.stride = sensorFormat.planes[0].bpl;
+ cfg.frameSize = sensorFormat.planes[0].size;
+
rawCount++;
} else {
outSize[outCount] = std::make_pair(count, cfg.size);
@@ -478,19 +486,34 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
* have that fixed up in the code above.
*
*/
- PixelFormat &cfgPixFmt = config_.at(outSize[i].first).pixelFormat;
- V4L2PixFmtMap fmts;
+ StreamConfiguration &cfg = config_.at(outSize[i].first);
+ PixelFormat &cfgPixFmt = cfg.pixelFormat;
+ V4L2VideoDevice *dev;
if (i == maxIndex)
- fmts = data_->isp_[Isp::Output0].dev()->formats();
+ dev = data_->isp_[Isp::Output0].dev();
else
- fmts = data_->isp_[Isp::Output1].dev()->formats();
+ dev = data_->isp_[Isp::Output1].dev();
+
+ V4L2PixFmtMap fmts = dev->formats();
if (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {
/* If we cannot find a native format, use a default one. */
cfgPixFmt = formats::NV12;
status = Adjusted;
}
+
+ V4L2DeviceFormat format = {};
+ format.fourcc = dev->toV4L2PixelFormat(cfg.pixelFormat);
+ format.size = cfg.size;
+
+ int ret = dev->tryFormat(&format);
+ if (ret)
+ return Invalid;
+
+ cfg.stride = format.planes[0].bpl;
+ cfg.frameSize = format.planes[0].size;
+
}
return status;
@@ -655,7 +678,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
if (isRaw(cfg.pixelFormat)) {
cfg.setStream(&data->isp_[Isp::Input]);
- cfg.stride = sensorFormat.planes[0].bpl;
data->isp_[Isp::Input].setExternal(true);
continue;
}
@@ -679,7 +701,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
}
cfg.setStream(&data->isp_[Isp::Output0]);
- cfg.stride = format.planes[0].bpl;
data->isp_[Isp::Output0].setExternal(true);
}
@@ -705,7 +726,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
*/
if (!cfg.stream()) {
cfg.setStream(&data->isp_[Isp::Output1]);
- cfg.stride = format.planes[0].bpl;
data->isp_[Isp::Output1].setExternal(true);
}
}