From patchwork Fri Feb 28 03:29:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2915 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C475A6271F for ; Fri, 28 Feb 2020 04:29:40 +0100 (CET) X-Halon-ID: 8d4fcf04-59da-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 8d4fcf04-59da-11ea-9f85-005056917a89; Fri, 28 Feb 2020 04:29:39 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 28 Feb 2020 04:29:12 +0100 Message-Id: <20200228032913.497826-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200228032913.497826-1-niklas.soderlund@ragnatech.se> References: <20200228032913.497826-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 5/6] libcamera: v4l2_videodevice: Remove pixel format translators X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Feb 2020 03:29:41 -0000 Switch to use PixelFormat to translate between DRM and V4L2 instead of having a proxy implementation inside V4L2VideoDevice. Signed-off-by: Niklas Söderlund --- src/libcamera/include/v4l2_videodevice.h | 4 --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 +-- src/libcamera/pipeline/uvcvideo.cpp | 4 +-- src/libcamera/pipeline/vimc.cpp | 4 +-- src/libcamera/v4l2_videodevice.cpp | 44 ------------------------ test/camera/buffer_import.cpp | 2 +- 6 files changed, 7 insertions(+), 55 deletions(-) diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 982df9d2f918e49c..9666a4dd2438a5ee 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -199,10 +199,6 @@ public: static V4L2VideoDevice *fromEntityName(const MediaDevice *media, const std::string &entity); - static PixelFormat toPixelFormat(uint32_t v4l2Fourcc); - uint32_t toV4L2Fourcc(PixelFormat pixelFormat); - static uint32_t toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar); - protected: std::string logPrefix() const; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 323fa3596c6ee242..f1ffb7acded5f4ee 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -629,7 +629,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "Resizer output pad configured with " << format.toString(); V4L2DeviceFormat outputFormat = {}; - outputFormat.fourcc = video_->toV4L2Fourcc(cfg.pixelFormat); + outputFormat.fourcc = cfg.pixelFormat.v4l2(); outputFormat.size = cfg.size; outputFormat.planesCount = 2; @@ -638,7 +638,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) return ret; if (outputFormat.size != cfg.size || - outputFormat.fourcc != video_->toV4L2Fourcc(cfg.pixelFormat)) { + outputFormat.fourcc != cfg.pixelFormat.v4l2()) { 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 75fbfe1eb9145424..89c47b99df22395b 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -177,7 +177,7 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config) int ret; V4L2DeviceFormat format = {}; - format.fourcc = data->video_->toV4L2Fourcc(cfg.pixelFormat); + format.fourcc = cfg.pixelFormat.v4l2(); format.size = cfg.size; ret = data->video_->setFormat(&format); @@ -185,7 +185,7 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config) return ret; if (format.size != cfg.size || - format.fourcc != data->video_->toV4L2Fourcc(cfg.pixelFormat)) + format.fourcc != cfg.pixelFormat.v4l2()) return -EINVAL; cfg.setStream(&data->stream_); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index a591c424919b0783..f9e24f288d732f74 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -232,7 +232,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) return ret; V4L2DeviceFormat format = {}; - format.fourcc = data->video_->toV4L2Fourcc(cfg.pixelFormat); + format.fourcc = cfg.pixelFormat.v4l2(); format.size = cfg.size; ret = data->video_->setFormat(&format); @@ -240,7 +240,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) return ret; if (format.size != cfg.size || - format.fourcc != data->video_->toV4L2Fourcc(cfg.pixelFormat)) + format.fourcc != cfg.pixelFormat.v4l2()) return -EINVAL; /* diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index e9d3e60198e140a0..d3d5f73193e3abef 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1410,50 +1410,6 @@ V4L2VideoDevice *V4L2VideoDevice::fromEntityName(const MediaDevice *media, return new V4L2VideoDevice(mediaEntity); } -/** - * \brief Convert a \a v4l2Fourcc to the corresponding PixelFormat - * \param[in] v4l2Fourcc The V4L2 pixel format (V4L2_PIX_FORMAT_*) - * \return The PixelFormat corresponding to \a v4l2Fourcc - */ -PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) -{ - return PixelFormat(v4l2Fourcc); -} - -/** - * \brief Convert \a PixelFormat to its corresponding V4L2 FourCC - * \param[in] pixelFormat The PixelFormat to convert - * - * For multiplanar formats, the V4L2 format variant (contiguous or - * non-contiguous planes) is selected automatically based on the capabilities - * of the video device. If the video device supports the V4L2 multiplanar API, - * non-contiguous formats are preferred. - * - * \return The V4L2_PIX_FMT_* pixel format code corresponding to \a pixelFormat - */ -uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat) -{ - return V4L2VideoDevice::toV4L2Fourcc(pixelFormat, caps_.isMultiplanar()); -} - -/** - * \brief Convert \a pixelFormat to its corresponding V4L2 FourCC - * \param[in] pixelFormat The PixelFormat to convert - * \param[in] multiplanar V4L2 Multiplanar API support flag - * - * Multiple V4L2 formats may exist for one PixelFormat when the format uses - * multiple planes, as V4L2 defines separate 4CCs for contiguous and separate - * planes formats. Set the \a multiplanar parameter to false to select a format - * with contiguous planes, or to true to select a format with non-contiguous - * planes. - * - * \return The V4L2_PIX_FMT_* pixel format code corresponding to \a pixelFormat - */ -uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar) -{ - return pixelFormat.v4l2(); -} - /** * \class V4L2M2MDevice * \brief Memory-to-Memory video device diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp index ab6e74bd1671e6f5..d47a9d8516c58375 100644 --- a/test/camera/buffer_import.cpp +++ b/test/camera/buffer_import.cpp @@ -89,7 +89,7 @@ public: } format.size = config.size; - format.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false); + format.fourcc = config.pixelFormat.v4l2(); if (video_->setFormat(&format)) { std::cout << "Failed to set format on output device" << std::endl; return TestFail;