From 05b0e5ed531553ad20c4c787de3c337425e6b907 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 14 Apr 2019 21:26:07 +0300 Subject: libcamera: v4l2_subdevice: Add method to retrieve the media entity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a method to retrieve the media entity associated with a subdevice. The entityName() and deviceNode() methods are not needed anymore as they can be accessed through the media entity, remove them. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/include/v4l2_subdevice.h | 3 +-- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++-- src/libcamera/v4l2_subdevice.cpp | 22 +++++++--------------- 3 files changed, 10 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h index e592d67d..c7b0b4cb 100644 --- a/src/libcamera/include/v4l2_subdevice.h +++ b/src/libcamera/include/v4l2_subdevice.h @@ -41,8 +41,7 @@ public: bool isOpen() const; void close(); - const std::string &deviceNode() const { return entity_->deviceNode(); } - const std::string &entityName() const { return entity_->name(); } + const MediaEntity *entity() const { return entity_; } int setCrop(unsigned int pad, Rectangle *rect); int setCompose(unsigned int pad, Rectangle *rect); diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index fb9ee0af..f4396909 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -590,7 +590,7 @@ int PipelineHandlerIPU3::registerCameras() &IPU3CameraData::imguOutputBufferReady); /* Create and register the Camera instance. */ - std::string cameraName = cio2->sensor_->entityName() + " " + std::string cameraName = cio2->sensor_->entity()->name() + " " + std::to_string(id); std::shared_ptr camera = Camera::create(this, cameraName, @@ -1066,7 +1066,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index) } } if (maxSize_.width == 0) { - LOG(IPU3, Info) << "Sensor '" << sensor_->entityName() + LOG(IPU3, Info) << "Sensor '" << sensor_->entity()->name() << "' detected, but no supported image format " << " found: skip camera creation"; return -ENODEV; diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a03fadfd..5d5b168f 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -131,12 +131,12 @@ int V4L2Subdevice::open() return -EBUSY; } - ret = ::open(deviceNode().c_str(), O_RDWR); + ret = ::open(entity_->deviceNode().c_str(), O_RDWR); if (ret < 0) { ret = -errno; LOG(V4L2Subdev, Error) - << "Failed to open V4L2 subdevice '" << deviceNode() - << "': " << strerror(-ret); + << "Failed to open V4L2 subdevice '" + << entity_->deviceNode() << "': " << strerror(-ret); return ret; } fd_ = ret; @@ -166,17 +166,9 @@ void V4L2Subdevice::close() } /** - * \fn V4L2Subdevice::deviceNode() - * \brief Retrieve the path of the device node associated with the subdevice - * - * \return The subdevice's device node system path - */ - -/** - * \fn V4L2Subdevice::entityName() - * \brief Retrieve the name of the media entity associated with the subdevice - * - * \return The name of the media entity the subdevice is associated to + * \fn V4L2Subdevice::entity() + * \brief Retrieve the media entity associated with the subdevice + * \return The subdevice's associated media entity. */ /** @@ -343,7 +335,7 @@ V4L2Subdevice *V4L2Subdevice::fromEntityName(const MediaDevice *media, std::string V4L2Subdevice::logPrefix() const { - return "'" + entityName() + "'"; + return "'" + entity_->name() + "'"; } int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code, -- cgit v1.2.1