summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2019-10-25 13:05:16 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-28 17:04:20 +0200
commit448716d8f75185795d9b01164440d0753850a80a (patch)
treebe19233b0fa0e29b607e52dd62ea10d255dde36a /src
parent2a8bf04227811b29bc94b942e78f1567afd8874b (diff)
libcamera: Switch PixelFormat to DRM FourCC values
Use DRM FourCC values for the newly defined PixelFormat. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/ipu3/ipu3.cpp7
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp25
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp4
-rw-r--r--src/libcamera/pipeline/vimc.cpp15
-rw-r--r--src/libcamera/pixelformats.cpp6
-rw-r--r--src/qcam/format_converter.cpp30
6 files changed, 46 insertions, 41 deletions
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 8d3ad568..1c5fccf6 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -10,6 +10,7 @@
#include <memory>
#include <vector>
+#include <linux/drm_fourcc.h>
#include <linux/media-bus-format.h>
#include <libcamera/camera.h>
@@ -249,7 +250,7 @@ IPU3CameraConfiguration::IPU3CameraConfiguration(Camera *camera,
void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale)
{
/* The only pixel format the driver supports is NV12. */
- cfg.pixelFormat = V4L2_PIX_FMT_NV12;
+ cfg.pixelFormat = DRM_FORMAT_NV12;
if (scale) {
/*
@@ -404,7 +405,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
StreamConfiguration cfg = {};
IPU3Stream *stream = nullptr;
- cfg.pixelFormat = V4L2_PIX_FMT_NV12;
+ cfg.pixelFormat = DRM_FORMAT_NV12;
switch (role) {
case StreamRole::StillCapture:
@@ -1121,7 +1122,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output,
return 0;
V4L2DeviceFormat outputFormat = {};
- outputFormat.fourcc = V4L2_PIX_FMT_NV12;
+ outputFormat.fourcc = dev->toV4L2Fourcc(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 7a28b03b..b21cf924 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -11,6 +11,7 @@
#include <memory>
#include <queue>
+#include <linux/drm_fourcc.h>
#include <linux/media-bus-format.h>
#include <ipa/rkisp1.h>
@@ -434,14 +435,14 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,
CameraConfiguration::Status RkISP1CameraConfiguration::validate()
{
static const std::array<unsigned int, 8> formats{
- V4L2_PIX_FMT_YUYV,
- V4L2_PIX_FMT_YVYU,
- V4L2_PIX_FMT_VYUY,
- V4L2_PIX_FMT_NV16,
- V4L2_PIX_FMT_NV61,
- V4L2_PIX_FMT_NV21,
- V4L2_PIX_FMT_NV12,
- V4L2_PIX_FMT_GREY,
+ DRM_FORMAT_YUYV,
+ DRM_FORMAT_YVYU,
+ DRM_FORMAT_VYUY,
+ DRM_FORMAT_NV16,
+ DRM_FORMAT_NV61,
+ DRM_FORMAT_NV21,
+ DRM_FORMAT_NV12,
+ /* \todo Add support for 8-bit greyscale to DRM formats */
};
const CameraSensor *sensor = data_->sensor_;
@@ -462,7 +463,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 = V4L2_PIX_FMT_NV12;
+ cfg.pixelFormat = DRM_FORMAT_NV12,
status = Adjusted;
}
@@ -541,7 +542,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera
return config;
StreamConfiguration cfg{};
- cfg.pixelFormat = V4L2_PIX_FMT_NV12;
+ cfg.pixelFormat = DRM_FORMAT_NV12;
cfg.size = data->sensor_->resolution();
config->addConfiguration(cfg);
@@ -623,7 +624,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
LOG(RkISP1, Debug) << "ISP output pad configured with " << format.toString();
V4L2DeviceFormat outputFormat = {};
- outputFormat.fourcc = cfg.pixelFormat;
+ outputFormat.fourcc = video_->toV4L2Fourcc(cfg.pixelFormat);
outputFormat.size = cfg.size;
outputFormat.planesCount = 2;
@@ -632,7 +633,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
return ret;
if (outputFormat.size != cfg.size ||
- outputFormat.fourcc != cfg.pixelFormat) {
+ outputFormat.fourcc != video_->toV4L2Fourcc(cfg.pixelFormat)) {
LOG(RkISP1, Error)
<< "Unable to configure capture in " << cfg.toString();
return -EINVAL;
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index fae0ffc4..45448d6f 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -176,7 +176,7 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)
int ret;
V4L2DeviceFormat format = {};
- format.fourcc = cfg.pixelFormat;
+ format.fourcc = data->video_->toV4L2Fourcc(cfg.pixelFormat);
format.size = cfg.size;
ret = data->video_->setFormat(&format);
@@ -184,7 +184,7 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)
return ret;
if (format.size != cfg.size ||
- format.fourcc != cfg.pixelFormat)
+ format.fourcc != data->video_->toV4L2Fourcc(cfg.pixelFormat))
return -EINVAL;
cfg.setStream(&data->stream_);
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
index c16ae4cb..e6ab6a08 100644
--- a/src/libcamera/pipeline/vimc.cpp
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -10,6 +10,7 @@
#include <iomanip>
#include <tuple>
+#include <linux/drm_fourcc.h>
#include <linux/media-bus-format.h>
#include <ipa/ipa_interface.h>
@@ -106,9 +107,9 @@ private:
namespace {
constexpr std::array<unsigned int, 3> pixelformats{
- V4L2_PIX_FMT_BGR24,
- V4L2_PIX_FMT_RGB24,
- V4L2_PIX_FMT_ARGB32,
+ DRM_FORMAT_RGB888,
+ DRM_FORMAT_BGR888,
+ DRM_FORMAT_BGRA8888,
};
} /* namespace */
@@ -137,7 +138,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 = V4L2_PIX_FMT_RGB24;
+ cfg.pixelFormat = DRM_FORMAT_BGR888;
status = Adjusted;
}
@@ -186,7 +187,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
StreamConfiguration cfg(formats.data());
- cfg.pixelFormat = V4L2_PIX_FMT_RGB24;
+ cfg.pixelFormat = DRM_FORMAT_BGR888;
cfg.size = { 1920, 1080 };
cfg.bufferCount = 4;
@@ -231,7 +232,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
return ret;
V4L2DeviceFormat format = {};
- format.fourcc = cfg.pixelFormat;
+ format.fourcc = data->video_->toV4L2Fourcc(cfg.pixelFormat);
format.size = cfg.size;
ret = data->video_->setFormat(&format);
@@ -239,7 +240,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
return ret;
if (format.size != cfg.size ||
- format.fourcc != cfg.pixelFormat)
+ format.fourcc != data->video_->toV4L2Fourcc(cfg.pixelFormat))
return -EINVAL;
/*
diff --git a/src/libcamera/pixelformats.cpp b/src/libcamera/pixelformats.cpp
index 9377fb5e..c0333540 100644
--- a/src/libcamera/pixelformats.cpp
+++ b/src/libcamera/pixelformats.cpp
@@ -19,8 +19,10 @@ namespace libcamera {
* \brief libcamera image pixel format
*
* The PixelFormat type describes the format of images in the public libcamera
- * API. It stores a FourCC value in a 32-bit unsigned integer. The values are
- * defined in the Linux kernel V4L2 API (see linux/videodev2.h).
+ * API. It stores a FourCC value as a 32-bit unsigned integer. The values are
+ * defined in the Linux kernel DRM/KMS API (see linux/drm_fourcc.h).
+ *
+ * \todo Add support for format modifiers
*/
} /* namespace libcamera */
diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp
index 86b03b2c..383d4822 100644
--- a/src/qcam/format_converter.cpp
+++ b/src/qcam/format_converter.cpp
@@ -7,7 +7,7 @@
#include <errno.h>
-#include <linux/videodev2.h>
+#include <linux/drm_fourcc.h>
#include <QImage>
@@ -31,84 +31,84 @@ int FormatConverter::configure(unsigned int format, unsigned int width,
unsigned int height)
{
switch (format) {
- case V4L2_PIX_FMT_NV12:
+ case DRM_FORMAT_NV12:
formatFamily_ = NV;
horzSubSample_ = 2;
vertSubSample_ = 2;
nvSwap_ = false;
break;
- case V4L2_PIX_FMT_NV21:
+ case DRM_FORMAT_NV21:
formatFamily_ = NV;
horzSubSample_ = 2;
vertSubSample_ = 2;
nvSwap_ = true;
break;
- case V4L2_PIX_FMT_NV16:
+ case DRM_FORMAT_NV16:
formatFamily_ = NV;
horzSubSample_ = 2;
vertSubSample_ = 1;
nvSwap_ = false;
break;
- case V4L2_PIX_FMT_NV61:
+ case DRM_FORMAT_NV61:
formatFamily_ = NV;
horzSubSample_ = 2;
vertSubSample_ = 1;
nvSwap_ = true;
break;
- case V4L2_PIX_FMT_NV24:
+ case DRM_FORMAT_NV24:
formatFamily_ = NV;
horzSubSample_ = 1;
vertSubSample_ = 1;
nvSwap_ = false;
break;
- case V4L2_PIX_FMT_NV42:
+ case DRM_FORMAT_NV42:
formatFamily_ = NV;
horzSubSample_ = 1;
vertSubSample_ = 1;
nvSwap_ = true;
break;
- case V4L2_PIX_FMT_BGR24:
+ case DRM_FORMAT_RGB888:
formatFamily_ = RGB;
r_pos_ = 2;
g_pos_ = 1;
b_pos_ = 0;
bpp_ = 3;
break;
- case V4L2_PIX_FMT_RGB24:
+ case DRM_FORMAT_BGR888:
formatFamily_ = RGB;
r_pos_ = 0;
g_pos_ = 1;
b_pos_ = 2;
bpp_ = 3;
break;
- case V4L2_PIX_FMT_ARGB32:
+ case DRM_FORMAT_BGRA8888:
formatFamily_ = RGB;
r_pos_ = 1;
g_pos_ = 2;
b_pos_ = 3;
bpp_ = 4;
break;
- case V4L2_PIX_FMT_VYUY:
+ case DRM_FORMAT_VYUY:
formatFamily_ = YUV;
y_pos_ = 1;
cb_pos_ = 2;
break;
- case V4L2_PIX_FMT_YVYU:
+ case DRM_FORMAT_YVYU:
formatFamily_ = YUV;
y_pos_ = 0;
cb_pos_ = 3;
break;
- case V4L2_PIX_FMT_UYVY:
+ case DRM_FORMAT_UYVY:
formatFamily_ = YUV;
y_pos_ = 1;
cb_pos_ = 0;
break;
- case V4L2_PIX_FMT_YUYV:
+ case DRM_FORMAT_YUYV:
formatFamily_ = YUV;
y_pos_ = 0;
cb_pos_ = 1;
break;
- case V4L2_PIX_FMT_MJPEG:
+ case DRM_FORMAT_MJPEG:
formatFamily_ = MJPEG;
break;
default: