From patchwork Fri Jul 15 13:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16644 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1FF75BE173 for ; Fri, 15 Jul 2022 13:50:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D37246331E; Fri, 15 Jul 2022 15:50:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657893030; bh=xsOmi0ExAprMxJ0HW3/9PchbaC2LQxkXWJ+JkZTpw/w=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=aIrKU66eVOSLnfLcMY7DnZRQviKQaKvqHAmpwSCKdGnvALwiqz7gb1jB4vkXjctRs hOMRHriPqUB9VLxd9wpLLK3g4BVsLe3v0OL6Ns+eOke4dGURNX0VeXsebt50E/RqUE rDC1nK3deaZG7JfG9QtVJGXV6Ztr4oCjv9yPE3qkknvZ3MvD8ON7VfFtB+piWwGHc2 M6hNuqY42489QYdyhM5oaM+6Fe6Rz+32X6Y+/mVGOdC0SB3JgHVe1x+cW72/wGUaJk 6SbEaI7Q9Y/vKiE56GbKl1UTiXJH4EoVQfM2MukFoYhmrLcS/GHPTYwoJsvMz+xt+G JHj+CoQpXuf5Q== Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 68B2D63316 for ; Fri, 15 Jul 2022 15:50:27 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 3F29860005; Fri, 15 Jul 2022 13:50:26 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Fri, 15 Jul 2022 15:50:06 +0200 Message-Id: <20220715135007.53574-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220715135007.53574-1-jacopo@jmondi.org> References: <20220715135007.53574-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/7] libcamera: v4l2_videodevice: Add multiplanar argument to toV4L2PixelFormat 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-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: jozef@mlich.cz, Pavel Machek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The toV4L2PixelFormat() function selects which V4L2 format variant to use (contiguous planes vs non-contiguous version) by using video device multiplanar API from the capabilities. The isMultiplanar() function however verifies if the video device uses the singleplanar or the multiplanar V4L2 API, something which is unrelated to the format variant to use. Add a 'multiplanar' flag, which defaults to false, to the toV4L2PixelFormat() function to allow explicit selection of the format variant. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/v4l2_videodevice.h | 3 ++- src/libcamera/v4l2_videodevice.cpp | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 6d8850c99afd..64296c5849f2 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -228,7 +228,8 @@ public: static std::unique_ptr fromEntityName(const MediaDevice *media, const std::string &entity); - V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const; + V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat, + bool multiplanar = false) const; protected: std::string logPrefix() const override; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index a3242ba755c0..767ab2361ef5 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1992,23 +1992,24 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media, /** * \brief Convert \a PixelFormat to one of the device supported V4L2 FourCC * \param[in] pixelFormat The PixelFormat to convert + * \param[in] multiplanar Use the multiplanar format version, default to false * * Convert a\ pixelformat to a V4L2 FourCC that is known to be supported by * the video device. * - * 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. + * V4L2 defines different format variants for the same format when using + * contiguous or non-contiguous planes. The \a multiplanar parameter allows + * to select which variant to use. * * \return The V4L2PixelFormat corresponding to \a pixelFormat or an invalid * PixelFormat if \a pixelFormat is not supported by the video device */ -V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelFormat) const +V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelFormat, + bool multiplanar) const { std::vector deviceFormats = enumPixelformats(0); std::vector v4l2PixelFormats = - V4L2PixelFormat::fromPixelFormat(pixelFormat, caps_.isMultiplanar()); + V4L2PixelFormat::fromPixelFormat(pixelFormat, multiplanar); for (const V4L2PixelFormat &v4l2Format : v4l2PixelFormats) { auto it = std::find_if(deviceFormats.begin(), deviceFormats.end(),