[libcamera-devel] [PATCH 2/3] libcamera: pipeline: vimc: Use V4L2*::fromEntityName() where possible
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat Dec 12 19:51:15 CET 2020
Replace manual construction of V4L2VideoDevice and V4L2Subdevide with
the fromEntityName() helper where possible. The returned pointer is
managed as a std::unique_ptr<>, which simplifies the VimcCameraData
destructor.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/libcamera/pipeline/vimc/vimc.cpp | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index 2a5054a8b1b8..72256f5b4190 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -42,19 +42,13 @@ class VimcCameraData : public CameraData
{
public:
VimcCameraData(PipelineHandler *pipe, MediaDevice *media)
- : CameraData(pipe), media_(media), sensor_(nullptr),
- debayer_(nullptr), scaler_(nullptr), video_(nullptr),
- raw_(nullptr)
+ : CameraData(pipe), media_(media), sensor_(nullptr)
{
}
~VimcCameraData()
{
delete sensor_;
- delete debayer_;
- delete scaler_;
- delete video_;
- delete raw_;
}
int init();
@@ -62,10 +56,10 @@ public:
MediaDevice *media_;
CameraSensor *sensor_;
- V4L2Subdevice *debayer_;
- V4L2Subdevice *scaler_;
- V4L2VideoDevice *video_;
- V4L2VideoDevice *raw_;
+ std::unique_ptr<V4L2Subdevice> debayer_;
+ std::unique_ptr<V4L2Subdevice> scaler_;
+ std::unique_ptr<V4L2VideoDevice> video_;
+ std::unique_ptr<V4L2VideoDevice> raw_;
Stream stream_;
};
@@ -472,21 +466,21 @@ int VimcCameraData::init()
if (ret)
return ret;
- debayer_ = new V4L2Subdevice(media_->getEntityByName("Debayer B"));
+ debayer_ = V4L2Subdevice::fromEntityName(media_, "Debayer B");
if (debayer_->open())
return -ENODEV;
- scaler_ = new V4L2Subdevice(media_->getEntityByName("Scaler"));
+ scaler_ = V4L2Subdevice::fromEntityName(media_, "Scaler");
if (scaler_->open())
return -ENODEV;
- video_ = new V4L2VideoDevice(media_->getEntityByName("RGB/YUV Capture"));
+ video_ = V4L2VideoDevice::fromEntityName(media_, "RGB/YUV Capture");
if (video_->open())
return -ENODEV;
video_->bufferReady.connect(this, &VimcCameraData::bufferReady);
- raw_ = new V4L2VideoDevice(media_->getEntityByName("Raw Capture 1"));
+ raw_ = V4L2VideoDevice::fromEntityName(media_, "Raw Capture 1");
if (raw_->open())
return -ENODEV;
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list