From patchwork Wed Feb 20 13:17:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 589 Return-Path: Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 77351601E4 for ; Wed, 20 Feb 2019 14:17:40 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 033DC4000B; Wed, 20 Feb 2019 13:17:39 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Feb 2019 14:17:53 +0100 Message-Id: <20190220131757.14004-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220131757.14004-1-jacopo@jmondi.org> References: <20190220131757.14004-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: v4l2_subdevice: Make crop/compose rectangle a reference X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2019 13:17:40 -0000 As the crop/compose rectangle provided to setCrop and setCompose methods is never modified, make it a const reference. Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_subdevice.h | 6 +++--- src/libcamera/v4l2_subdevice.cpp | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h index 40becd0ca99b..18000d6ed06b 100644 --- a/src/libcamera/include/v4l2_subdevice.h +++ b/src/libcamera/include/v4l2_subdevice.h @@ -44,8 +44,8 @@ public: std::string deviceNode() const { return deviceNode_; } std::string deviceName() const { return deviceName_; } - int setCrop(unsigned int pad, Rectangle *rect); - int setCompose(unsigned int pad, Rectangle *rect); + int setCrop(unsigned int pad, const Rectangle &rect); + int setCompose(unsigned int pad, const Rectangle &rect); int enumFormat(unsigned int pad, V4L2SubdeviceFormatEnum *formatEnum); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format); @@ -53,7 +53,7 @@ public: private: int setSelection(unsigned int pad, unsigned int target, - Rectangle *rect); + const Rectangle &rect); std::string deviceNode_; std::string deviceName_; diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 4411ffa51460..2e73edee68c9 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -203,11 +203,11 @@ void V4L2Subdevice::close() /** * \brief Set a crop rectangle on one of the V4L2 subdevice pads * \param[in] pad The 0-indexed pad number the rectangle is to be applied to - * \param[inout] rect The rectangle describing crop target area + * \param[in] rect The rectangle describing crop target area * * \return 0 on success, or a negative error code otherwise */ -int V4L2Subdevice::setCrop(unsigned int pad, Rectangle *rect) +int V4L2Subdevice::setCrop(unsigned int pad, const Rectangle &rect) { return setSelection(pad, V4L2_SEL_TGT_CROP, rect); } @@ -215,11 +215,11 @@ int V4L2Subdevice::setCrop(unsigned int pad, Rectangle *rect) /** * \brief Set a compose rectangle on one of the V4L2 subdevice pads * \param[in] pad The 0-indexed pad number the rectangle is to be applied to - * \param[inout] rect The rectangle describing the compose target area + * \param[in] rect The rectangle describing the compose target area * * \return 0 on success, or a negative error code otherwise */ -int V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect) +int V4L2Subdevice::setCompose(unsigned int pad, const Rectangle &rect) { return setSelection(pad, V4L2_SEL_TGT_COMPOSE, rect); } @@ -333,7 +333,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format) } int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, - Rectangle *rect) + const Rectangle &rect) { struct v4l2_subdev_selection sel = {}; @@ -342,10 +342,10 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, sel.target = target; sel.flags = 0; - sel.r.left = rect->y; - sel.r.top = rect->x; - sel.r.width = rect->w; - sel.r.height = rect->h; + sel.r.left = rect.y; + sel.r.top = rect.x; + sel.r.width = rect.w; + sel.r.height = rect.h; int ret = ioctl(fd_, VIDIOC_SUBDEV_S_SELECTION, &sel); if (ret < 0) {