From patchwork Mon Jan 21 17:27:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 302 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A64060C83 for ; Mon, 21 Jan 2019 18:27:03 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 0DD711BF214; Mon, 21 Jan 2019 17:27:02 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:00 +0100 Message-Id: <20190121172705.19985-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/6] libcamera: v4l2_device: Add MediaEntity contructor 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: Mon, 21 Jan 2019 17:27:03 -0000 Construct a V4L2Device from a MediaEntity device node path. While at there mark constructor as explicit to avoid copy-construction. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/v4l2_device.h | 4 +++- src/libcamera/v4l2_device.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 474c05b..c6f3d9a 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -32,10 +32,12 @@ struct V4L2Capability final : v4l2_capability { bool hasStreaming() const { return capabilities & V4L2_CAP_STREAMING; } }; +class MediaEntity; class V4L2Device { public: - V4L2Device(const std::string &devnode); + explicit V4L2Device(const std::string &devnode); + explicit V4L2Device(const MediaEntity &entity); V4L2Device(const V4L2Device &) = delete; ~V4L2Device(); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 54b53de..59a1ad9 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -12,6 +12,7 @@ #include #include "log.h" +#include "media_object.h" #include "v4l2_device.h" /** @@ -92,6 +93,17 @@ V4L2Device::V4L2Device(const std::string &devnode) { } +/** + * \brief Construct a V4L2Device from a MediaEntity + * \param entity The MediaEntity to build the device from + * + * Construct a V4L2Device from a MediaEntity's device node path. + */ +V4L2Device::V4L2Device(const MediaEntity &entity) + : V4L2Device(entity.devnode()) +{ +} + V4L2Device::~V4L2Device() { close(); From patchwork Mon Jan 21 17:27:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 303 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F62160C96 for ; Mon, 21 Jan 2019 18:27:04 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id BBFD91BF206; Mon, 21 Jan 2019 17:27:03 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:01 +0100 Message-Id: <20190121172705.19985-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/6] libcamera: v4l2_device: Add setControl function 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: Mon, 21 Jan 2019 17:27:04 -0000 Add function to set controls on a V4L2Device object. Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_device.h | 2 ++ src/libcamera/v4l2_device.cpp | 38 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index c6f3d9a..2787847 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -51,6 +51,8 @@ public: const char *deviceName() const { return caps_.card(); } const char *busName() const { return caps_.bus_info(); } + int setControl(unsigned int control, int value); + private: std::string devnode_; int fd_; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 59a1ad9..aef0996 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -195,4 +195,42 @@ void V4L2Device::close() * \return The string containing the device location */ +/** + * \brief Set a control value + * \param control The control identifier + * \param value The new control value + * + * Set a user control to the requested value. The function returns the + * new value actually assigned to the control, which might be different + * from the requested \a value one. + * + * \return The new control's value for success, or a negative error code otherwise + */ +int V4L2Device::setControl(unsigned int control, int value) +{ + struct v4l2_control v4l2_ctrl = { + .id = control, + .value = value, + }; + + int ret = ioctl(fd_, VIDIOC_S_CTRL, &v4l2_ctrl); + if (ret) { + ret = -errno; + LOG(Error) << "Failed to set control: " << strerror(-ret); + return ret; + } + + v4l2_ctrl = { }; + v4l2_ctrl.id = control; + + ret = ioctl(fd_, VIDIOC_G_CTRL, &v4l2_ctrl); + if (ret) { + ret = -errno; + LOG(Error) << "Failed to get control: " << strerror(-ret); + return ret; + } + + return v4l2_ctrl.value; +} + } /* namespace libcamera */ From patchwork Mon Jan 21 17:27:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 304 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CBC7760C96 for ; Mon, 21 Jan 2019 18:27:04 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 5F1631BF206; Mon, 21 Jan 2019 17:27:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:02 +0100 Message-Id: <20190121172705.19985-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/6] libcamera: v4l2_device: Identify single/multiplane 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: Mon, 21 Jan 2019 17:27:05 -0000 Add functions to V4L2Capability to identify if a V4L2 device supports single or multiplane APIs. Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_device.h | 6 +++-- src/libcamera/v4l2_device.cpp | 37 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 2787847..0101a4b 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -27,8 +27,10 @@ struct V4L2Capability final : v4l2_capability { return reinterpret_cast(v4l2_capability::bus_info); } - bool isCapture() const { return capabilities & V4L2_CAP_VIDEO_CAPTURE; } - bool isOutput() const { return capabilities & V4L2_CAP_VIDEO_OUTPUT; } + bool isSinglePlane() const; + bool isMultiPlane() const; + bool isCapture() const; + bool isOutput() const; bool hasStreaming() const { return capabilities & V4L2_CAP_STREAMING; } }; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index aef0996..7cd89d7 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -47,17 +47,46 @@ namespace libcamera { * \return The string containing the device location */ + +/** + * \brief Identify if the device implements V4L2 single plane APIs + * \return true if the device supports single plane APIs + */ +bool V4L2Capability::isSinglePlane() const +{ + return (capabilities & V4L2_CAP_VIDEO_CAPTURE) || + (capabilities & V4L2_CAP_VIDEO_OUTPUT); +} + +/** + * \brief Identify if the device implements V4L2 multiplanar APIs + * \return true if the device supports multiplanar APIs + */ +bool V4L2Capability::isMultiPlane() const +{ + return (capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) || + (capabilities & V4L2_CAP_VIDEO_OUTPUT_MPLANE); +} + /** - * \fn bool V4L2Capability::isCapture() * \brief Identify if the device is capable of capturing video - * \return True if the device can capture video frames + * \return true if the device can capture video frames */ +bool V4L2Capability::isCapture() const +{ + return (capabilities & V4L2_CAP_VIDEO_CAPTURE) || + (capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE); +} /** - * \fn bool V4L2Capability::isOutput() * \brief Identify if the device is capable of outputting video - * \return True if the device can output video frames + * \return true if the device can capture video frames */ +bool V4L2Capability::isOutput() const +{ + return (capabilities & V4L2_CAP_VIDEO_OUTPUT) || + (capabilities & V4L2_CAP_VIDEO_OUTPUT_MPLANE); +} /** * \fn bool V4L2Capability::hasStreaming() From patchwork Mon Jan 21 17:27:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 305 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DEDE60C96 for ; Mon, 21 Jan 2019 18:27:05 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 03C7B1BF206; Mon, 21 Jan 2019 17:27:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:03 +0100 Message-Id: <20190121172705.19985-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/6] libcamera: v4l2_device: Add single/multiplane formats 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: Mon, 21 Jan 2019 17:27:05 -0000 Add a class hierarchy internal to V4L2Device to handle set/get format operations in the single/multi plane use case. Provide stubs only for get/setFormat methods at the moment. --- src/libcamera/include/v4l2_device.h | 34 +++++++++++++++++ src/libcamera/v4l2_device.cpp | 59 +++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 0101a4b..81992dc 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_V4L2_DEVICE_H__ #define __LIBCAMERA_V4L2_DEVICE_H__ +#include #include #include @@ -54,11 +55,44 @@ public: const char *busName() const { return caps_.bus_info(); } int setControl(unsigned int control, int value); + int getFormat(); + int setFormat(); private: + class V4L2Format + { + public: + virtual ~V4L2Format() { } + virtual int setFormat() = 0; + virtual int getFormat() = 0; + + protected: + V4L2Format() { } + V4L2Format(V4L2Format &) = delete; + }; + + class V4L2FormatSPlane : public V4L2Format + { + public: + V4L2FormatSPlane() { } + ~V4L2FormatSPlane() { } + int setFormat(); + int getFormat(); + }; + + class V4L2FormatMPlane : public V4L2Format + { + public: + V4L2FormatMPlane() { } + ~V4L2FormatMPlane() { } + int setFormat(); + int getFormat(); + }; + std::string devnode_; int fd_; V4L2Capability caps_; + std::unique_ptr format_; }; } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 7cd89d7..126f6f2 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -5,6 +5,8 @@ * v4l2_device.cpp - V4L2 Device */ +#include + #include #include #include @@ -13,6 +15,7 @@ #include "log.h" #include "media_object.h" +#include "utils.h" #include "v4l2_device.h" /** @@ -182,6 +185,12 @@ int V4L2Device::open() return -EINVAL; } + /* Create single/multi plane format handler. */ + if (caps_.isSinglePlane()) + format_ = utils::make_unique(); + else + format_ = utils::make_unique(); + return 0; } @@ -262,4 +271,54 @@ int V4L2Device::setControl(unsigned int control, int value) return v4l2_ctrl.value; } +/** + * \brief Retrieve the image format set on the V4L2 device + * + * TODO: define how the image format is encoded + * FIXME: this function is a stub at the moment + * + * \return 0 for success, a negative error code otherwise + */ +int V4L2Device::getFormat() +{ + return format_->getFormat(); +} + +/** + * \brief Program an image format on the V4L2 device + * + * TODO: define how the image format is encoded + * FIXME: this function is a stub at the moment + * + * \return 0 for success, a negative error code otherwise + */ +int V4L2Device::setFormat() +{ + return format_->setFormat(); +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatSPlane::getFormat() +{ + return 0; +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatSPlane::setFormat() +{ + return 0; +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatMPlane::getFormat() +{ + return 0; +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatMPlane::setFormat() +{ + return 0; +} + } /* namespace libcamera */ From patchwork Mon Jan 21 17:27:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 306 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 081C860CA0 for ; Mon, 21 Jan 2019 18:27:06 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 966821BF213; Mon, 21 Jan 2019 17:27:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:04 +0100 Message-Id: <20190121172705.19985-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/6] libcamera: ipu3: Create CIO2 V4L2 devices 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: Mon, 21 Jan 2019 17:27:06 -0000 Create V4L2 devices for the CIO2 capture video nodes. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index daf681c..0689ce8 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -15,6 +15,8 @@ #include "log.h" #include "media_device.h" #include "pipeline_handler.h" +#include "utils.h" +#include "v4l2_device.h" namespace libcamera { @@ -30,6 +32,9 @@ private: MediaDevice *cio2_; MediaDevice *imgu_; + std::vector> videoDevices_; + + void createVideoDevices(); void registerCameras(CameraManager *manager); }; @@ -91,6 +96,12 @@ bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumer cio2_->acquire(); imgu_->acquire(); + /* Create video device nodes for CIO2 outputs */ + if (cio2_->open()) + goto error_release_mdev; + + createVideoDevices(); + /* * Disable all links that are enabled by default on CIO2, as camera * creation enables all valid links it finds. @@ -98,9 +109,6 @@ bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumer * Close the CIO2 media device after, as links are enabled and should * not need to be changed after. */ - if (cio2_->open()) - goto error_release_mdev; - if (cio2_->disableLinks()) goto error_close_cio2; @@ -120,6 +128,28 @@ error_release_mdev: return false; } +/* + * Create video devices for the CIO2 unit capture nodes and cache them + * for later reuse. + */ +void PipelineHandlerIPU3::createVideoDevices() +{ + for (unsigned int id = 0; id < 3; ++id) { + std::string cio2Name = "ipu3-cio2 " + std::to_string(id); + MediaEntity *cio2 = cio2_->getEntityByName(cio2Name); + if (!cio2) + continue; + + std::unique_ptr dev = + utils::make_unique(*cio2); + if (dev->open()) + continue; + dev->close(); + + videoDevices_.push_back(std::move(dev)); + } +} + /* * Cameras are created associating an image sensor (represented by a * media entity with function MEDIA_ENT_F_CAM_SENSOR) to one of the four From patchwork Mon Jan 21 17:27:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 307 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC90460C97 for ; Mon, 21 Jan 2019 18:27:06 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 319E61BF20C; Mon, 21 Jan 2019 17:27:06 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:05 +0100 Message-Id: <20190121172705.19985-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/6] libcamera: Global s/devnode/deviceNode rename 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: Mon, 21 Jan 2019 17:27:07 -0000 Do not use the abreviated version for members, variables and getter methods. Library-wise rename, no intended functional changes. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/media_device.h | 6 +++--- src/libcamera/include/media_object.h | 6 +++--- src/libcamera/include/v4l2_device.h | 4 ++-- src/libcamera/media_device.cpp | 14 +++++++------- src/libcamera/media_object.cpp | 14 +++++++------- src/libcamera/v4l2_device.cpp | 14 +++++++------- test/media_device/media_device_link_test.cpp | 2 +- test/media_device/media_device_print_test.cpp | 12 ++++++------ test/pipeline/ipu3/ipu3_pipeline_test.cpp | 6 +++--- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h index a8dec0d..ba3046d 100644 --- a/src/libcamera/include/media_device.h +++ b/src/libcamera/include/media_device.h @@ -21,7 +21,7 @@ namespace libcamera { class MediaDevice { public: - MediaDevice(const std::string &devnode); + MediaDevice(const std::string &deviceNode); ~MediaDevice(); bool acquire(); @@ -35,7 +35,7 @@ public: bool valid() const { return valid_; } const std::string driver() const { return driver_; } - const std::string devnode() const { return devnode_; } + const std::string deviceNode() const { return deviceNode_; } const std::vector &entities() const { return entities_; } MediaEntity *getEntityByName(const std::string &name) const; @@ -49,7 +49,7 @@ public: private: std::string driver_; - std::string devnode_; + std::string deviceNode_; int fd_; bool valid_; bool acquired_; diff --git a/src/libcamera/include/media_object.h b/src/libcamera/include/media_object.h index fad55a0..64095be 100644 --- a/src/libcamera/include/media_object.h +++ b/src/libcamera/include/media_object.h @@ -85,7 +85,7 @@ class MediaEntity : public MediaObject public: const std::string &name() const { return name_; } unsigned int function() const { return function_; } - const std::string &devnode() const { return devnode_; } + const std::string &deviceNode() const { return deviceNode_; } unsigned int deviceMajor() const { return major_; } unsigned int deviceMinor() const { return minor_; } @@ -94,7 +94,7 @@ public: const MediaPad *getPadByIndex(unsigned int index) const; const MediaPad *getPadById(unsigned int id) const; - int setDeviceNode(const std::string &devnode); + int setDeviceNode(const std::string &deviceNode); private: friend class MediaDevice; @@ -106,7 +106,7 @@ private: std::string name_; unsigned int function_; - std::string devnode_; + std::string deviceNode_; unsigned int major_; unsigned int minor_; diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 81992dc..ca4583c 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -39,7 +39,7 @@ class MediaEntity; class V4L2Device { public: - explicit V4L2Device(const std::string &devnode); + explicit V4L2Device(const std::string &deviceNode); explicit V4L2Device(const MediaEntity &entity); V4L2Device(const V4L2Device &) = delete; ~V4L2Device(); @@ -89,7 +89,7 @@ private: int getFormat(); }; - std::string devnode_; + std::string deviceNode_; int fd_; V4L2Capability caps_; std::unique_ptr format_; diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index 0ee5506..7cf4ce6 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -61,13 +61,13 @@ namespace libcamera { /** * \brief Construct a MediaDevice - * \param devnode The media device node path + * \param deviceNode The media device node path * * Once constructed the media device is invalid, and must be opened and * populated with open() and populate() before the media graph can be queried. */ -MediaDevice::MediaDevice(const std::string &devnode) - : devnode_(devnode), fd_(-1), valid_(false), acquired_(false) +MediaDevice::MediaDevice(const std::string &deviceNode) + : deviceNode_(deviceNode), fd_(-1), valid_(false), acquired_(false) { } @@ -143,10 +143,10 @@ int MediaDevice::open() return -EBUSY; } - int ret = ::open(devnode_.c_str(), O_RDWR); + int ret = ::open(deviceNode_.c_str(), O_RDWR); if (ret < 0) { ret = -errno; - LOG(Error) << "Failed to open media device at " << devnode_ + LOG(Error) << "Failed to open media device at " << deviceNode_ << ": " << strerror(-ret); return ret; } @@ -280,9 +280,9 @@ int MediaDevice::populate() */ /** - * \fn MediaDevice::devnode() + * \fn MediaDevice::deviceNode() * \brief Retrieve the media device device node path - * \return The MediaDevice devnode path + * \return The MediaDevice deviceNode path */ /** diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp index 7d07538..bda1e6c 100644 --- a/src/libcamera/media_object.cpp +++ b/src/libcamera/media_object.cpp @@ -244,7 +244,7 @@ void MediaPad::addLink(MediaLink *link) * * In addition to their graph id, media graph entities are identified by a * name() unique in the media device context. They implement a function() and - * may expose a devnode(). + * may expose a deviceNode(). */ /** @@ -264,7 +264,7 @@ void MediaPad::addLink(MediaLink *link) */ /** - * \fn MediaEntity::devnode() + * \fn MediaEntity::deviceNode() * \brief Retrieve the entity's device node path, if any * * \sa int setDeviceNode() @@ -324,22 +324,22 @@ const MediaPad *MediaEntity::getPadById(unsigned int id) const /** * \brief Set the path to the device node for the associated interface - * \param devnode The interface device node path associated with this entity + * \param deviceNode The interface device node path associated with this entity * \return 0 on success, or a negative error code if the device node can't be * accessed */ -int MediaEntity::setDeviceNode(const std::string &devnode) +int MediaEntity::setDeviceNode(const std::string &deviceNode) { /* Make sure the device node can be accessed. */ - int ret = ::access(devnode.c_str(), R_OK | W_OK); + int ret = ::access(deviceNode.c_str(), R_OK | W_OK); if (ret < 0) { ret = -errno; - LOG(Error) << "Device node " << devnode << " can't be accessed: " + LOG(Error) << "Device node " << deviceNode << " can't be accessed: " << strerror(-ret); return ret; } - devnode_ = devnode; + deviceNode_ = deviceNode; return 0; } diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 126f6f2..0e15f86 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -118,10 +118,10 @@ bool V4L2Capability::isOutput() const /** * \brief Construct a V4L2Device - * \param devnode The file-system path to the video device node + * \param deviceNode The file-system path to the video device node */ -V4L2Device::V4L2Device(const std::string &devnode) - : devnode_(devnode), fd_(-1) +V4L2Device::V4L2Device(const std::string &deviceNode) + : deviceNode_(deviceNode), fd_(-1) { } @@ -132,7 +132,7 @@ V4L2Device::V4L2Device(const std::string &devnode) * Construct a V4L2Device from a MediaEntity's device node path. */ V4L2Device::V4L2Device(const MediaEntity &entity) - : V4L2Device(entity.devnode()) + : V4L2Device(entity.deviceNode()) { } @@ -154,10 +154,10 @@ int V4L2Device::open() return -EBUSY; } - ret = ::open(devnode_.c_str(), O_RDWR); + ret = ::open(deviceNode_.c_str(), O_RDWR); if (ret < 0) { ret = -errno; - LOG(Error) << "Failed to open V4L2 device '" << devnode_ + LOG(Error) << "Failed to open V4L2 device '" << deviceNode_ << "': " << strerror(-ret); return ret; } @@ -171,7 +171,7 @@ int V4L2Device::open() return ret; } - LOG(Debug) << "Opened '" << devnode_ << "' " + LOG(Debug) << "Opened '" << deviceNode_ << "' " << caps_.bus_info() << ": " << caps_.driver() << ": " << caps_.card(); diff --git a/test/media_device/media_device_link_test.cpp b/test/media_device/media_device_link_test.cpp index 2297e33..ac5b632 100644 --- a/test/media_device/media_device_link_test.cpp +++ b/test/media_device/media_device_link_test.cpp @@ -55,7 +55,7 @@ class MediaDeviceLinkTest : public Test if (dev_->open()) { cerr << "Failed to open media device at " - << dev_->devnode() << endl; + << dev_->deviceNode() << endl; return TestFail; } diff --git a/test/media_device/media_device_print_test.cpp b/test/media_device/media_device_print_test.cpp index 13af722..3eef973 100644 --- a/test/media_device/media_device_print_test.cpp +++ b/test/media_device/media_device_print_test.cpp @@ -35,7 +35,7 @@ protected: void cleanup() { } private: - int testMediaDevice(string devnode); + int testMediaDevice(string deviceNode); void printMediaGraph(const MediaDevice &media, ostream &os); void printLinkFlags(const MediaLink *link, ostream &os); @@ -68,7 +68,7 @@ void MediaDevicePrintTest::printLinkFlags(const MediaLink *link, ostream &os) */ void MediaDevicePrintTest::printMediaGraph(const MediaDevice &media, ostream &os) { - os << "\n" << media.driver() << " - " << media.devnode() << "\n\n"; + os << "\n" << media.driver() << " - " << media.deviceNode() << "\n\n"; for (auto const &entity : media.entities()) { os << "\"" << entity->name() << "\"\n"; @@ -108,9 +108,9 @@ void MediaDevicePrintTest::printMediaGraph(const MediaDevice &media, ostream &os } /* Test a single media device. */ -int MediaDevicePrintTest::testMediaDevice(const string devnode) +int MediaDevicePrintTest::testMediaDevice(const string deviceNode) { - MediaDevice dev(devnode); + MediaDevice dev(deviceNode); int ret; /* Fuzzy open/close sequence. */ @@ -144,7 +144,7 @@ int MediaDevicePrintTest::testMediaDevice(const string devnode) #define MAX_MEDIA_DEV 256 int MediaDevicePrintTest::run() { - const string devnode("/dev/media"); + const string deviceNode("/dev/media"); unsigned int i; int ret = 77; /* skip test exit code */ @@ -153,7 +153,7 @@ int MediaDevicePrintTest::run() * system, if any. */ for (i = 0; i < MAX_MEDIA_DEV; i++) { - string mediadev = devnode + to_string(i); + string mediadev = deviceNode + to_string(i); struct stat pstat = { }; if (stat(mediadev.c_str(), &pstat)) diff --git a/test/pipeline/ipu3/ipu3_pipeline_test.cpp b/test/pipeline/ipu3/ipu3_pipeline_test.cpp index deaee40..efe9eaf 100644 --- a/test/pipeline/ipu3/ipu3_pipeline_test.cpp +++ b/test/pipeline/ipu3/ipu3_pipeline_test.cpp @@ -45,7 +45,7 @@ private: int IPU3PipelineTest::init() { - const string devnode("/dev/media"); + const string deviceNode("/dev/media"); bool cio2 = false; bool imgu = false; unsigned int i; @@ -59,7 +59,7 @@ int IPU3PipelineTest::init() * as soon as we hit a non accessible media device. */ for (i = 0; i < 256; i++) { - string mediadev = devnode + to_string(i); + string mediadev = deviceNode + to_string(i); struct stat pstat = { }; if (stat(mediadev.c_str(), &pstat)) @@ -82,7 +82,7 @@ int IPU3PipelineTest::init() */ ret = dev.populate(); if (ret) { - cerr << "Failed to populate media device " << dev.devnode() << endl; + cerr << "Failed to populate media device " << dev.deviceNode() << endl; return TestFail; }