diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-07-13 09:51:51 +0100 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2024-06-19 16:54:00 +0100 |
commit | 4d8f2077aba70fc69657c90dd8e28020809df243 (patch) | |
tree | b710b7d3d9a430077640ba81cb3b97e08a536610 /src | |
parent | a11c6ede4dd0d3040ec6751365972ad4d548b08d (diff) |
libcamera: pipeline: vivid: Configure the device
When the configurations have been generated and validated, they can be
applied to a device.
Vivid supports only a single stream, so it directly obtains the first
StreamConfiguration from the CameraConfiguration.
The VIVID catpure device is a V4L2Video device, so we generate a
V4L2DeviceFormat to apply directly to the capture device node.
Note that we convert the libcamera Format stored in
cfg.pixelFormat to a V4L2PixelFormat using V4L2PixelFormat helper. This
currently defaults to the single-planar formats, and should be extended
to support the Multiplanar configuration from the V4L2Device.
[todo Repair the link between the multiplanar configuration of the
V4L2VideoDevice and the pixel format selection]
Following the call to set the format using the Kernel API, if the format
has been adjusted in any way by the kernel driver, then we have failed
to correctly handle the validation stages, and thus the configure
operation is idendified has having failed.
Finally stream specific data can be directly stored and set as
reflecting the state of the stream.
[NOTE: the cfg.setStream() call here associates the stream to the
StreamConfiguration however that should quite likely be done as part of
the validation process. TBD]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/pipeline/vivid/vivid.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/libcamera/pipeline/vivid/vivid.cpp b/src/libcamera/pipeline/vivid/vivid.cpp index 3f697789..56ca9b08 100644 --- a/src/libcamera/pipeline/vivid/vivid.cpp +++ b/src/libcamera/pipeline/vivid/vivid.cpp @@ -164,7 +164,26 @@ PipelineHandlerVivid::generateConfiguration(Camera *camera, Span<const StreamRol int PipelineHandlerVivid::configure(Camera *camera, CameraConfiguration *config) { - return -1; + VividCameraData *data = cameraData(camera); + StreamConfiguration &cfg = config->at(0); + int ret; + + V4L2DeviceFormat format = {}; + format.fourcc = data->video_->toV4L2PixelFormat(cfg.pixelFormat); + format.size = cfg.size; + + ret = data->video_->setFormat(&format); + if (ret) + return ret; + + if (format.size != cfg.size || + format.fourcc != data->video_->toV4L2PixelFormat(cfg.pixelFormat)) + return -EINVAL; + + cfg.setStream(&data->stream_); + cfg.stride = format.planes[0].bpl; + + return 0; } int PipelineHandlerVivid::exportFrameBuffers(Camera *camera, Stream *stream, |