summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-07-04 17:56:47 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-07-10 16:11:38 +0900
commit7c3831d2d1dafdba5c70d7488db7f094e303cb1d (patch)
treea3c727907dd0e97296f4c810134b38552b4257f0 /src
parentd0395efd3a8e51af4b6d94fd37054c4241b74447 (diff)
libcamera: vimc: 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> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/vimc/vimc.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index b6530662..a6f457c7 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -72,9 +72,12 @@ public:
class VimcCameraConfiguration : public CameraConfiguration
{
public:
- VimcCameraConfiguration();
+ VimcCameraConfiguration(VimcCameraData *data);
Status validate() override;
+
+private:
+ VimcCameraData *data_;
};
class PipelineHandlerVimc : public PipelineHandler
@@ -115,8 +118,8 @@ static const std::map<PixelFormat, uint32_t> pixelformats{
} /* namespace */
-VimcCameraConfiguration::VimcCameraConfiguration()
- : CameraConfiguration()
+VimcCameraConfiguration::VimcCameraConfiguration(VimcCameraData *data)
+ : CameraConfiguration(), data_(data)
{
}
@@ -160,6 +163,17 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
cfg.bufferCount = 4;
+ V4L2DeviceFormat format = {};
+ format.fourcc = data_->video_->toV4L2PixelFormat(cfg.pixelFormat);
+ format.size = cfg.size;
+
+ int ret = data_->video_->tryFormat(&format);
+ if (ret)
+ return Invalid;
+
+ cfg.stride = format.planes[0].bpl;
+ cfg.frameSize = format.planes[0].size;
+
return status;
}
@@ -171,8 +185,8 @@ PipelineHandlerVimc::PipelineHandlerVimc(CameraManager *manager)
CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
const StreamRoles &roles)
{
- CameraConfiguration *config = new VimcCameraConfiguration();
VimcCameraData *data = cameraData(camera);
+ CameraConfiguration *config = new VimcCameraConfiguration(data);
if (roles.empty())
return config;
@@ -282,7 +296,6 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
return ret;
cfg.setStream(&data->stream_);
- cfg.stride = format.planes[0].bpl;
return 0;
}