mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-22 08:05:06 +03:00
libcamera: pipeline: simple: Cache pipeline config in SimpleCameraConfiguration
As the pipeline configuration is selected in SimpleCameraConfiguration::validate() already, cache it in the SimpleCameraConfiguration instead of looking it up in SimplePipelineHandler::configure(). This makes little difference at the moment, but will save duplication of more complex logic between validate() and configure() when adding support for multiple streams. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
7b29587840
commit
23c60fcdff
1 changed files with 21 additions and 17 deletions
|
@ -177,6 +177,11 @@ public:
|
||||||
|
|
||||||
Status validate() override;
|
Status validate() override;
|
||||||
|
|
||||||
|
const SimpleCameraData::Configuration *pipeConfig() const
|
||||||
|
{
|
||||||
|
return pipeConfig_;
|
||||||
|
}
|
||||||
|
|
||||||
bool needConversion() const { return needConversion_; }
|
bool needConversion() const { return needConversion_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -188,6 +193,7 @@ private:
|
||||||
std::shared_ptr<Camera> camera_;
|
std::shared_ptr<Camera> camera_;
|
||||||
const SimpleCameraData *data_;
|
const SimpleCameraData *data_;
|
||||||
|
|
||||||
|
const SimpleCameraData::Configuration *pipeConfig_;
|
||||||
bool needConversion_;
|
bool needConversion_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -506,7 +512,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,
|
||||||
SimpleCameraConfiguration::SimpleCameraConfiguration(Camera *camera,
|
SimpleCameraConfiguration::SimpleCameraConfiguration(Camera *camera,
|
||||||
SimpleCameraData *data)
|
SimpleCameraData *data)
|
||||||
: CameraConfiguration(), camera_(camera->shared_from_this()),
|
: CameraConfiguration(), camera_(camera->shared_from_this()),
|
||||||
data_(data)
|
data_(data), pipeConfig_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,18 +548,18 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()
|
||||||
status = Adjusted;
|
status = Adjusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SimpleCameraData::Configuration &pipeConfig = it->second;
|
pipeConfig_ = &it->second;
|
||||||
if (!pipeConfig.outputSizes.contains(cfg.size)) {
|
if (!pipeConfig_->outputSizes.contains(cfg.size)) {
|
||||||
LOG(SimplePipeline, Debug)
|
LOG(SimplePipeline, Debug)
|
||||||
<< "Adjusting size from " << cfg.size.toString()
|
<< "Adjusting size from " << cfg.size.toString()
|
||||||
<< " to " << pipeConfig.captureSize.toString();
|
<< " to " << pipeConfig_->captureSize.toString();
|
||||||
cfg.size = pipeConfig.captureSize;
|
cfg.size = pipeConfig_->captureSize;
|
||||||
status = Adjusted;
|
status = Adjusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \todo Create a libcamera core class to group format and size */
|
/* \todo Create a libcamera core class to group format and size */
|
||||||
needConversion_ = cfg.pixelFormat != pipeConfig.captureFormat
|
needConversion_ = cfg.pixelFormat != pipeConfig_->captureFormat
|
||||||
|| cfg.size != pipeConfig.captureSize;
|
|| cfg.size != pipeConfig_->captureSize;
|
||||||
|
|
||||||
cfg.bufferCount = 3;
|
cfg.bufferCount = 3;
|
||||||
|
|
||||||
|
@ -647,21 +653,19 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
const SimpleCameraData::Configuration &pipeConfig =
|
const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig();
|
||||||
data->formats_[cfg.pixelFormat];
|
V4L2SubdeviceFormat format{ pipeConfig->code, data->sensor_->resolution() };
|
||||||
|
|
||||||
V4L2SubdeviceFormat format{ pipeConfig.code, data->sensor_->resolution() };
|
|
||||||
|
|
||||||
ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat);
|
ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Configure the video node. */
|
/* Configure the video node. */
|
||||||
V4L2PixelFormat videoFormat = video->toV4L2PixelFormat(pipeConfig.captureFormat);
|
V4L2PixelFormat videoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat);
|
||||||
|
|
||||||
V4L2DeviceFormat captureFormat;
|
V4L2DeviceFormat captureFormat;
|
||||||
captureFormat.fourcc = videoFormat;
|
captureFormat.fourcc = videoFormat;
|
||||||
captureFormat.size = pipeConfig.captureSize;
|
captureFormat.size = pipeConfig->captureSize;
|
||||||
|
|
||||||
ret = video->setFormat(&captureFormat);
|
ret = video->setFormat(&captureFormat);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -674,10 +678,10 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (captureFormat.fourcc != videoFormat ||
|
if (captureFormat.fourcc != videoFormat ||
|
||||||
captureFormat.size != pipeConfig.captureSize) {
|
captureFormat.size != pipeConfig->captureSize) {
|
||||||
LOG(SimplePipeline, Error)
|
LOG(SimplePipeline, Error)
|
||||||
<< "Unable to configure capture in "
|
<< "Unable to configure capture in "
|
||||||
<< pipeConfig.captureSize.toString() << "-"
|
<< pipeConfig->captureSize.toString() << "-"
|
||||||
<< videoFormat.toString();
|
<< videoFormat.toString();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -687,8 +691,8 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
|
||||||
|
|
||||||
if (useConverter_) {
|
if (useConverter_) {
|
||||||
StreamConfiguration inputCfg;
|
StreamConfiguration inputCfg;
|
||||||
inputCfg.pixelFormat = pipeConfig.captureFormat;
|
inputCfg.pixelFormat = pipeConfig->captureFormat;
|
||||||
inputCfg.size = pipeConfig.captureSize;
|
inputCfg.size = pipeConfig->captureSize;
|
||||||
inputCfg.stride = captureFormat.planes[0].bpl;
|
inputCfg.stride = captureFormat.planes[0].bpl;
|
||||||
inputCfg.bufferCount = cfg.bufferCount;
|
inputCfg.bufferCount = cfg.bufferCount;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue