summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libcamera/pipeline/ipu3/imgu.cpp17
-rw-r--r--src/libcamera/pipeline/ipu3/imgu.h33
2 files changed, 19 insertions, 31 deletions
diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp
index c4bb6100..d7f4173d 100644
--- a/src/libcamera/pipeline/ipu3/imgu.cpp
+++ b/src/libcamera/pipeline/ipu3/imgu.cpp
@@ -44,28 +44,29 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)
* by the match() function: no need to check for newly created
* video devices and subdevice validity here.
*/
- imgu_ = V4L2Subdevice::fromEntityName(media, name_);
+ imgu_.reset(V4L2Subdevice::fromEntityName(media, name_));
ret = imgu_->open();
if (ret)
return ret;
- input_ = V4L2VideoDevice::fromEntityName(media, name_ + " input");
+ input_.reset(V4L2VideoDevice::fromEntityName(media, name_ + " input"));
ret = input_->open();
if (ret)
return ret;
- output_ = V4L2VideoDevice::fromEntityName(media, name_ + " output");
+ output_.reset(V4L2VideoDevice::fromEntityName(media,
+ name_ + " output"));
ret = output_->open();
if (ret)
return ret;
- viewfinder_ = V4L2VideoDevice::fromEntityName(media,
- name_ + " viewfinder");
+ viewfinder_.reset(V4L2VideoDevice::fromEntityName(media,
+ name_ + " viewfinder"));
ret = viewfinder_->open();
if (ret)
return ret;
- stat_ = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat");
+ stat_.reset(V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat"));
ret = stat_->open();
if (ret)
return ret;
@@ -150,7 +151,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,
return ret;
/* No need to apply format to the stat node. */
- if (dev == stat_)
+ if (dev == stat_.get())
return 0;
*outputFormat = {};
@@ -162,7 +163,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,
if (ret)
return ret;
- const char *name = dev == output_ ? "output" : "viewfinder";
+ const char *name = dev == output_.get() ? "output" : "viewfinder";
LOG(IPU3, Debug) << "ImgU " << name << " format = "
<< outputFormat->toString();
diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h
index 66146911..5c124af2 100644
--- a/src/libcamera/pipeline/ipu3/imgu.h
+++ b/src/libcamera/pipeline/ipu3/imgu.h
@@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_PIPELINE_IPU3_IMGU_H__
#define __LIBCAMERA_PIPELINE_IPU3_IMGU_H__
+#include <memory>
#include <string>
#include "libcamera/internal/v4l2_subdevice.h"
@@ -22,21 +23,6 @@ struct StreamConfiguration;
class ImgUDevice
{
public:
- ImgUDevice()
- : imgu_(nullptr), input_(nullptr), output_(nullptr),
- viewfinder_(nullptr), stat_(nullptr)
- {
- }
-
- ~ImgUDevice()
- {
- delete imgu_;
- delete input_;
- delete output_;
- delete viewfinder_;
- delete stat_;
- }
-
int init(MediaDevice *media, unsigned int index);
int configureInput(const Size &size, V4L2DeviceFormat *inputFormat);
@@ -44,21 +30,22 @@ public:
int configureOutput(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat)
{
- return configureVideoDevice(output_, PAD_OUTPUT, cfg,
+ return configureVideoDevice(output_.get(), PAD_OUTPUT, cfg,
outputFormat);
}
int configureViewfinder(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat)
{
- return configureVideoDevice(viewfinder_, PAD_VF, cfg,
+ return configureVideoDevice(viewfinder_.get(), PAD_VF, cfg,
outputFormat);
}
int configureStat(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat)
{
- return configureVideoDevice(stat_, PAD_STAT, cfg, outputFormat);
+ return configureVideoDevice(stat_.get(), PAD_STAT, cfg,
+ outputFormat);
}
int allocateBuffers(unsigned int bufferCount);
@@ -69,11 +56,11 @@ public:
int enableLinks(bool enable);
- V4L2Subdevice *imgu_;
- V4L2VideoDevice *input_;
- V4L2VideoDevice *output_;
- V4L2VideoDevice *viewfinder_;
- V4L2VideoDevice *stat_;
+ std::unique_ptr<V4L2Subdevice> imgu_;
+ std::unique_ptr<V4L2VideoDevice> input_;
+ std::unique_ptr<V4L2VideoDevice> output_;
+ std::unique_ptr<V4L2VideoDevice> viewfinder_;
+ std::unique_ptr<V4L2VideoDevice> stat_;
/* \todo Add param video device for 3A tuning */
private: