[libcamera-devel] [RFC PATCH v2 4/5] libcamera: CameraSensor: Attach available test pattern modes
Kieran Bingham
kieran.bingham at ideasonboard.com
Tue Apr 13 23:19:52 CEST 2021
Hi Hiro
On 13/04/2021 08:50, Hirokazu Honda wrote:
> This add available test pattern modes to libcamera to
> CameraSensorInfo.
>
> Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
> ---
> include/libcamera/internal/camera_sensor.h | 2 ++
> src/libcamera/camera_sensor.cpp | 38 ++++++++++++++++++++++
> 2 files changed, 40 insertions(+)
>
> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
> index 3fa3a419..75b884db 100644
> --- a/include/libcamera/internal/camera_sensor.h
> +++ b/include/libcamera/internal/camera_sensor.h
> @@ -38,6 +38,8 @@ struct CameraSensorInfo {
>
> uint32_t minFrameLength;
> uint32_t maxFrameLength;
> +
> + std::vector<int32_t> availableTestPatternModes;
> };
>
> class CameraSensor : protected Loggable
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index c012385f..81d6af44 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -840,6 +840,44 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
> info->minFrameLength = info->outputSize.height + vblank.min().get<int32_t>();
> info->maxFrameLength = info->outputSize.height + vblank.max().get<int32_t>();
>
> + const SensorInfo *staticInfo = SensorDatabase::get(model_);
> + if (!staticInfo) {
> + LOG(CameraSensor, Warning)
> + << "No static properties available for '" << model_ << "'";
> + LOG(CameraSensor, Warning)
> + << "Please consider updating the sensor database";
> + return -EINVAL;
> + }
> +
> + const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);
> + if (v4l2TestPattern == controls().end()) {
> + LOG(CameraSensor, Error) << "No static test pattern map for \'"
> + << model() << "\'";
Is this an error? Do all sensors have to provide a test pattern?
(Maybe they do provide them, but is it a requirement?)
> + return 0;
> + }
> +
> + for (const ControlValue &value : v4l2TestPattern->second.values()) {
> + const ControlMenu &menu = value.get<ControlMenu>();
> + ASSERT(menu.isName);
> +
> + int32_t matchedTestPattern = -1;
> + for (const auto &[name, testPattern] : staticInfo->testPatternModeMap) {
> + if (strcmp(menu.name, name) == 0) {
> + matchedTestPattern = testPattern;
> + break;
> + }
> + }
> +
> + if (matchedTestPattern != -1) {
> + LOG(CameraSensor, Debug) << "Test pattern mode named \'"
> + << menu.name << "\' added";
> + info->availableTestPatternModes.push_back(matchedTestPattern);
> + } else {
> + LOG(CameraSensor, Debug) << "Test pattern mode named \'"
> + << menu.name << "\' ignored";
> + }
> + }
> +
> return 0;
> }
>
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list