{"id":3087,"url":"https://patchwork.libcamera.org/api/patches/3087/?format=json","web_url":"https://patchwork.libcamera.org/patch/3087/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200313233856.25202-4-laurent.pinchart@ideasonboard.com>","date":"2020-03-13T23:38:51","name":"[libcamera-devel,3/8] libcamera: v4l2_subdevice: Extend [gs]etFormat() to specify format type","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"191c05b034931f8f69d385209ec72de50c4df322","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3087/mbox/","series":[{"id":718,"url":"https://patchwork.libcamera.org/api/series/718/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=718","date":"2020-03-13T23:38:48","name":"Simple pipeline handler","version":1,"mbox":"https://patchwork.libcamera.org/series/718/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3087/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3087/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 AD2EA62930\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Mar 2020 00:39:06 +0100 (CET)","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 07E0A140C;\n\tSat, 14 Mar 2020 00:39:05 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584142746;\n\tbh=ccFH0E4QJ0xIQdFikzS5FmkxKJO2msekLDi02QZbSNg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=nKD0NwAjPD4yRecKLt47aygST8FQ9b9xBxIlmrEpqOf7XDA3NPRatMtYrmm2F5JST\n\t0PENmCNTN63G+J7V4hKeMolJ4nfNBCwVKjiLp0KSK/N7pUDrgq1Q/97ya/+kN9mJ6j\n\tmN7gjGWgQOsPN5zvYhAtjIAtn+Ojf9FFYxM4a53I=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Martijn Braam <martijn@brixit.nl>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>,\n\tMickael GUENE <mickael.guene@st.com>,\n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>","Date":"Sat, 14 Mar 2020 01:38:51 +0200","Message-Id":"<20200313233856.25202-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200313233856.25202-1-laurent.pinchart@ideasonboard.com>","References":"<20200313233856.25202-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/8] libcamera: v4l2_subdevice: Extend\n\t[gs]etFormat() to specify format type","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, 13 Mar 2020 23:39:06 -0000"},"content":"The V4L2 subdevice API exposes ACTIVE and TRY formats, but the\nV4L2Subdevice getFormat() and setFormat() operations only apply on\nACTIVE formats. Extend them to support TRY formats as well.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_subdevice.h | 11 +++++++++--\n src/libcamera/v4l2_subdevice.cpp       | 23 +++++++++++++++++++----\n 2 files changed, 28 insertions(+), 6 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 9c077674f997..4a04eadfb1f9 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -32,6 +32,11 @@ struct V4L2SubdeviceFormat {\n class V4L2Subdevice : public V4L2Device\n {\n public:\n+\tenum Whence {\n+\t\tActiveFormat,\n+\t\tTryFormat,\n+\t};\n+\n \texplicit V4L2Subdevice(const MediaEntity *entity);\n \tV4L2Subdevice(const V4L2Subdevice &) = delete;\n \tV4L2Subdevice &operator=(const V4L2Subdevice &) = delete;\n@@ -46,8 +51,10 @@ public:\n \n \tImageFormats formats(unsigned int pad);\n \n-\tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n-\tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n+\tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+\t\t      Whence whence = ActiveFormat);\n+\tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+\t\t      Whence whence = ActiveFormat);\n \n \tstatic V4L2Subdevice *fromEntityName(const MediaDevice *media,\n \t\t\t\t\t     const std::string &entity);\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex f2bcd7f73c5c..d9c90a34c0d8 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -95,6 +95,15 @@ const std::string V4L2SubdeviceFormat::toString() const\n  * any device left open will be closed, and any resources released.\n  */\n \n+/**\n+ * \\enum V4L2Subdevice::Whence\n+ * \\brief Specify the type of format for getFormat() and setFormat() operations\n+ * \\var V4L2Subdevice::ActiveFormat\n+ * \\brief The format operation applies to ACTIVE formats\n+ * \\var V4L2Subdevice::TryFormat\n+ * \\brief The format operation applies to TRY formats\n+ */\n+\n /**\n  * \\brief Create a V4L2 subdevice from a MediaEntity using its device node\n  * path\n@@ -184,12 +193,15 @@ ImageFormats V4L2Subdevice::formats(unsigned int pad)\n  * \\brief Retrieve the image format set on one of the V4L2 subdevice pads\n  * \\param[in] pad The 0-indexed pad number the format is to be retrieved from\n  * \\param[out] format The image bus format\n+ * \\param[in] whence The format to retrieve, ACTIVE or TRY\n  * \\return 0 on success or a negative error code otherwise\n  */\n-int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n+int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+\t\t\t     Whence whence)\n {\n \tstruct v4l2_subdev_format subdevFmt = {};\n-\tsubdevFmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\tsubdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE\n+\t\t\t: V4L2_SUBDEV_FORMAT_TRY;\n \tsubdevFmt.pad = pad;\n \n \tint ret = ioctl(VIDIOC_SUBDEV_G_FMT, &subdevFmt);\n@@ -211,6 +223,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n  * \\brief Set an image format on one of the V4L2 subdevice pads\n  * \\param[in] pad The 0-indexed pad number the format is to be applied to\n  * \\param[inout] format The image bus format to apply to the subdevice's pad\n+ * \\param[in] whence The format to set, ACTIVE or TRY\n  *\n  * Apply the requested image format to the desired media pad and return the\n  * actually applied format parameters, as \\ref V4L2Subdevice::getFormat would\n@@ -218,10 +231,12 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n  *\n  * \\return 0 on success or a negative error code otherwise\n  */\n-int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n+int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+\t\t\t     Whence whence)\n {\n \tstruct v4l2_subdev_format subdevFmt = {};\n-\tsubdevFmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\tsubdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE\n+\t\t\t: V4L2_SUBDEV_FORMAT_TRY;\n \tsubdevFmt.pad = pad;\n \tsubdevFmt.format.width = format->size.width;\n \tsubdevFmt.format.height = format->size.height;\n","prefixes":["libcamera-devel","3/8"]}