diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-23 04:49:10 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-06-04 11:02:33 +0300 |
commit | 1a77984c892d186859ba699dc9e6a23beb7b739a (patch) | |
tree | 1ac36acf62eadf32b21cbb6056433d7dc4bc5759 | |
parent | 3714034eb74d35ddf718997a48f49f095797058a (diff) |
libcamera: pipeline: vimc: Use appropriate media bus format
Pick the correct media bus format based on the video pixel format on the
capture node.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r-- | src/libcamera/pipeline/vimc/vimc.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index ca36348a..68d65bc7 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -6,8 +6,8 @@ */ #include <algorithm> -#include <array> #include <iomanip> +#include <map> #include <math.h> #include <tuple> @@ -107,10 +107,10 @@ private: namespace { -static const std::array<PixelFormat, 3> pixelformats{ - PixelFormat(DRM_FORMAT_RGB888), - PixelFormat(DRM_FORMAT_BGR888), - PixelFormat(DRM_FORMAT_BGRA8888), +static const std::map<PixelFormat, uint32_t> pixelformats{ + { PixelFormat(DRM_FORMAT_RGB888), MEDIA_BUS_FMT_BGR888_1X24 }, + { PixelFormat(DRM_FORMAT_BGR888), MEDIA_BUS_FMT_RGB888_1X24 }, + { PixelFormat(DRM_FORMAT_BGRA8888), MEDIA_BUS_FMT_ARGB8888_1X32 }, }; } /* namespace */ @@ -136,8 +136,7 @@ CameraConfiguration::Status VimcCameraConfiguration::validate() StreamConfiguration &cfg = config_[0]; /* Adjust the pixel format. */ - if (std::find(pixelformats.begin(), pixelformats.end(), cfg.pixelFormat) == - pixelformats.end()) { + if (pixelformats.find(cfg.pixelFormat) == pixelformats.end()) { LOG(VIMC, Debug) << "Adjusting format to RGB24"; cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888); status = Adjusted; @@ -178,12 +177,12 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, std::map<PixelFormat, std::vector<SizeRange>> formats; - for (PixelFormat pixelformat : pixelformats) { + for (const auto &pixelformat : pixelformats) { /* The scaler hardcodes a x3 scale-up ratio. */ std::vector<SizeRange> sizes{ SizeRange{ { 48, 48 }, { 4096, 2160 } } }; - formats[pixelformat] = sizes; + formats[pixelformat.first] = sizes; } StreamConfiguration cfg(formats); @@ -218,7 +217,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) if (ret) return ret; - subformat.mbus_code = MEDIA_BUS_FMT_RGB888_1X24; + subformat.mbus_code = pixelformats.find(cfg.pixelFormat)->second; ret = data->debayer_->setFormat(1, &subformat); if (ret) return ret; |