Message ID | 20210827120757.110615-5-jacopo@jmondi.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, On Fri, Aug 27, 2021 at 02:07:45PM +0200, Jacopo Mondi wrote: > 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> Looks good to me. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > src/android/camera_capabilities.cpp | 36 ++++++++++++++++++++++++++--- > src/android/camera_capabilities.h | 2 ++ > 2 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp > index c16e755f4695..fdda90379ce2 100644 > --- a/src/android/camera_capabilities.cpp > +++ b/src/android/camera_capabilities.cpp > @@ -608,7 +608,29 @@ 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. > + */ > + 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 > @@ -620,10 +642,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); > } > } > diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h > index a12596993ee5..6e55ddab445e 100644 > --- a/src/android/camera_capabilities.h > +++ b/src/android/camera_capabilities.h > @@ -43,6 +43,8 @@ private: > struct Camera3StreamConfiguration { > libcamera::Size resolution; > int androidFormat; > + int64_t minFrameDurationNsec; > + int64_t maxFrameDurationNsec; > }; > > bool validateManualSensorCapability(); > -- > 2.32.0 >
Hi Jacopo, On 8/27/21 5:37 PM, Jacopo Mondi wrote: > 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: Umang Jain <umang.jain@ideasonboard.com> > --- > src/android/camera_capabilities.cpp | 36 ++++++++++++++++++++++++++--- > src/android/camera_capabilities.h | 2 ++ > 2 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp > index c16e755f4695..fdda90379ce2 100644 > --- a/src/android/camera_capabilities.cpp > +++ b/src/android/camera_capabilities.cpp > @@ -608,7 +608,29 @@ 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. > + */ > + 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 > @@ -620,10 +642,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); > } > } > diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h > index a12596993ee5..6e55ddab445e 100644 > --- a/src/android/camera_capabilities.h > +++ b/src/android/camera_capabilities.h > @@ -43,6 +43,8 @@ private: > struct Camera3StreamConfiguration { > libcamera::Size resolution; > int androidFormat; > + int64_t minFrameDurationNsec; > + int64_t maxFrameDurationNsec; > }; > > bool validateManualSensorCapability();
diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index c16e755f4695..fdda90379ce2 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -608,7 +608,29 @@ 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. + */ + 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 @@ -620,10 +642,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); } } diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index a12596993ee5..6e55ddab445e 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -43,6 +43,8 @@ private: struct Camera3StreamConfiguration { libcamera::Size resolution; int androidFormat; + int64_t minFrameDurationNsec; + int64_t maxFrameDurationNsec; }; bool validateManualSensorCapability();
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> --- src/android/camera_capabilities.cpp | 36 ++++++++++++++++++++++++++--- src/android/camera_capabilities.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-)