libcamera: pipeline: vimc: Skip unsupported formats

Older kernels do not support all 'reported' formats. Skip them on those
kernels.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Kieran Bingham 2020-05-22 17:29:08 +01:00
parent a69a8ffb02
commit 3d978a5655

View file

@ -136,8 +136,9 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
StreamConfiguration &cfg = config_[0]; StreamConfiguration &cfg = config_[0];
/* Adjust the pixel format. */ /* Adjust the pixel format. */
if (pixelformats.find(cfg.pixelFormat) == pixelformats.end()) { const std::vector<libcamera::PixelFormat> formats = cfg.formats().pixelformats();
LOG(VIMC, Debug) << "Adjusting format to RGB24"; if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == formats.end()) {
LOG(VIMC, Debug) << "Adjusting format to BGR888";
cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888); cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);
status = Adjusted; status = Adjusted;
} }
@ -171,6 +172,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
const StreamRoles &roles) const StreamRoles &roles)
{ {
CameraConfiguration *config = new VimcCameraConfiguration(); CameraConfiguration *config = new VimcCameraConfiguration();
VimcCameraData *data = cameraData(camera);
if (roles.empty()) if (roles.empty())
return config; return config;
@ -178,6 +180,19 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
std::map<PixelFormat, std::vector<SizeRange>> formats; std::map<PixelFormat, std::vector<SizeRange>> formats;
for (const auto &pixelformat : pixelformats) { for (const auto &pixelformat : pixelformats) {
/*
* Kernels prior to v5.7 incorrectly report support for RGB888,
* but it isn't functional within the pipeline.
*/
if (data->media_->version() < KERNEL_VERSION(5, 7, 0)) {
if (pixelformat.first != PixelFormat(DRM_FORMAT_BGR888)) {
LOG(VIMC, Info)
<< "Skipping unsupported pixel format "
<< pixelformat.first.toString();
continue;
}
}
/* The scaler hardcodes a x3 scale-up ratio. */ /* The scaler hardcodes a x3 scale-up ratio. */
std::vector<SizeRange> sizes{ std::vector<SizeRange> sizes{
SizeRange{ { 48, 48 }, { 4096, 2160 } } SizeRange{ { 48, 48 }, { 4096, 2160 } }