ipa: raspberrypi: Move IPA parameters to the RPi namespace

All IPA related types/params are now moved to the RPi namespace.

There are no functional changes in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Kieran: Rebase merge conflicts fixed]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2020-09-24 10:19:26 +01:00 committed by Kieran Bingham
parent 2f46dec949
commit 0e2c714024
5 changed files with 61 additions and 57 deletions

View file

@ -10,25 +10,29 @@
#include <libcamera/control_ids.h> #include <libcamera/control_ids.h>
#include <libcamera/controls.h> #include <libcamera/controls.h>
enum RPiConfigParameters { namespace libcamera {
RPI_IPA_CONFIG_LS_TABLE = (1 << 0),
RPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1), namespace RPi {
RPI_IPA_CONFIG_SENSOR = (1 << 2),
RPI_IPA_CONFIG_DROP_FRAMES = (1 << 3), enum ConfigParameters {
IPA_CONFIG_LS_TABLE = (1 << 0),
IPA_CONFIG_STAGGERED_WRITE = (1 << 1),
IPA_CONFIG_SENSOR = (1 << 2),
IPA_CONFIG_DROP_FRAMES = (1 << 3),
}; };
enum RPiOperations { enum Operations {
RPI_IPA_ACTION_V4L2_SET_STAGGERED = 1, IPA_ACTION_V4L2_SET_STAGGERED = 1,
RPI_IPA_ACTION_V4L2_SET_ISP, IPA_ACTION_V4L2_SET_ISP,
RPI_IPA_ACTION_STATS_METADATA_COMPLETE, IPA_ACTION_STATS_METADATA_COMPLETE,
RPI_IPA_ACTION_RUN_ISP, IPA_ACTION_RUN_ISP,
RPI_IPA_ACTION_EMBEDDED_COMPLETE, IPA_ACTION_EMBEDDED_COMPLETE,
RPI_IPA_EVENT_SIGNAL_STAT_READY, IPA_EVENT_SIGNAL_STAT_READY,
RPI_IPA_EVENT_SIGNAL_ISP_PREPARE, IPA_EVENT_SIGNAL_ISP_PREPARE,
RPI_IPA_EVENT_QUEUE_REQUEST, IPA_EVENT_QUEUE_REQUEST,
}; };
enum RPiBufferMask { enum BufferMask {
ID = 0x00ffff, ID = 0x00ffff,
STATS = 0x010000, STATS = 0x010000,
EMBEDDED_DATA = 0x020000, EMBEDDED_DATA = 0x020000,
@ -39,10 +43,8 @@ enum RPiBufferMask {
/* Size of the LS grid allocation. */ /* Size of the LS grid allocation. */
#define MAX_LS_GRID_SIZE (32 << 10) #define MAX_LS_GRID_SIZE (32 << 10)
namespace libcamera {
/* List of controls handled by the Raspberry Pi IPA */ /* List of controls handled by the Raspberry Pi IPA */
static const ControlInfoMap RPiControls = { static const ControlInfoMap Controls = {
{ &controls::AeEnable, ControlInfo(false, true) }, { &controls::AeEnable, ControlInfo(false, true) },
{ &controls::ExposureTime, ControlInfo(0, 999999) }, { &controls::ExposureTime, ControlInfo(0, 999999) },
{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) }, { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
@ -60,6 +62,8 @@ static const ControlInfoMap RPiControls = {
{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },
}; };
} /* namespace RPi */
} /* namespace libcamera */ } /* namespace libcamera */
#endif /* __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__ */ #endif /* __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__ */

View file

@ -224,7 +224,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,
result->data.push_back(exposureDelay); result->data.push_back(exposureDelay);
result->data.push_back(sensorMetadata); result->data.push_back(sensorMetadata);
result->operation |= RPI_IPA_CONFIG_STAGGERED_WRITE; result->operation |= RPi::IPA_CONFIG_STAGGERED_WRITE;
} }
/* Re-assemble camera mode using the sensor info. */ /* Re-assemble camera mode using the sensor info. */
@ -237,7 +237,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,
mode_.transform = static_cast<libcamera::Transform>(ipaConfig.data[0]); mode_.transform = static_cast<libcamera::Transform>(ipaConfig.data[0]);
/* Store the lens shading table pointer and handle if available. */ /* Store the lens shading table pointer and handle if available. */
if (ipaConfig.operation & RPI_IPA_CONFIG_LS_TABLE) { if (ipaConfig.operation & RPi::IPA_CONFIG_LS_TABLE) {
/* Remove any previous table, if there was one. */ /* Remove any previous table, if there was one. */
if (lsTable_) { if (lsTable_) {
munmap(lsTable_, MAX_LS_GRID_SIZE); munmap(lsTable_, MAX_LS_GRID_SIZE);
@ -277,7 +277,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,
} }
result->data.push_back(drop_frame); result->data.push_back(drop_frame);
result->operation |= RPI_IPA_CONFIG_DROP_FRAMES; result->operation |= RPi::IPA_CONFIG_DROP_FRAMES;
struct AgcStatus agcStatus; struct AgcStatus agcStatus;
/* These zero values mean not program anything (unless overwritten). */ /* These zero values mean not program anything (unless overwritten). */
@ -305,7 +305,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,
applyAGC(&agcStatus, ctrls); applyAGC(&agcStatus, ctrls);
result->controls.push_back(ctrls); result->controls.push_back(ctrls);
result->operation |= RPI_IPA_CONFIG_SENSOR; result->operation |= RPi::IPA_CONFIG_SENSOR;
} }
lastMode_ = mode_; lastMode_ = mode_;
@ -346,7 +346,7 @@ void IPARPi::unmapBuffers(const std::vector<unsigned int> &ids)
void IPARPi::processEvent(const IPAOperationData &event) void IPARPi::processEvent(const IPAOperationData &event)
{ {
switch (event.operation) { switch (event.operation) {
case RPI_IPA_EVENT_SIGNAL_STAT_READY: { case RPi::IPA_EVENT_SIGNAL_STAT_READY: {
unsigned int bufferId = event.data[0]; unsigned int bufferId = event.data[0];
if (++check_count_ != frame_count_) /* assert here? */ if (++check_count_ != frame_count_) /* assert here? */
@ -357,14 +357,14 @@ void IPARPi::processEvent(const IPAOperationData &event)
reportMetadata(); reportMetadata();
IPAOperationData op; IPAOperationData op;
op.operation = RPI_IPA_ACTION_STATS_METADATA_COMPLETE; op.operation = RPi::IPA_ACTION_STATS_METADATA_COMPLETE;
op.data = { bufferId & RPiBufferMask::ID }; op.data = { bufferId & RPi::BufferMask::ID };
op.controls = { libcameraMetadata_ }; op.controls = { libcameraMetadata_ };
queueFrameAction.emit(0, op); queueFrameAction.emit(0, op);
break; break;
} }
case RPI_IPA_EVENT_SIGNAL_ISP_PREPARE: { case RPi::IPA_EVENT_SIGNAL_ISP_PREPARE: {
unsigned int embeddedbufferId = event.data[0]; unsigned int embeddedbufferId = event.data[0];
unsigned int bayerbufferId = event.data[1]; unsigned int bayerbufferId = event.data[1];
@ -378,13 +378,13 @@ void IPARPi::processEvent(const IPAOperationData &event)
/* Ready to push the input buffer into the ISP. */ /* Ready to push the input buffer into the ISP. */
IPAOperationData op; IPAOperationData op;
op.operation = RPI_IPA_ACTION_RUN_ISP; op.operation = RPi::IPA_ACTION_RUN_ISP;
op.data = { bayerbufferId & RPiBufferMask::ID }; op.data = { bayerbufferId & RPi::BufferMask::ID };
queueFrameAction.emit(0, op); queueFrameAction.emit(0, op);
break; break;
} }
case RPI_IPA_EVENT_QUEUE_REQUEST: { case RPi::IPA_EVENT_QUEUE_REQUEST: {
queueRequest(event.controls[0]); queueRequest(event.controls[0]);
break; break;
} }
@ -705,8 +705,8 @@ void IPARPi::queueRequest(const ControlList &controls)
void IPARPi::returnEmbeddedBuffer(unsigned int bufferId) void IPARPi::returnEmbeddedBuffer(unsigned int bufferId)
{ {
IPAOperationData op; IPAOperationData op;
op.operation = RPI_IPA_ACTION_EMBEDDED_COMPLETE; op.operation = RPi::IPA_ACTION_EMBEDDED_COMPLETE;
op.data = { bufferId & RPiBufferMask::ID }; op.data = { bufferId & RPi::BufferMask::ID };
queueFrameAction.emit(0, op); queueFrameAction.emit(0, op);
} }
@ -770,7 +770,7 @@ void IPARPi::prepareISP(unsigned int bufferId)
if (!ctrls.empty()) { if (!ctrls.empty()) {
IPAOperationData op; IPAOperationData op;
op.operation = RPI_IPA_ACTION_V4L2_SET_ISP; op.operation = RPi::IPA_ACTION_V4L2_SET_ISP;
op.controls.push_back(ctrls); op.controls.push_back(ctrls);
queueFrameAction.emit(0, op); queueFrameAction.emit(0, op);
} }
@ -830,7 +830,7 @@ void IPARPi::processStats(unsigned int bufferId)
applyAGC(&agcStatus, ctrls); applyAGC(&agcStatus, ctrls);
IPAOperationData op; IPAOperationData op;
op.operation = RPI_IPA_ACTION_V4L2_SET_STAGGERED; op.operation = RPi::IPA_ACTION_V4L2_SET_STAGGERED;
op.controls.push_back(ctrls); op.controls.push_back(ctrls);
queueFrameAction.emit(0, op); queueFrameAction.emit(0, op);
} }

View file

@ -922,7 +922,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)
} }
/* Register the controls that the Raspberry Pi IPA can handle. */ /* Register the controls that the Raspberry Pi IPA can handle. */
data->controlInfo_ = RPiControls; data->controlInfo_ = RPi::Controls;
/* Initialize the camera properties. */ /* Initialize the camera properties. */
data->properties_ = data->sensor_->properties(); data->properties_ = data->sensor_->properties();
@ -1044,8 +1044,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)
* Pass the stats and embedded data buffers to the IPA. No other * Pass the stats and embedded data buffers to the IPA. No other
* buffers need to be passed. * buffers need to be passed.
*/ */
mapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), RPiBufferMask::STATS); mapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), RPi::BufferMask::STATS);
mapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), RPiBufferMask::EMBEDDED_DATA); mapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), RPi::BufferMask::EMBEDDED_DATA);
return 0; return 0;
} }
@ -1143,7 +1143,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)
return -ENOMEM; return -ENOMEM;
/* Allow the IPA to mmap the LS table via the file descriptor. */ /* Allow the IPA to mmap the LS table via the file descriptor. */
ipaConfig.operation = RPI_IPA_CONFIG_LS_TABLE; ipaConfig.operation = RPi::IPA_CONFIG_LS_TABLE;
ipaConfig.data.push_back(static_cast<unsigned int>(lsTable_.fd())); ipaConfig.data.push_back(static_cast<unsigned int>(lsTable_.fd()));
} }
@ -1161,7 +1161,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)
&result); &result);
unsigned int resultIdx = 0; unsigned int resultIdx = 0;
if (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) { if (result.operation & RPi::IPA_CONFIG_STAGGERED_WRITE) {
/* /*
* Setup our staggered control writer with the sensor default * Setup our staggered control writer with the sensor default
* gain and exposure delays. * gain and exposure delays.
@ -1187,13 +1187,13 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)
} }
} }
if (result.operation & RPI_IPA_CONFIG_SENSOR) { if (result.operation & RPi::IPA_CONFIG_SENSOR) {
const ControlList &ctrls = result.controls[0]; const ControlList &ctrls = result.controls[0];
if (!staggeredCtrl_.set(ctrls)) if (!staggeredCtrl_.set(ctrls))
LOG(RPI, Error) << "V4L2 staggered set failed"; LOG(RPI, Error) << "V4L2 staggered set failed";
} }
if (result.operation & RPI_IPA_CONFIG_DROP_FRAMES) { if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) {
/* Configure the number of dropped frames required on startup. */ /* Configure the number of dropped frames required on startup. */
dropFrameCount_ = result.data[resultIdx++]; dropFrameCount_ = result.data[resultIdx++];
} }
@ -1209,14 +1209,14 @@ void RPiCameraData::queueFrameAction([[maybe_unused]] unsigned int frame,
* a stopped state. * a stopped state.
*/ */
switch (action.operation) { switch (action.operation) {
case RPI_IPA_ACTION_V4L2_SET_STAGGERED: { case RPi::IPA_ACTION_V4L2_SET_STAGGERED: {
const ControlList &controls = action.controls[0]; const ControlList &controls = action.controls[0];
if (!staggeredCtrl_.set(controls)) if (!staggeredCtrl_.set(controls))
LOG(RPI, Error) << "V4L2 staggered set failed"; LOG(RPI, Error) << "V4L2 staggered set failed";
goto done; goto done;
} }
case RPI_IPA_ACTION_V4L2_SET_ISP: { case RPi::IPA_ACTION_V4L2_SET_ISP: {
ControlList controls = action.controls[0]; ControlList controls = action.controls[0];
isp_[Isp::Input].dev()->setControls(&controls); isp_[Isp::Input].dev()->setControls(&controls);
goto done; goto done;
@ -1231,7 +1231,7 @@ void RPiCameraData::queueFrameAction([[maybe_unused]] unsigned int frame,
* is in a stopped state. * is in a stopped state.
*/ */
switch (action.operation) { switch (action.operation) {
case RPI_IPA_ACTION_STATS_METADATA_COMPLETE: { case RPi::IPA_ACTION_STATS_METADATA_COMPLETE: {
unsigned int bufferId = action.data[0]; unsigned int bufferId = action.data[0];
FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId); FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId);
@ -1242,14 +1242,14 @@ void RPiCameraData::queueFrameAction([[maybe_unused]] unsigned int frame,
break; break;
} }
case RPI_IPA_ACTION_EMBEDDED_COMPLETE: { case RPi::IPA_ACTION_EMBEDDED_COMPLETE: {
unsigned int bufferId = action.data[0]; unsigned int bufferId = action.data[0];
FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId); FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId);
handleStreamBuffer(buffer, &unicam_[Unicam::Embedded]); handleStreamBuffer(buffer, &unicam_[Unicam::Embedded]);
break; break;
} }
case RPI_IPA_ACTION_RUN_ISP: { case RPi::IPA_ACTION_RUN_ISP: {
unsigned int bufferId = action.data[0]; unsigned int bufferId = action.data[0];
FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId); FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId);
@ -1367,8 +1367,8 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)
*/ */
if (stream == &isp_[Isp::Stats]) { if (stream == &isp_[Isp::Stats]) {
IPAOperationData op; IPAOperationData op;
op.operation = RPI_IPA_EVENT_SIGNAL_STAT_READY; op.operation = RPi::IPA_EVENT_SIGNAL_STAT_READY;
op.data = { RPiBufferMask::STATS | static_cast<unsigned int>(index) }; op.data = { RPi::BufferMask::STATS | static_cast<unsigned int>(index) };
ipa_->processEvent(op); ipa_->processEvent(op);
} else { } else {
/* Any other ISP output can be handed back to the application now. */ /* Any other ISP output can be handed back to the application now. */
@ -1473,7 +1473,7 @@ void RPiCameraData::handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *strea
{ {
unsigned int id = stream->getBufferId(buffer); unsigned int id = stream->getBufferId(buffer);
if (!(id & RPiBufferMask::EXTERNAL_BUFFER)) if (!(id & RPi::BufferMask::EXTERNAL_BUFFER))
return; return;
/* Stop the Stream object from tracking the buffer. */ /* Stop the Stream object from tracking the buffer. */
@ -1593,7 +1593,7 @@ void RPiCameraData::tryRunPipeline()
* queue the ISP output buffer listed in the request to start the HW * queue the ISP output buffer listed in the request to start the HW
* pipeline. * pipeline.
*/ */
op.operation = RPI_IPA_EVENT_QUEUE_REQUEST; op.operation = RPi::IPA_EVENT_QUEUE_REQUEST;
op.controls = { request->controls() }; op.controls = { request->controls() };
ipa_->processEvent(op); ipa_->processEvent(op);
@ -1607,13 +1607,13 @@ void RPiCameraData::tryRunPipeline()
unsigned int bayerId = unicam_[Unicam::Image].getBufferId(bayerBuffer); unsigned int bayerId = unicam_[Unicam::Image].getBufferId(bayerBuffer);
unsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer); unsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer);
LOG(RPI, Debug) << "Signalling RPI_IPA_EVENT_SIGNAL_ISP_PREPARE:" LOG(RPI, Debug) << "Signalling RPi::IPA_EVENT_SIGNAL_ISP_PREPARE:"
<< " Bayer buffer id: " << bayerId << " Bayer buffer id: " << bayerId
<< " Embedded buffer id: " << embeddedId; << " Embedded buffer id: " << embeddedId;
op.operation = RPI_IPA_EVENT_SIGNAL_ISP_PREPARE; op.operation = RPi::IPA_EVENT_SIGNAL_ISP_PREPARE;
op.data = { RPiBufferMask::EMBEDDED_DATA | embeddedId, op.data = { RPi::BufferMask::EMBEDDED_DATA | embeddedId,
RPiBufferMask::BAYER_DATA | bayerId }; RPi::BufferMask::BAYER_DATA | bayerId };
ipa_->processEvent(op); ipa_->processEvent(op);
} }

View file

@ -70,7 +70,7 @@ int Stream::getBufferId(FrameBuffer *buffer) const
void Stream::setExternalBuffer(FrameBuffer *buffer) void Stream::setExternalBuffer(FrameBuffer *buffer)
{ {
bufferMap_.emplace(RPiBufferMask::EXTERNAL_BUFFER | id_.get(), buffer); bufferMap_.emplace(RPi::BufferMask::EXTERNAL_BUFFER | id_.get(), buffer);
} }
void Stream::removeExternalBuffer(FrameBuffer *buffer) void Stream::removeExternalBuffer(FrameBuffer *buffer)
@ -78,7 +78,7 @@ void Stream::removeExternalBuffer(FrameBuffer *buffer)
int id = getBufferId(buffer); int id = getBufferId(buffer);
/* Ensure we have this buffer in the stream, and it is marked external. */ /* Ensure we have this buffer in the stream, and it is marked external. */
ASSERT(id != -1 && (id & RPiBufferMask::EXTERNAL_BUFFER)); ASSERT(id != -1 && (id & RPi::BufferMask::EXTERNAL_BUFFER));
bufferMap_.erase(id); bufferMap_.erase(id);
} }

View file

@ -31,13 +31,13 @@ class Stream : public libcamera::Stream
{ {
public: public:
Stream() Stream()
: id_(RPiBufferMask::ID) : id_(RPi::BufferMask::ID)
{ {
} }
Stream(const char *name, MediaEntity *dev, bool importOnly = false) Stream(const char *name, MediaEntity *dev, bool importOnly = false)
: external_(false), importOnly_(importOnly), name_(name), : external_(false), importOnly_(importOnly), name_(name),
dev_(std::make_unique<V4L2VideoDevice>(dev)), id_(RPiBufferMask::ID) dev_(std::make_unique<V4L2VideoDevice>(dev)), id_(RPi::BufferMask::ID)
{ {
} }