summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-09 13:40:11 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-14 15:46:03 +0200
commit1c2b54a0173f5ad6d792617246439ec1823bab5a (patch)
tree8efe06afe134bbd5ea9def9f7997dab3b89b08dc
parentcd4636c14fff91a3f729918d96d76e2dae095b91 (diff)
libcamera: pipeline: vimc: Use V4L2*::fromEntityName() where possible
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@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/vimc/vimc.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index 2a5054a8..72256f5b 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;