diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-04-29 15:15:23 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-05-23 00:27:14 +0300 |
commit | 77ae64eb24bf6c2fe241b6f7b841315b1ee15707 (patch) | |
tree | 7c85eba53482bf3212644acc7b02796dea2a3b48 /src/libcamera/pipeline/ipu3/ipu3.cpp | |
parent | a40023e6cc005dfc57cc535167ee44761f3ed9f6 (diff) |
libcamera: Refactor the camera configuration storage and API
Refactor the CameraConfiguration structure to not rely on Stream
instances. This is a step towards making the camera configuration object
more powerful with configuration validation using "try" semantics.
The CameraConfiguration now exposes a simple vector-like API to access
the contained stream configurations. Both operator[]() and at() are
provided to access elements. The isEmpty() method is renamed to empty()
and the methods reordered to match the std::vector class.
As applications need access to the Stream instances associated with the
configuration entries in order to associate buffers with streams when
creating requests, expose the stream selected by the pipeline handler
through a new StreamConfiguration::stream().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/pipeline/ipu3/ipu3.cpp')
-rw-r--r-- | src/libcamera/pipeline/ipu3/ipu3.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index d234a8ac..ed0ef69d 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -152,8 +152,7 @@ public: CameraConfiguration generateConfiguration(Camera *camera, const StreamRoles &roles) override; - int configure(Camera *camera, - const CameraConfiguration &config) override; + int configure(Camera *camera, CameraConfiguration &config) override; int allocateBuffers(Camera *camera, const std::set<Stream *> &streams) override; @@ -299,14 +298,13 @@ PipelineHandlerIPU3::generateConfiguration(Camera *camera, cfg.pixelFormat = V4L2_PIX_FMT_NV12; cfg.bufferCount = IPU3_BUFFER_COUNT; - config[stream] = cfg; + config.addConfiguration(cfg); } return config; } -int PipelineHandlerIPU3::configure(Camera *camera, - const CameraConfiguration &config) +int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration &config) { IPU3CameraData *data = cameraData(camera); IPU3Stream *outStream = &data->outStream_; @@ -318,9 +316,13 @@ int PipelineHandlerIPU3::configure(Camera *camera, outStream->active_ = false; vfStream->active_ = false; - for (Stream *s : config) { - IPU3Stream *stream = static_cast<IPU3Stream *>(s); - const StreamConfiguration &cfg = config[stream]; + for (StreamConfiguration &cfg : config) { + /* + * Pick a stream for the configuration entry. + * \todo: This is a naive temporary implementation that will be + * reworked when implementing camera configuration validation. + */ + IPU3Stream *stream = vfStream->active_ ? outStream : vfStream; /* * Verify that the requested size respects the IPU3 alignment @@ -355,6 +357,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, sensorSize.height = cfg.size.height; stream->active_ = true; + cfg.setStream(stream); } /* @@ -379,10 +382,9 @@ int PipelineHandlerIPU3::configure(Camera *camera, return ret; /* Apply the format to the configured streams output devices. */ - for (Stream *s : config) { - IPU3Stream *stream = static_cast<IPU3Stream *>(s); - - ret = imgu->configureOutput(stream->device_, config[stream]); + for (StreamConfiguration &cfg : config) { + IPU3Stream *stream = static_cast<IPU3Stream *>(cfg.stream()); + ret = imgu->configureOutput(stream->device_, cfg); if (ret) return ret; } @@ -393,15 +395,13 @@ int PipelineHandlerIPU3::configure(Camera *camera, * be at least one active stream in the configuration request). */ if (!outStream->active_) { - ret = imgu->configureOutput(outStream->device_, - config[vfStream]); + ret = imgu->configureOutput(outStream->device_, config[0]); if (ret) return ret; } if (!vfStream->active_) { - ret = imgu->configureOutput(vfStream->device_, - config[outStream]); + ret = imgu->configureOutput(vfStream->device_, config[0]); if (ret) return ret; } |