android: capabilities: Collect per-stream frame durations

Collect the per-stream frame durations while building the list
of supported stream formats and resolutions.

In order to get an updated list of controls it is necessary to apply
to the Camera the configuration we're testing, which was so far only
validated.

The per-configuration durations will be used to populate the Android
ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS static metadata.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi 2021-06-29 17:26:23 +02:00
parent 4ed22985a8
commit 56ee14e16d
2 changed files with 38 additions and 3 deletions

View file

@ -619,7 +619,32 @@ int CameraCapabilities::initializeStreamConfigurations()
}
for (const Size &res : resolutions) {
streamConfigurations_.push_back({ res, androidFormat });
/*
* Configure the Camera with the collected format and
* resolution to get an updated list of controls.
*
* \todo Avoid the need to configure the camera when
* redesigning the configuration API.
*/
cfg.size = res;
int ret = camera_->configure(cameraConfig.get());
if (ret)
return ret;
const ControlInfoMap &controls = camera_->controls();
const auto frameDurations = controls.find(
&controls::FrameDurationLimits);
if (frameDurations == controls.end()) {
LOG(HAL, Error)
<< "Camera does not report frame durations";
return -EINVAL;
}
int64_t minFrameDuration = frameDurations->second.min().get<int64_t>() * 1000;
int64_t maxFrameDuration = frameDurations->second.max().get<int64_t>() * 1000;
streamConfigurations_.push_back({
res, androidFormat, minFrameDuration, maxFrameDuration,
});
/*
* If the format is HAL_PIXEL_FORMAT_YCbCr_420_888
@ -631,10 +656,18 @@ int CameraCapabilities::initializeStreamConfigurations()
*
* \todo Support JPEG streams produced by the camera
* natively.
*
* \todo HAL_PIXEL_FORMAT_BLOB is a 'stalling' format,
* its duration should take into account the time
* required for the YUV to JPEG encoding. For now
* use the same frame durations as collected for
* the YUV/RGB streams.
*/
if (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {
streamConfigurations_.push_back(
{ res, HAL_PIXEL_FORMAT_BLOB });
streamConfigurations_.push_back({
res, HAL_PIXEL_FORMAT_BLOB,
minFrameDuration, maxFrameDuration,
});
maxJpegSize = std::max(maxJpegSize, res);
}
}

View file

@ -43,6 +43,8 @@ private:
struct Camera3StreamConfiguration {
libcamera::Size resolution;
int androidFormat;
int64_t minFrameDurationNsec;
int64_t maxFrameDurationNsec;
};
bool validateManualSensorCapability();