libcamera: ipu3: cio2: Make the V4L2 devices private
In order to make the CIO2 easier to extend with new features make the V4L2 devices (sensor, CIO2 and video device) private members. This requires a few helper functions to be added to allow for the IPU3 driver to still be able to interact with all parts of the CIO2. These helper functions will later be extended to add new features to the IPU3 pipeline. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
d2c94456d9
commit
bb82835bc5
3 changed files with 41 additions and 15 deletions
|
@ -33,7 +33,7 @@ static const std::map<uint32_t, PixelFormat> mbusCodesToInfo = {
|
||||||
} /* namespace */
|
} /* namespace */
|
||||||
|
|
||||||
CIO2Device::CIO2Device()
|
CIO2Device::CIO2Device()
|
||||||
: output_(nullptr), csi2_(nullptr), sensor_(nullptr)
|
: sensor_(nullptr), csi2_(nullptr), output_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
output_->bufferReady.connect(this, &CIO2Device::cio2BufferReady);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +228,12 @@ int CIO2Device::allocateBuffers()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIO2Device::exportBuffers(unsigned int count,
|
||||||
|
std::vector<std::unique_ptr<FrameBuffer>> *buffers)
|
||||||
|
{
|
||||||
|
return output_->exportBuffers(count, buffers);
|
||||||
|
}
|
||||||
|
|
||||||
void CIO2Device::freeBuffers()
|
void CIO2Device::freeBuffers()
|
||||||
{
|
{
|
||||||
/* The default std::queue constructor is explicit with gcc 5 and 6. */
|
/* The default std::queue constructor is explicit with gcc 5 and 6. */
|
||||||
|
@ -266,4 +274,14 @@ int CIO2Device::stop()
|
||||||
return output_->streamOff();
|
return output_->streamOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIO2Device::queueBuffer(FrameBuffer *buffer)
|
||||||
|
{
|
||||||
|
return output_->queueBuffer(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CIO2Device::cio2BufferReady(FrameBuffer *buffer)
|
||||||
|
{
|
||||||
|
bufferReady.emit(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <libcamera/signal.h>
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
class CameraSensor;
|
class CameraSensor;
|
||||||
|
@ -36,6 +38,8 @@ public:
|
||||||
StreamConfiguration generateConfiguration(Size size) const;
|
StreamConfiguration generateConfiguration(Size size) const;
|
||||||
|
|
||||||
int allocateBuffers();
|
int allocateBuffers();
|
||||||
|
int exportBuffers(unsigned int count,
|
||||||
|
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
|
||||||
void freeBuffers();
|
void freeBuffers();
|
||||||
|
|
||||||
FrameBuffer *getBuffer();
|
FrameBuffer *getBuffer();
|
||||||
|
@ -44,11 +48,18 @@ public:
|
||||||
int start();
|
int start();
|
||||||
int stop();
|
int stop();
|
||||||
|
|
||||||
V4L2VideoDevice *output_;
|
CameraSensor *sensor() { return sensor_; }
|
||||||
V4L2Subdevice *csi2_;
|
|
||||||
CameraSensor *sensor_;
|
int queueBuffer(FrameBuffer *buffer);
|
||||||
|
Signal<FrameBuffer *> bufferReady;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void cio2BufferReady(FrameBuffer *buffer);
|
||||||
|
|
||||||
|
CameraSensor *sensor_;
|
||||||
|
V4L2Subdevice *csi2_;
|
||||||
|
V4L2VideoDevice *output_;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<FrameBuffer>> buffers_;
|
std::vector<std::unique_ptr<FrameBuffer>> buffers_;
|
||||||
std::queue<FrameBuffer *> availableBuffers_;
|
std::queue<FrameBuffer *> availableBuffers_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -431,7 +431,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
|
||||||
|
|
||||||
stream = &data->rawStream_;
|
stream = &data->rawStream_;
|
||||||
|
|
||||||
cfg.size = data->cio2_.sensor_->resolution();
|
cfg.size = data->cio2_.sensor()->resolution();
|
||||||
|
|
||||||
cfg = data->cio2_.generateConfiguration(cfg.size);
|
cfg = data->cio2_.generateConfiguration(cfg.size);
|
||||||
break;
|
break;
|
||||||
|
@ -460,7 +460,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
|
||||||
* available sensor resolution and to the IPU3
|
* available sensor resolution and to the IPU3
|
||||||
* alignment constraints.
|
* alignment constraints.
|
||||||
*/
|
*/
|
||||||
const Size &res = data->cio2_.sensor_->resolution();
|
const Size &res = data->cio2_.sensor()->resolution();
|
||||||
unsigned int width = std::min(1280U, res.width);
|
unsigned int width = std::min(1280U, res.width);
|
||||||
unsigned int height = std::min(720U, res.height);
|
unsigned int height = std::min(720U, res.height);
|
||||||
cfg.size = { width & ~7, height & ~3 };
|
cfg.size = { width & ~7, height & ~3 };
|
||||||
|
@ -640,14 +640,11 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,
|
||||||
IPU3CameraData *data = cameraData(camera);
|
IPU3CameraData *data = cameraData(camera);
|
||||||
IPU3Stream *ipu3stream = static_cast<IPU3Stream *>(stream);
|
IPU3Stream *ipu3stream = static_cast<IPU3Stream *>(stream);
|
||||||
unsigned int count = stream->configuration().bufferCount;
|
unsigned int count = stream->configuration().bufferCount;
|
||||||
V4L2VideoDevice *video;
|
|
||||||
|
|
||||||
if (ipu3stream->raw_)
|
if (ipu3stream->raw_)
|
||||||
video = data->cio2_.output_;
|
return data->cio2_.exportBuffers(count, buffers);
|
||||||
else
|
|
||||||
video = ipu3stream->device_->dev;
|
|
||||||
|
|
||||||
return video->exportBuffers(count, buffers);
|
return ipu3stream->device_->dev->exportBuffers(count, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -757,7 +754,7 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
buffer->setRequest(request);
|
buffer->setRequest(request);
|
||||||
data->cio2_.output_->queueBuffer(buffer);
|
data->cio2_.queueBuffer(buffer);
|
||||||
|
|
||||||
for (auto it : request->buffers()) {
|
for (auto it : request->buffers()) {
|
||||||
IPU3Stream *stream = static_cast<IPU3Stream *>(it.first);
|
IPU3Stream *stream = static_cast<IPU3Stream *>(it.first);
|
||||||
|
@ -870,7 +867,7 @@ int PipelineHandlerIPU3::registerCameras()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Initialize the camera properties. */
|
/* Initialize the camera properties. */
|
||||||
data->properties_ = cio2->sensor_->properties();
|
data->properties_ = cio2->sensor()->properties();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \todo Dynamically assign ImgU and output devices to each
|
* \todo Dynamically assign ImgU and output devices to each
|
||||||
|
@ -894,7 +891,7 @@ int PipelineHandlerIPU3::registerCameras()
|
||||||
* associated ImgU input where they get processed and
|
* associated ImgU input where they get processed and
|
||||||
* returned through the ImgU main and secondary outputs.
|
* returned through the ImgU main and secondary outputs.
|
||||||
*/
|
*/
|
||||||
data->cio2_.output_->bufferReady.connect(data.get(),
|
data->cio2_.bufferReady.connect(data.get(),
|
||||||
&IPU3CameraData::cio2BufferReady);
|
&IPU3CameraData::cio2BufferReady);
|
||||||
data->imgu_->input_->bufferReady.connect(data.get(),
|
data->imgu_->input_->bufferReady.connect(data.get(),
|
||||||
&IPU3CameraData::imguInputBufferReady);
|
&IPU3CameraData::imguInputBufferReady);
|
||||||
|
@ -904,7 +901,7 @@ int PipelineHandlerIPU3::registerCameras()
|
||||||
&IPU3CameraData::imguOutputBufferReady);
|
&IPU3CameraData::imguOutputBufferReady);
|
||||||
|
|
||||||
/* Create and register the Camera instance. */
|
/* Create and register the Camera instance. */
|
||||||
std::string cameraName = cio2->sensor_->entity()->name();
|
std::string cameraName = cio2->sensor()->entity()->name();
|
||||||
std::shared_ptr<Camera> camera = Camera::create(this,
|
std::shared_ptr<Camera> camera = Camera::create(this,
|
||||||
cameraName,
|
cameraName,
|
||||||
streams);
|
streams);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue