diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-02-05 19:10:56 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-02-06 08:03:03 +0200 |
commit | 8cbe8fe650efca1119c456d9c6e6a99da9e12db7 (patch) | |
tree | 2e5397f62f9a7c6c338e2203928c32295d7545d0 /src | |
parent | bbbf76a6c511c9f70bc317c5ee0b798ffc8bb2c9 (diff) |
libcamera: pipeline: vimc: Implement capture support
Replace the buffer allocation, capture start/stop and request queue
stubs with real implementations.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/pipeline/vimc.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 9c0406be..0e9ad7b5 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -6,6 +6,7 @@ */ #include <libcamera/camera.h> +#include <libcamera/request.h> #include <libcamera/stream.h> #include "device_enumerator.h" @@ -83,35 +84,53 @@ int PipeHandlerVimc::configureStreams(Camera *camera, { StreamConfiguration *cfg = &config[&stream_]; - LOG(VIMC, Info) << "TODO: Configure the camera for resolution " - << cfg->width << "x" << cfg->height; + LOG(VIMC, Debug) << "Configure the camera for resolution " + << cfg->width << "x" << cfg->height; - return 0; + V4L2DeviceFormat format = {}; + format.width = cfg->width; + format.height = cfg->height; + format.fourcc = cfg->pixelFormat; + + return video_->setFormat(&format); } int PipeHandlerVimc::allocateBuffers(Camera *camera, Stream *stream) { - return -ENOTRECOVERABLE; + const StreamConfiguration &cfg = stream->configuration(); + + LOG(VIMC, Debug) << "Requesting " << cfg.bufferCount << " buffers"; + + return video_->exportBuffers(cfg.bufferCount, &stream->bufferPool()); } int PipeHandlerVimc::freeBuffers(Camera *camera, Stream *stream) { - return 0; + return video_->releaseBuffers(); } int PipeHandlerVimc::start(const Camera *camera) { - LOG(VIMC, Error) << "TODO: start camera"; - return 0; + return video_->streamOn(); } void PipeHandlerVimc::stop(const Camera *camera) { - LOG(VIMC, Error) << "TODO: stop camera"; + video_->streamOff(); } int PipeHandlerVimc::queueRequest(const Camera *camera, Request *request) { + Buffer *buffer = request->findBuffer(&stream_); + if (!buffer) { + LOG(VIMC, Error) + << "Attempt to queue request with invalid stream"; + + return -ENOENT; + } + + video_->queueBuffer(buffer); + return 0; } |