libcamera: src/ipa/ipu3/algorithms/af.h Source File

libcamera v0.3.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
af.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2021, Red Hat
4 *
5 * IPU3 Af algorithm
6 */
7
8#pragma once
9
10#include <linux/intel-ipu3.h>
11
12#include <libcamera/base/utils.h>
13
14#include <libcamera/geometry.h>
15
16#include "algorithm.h"
17
18namespace libcamera {
19
20namespace ipa::ipu3::algorithms {
21
22 class Af : public Algorithm
23{
24 /* The format of y_table. From ipu3-ipa repo */
25 typedef struct __attribute__((packed)) y_table_item {
26 uint16_t y1_avg;
27 uint16_t y2_avg;
28 } y_table_item_t;
29public:
30 Af();
31 ~Af() = default;
32
33 int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
34 void prepare(IPAContext &context, const uint32_t frame,
35 IPAFrameContext &frameContext,
36 ipu3_uapi_params *params) override;
37 void process(IPAContext &context, const uint32_t frame,
38 IPAFrameContext &frameContext,
39 const ipu3_uapi_stats_3a *stats,
40 ControlList &metadata) override;
41
42private:
43 void afCoarseScan(IPAContext &context);
44 void afFineScan(IPAContext &context);
45 bool afScan(IPAContext &context, int min_step);
46 void afReset(IPAContext &context);
47 bool afNeedIgnoreFrame();
48 void afIgnoreFrameReset();
49 double afEstimateVariance(Span<const y_table_item_t> y_items, bool isY1);
50
51 bool afIsOutOfFocus(IPAContext &context);
52
53 /* VCM step configuration. It is the current setting of the VCM step. */
54 uint32_t focus_;
55 /* The best VCM step. It is a local optimum VCM step during scanning. */
56 uint32_t bestFocus_;
57 /* Current AF statistic variance. */
58 double currentVariance_;
59 /* The frames are ignore before starting measuring. */
60 uint32_t ignoreCounter_;
61 /* It is used to determine the derivative during scanning */
62 double previousVariance_;
63 /* The designated maximum range of focus scanning. */
64 uint32_t maxStep_;
65 /* If the coarse scan completes, it is set to true. */
66 bool coarseCompleted_;
67 /* If the fine scan completes, it is set to true. */
68 bool fineCompleted_;
69};
70
71} /* namespace ipa::ipu3::algorithms */
72
73} /* namespace libcamera */
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:350
libcamera::ipa::Algorithm
The base class for all IPA algorithms.
Definition algorithm.h:23
libcamera::ipa::ipu3::algorithms::Af
An auto-focus algorithm based on IPU3 statistics.
Definition af.h:23
libcamera::ipa::ipu3::algorithms::Af::process
void process(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, const ipu3_uapi_stats_3a *stats, ControlList &metadata) override
Determine the max contrast image and lens position.
Definition af.cpp:422
libcamera::ipa::ipu3::algorithms::Af::prepare
void prepare(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, ipu3_uapi_params *params) override
Fill the params buffer with ISP processing parameters for a frame.
Definition af.cpp:184
libcamera::ipa::ipu3::algorithms::Af::configure
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override
Configure the Af given a configInfo.
Definition af.cpp:119
geometry.h
Data structures related to geometric objects.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::ipa::ipu3::IPAContext
Global IPA context data shared between all algorithms.
Definition ipa_context.h:86
libcamera::ipa::ipu3::IPAFrameContext
IPU3-specific FrameContext.
Definition ipa_context.h:79
utils.h
Miscellaneous utility functions.