{"id":3380,"url":"https://patchwork.libcamera.org/api/1.1/patches/3380/?format=json","web_url":"https://patchwork.libcamera.org/patch/3380/","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":"<20200404004438.17992-4-laurent.pinchart@ideasonboard.com>","date":"2020-04-04T00:44:30","name":"[libcamera-devel,v4,03/11] libcamera: v4l2_subdevice: Extend [gs]etFormat() to specify format type","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"38932126921d741cd9b8807f0412a66b6d384d91","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/3380/mbox/","series":[{"id":796,"url":"https://patchwork.libcamera.org/api/1.1/series/796/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=796","date":"2020-04-04T00:44:27","name":"Simple pipeline handler","version":4,"mbox":"https://patchwork.libcamera.org/series/796/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3380/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3380/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 29D64629B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Apr 2020 02:44:53 +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 939E011C5;\n\tSat,  4 Apr 2020 02:44:52 +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=\"pZr+jKT3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1585961092;\n\tbh=c10gNrHAm+EO2q6JnAi1ds4eikzpT59BYjnc+NZNhs8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=pZr+jKT3PoYkRsusCJg3iD7rVlOwRQvOqd+7Q6rDD+ueVaRbB/EEFrIQs6qLPVVel\n\tKXeAOkLBRIpgUsoq97POPLTmQ5mkntvogfyJps2E8HGGEa+p9W5AE4tTM/DjW+xagh\n\t3eMTRsuM5YhiexvMRxN2X24Ag6U7bho6k1Bq/mso=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Martijn Braam <martijn@brixit.nl>,\n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>","Date":"Sat,  4 Apr 2020 03:44:30 +0300","Message-Id":"<20200404004438.17992-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200404004438.17992-1-laurent.pinchart@ideasonboard.com>","References":"<20200404004438.17992-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 03/11] libcamera: v4l2_subdevice:\n\tExtend [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":"Sat, 04 Apr 2020 00:44:54 -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>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges since v2:\n\n- Reference ActiveFormat and TryFormat correctly from documentation\n---\n src/libcamera/include/v4l2_subdevice.h | 11 +++++++++--\n src/libcamera/v4l2_subdevice.cpp       | 25 +++++++++++++++++++++----\n 2 files changed, 30 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 8b9da81e8ab3..f554d2385fff 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,16 @@ 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 get, \\ref V4L2Subdevice::ActiveFormat\n+ * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\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 +224,8 @@ 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, \\ref V4L2Subdevice::ActiveFormat\n+ * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\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 +233,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","v4","03/11"]}