summaryrefslogtreecommitdiff
path: root/src/libcamera
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-16 10:07:26 +0200
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-03-18 18:02:40 +0100
commit718f5e99a966246de8d129902ad470872652b749 (patch)
tree0e16bc1b512304c8341c4a1334654d508631a7a7 /src/libcamera
parent8c0bbcd3d3751a716eb8bf03e703aa6fdbe1bd3f (diff)
libcamera: PixelFormat: Make constructor explicit
To achieve the goal of preventing unwanted conversion between a DRM and a V4L2 FourCC, make the PixelFormat constructor that takes an integer value explicit. All users of pixel formats flagged by the compiler are fixed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera')
-rw-r--r--src/libcamera/pipeline/ipu3/ipu3.cpp6
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp18
-rw-r--r--src/libcamera/pipeline/vimc.cpp10
-rw-r--r--src/libcamera/v4l2_videodevice.cpp26
4 files changed, 30 insertions, 30 deletions
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 84158ebe..9c7ec9ed 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -246,7 +246,7 @@ IPU3CameraConfiguration::IPU3CameraConfiguration(Camera *camera,
void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale)
{
/* The only pixel format the driver supports is NV12. */
- cfg.pixelFormat = DRM_FORMAT_NV12;
+ cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);
if (scale) {
/*
@@ -401,7 +401,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
StreamConfiguration cfg = {};
IPU3Stream *stream = nullptr;
- cfg.pixelFormat = DRM_FORMAT_NV12;
+ cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);
switch (role) {
case StreamRole::StillCapture:
@@ -1141,7 +1141,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output,
return 0;
V4L2DeviceFormat outputFormat = {};
- outputFormat.fourcc = dev->toV4L2Fourcc(DRM_FORMAT_NV12);
+ outputFormat.fourcc = dev->toV4L2Fourcc(PixelFormat(DRM_FORMAT_NV12));
outputFormat.size = cfg.size;
outputFormat.planesCount = 2;
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index d1abdb50..6ee8da35 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -433,13 +433,13 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,
CameraConfiguration::Status RkISP1CameraConfiguration::validate()
{
static const std::array<PixelFormat, 8> formats{
- DRM_FORMAT_YUYV,
- DRM_FORMAT_YVYU,
- DRM_FORMAT_VYUY,
- DRM_FORMAT_NV16,
- DRM_FORMAT_NV61,
- DRM_FORMAT_NV21,
- DRM_FORMAT_NV12,
+ PixelFormat(DRM_FORMAT_YUYV),
+ PixelFormat(DRM_FORMAT_YVYU),
+ PixelFormat(DRM_FORMAT_VYUY),
+ PixelFormat(DRM_FORMAT_NV16),
+ PixelFormat(DRM_FORMAT_NV61),
+ PixelFormat(DRM_FORMAT_NV21),
+ PixelFormat(DRM_FORMAT_NV12),
/* \todo Add support for 8-bit greyscale to DRM formats */
};
@@ -461,7 +461,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) ==
formats.end()) {
LOG(RkISP1, Debug) << "Adjusting format to NV12";
- cfg.pixelFormat = DRM_FORMAT_NV12,
+ cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12),
status = Adjusted;
}
@@ -540,7 +540,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera
return config;
StreamConfiguration cfg{};
- cfg.pixelFormat = DRM_FORMAT_NV12;
+ cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);
cfg.size = data->sensor_->resolution();
config->addConfiguration(cfg);
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
index 00cb7389..097bbd5b 100644
--- a/src/libcamera/pipeline/vimc.cpp
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -106,9 +106,9 @@ private:
namespace {
static const std::array<PixelFormat, 3> pixelformats{
- DRM_FORMAT_RGB888,
- DRM_FORMAT_BGR888,
- DRM_FORMAT_BGRA8888,
+ PixelFormat(DRM_FORMAT_RGB888),
+ PixelFormat(DRM_FORMAT_BGR888),
+ PixelFormat(DRM_FORMAT_BGRA8888),
};
} /* namespace */
@@ -137,7 +137,7 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
if (std::find(pixelformats.begin(), pixelformats.end(), cfg.pixelFormat) ==
pixelformats.end()) {
LOG(VIMC, Debug) << "Adjusting format to RGB24";
- cfg.pixelFormat = DRM_FORMAT_BGR888;
+ cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);
status = Adjusted;
}
@@ -186,7 +186,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
StreamConfiguration cfg(formats);
- cfg.pixelFormat = DRM_FORMAT_BGR888;
+ cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);
cfg.size = { 1920, 1080 };
cfg.bufferCount = 4;
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index ce67e04c..455675fd 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1427,39 +1427,39 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)
switch (v4l2Fourcc) {
/* RGB formats. */
case V4L2_PIX_FMT_RGB24:
- return DRM_FORMAT_BGR888;
+ return PixelFormat(DRM_FORMAT_BGR888);
case V4L2_PIX_FMT_BGR24:
- return DRM_FORMAT_RGB888;
+ return PixelFormat(DRM_FORMAT_RGB888);
case V4L2_PIX_FMT_ARGB32:
- return DRM_FORMAT_BGRA8888;
+ return PixelFormat(DRM_FORMAT_BGRA8888);
/* YUV packed formats. */
case V4L2_PIX_FMT_YUYV:
- return DRM_FORMAT_YUYV;
+ return PixelFormat(DRM_FORMAT_YUYV);
case V4L2_PIX_FMT_YVYU:
- return DRM_FORMAT_YVYU;
+ return PixelFormat(DRM_FORMAT_YVYU);
case V4L2_PIX_FMT_UYVY:
- return DRM_FORMAT_UYVY;
+ return PixelFormat(DRM_FORMAT_UYVY);
case V4L2_PIX_FMT_VYUY:
- return DRM_FORMAT_VYUY;
+ return PixelFormat(DRM_FORMAT_VYUY);
/* YUY planar formats. */
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV16M:
- return DRM_FORMAT_NV16;
+ return PixelFormat(DRM_FORMAT_NV16);
case V4L2_PIX_FMT_NV61:
case V4L2_PIX_FMT_NV61M:
- return DRM_FORMAT_NV61;
+ return PixelFormat(DRM_FORMAT_NV61);
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV12M:
- return DRM_FORMAT_NV12;
+ return PixelFormat(DRM_FORMAT_NV12);
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV21M:
- return DRM_FORMAT_NV21;
+ return PixelFormat(DRM_FORMAT_NV21);
/* Compressed formats. */
case V4L2_PIX_FMT_MJPEG:
- return DRM_FORMAT_MJPEG;
+ return PixelFormat(DRM_FORMAT_MJPEG);
/* V4L2 formats not yet supported by DRM. */
case V4L2_PIX_FMT_GREY:
@@ -1472,7 +1472,7 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)
LogError).stream()
<< "Unsupported V4L2 pixel format "
<< utils::hex(v4l2Fourcc);
- return 0;
+ return PixelFormat();
}
}