pipeline: rkisp1: Properly handle the bufferCount set in the stream configuration
The StreamConfiguration::bufferCount is reset to a hardcoded value of 4 in RkISP1Path::validate(). Keep the minimum value of 4 but do not reset it, if it was set to a larger value. This allows the user to set bufferCount to an arbitrary number of buffers which then can be allocated for example by the FrameBufferAllocator. If the bufferCount is set to a smaller value it gets reset to kRkISP1MinBufferCount again and the configuration is marked as adjusted. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Tested-by: Sven Püschel <s.pueschel@pengutronix.de> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <uajain@igalia.com>
This commit is contained in:
@@ -165,6 +165,8 @@ namespace {
|
||||
*/
|
||||
static constexpr unsigned int kRkISP1MaxQueuedRequests = 4;
|
||||
|
||||
static constexpr unsigned int kRkISP1MinBufferCount = 4;
|
||||
|
||||
} /* namespace */
|
||||
|
||||
class PipelineHandlerRkISP1 : public PipelineHandler
|
||||
@@ -608,6 +610,12 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tryCfg.bufferCount < kRkISP1MinBufferCount) {
|
||||
if (expectedStatus == Valid)
|
||||
return false;
|
||||
tryCfg.bufferCount = kRkISP1MinBufferCount;
|
||||
}
|
||||
|
||||
cfg = tryCfg;
|
||||
cfg.setStream(stream);
|
||||
return true;
|
||||
@@ -797,6 +805,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
|
||||
return nullptr;
|
||||
|
||||
cfg.colorSpace = colorSpace;
|
||||
cfg.bufferCount = kRkISP1MinBufferCount;
|
||||
config->addConfiguration(cfg);
|
||||
}
|
||||
|
||||
@@ -1130,14 +1139,14 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL
|
||||
}
|
||||
|
||||
if (data->mainPath_->isEnabled()) {
|
||||
ret = mainPath_.start();
|
||||
ret = mainPath_.start(data->mainPathStream_.configuration().bufferCount);
|
||||
if (ret)
|
||||
return ret;
|
||||
actions += [&]() { mainPath_.stop(); };
|
||||
}
|
||||
|
||||
if (hasSelfPath_ && data->selfPath_->isEnabled()) {
|
||||
ret = selfPath_.start();
|
||||
ret = selfPath_.start(data->selfPathStream_.configuration().bufferCount);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,6 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,
|
||||
StreamConfiguration cfg(formats);
|
||||
cfg.pixelFormat = format;
|
||||
cfg.size = streamSize;
|
||||
cfg.bufferCount = RKISP1_BUFFER_COUNT;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
@@ -383,7 +382,6 @@ RkISP1Path::validate(const CameraSensor *sensor,
|
||||
|
||||
cfg->size.boundTo(maxResolution);
|
||||
cfg->size.expandTo(minResolution);
|
||||
cfg->bufferCount = RKISP1_BUFFER_COUNT;
|
||||
|
||||
V4L2DeviceFormat format;
|
||||
format.fourcc = video_->toV4L2PixelFormat(cfg->pixelFormat);
|
||||
@@ -480,15 +478,14 @@ int RkISP1Path::configure(const StreamConfiguration &config,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RkISP1Path::start()
|
||||
int RkISP1Path::start(unsigned int bufferCount)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (running_)
|
||||
return -EBUSY;
|
||||
|
||||
/* \todo Make buffer count user configurable. */
|
||||
ret = video_->importBuffers(RKISP1_BUFFER_COUNT);
|
||||
ret = video_->importBuffers(bufferCount);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
return video_->exportBuffers(bufferCount, buffers);
|
||||
}
|
||||
|
||||
int start();
|
||||
int start(unsigned int bufferCount);
|
||||
void stop();
|
||||
|
||||
int queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }
|
||||
@@ -69,8 +69,6 @@ private:
|
||||
void populateFormats();
|
||||
Size filterSensorResolution(const CameraSensor *sensor);
|
||||
|
||||
static constexpr unsigned int RKISP1_BUFFER_COUNT = 4;
|
||||
|
||||
const char *name_;
|
||||
bool running_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user