From patchwork Sat Jul 23 09:53:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16745 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 5C74EBE173 for ; Sat, 23 Jul 2022 09:54:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 197346331B; Sat, 23 Jul 2022 11:54:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658570057; bh=W4t/laySClNJw1u9vyAMEbpDCAxoN7T8DlUDQfp7+II=; 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=kWrfawqZSpFXs0U93n5xsVQgvE3OJ2H8pMj/L56cYJG3t/O1SjJkf8oKMflvg4iss ez68UDaa5WA1udIBkDh3ewp8g8wsYYXP3fe1fcIFTE7bD8WKhCMttWs5ugzr/4x4Do bvHirBnenFc8btFCCYxqIYxtdqonAM1zuGJQHjerzoOiHUwt4tqPIn8IFQAVEpOteN Ae02MVQLs9pxV5AlAejubk8cFgKgMcnpRBp3vzK/CEItiiYzkD6glbq45Xg5RafQy2 w5CebjcLd6/ETWjhbq456TbHzLgvBRkG4JjRsrilmEqVl+pJq2M87YdouCiDEnluLe 8UxAgP/Wig6jQ== Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D0986330E for ; Sat, 23 Jul 2022 11:54:15 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id A15AC1BF20D; Sat, 23 Jul 2022 09:54:12 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Jul 2022 11:53:28 +0200 Message-Id: <20220723095330.43542-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220723095330.43542-1-jacopo@jmondi.org> References: <20220723095330.43542-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/8] 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(),