[libcamera-devel] [PATCH v2 12/13] libcamera: ipu3: imgu: Remove ImgUOutput
Niklas Söderlund
niklas.soderlund at ragnatech.se
Sun Jun 28 02:15:31 CEST 2020
The struct ImgUOutput now only contains one member that is in use, the
video device. Remove the struct and use the video device directly
instead.
Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
* Changes since v1
- Fix indentation
---
src/libcamera/pipeline/ipu3/imgu.cpp | 51 ++++++++++++----------------
src/libcamera/pipeline/ipu3/imgu.h | 32 ++++++-----------
src/libcamera/pipeline/ipu3/ipu3.cpp | 12 +++----
3 files changed, 38 insertions(+), 57 deletions(-)
diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp
index 981239cba975f92e..6a721d47cdacf3d6 100644
--- a/src/libcamera/pipeline/ipu3/imgu.cpp
+++ b/src/libcamera/pipeline/ipu3/imgu.cpp
@@ -54,31 +54,22 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)
if (ret)
return ret;
- output_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " output");
- ret = output_.dev->open();
+ output_ = V4L2VideoDevice::fromEntityName(media, name_ + " output");
+ ret = output_->open();
if (ret)
return ret;
- output_.pad = PAD_OUTPUT;
- output_.name = "output";
-
- viewfinder_.dev = V4L2VideoDevice::fromEntityName(media,
- name_ + " viewfinder");
- ret = viewfinder_.dev->open();
+ viewfinder_ = V4L2VideoDevice::fromEntityName(media,
+ name_ + " viewfinder");
+ ret = viewfinder_->open();
if (ret)
return ret;
- viewfinder_.pad = PAD_VF;
- viewfinder_.name = "viewfinder";
-
- stat_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat");
- ret = stat_.dev->open();
+ stat_ = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat");
+ ret = stat_->open();
if (ret)
return ret;
- stat_.pad = PAD_STAT;
- stat_.name = "stat";
-
return 0;
}
@@ -159,7 +150,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,
return ret;
/* No need to apply format to the stat node. */
- if (dev == stat_.dev)
+ if (dev == stat_)
return 0;
*outputFormat = {};
@@ -171,7 +162,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,
if (ret)
return ret;
- const char *name = dev == output_.dev ? "output" : "viewfinder";
+ const char *name = dev == output_ ? "output" : "viewfinder";
LOG(IPU3, Debug) << "ImgU " << name << " format = "
<< outputFormat->toString();
@@ -197,7 +188,7 @@ int ImgUDevice::allocateBuffers(unsigned int bufferCount)
*
* \todo To be revised when we'll actually use the stat node.
*/
- ret = stat_.dev->importBuffers(bufferCount);
+ ret = stat_->importBuffers(bufferCount);
if (ret < 0) {
LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers";
goto error;
@@ -208,13 +199,13 @@ int ImgUDevice::allocateBuffers(unsigned int bufferCount)
* corresponding stream is active or inactive, as the driver needs
* buffers to be requested on the V4L2 devices in order to operate.
*/
- ret = output_.dev->importBuffers(bufferCount);
+ ret = output_->importBuffers(bufferCount);
if (ret < 0) {
LOG(IPU3, Error) << "Failed to import ImgU output buffers";
goto error;
}
- ret = viewfinder_.dev->importBuffers(bufferCount);
+ ret = viewfinder_->importBuffers(bufferCount);
if (ret < 0) {
LOG(IPU3, Error) << "Failed to import ImgU viewfinder buffers";
goto error;
@@ -235,15 +226,15 @@ void ImgUDevice::freeBuffers()
{
int ret;
- ret = output_.dev->releaseBuffers();
+ ret = output_->releaseBuffers();
if (ret)
LOG(IPU3, Error) << "Failed to release ImgU output buffers";
- ret = stat_.dev->releaseBuffers();
+ ret = stat_->releaseBuffers();
if (ret)
LOG(IPU3, Error) << "Failed to release ImgU stat buffers";
- ret = viewfinder_.dev->releaseBuffers();
+ ret = viewfinder_->releaseBuffers();
if (ret)
LOG(IPU3, Error) << "Failed to release ImgU viewfinder buffers";
@@ -257,19 +248,19 @@ int ImgUDevice::start()
int ret;
/* Start the ImgU video devices. */
- ret = output_.dev->streamOn();
+ ret = output_->streamOn();
if (ret) {
LOG(IPU3, Error) << "Failed to start ImgU output";
return ret;
}
- ret = viewfinder_.dev->streamOn();
+ ret = viewfinder_->streamOn();
if (ret) {
LOG(IPU3, Error) << "Failed to start ImgU viewfinder";
return ret;
}
- ret = stat_.dev->streamOn();
+ ret = stat_->streamOn();
if (ret) {
LOG(IPU3, Error) << "Failed to start ImgU stat";
return ret;
@@ -288,9 +279,9 @@ int ImgUDevice::stop()
{
int ret;
- ret = output_.dev->streamOff();
- ret |= viewfinder_.dev->streamOff();
- ret |= stat_.dev->streamOff();
+ ret = output_->streamOff();
+ ret |= viewfinder_->streamOff();
+ ret |= stat_->streamOff();
ret |= input_->streamOff();
return ret;
diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h
index 5f1dbfd8f45f7924..7be25e40957fcb03 100644
--- a/src/libcamera/pipeline/ipu3/imgu.h
+++ b/src/libcamera/pipeline/ipu3/imgu.h
@@ -24,28 +24,19 @@ struct StreamConfiguration;
class ImgUDevice
{
public:
- /* ImgU output descriptor: group data specific to an ImgU output. */
- struct ImgUOutput {
- V4L2VideoDevice *dev;
- unsigned int pad;
- std::string name;
- };
-
ImgUDevice()
- : imgu_(nullptr), input_(nullptr)
+ : imgu_(nullptr), input_(nullptr), output_(nullptr),
+ viewfinder_(nullptr), stat_(nullptr)
{
- output_.dev = nullptr;
- viewfinder_.dev = nullptr;
- stat_.dev = nullptr;
}
~ImgUDevice()
{
delete imgu_;
delete input_;
- delete output_.dev;
- delete viewfinder_.dev;
- delete stat_.dev;
+ delete output_;
+ delete viewfinder_;
+ delete stat_;
}
int init(MediaDevice *media, unsigned int index);
@@ -55,22 +46,21 @@ public:
int configureOutput(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat)
{
- return configureVideoDevice(output_.dev, PAD_OUTPUT, cfg,
+ return configureVideoDevice(output_, PAD_OUTPUT, cfg,
outputFormat);
}
int configureViewfinder(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat)
{
- return configureVideoDevice(viewfinder_.dev, PAD_VF, cfg,
+ return configureVideoDevice(viewfinder_, PAD_VF, cfg,
outputFormat);
}
int configureStat(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat)
{
- return configureVideoDevice(stat_.dev, PAD_STAT, cfg,
- outputFormat);
+ return configureVideoDevice(stat_, PAD_STAT, cfg, outputFormat);
}
int allocateBuffers(unsigned int bufferCount);
@@ -83,9 +73,9 @@ public:
V4L2Subdevice *imgu_;
V4L2VideoDevice *input_;
- ImgUOutput output_;
- ImgUOutput viewfinder_;
- ImgUOutput stat_;
+ V4L2VideoDevice *output_;
+ V4L2VideoDevice *viewfinder_;
+ V4L2VideoDevice *stat_;
/* \todo Add param video device for 3A tuning */
private:
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 4e997c529153662c..7d9fca320d608a0e 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -563,9 +563,9 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,
unsigned int count = stream->configuration().bufferCount;
if (stream == &data->outStream_)
- return data->imgu_->output_.dev->exportBuffers(count, buffers);
+ return data->imgu_->output_->exportBuffers(count, buffers);
else if (stream == &data->vfStream_)
- return data->imgu_->viewfinder_.dev->exportBuffers(count, buffers);
+ return data->imgu_->viewfinder_->exportBuffers(count, buffers);
else if (stream == &data->rawStream_)
return data->cio2_.exportBuffers(count, buffers);
@@ -683,9 +683,9 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)
int ret = 0;
if (stream == &data->outStream_)
- ret = data->imgu_->output_.dev->queueBuffer(buffer);
+ ret = data->imgu_->output_->queueBuffer(buffer);
else if (stream == &data->vfStream_)
- ret = data->imgu_->viewfinder_.dev->queueBuffer(buffer);
+ ret = data->imgu_->viewfinder_->queueBuffer(buffer);
if (ret < 0)
error = ret;
@@ -811,9 +811,9 @@ int PipelineHandlerIPU3::registerCameras()
&IPU3CameraData::cio2BufferReady);
data->imgu_->input_->bufferReady.connect(&data->cio2_,
&CIO2Device::tryReturnBuffer);
- data->imgu_->output_.dev->bufferReady.connect(data.get(),
+ data->imgu_->output_->bufferReady.connect(data.get(),
&IPU3CameraData::imguOutputBufferReady);
- data->imgu_->viewfinder_.dev->bufferReady.connect(data.get(),
+ data->imgu_->viewfinder_->bufferReady.connect(data.get(),
&IPU3CameraData::imguOutputBufferReady);
/* Create and register the Camera instance. */
--
2.27.0
More information about the libcamera-devel
mailing list