libcamera: ipu3: Validate the pipe configuration

Collect the desired ImgU pipe configuration while assigning
streams in the pipeline handler validate() function and ask the
ImgUDevice class to calculate the pipe configuration parameters.

If the requested pipe configuration results in a non-valid
configuration, return an error from the validate() function.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi
2020-07-08 14:26:52 +02:00
parent 968ab9bad0
commit 4ecbd0ea5a

View File

@@ -77,6 +77,7 @@ private:
const IPU3CameraData *data_;
StreamConfiguration cio2Configuration_;
ImgUDevice::PipeConfig pipeConfig_;
};
class PipelineHandlerIPU3 : public PipelineHandler
@@ -189,6 +190,9 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
LOG(IPU3, Debug) << "CIO2 configuration: " << cio2Configuration_.toString();
ImgUDevice::Pipe pipe{};
pipe.input = cio2Configuration_.size;
/*
* Adjust the configurations if needed and assign streams while
* iterating them.
@@ -263,10 +267,15 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
cfg->setStream(const_cast<Stream *>(&data_->outStream_));
mainOutputAvailable = false;
pipe.main = cfg->size;
if (yuvCount == 1)
pipe.viewfinder = pipe.main;
LOG(IPU3, Debug) << "Assigned " << cfg->toString()
<< " to the main output";
} else {
cfg->setStream(const_cast<Stream *>(&data_->vfStream_));
pipe.viewfinder = cfg->size;
LOG(IPU3, Debug) << "Assigned " << cfg->toString()
<< " to the viewfinder output";
@@ -282,6 +291,16 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
}
}
/* Only compute the ImgU configuration if a YUV stream has been requested. */
if (yuvCount) {
pipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe);
if (pipeConfig_.isNull()) {
LOG(IPU3, Error) << "Failed to calculate pipe configuration: "
<< "unsupported resolutions.";
return Invalid;
}
}
return status;
}