libcamera: camera: Zero streams before validate()

The current implementation of the Camera::configure() method zeroes the
stream pointers assigned to the StreamConfiguration items before calling
the pipeline handler configure() operation, just after the
CameraConfiguration has been validated.

This discards the stream assignment performed at pipeline hander
validation time, requiring platforms that need to perform that early
assignment to maintain the association in place with custom data
structures.

To allow pipeline handlers to use StreamConfiguration::setStream() at
validate() time, zero the stream assignment before calling validate().

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-07 16:25:34 +02:00
parent 117e65cef2
commit 4217c9f1aa

View file

@ -753,6 +753,9 @@ int Camera::configure(CameraConfiguration *config)
if (ret < 0) if (ret < 0)
return ret; return ret;
for (auto it : *config)
it.setStream(nullptr);
if (config->validate() != CameraConfiguration::Valid) { if (config->validate() != CameraConfiguration::Valid) {
LOG(Camera, Error) LOG(Camera, Error)
<< "Can't configure camera with invalid configuration"; << "Can't configure camera with invalid configuration";
@ -763,7 +766,6 @@ int Camera::configure(CameraConfiguration *config)
for (unsigned int index = 0; index < config->size(); ++index) { for (unsigned int index = 0; index < config->size(); ++index) {
StreamConfiguration &cfg = config->at(index); StreamConfiguration &cfg = config->at(index);
cfg.setStream(nullptr);
msg << " (" << index << ") " << cfg.toString(); msg << " (" << index << ") " << cfg.toString();
} }