{"id":3849,"url":"https://patchwork.libcamera.org/api/1.1/patches/3849/?format=json","web_url":"https://patchwork.libcamera.org/patch/3849/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200522145459.16836-12-laurent.pinchart@ideasonboard.com>","date":"2020-05-22T14:54:58","name":"[libcamera-devel,PATCH/RFC,10/11] libcamera: pipeline: Replace explicit DRM FourCCs with libcamera formats","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"69ce95adc83835099545a6305a9ad5c209a015d2","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3849/mbox/","series":[{"id":923,"url":"https://patchwork.libcamera.org/api/1.1/series/923/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=923","date":"2020-05-22T14:54:47","name":"Introduce formats:: namespace for libcamera pixel formats","version":1,"mbox":"https://patchwork.libcamera.org/series/923/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3849/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3849/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D0FD6610DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 May 2020 16:55:22 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 79E7A528\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 May 2020 16:55:22 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lmKvnjDF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1590159322;\n\tbh=3LsHp4Viomojxqj844xcEW+zWLhu8tsNu0n1sdnDHW0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=lmKvnjDFQjlx3022piDyyNGxg26V090iiRMz3Ow0eizL9ZImFFXXBiLvs9IstCUGb\n\tZ5UPIns1hk0zvyGhlwCuA+XdQ5KvokRFHZ6G36lHqqocD0+8QnyDfDbkUqQL92uT2P\n\tsCKOHieasCmhqNDP4XHVyhz9mIbAr+8NqSk7zQ2M=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 22 May 2020 17:54:58 +0300","Message-Id":"<20200522145459.16836-12-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200522145459.16836-1-laurent.pinchart@ideasonboard.com>","References":"<20200522145459.16836-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH/RFC 10/11] libcamera: pipeline: Replace\n\texplicit DRM FourCCs with libcamera formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 22 May 2020 14:55:26 -0000"},"content":"Use the new pixel format constants to replace usage of macros from\ndrm_fourcc.h.\n\nThe IPU3 pipeline handler still uses DRM FourCCs for IPU3-specific\nformats that are not defined in the libcamera public API.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp          |  8 +++++---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 10 +++++-----\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 19 ++++++++++---------\n src/libcamera/pipeline/vimc/vimc.cpp          | 11 ++++++-----\n 4 files changed, 26 insertions(+), 22 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex b805fea71c2d..f23f338d4eb7 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -11,9 +11,11 @@\n #include <queue>\n #include <vector>\n \n+#include <linux/drm_fourcc.h>\n #include <linux/media-bus-format.h>\n \n #include <libcamera/camera.h>\n+#include <libcamera/formats.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n@@ -261,7 +263,7 @@ IPU3CameraConfiguration::IPU3CameraConfiguration(Camera *camera,\n void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale)\n {\n \t/* The only pixel format the driver supports is NV12. */\n-\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\tcfg.pixelFormat = formats::NV12;\n \n \tif (scale) {\n \t\t/*\n@@ -430,7 +432,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n \t\tStreamConfiguration cfg = {};\n \t\tIPU3Stream *stream = nullptr;\n \n-\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\t\tcfg.pixelFormat = formats::NV12;\n \n \t\tswitch (role) {\n \t\tcase StreamRole::StillCapture:\n@@ -1193,7 +1195,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n \t\treturn 0;\n \n \t*outputFormat = {};\n-\toutputFormat->fourcc = dev->toV4L2PixelFormat(PixelFormat(DRM_FORMAT_NV12));\n+\toutputFormat->fourcc = dev->toV4L2PixelFormat(formats::NV12);\n \toutputFormat->size = cfg.size;\n \toutputFormat->planesCount = 2;\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex e16a9c7f10d3..d3d11f87ecb5 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -13,12 +13,12 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n+#include <libcamera/formats.h>\n #include <libcamera/ipa/raspberrypi.h>\n #include <libcamera/logging.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n-#include <linux/drm_fourcc.h>\n #include <linux/videodev2.h>\n \n #include \"libcamera/internal/camera_sensor.h\"\n@@ -490,7 +490,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \n \t\tif (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {\n \t\t\t/* If we cannot find a native format, use a default one. */\n-\t\t\tcfgPixFmt = PixelFormat(DRM_FORMAT_NV12);\n+\t\t\tcfgPixFmt = formats::NV12;\n \t\t\tstatus = Adjusted;\n \t\t}\n \t}\n@@ -537,20 +537,20 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \t\t\tbreak;\n \n \t\tcase StreamRole::StillCapture:\n-\t\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\t\t\tcfg.pixelFormat = formats::NV12;\n \t\t\t/* Return the largest sensor resolution. */\n \t\t\tcfg.size = data->sensor_->resolution();\n \t\t\tcfg.bufferCount = 1;\n \t\t\tbreak;\n \n \t\tcase StreamRole::VideoRecording:\n-\t\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\t\t\tcfg.pixelFormat = formats::NV12;\n \t\t\tcfg.size = { 1920, 1080 };\n \t\t\tcfg.bufferCount = 4;\n \t\t\tbreak;\n \n \t\tcase StreamRole::Viewfinder:\n-\t\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_ARGB8888);\n+\t\t\tcfg.pixelFormat = formats::ARGB8888;\n \t\t\tcfg.size = { 800, 600 };\n \t\t\tcfg.bufferCount = 4;\n \t\t\tbreak;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex d807fc2cf535..401e777fbbf7 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -16,6 +16,7 @@\n #include <libcamera/buffer.h>\n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n+#include <libcamera/formats.h>\n #include <libcamera/ipa/rkisp1.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n@@ -459,13 +460,13 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,\n CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n {\n \tstatic const std::array<PixelFormat, 8> formats{\n-\t\tPixelFormat(DRM_FORMAT_YUYV),\n-\t\tPixelFormat(DRM_FORMAT_YVYU),\n-\t\tPixelFormat(DRM_FORMAT_VYUY),\n-\t\tPixelFormat(DRM_FORMAT_NV16),\n-\t\tPixelFormat(DRM_FORMAT_NV61),\n-\t\tPixelFormat(DRM_FORMAT_NV21),\n-\t\tPixelFormat(DRM_FORMAT_NV12),\n+\t\tformats::YUYV,\n+\t\tformats::YVYU,\n+\t\tformats::VYUY,\n+\t\tformats::NV16,\n+\t\tformats::NV61,\n+\t\tformats::NV21,\n+\t\tformats::NV12,\n \t\t/* \\todo Add support for 8-bit greyscale to DRM formats */\n \t};\n \n@@ -487,7 +488,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \tif (std::find(formats.begin(), formats.end(), cfg.pixelFormat) ==\n \t    formats.end()) {\n \t\tLOG(RkISP1, Debug) << \"Adjusting format to NV12\";\n-\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12),\n+\t\tcfg.pixelFormat = formats::NV12,\n \t\tstatus = Adjusted;\n \t}\n \n@@ -566,7 +567,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera\n \t\treturn config;\n \n \tStreamConfiguration cfg{};\n-\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\tcfg.pixelFormat = formats::NV12;\n \tcfg.size = data->sensor_->resolution();\n \n \tconfig->addConfiguration(cfg);\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex ca36348a5eb6..ce6db27ce576 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -17,6 +17,7 @@\n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n #include <libcamera/controls.h>\n+#include <libcamera/formats.h>\n #include <libcamera/ipa/ipa_interface.h>\n #include <libcamera/ipa/ipa_module_info.h>\n #include <libcamera/request.h>\n@@ -108,9 +109,9 @@ private:\n namespace {\n \n static const std::array<PixelFormat, 3> pixelformats{\n-\tPixelFormat(DRM_FORMAT_RGB888),\n-\tPixelFormat(DRM_FORMAT_BGR888),\n-\tPixelFormat(DRM_FORMAT_BGRA8888),\n+\tformats::RGB888,\n+\tformats::BGR888,\n+\tformats::BGRA8888,\n };\n \n } /* namespace */\n@@ -139,7 +140,7 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()\n \tif (std::find(pixelformats.begin(), pixelformats.end(), cfg.pixelFormat) ==\n \t    pixelformats.end()) {\n \t\tLOG(VIMC, Debug) << \"Adjusting format to RGB24\";\n-\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);\n+\t\tcfg.pixelFormat = formats::BGR888;\n \t\tstatus = Adjusted;\n \t}\n \n@@ -188,7 +189,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \n \tStreamConfiguration cfg(formats);\n \n-\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);\n+\tcfg.pixelFormat = formats::BGR888;\n \tcfg.size = { 1920, 1080 };\n \tcfg.bufferCount = 4;\n \n","prefixes":["libcamera-devel","PATCH/RFC","10/11"]}