libcamera: pipeline: simple: Factor out format test to separate function
To prepare for the implementation of a more complex format discovery method, factor out code that tries a pipeline configuration to a separate function. No functional change intended. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
0416488635
commit
6984f07c0e
1 changed files with 67 additions and 51 deletions
|
@ -250,6 +250,8 @@ public:
|
||||||
std::queue<std::map<unsigned int, FrameBuffer *>> converterQueue_;
|
std::queue<std::map<unsigned int, FrameBuffer *>> converterQueue_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void tryPipeline(unsigned int code, const Size &size);
|
||||||
|
|
||||||
void converterInputDone(FrameBuffer *buffer);
|
void converterInputDone(FrameBuffer *buffer);
|
||||||
void converterOutputDone(FrameBuffer *buffer);
|
void converterOutputDone(FrameBuffer *buffer);
|
||||||
};
|
};
|
||||||
|
@ -466,27 +468,63 @@ int SimpleCameraData::init()
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enumerate the possible pipeline configurations. For each media bus
|
* Generate the list of possible pipeline configurations by trying each
|
||||||
* format supported by the sensor, propagate the formats through the
|
* media bus format supported by the sensor.
|
||||||
* pipeline, and enumerate the corresponding possible V4L2 pixel
|
*/
|
||||||
* formats on the video node.
|
for (unsigned int code : sensor_->mbusCodes())
|
||||||
|
tryPipeline(code, sensor_->resolution());
|
||||||
|
|
||||||
|
if (configs_.empty()) {
|
||||||
|
LOG(SimplePipeline, Error) << "No valid configuration found";
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map the pixel formats to configurations. Any previously stored value
|
||||||
|
* is overwritten, as the pipeline handler currently doesn't care about
|
||||||
|
* how a particular PixelFormat is achieved.
|
||||||
|
*/
|
||||||
|
for (const Configuration &config : configs_) {
|
||||||
|
formats_[config.captureFormat] = &config;
|
||||||
|
|
||||||
|
for (PixelFormat fmt : config.outputFormats)
|
||||||
|
formats_[fmt] = &config;
|
||||||
|
}
|
||||||
|
|
||||||
|
properties_ = sensor_->properties();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate a list of supported pipeline configurations for a sensor media bus
|
||||||
|
* code and size.
|
||||||
|
*
|
||||||
|
* First propagate the media bus code and size through the pipeline from the
|
||||||
|
* camera sensor to the video node. Then, query the video node for all supported
|
||||||
|
* pixel formats compatible with the media bus code. For each pixel format, store
|
||||||
|
* a full pipeline configuration in the configs_ vector.
|
||||||
|
*/
|
||||||
|
void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Propagate the format through the pipeline, and enumerate the
|
||||||
|
* corresponding possible V4L2 pixel formats on the video node.
|
||||||
*/
|
*/
|
||||||
for (unsigned int code : sensor_->mbusCodes()) {
|
|
||||||
V4L2SubdeviceFormat format{};
|
V4L2SubdeviceFormat format{};
|
||||||
format.mbus_code = code;
|
format.mbus_code = code;
|
||||||
format.size = sensor_->resolution();
|
format.size = size;
|
||||||
|
|
||||||
ret = setupFormats(&format, V4L2Subdevice::TryFormat);
|
int ret = setupFormats(&format, V4L2Subdevice::TryFormat);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
/* Pipeline configuration failed, skip this configuration. */
|
||||||
LOG(SimplePipeline, Debug)
|
LOG(SimplePipeline, Debug)
|
||||||
<< "Media bus code " << utils::hex(code, 4)
|
<< "Media bus code " << utils::hex(code, 4)
|
||||||
<< " not supported for this pipeline";
|
<< " not supported for this pipeline";
|
||||||
/* Try next mbus_code supported by the sensor */
|
return;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
V4L2VideoDevice::Formats videoFormats =
|
V4L2VideoDevice::Formats videoFormats = video_->formats(format.mbus_code);
|
||||||
video_->formats(format.mbus_code);
|
|
||||||
|
|
||||||
LOG(SimplePipeline, Debug)
|
LOG(SimplePipeline, Debug)
|
||||||
<< "Adding configuration for " << format.size
|
<< "Adding configuration for " << format.size
|
||||||
|
@ -517,28 +555,6 @@ int SimpleCameraData::init()
|
||||||
|
|
||||||
configs_.push_back(config);
|
configs_.push_back(config);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (configs_.empty()) {
|
|
||||||
LOG(SimplePipeline, Error) << "No valid configuration found";
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Map the pixel formats to configurations. Any previously stored value
|
|
||||||
* is overwritten, as the pipeline handler currently doesn't care about
|
|
||||||
* how a particular PixelFormat is achieved.
|
|
||||||
*/
|
|
||||||
for (const Configuration &config : configs_) {
|
|
||||||
formats_[config.captureFormat] = &config;
|
|
||||||
|
|
||||||
for (PixelFormat fmt : config.outputFormats)
|
|
||||||
formats_[fmt] = &config;
|
|
||||||
}
|
|
||||||
|
|
||||||
properties_ = sensor_->properties();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SimpleCameraData::setupLinks()
|
int SimpleCameraData::setupLinks()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue