libcamera: pipeline: raspberrypi: Pass the drop frame count in start, not configure
The number of frames to drop (not display) is passed back now from the start method, not configure. This means applications have a chance to set fixed exposure/gain before starting the camera and this can affect the frame drop count that is returned. Note how we need to be able to tell the very first time we start the camera from subsequent restarts, hence addition of the "firstStart_" flag. Both the IPA implementation file and the pipeline handler need matching modifications. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
a93775cab6
commit
10bcc51ca3
2 changed files with 38 additions and 32 deletions
|
@ -67,7 +67,7 @@ public:
|
||||||
IPARPi()
|
IPARPi()
|
||||||
: lastMode_({}), controller_(), controllerInit_(false),
|
: lastMode_({}), controller_(), controllerInit_(false),
|
||||||
frameCount_(0), checkCount_(0), mistrustCount_(0),
|
frameCount_(0), checkCount_(0), mistrustCount_(0),
|
||||||
lsTable_(nullptr)
|
lsTable_(nullptr), firstStart_(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,9 @@ private:
|
||||||
/* LS table allocation passed in from the pipeline handler. */
|
/* LS table allocation passed in from the pipeline handler. */
|
||||||
FileDescriptor lsTableHandle_;
|
FileDescriptor lsTableHandle_;
|
||||||
void *lsTable_;
|
void *lsTable_;
|
||||||
|
|
||||||
|
/* Distinguish the first camera start from others. */
|
||||||
|
bool firstStart_;
|
||||||
};
|
};
|
||||||
|
|
||||||
int IPARPi::init(const IPASettings &settings)
|
int IPARPi::init(const IPASettings &settings)
|
||||||
|
@ -180,6 +183,27 @@ int IPARPi::start(const IPAOperationData &data, IPAOperationData *result)
|
||||||
result->operation |= RPi::IPA_CONFIG_SENSOR;
|
result->operation |= RPi::IPA_CONFIG_SENSOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise frame counts, and decide how many frames must be hidden or
|
||||||
|
* "mistrusted", which depends on whether this is a startup from cold,
|
||||||
|
* or merely a mode switch in a running system.
|
||||||
|
*/
|
||||||
|
frameCount_ = 0;
|
||||||
|
checkCount_ = 0;
|
||||||
|
unsigned int dropFrame = 0;
|
||||||
|
if (firstStart_) {
|
||||||
|
dropFrame = helper_->HideFramesStartup();
|
||||||
|
mistrustCount_ = helper_->MistrustFramesStartup();
|
||||||
|
} else {
|
||||||
|
dropFrame = helper_->HideFramesModeSwitch();
|
||||||
|
mistrustCount_ = helper_->MistrustFramesModeSwitch();
|
||||||
|
}
|
||||||
|
|
||||||
|
result->data.push_back(dropFrame);
|
||||||
|
result->operation |= RPi::IPA_CONFIG_DROP_FRAMES;
|
||||||
|
|
||||||
|
firstStart_ = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,25 +329,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,
|
||||||
/* Pass the camera mode to the CamHelper to setup algorithms. */
|
/* Pass the camera mode to the CamHelper to setup algorithms. */
|
||||||
helper_->SetCameraMode(mode_);
|
helper_->SetCameraMode(mode_);
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialise frame counts, and decide how many frames must be hidden or
|
|
||||||
*"mistrusted", which depends on whether this is a startup from cold,
|
|
||||||
* or merely a mode switch in a running system.
|
|
||||||
*/
|
|
||||||
frameCount_ = 0;
|
|
||||||
checkCount_ = 0;
|
|
||||||
unsigned int dropFrame = 0;
|
|
||||||
if (controllerInit_) {
|
|
||||||
dropFrame = helper_->HideFramesModeSwitch();
|
|
||||||
mistrustCount_ = helper_->MistrustFramesModeSwitch();
|
|
||||||
} else {
|
|
||||||
dropFrame = helper_->HideFramesStartup();
|
|
||||||
mistrustCount_ = helper_->MistrustFramesStartup();
|
|
||||||
}
|
|
||||||
|
|
||||||
result->data.push_back(dropFrame);
|
|
||||||
result->operation |= RPi::IPA_CONFIG_DROP_FRAMES;
|
|
||||||
|
|
||||||
if (!controllerInit_) {
|
if (!controllerInit_) {
|
||||||
/* Load the tuning file for this sensor. */
|
/* Load the tuning file for this sensor. */
|
||||||
controller_.Read(tuningFile_.c_str());
|
controller_.Read(tuningFile_.c_str());
|
||||||
|
|
|
@ -745,13 +745,6 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = queueAllBuffers(camera);
|
|
||||||
if (ret) {
|
|
||||||
LOG(RPI, Error) << "Failed to queue buffers";
|
|
||||||
stop(camera);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if a ScalerCrop control was specified. */
|
/* Check if a ScalerCrop control was specified. */
|
||||||
if (controls)
|
if (controls)
|
||||||
data->applyScalerCrop(*controls);
|
data->applyScalerCrop(*controls);
|
||||||
|
@ -779,6 +772,19 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont
|
||||||
LOG(RPI, Error) << "V4L2 staggered set failed";
|
LOG(RPI, Error) << "V4L2 staggered set failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) {
|
||||||
|
/* Configure the number of dropped frames required on startup. */
|
||||||
|
data->dropFrameCount_ = result.data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We need to set the dropFrameCount_ before queueing buffers. */
|
||||||
|
ret = queueAllBuffers(camera);
|
||||||
|
if (ret) {
|
||||||
|
LOG(RPI, Error) << "Failed to queue buffers";
|
||||||
|
stop(camera);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IPA configure may have changed the sensor flips - hence the bayer
|
* IPA configure may have changed the sensor flips - hence the bayer
|
||||||
* order. Get the sensor format and set the ISP input now.
|
* order. Get the sensor format and set the ISP input now.
|
||||||
|
@ -1237,11 +1243,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)
|
||||||
LOG(RPI, Error) << "V4L2 staggered set failed";
|
LOG(RPI, Error) << "V4L2 staggered set failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) {
|
|
||||||
/* Configure the number of dropped frames required on startup. */
|
|
||||||
dropFrameCount_ = result.data[resultIdx++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure the H/V flip controls based on the combination of
|
* Configure the H/V flip controls based on the combination of
|
||||||
* the sensor and user transform.
|
* the sensor and user transform.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue