summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/pwl.hpp
blob: bd7c766831036afd7f62c67dac729b5c09545059 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2019, Raspberry Pi (Trading) Limited
 *
 * pwl.hpp - piecewise linear functions interface
 */
#pragma once

#include <math.h>
#include <vector>

#include <boost/property_tree/ptree.hpp>

namespace RPi {

class Pwl
{
public:
	struct Interval {
		Interval(double _start, double _end) : start(_start), end(_end)
		{
		}
		double start, end;
		bool Contains(double value)
		{
			return value >= start && value <= end;
		}
		double Clip(double value)
		{
			return value < start ? start
					     : (value > end ? end : value);
		}
		double Len() const { return end - start; }
	};
	struct Point {
		Point() : x(0), y(0) {}
		Point(double _x, double _y) : x(_x), y(_y) {}
		double x, y;
		Point operator-(Point const &p) const
		{
			return Point(x - p.x, y - p.y);
		}
		Point operator+(Point const &p) const
		{
			return Point(x + p.x, y + p.y);
		}
		double operator%(Point const &p) const
		{
			return x * p.x + y * p.y;
		}
		Point operator*(double f) const { return Point(x * f, y * f); }
		Point operator/(double f) const { return Point(x / f, y / f); }
		double Len2() const { return x * x + y * y; }
		double Len() const { return sqrt(Len2()); }
	};
	Pwl() {}
	Pwl(std::vector<Point> const &points) : points_(points) {}
	void Read(boost::property_tree::ptree const &params);
	void Append(double x, double y, const double eps = 1e-6);
	void Prepend(double x, double y, const double eps = 1e-6);
	Interval Domain() const;
	Interval Range() const;
	bool Empty() const;
	// Evaluate Pwl, optionally supplying an initial guess for the
	// "span". The "span" may be optionally be updated.  If you want to know
	// the "span" value but don't have an initial guess you can set it to
	// -1.
	double Eval(double x, int *span_ptr = nullptr,
		    bool update_span = true) const;
	// Find perpendicular closest to xy, starting from span+1 so you can
	// call it repeatedly to check for multiple closest points (set span to
	// -1 on the first call). Also returns "pseudo" perpendiculars; see
	// PerpType enum.
	enum class PerpType {
		None, // no perpendicular found
		Start, // start of Pwl is closest point
		End, // end of Pwl is closest point
		Vertex, // vertex of Pwl is closest point
		Perpendicular // true perpendicular found
	};
	PerpType Invert(Point const &xy, Point &perp, int &span,
			const double eps = 1e-6) const;
	// Compose two Pwls together, doing "this" first and "other" after.
	Pwl Compose(Pwl const &other, const double eps = 1e-6) const;
	// Apply function to (x,y) values at every control point.
	void Map(std::function<void(double x, double y)> f) const;
	// Apply function to (x, y0, y1) values wherever either Pwl has a
	// control point.
	static void Map2(Pwl const &pwl0, Pwl const &pwl1,
			 std::function<void(double x, double y0, double y1)> f);
	// Combine two Pwls, meaning we create a new Pwl where the y values are
	// given by running f wherever either has a knot.
	static Pwl
	Combine(Pwl const &pwl0, Pwl const &pwl1,
		std::function<double(double x, double y0, double y1)> f,
		const double eps = 1e-6);
	// Make "this" match (at least) the given domain. Any extension my be
	// clipped or linear.
	void MatchDomain(Interval const &domain, bool clip = true,
			 const double eps = 1e-6);
	Pwl &operator*=(double d);
	void Debug(FILE *fp = stdout) const;

private:
	int findSpan(double x, int span) const;
	std::vector<Point> points_;
};

} // namespace RPi
9'>589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Copyright (C) 2019, Google Inc.
#
%YAML 1.2
---
# Unless otherwise stated, all controls are bi-directional, i.e. they can be
# set through Request::controls() and returned out through Request::metadata().
controls:
  - AeEnable:
      type: bool
      description: |
        Enable or disable the AE.

        \sa ExposureTime AnalogueGain

  - AeLocked:
      type: bool
      description: |
        Report the lock status of a running AE algorithm.

        If the AE algorithm is locked the value shall be set to true, if it's
        converging it shall be set to false. If the AE algorithm is not
        running the control shall not be present in the metadata control list.

        \sa AeEnable

  # AeMeteringMode needs further attention:
  # - Auto-generate max enum value.
  # - Better handling of custom types.
  - AeMeteringMode:
      type: int32_t
      description: |
        Specify a metering mode for the AE algorithm to use. The metering
        modes determine which parts of the image are used to determine the
        scene brightness. Metering modes may be platform specific and not
        all metering modes may be supported.
      enum:
        - name: MeteringCentreWeighted
          value: 0
          description: Centre-weighted metering mode.
        - name: MeteringSpot
          value: 1
          description: Spot metering mode.
        - name: MeteringMatrix
          value: 2
          description: Matrix metering mode.
        - name: MeteringCustom
          value: 3
          description: Custom metering mode.

  # AeConstraintMode needs further attention:
  # - Auto-generate max enum value.
  # - Better handling of custom types.
  - AeConstraintMode:
      type: int32_t
      description: |
        Specify a constraint mode for the AE algorithm to use. These determine
        how the measured scene brightness is adjusted to reach the desired
        target exposure. Constraint modes may be platform specific, and not
        all constraint modes may be supported.
      enum:
        - name: ConstraintNormal
          value: 0
          description: Default constraint mode.
            This mode aims to balance the exposure of different parts of the
            image so as to reach a reasonable average level. However, highlights
            in the image may appear over-exposed and lowlights may appear
            under-exposed.
        - name: ConstraintHighlight
          value: 1
          description: Highlight constraint mode.
            This mode adjusts the exposure levels in order to try and avoid
            over-exposing the brightest parts (highlights) of an image.
            Other non-highlight parts of the image may appear under-exposed.
        - name: ConstraintShadows
          value: 2
          description: Shadows constraint mode.
            This mode adjusts the exposure levels in order to try and avoid
            under-exposing the dark parts (shadows) of an image. Other normally
            exposed parts of the image may appear over-exposed.
        - name: ConstraintCustom
          value: 3
          description: Custom constraint mode.

  # AeExposureMode needs further attention:
  # - Auto-generate max enum value.
  # - Better handling of custom types.
  - AeExposureMode:
      type: int32_t
      description: |
        Specify an exposure mode for the AE algorithm to use. These specify
        how the desired total exposure is divided between the shutter time
        and the sensor's analogue gain. The exposure modes are platform
        specific, and not all exposure modes may be supported.
      enum:
        - name: ExposureNormal
          value: 0
          description: Default exposure mode.
        - name: ExposureShort
          value: 1
          description: Exposure mode allowing only short exposure times.
        - name: ExposureLong
          value: 2
          description: Exposure mode allowing long exposure times.
        - name: ExposureCustom
          value: 3
          description: Custom exposure mode.

  - ExposureValue:
      type: float
      description: |
        Specify an Exposure Value (EV) parameter. The EV parameter will only be
        applied if the AE algorithm is currently enabled.

        By convention EV adjusts the exposure as log2. For example
        EV = [-2, -1, 0.5, 0, 0.5, 1, 2] results in an exposure adjustment
        of [1/4x, 1/2x, 1/sqrt(2)x, 1x, sqrt(2)x, 2x, 4x].

        \sa AeEnable

  - ExposureTime:
      type: int32_t
      description: |
        Exposure time (shutter speed) for the frame applied in the sensor
        device. This value is specified in micro-seconds.

        Setting this value means that it is now fixed and the AE algorithm may
        not change it. Setting it back to zero returns it to the control of the
        AE algorithm.

        \sa AnalogueGain AeEnable

        \todo Document the interactions between AeEnable and setting a fixed
        value for this control. Consider interactions with other AE features,
        such as aperture and aperture/shutter priority mode, and decide if
        control of which features should be automatically adjusted shouldn't
        better be handled through a separate AE mode control.

  - AnalogueGain:
      type: float
      description: |
        Analogue gain value applied in the sensor device.
        The value of the control specifies the gain multiplier applied to all
        colour channels. This value cannot be lower than 1.0.

        Setting this value means that it is now fixed and the AE algorithm may
        not change it. Setting it back to zero returns it to the control of the
        AE algorithm.

        \sa ExposureTime AeEnable

        \todo Document the interactions between AeEnable and setting a fixed
        value for this control. Consider interactions with other AE features,
        such as aperture and aperture/shutter priority mode, and decide if
        control of which features should be automatically adjusted shouldn't
        better be handled through a separate AE mode control.

  - Brightness:
      type: float
      description: |
        Specify a fixed brightness parameter. Positive values (up to 1.0)
        produce brighter images; negative values (up to -1.0) produce darker
        images and 0.0 leaves pixels unchanged.

  - Contrast:
      type: float
      description:  |
        Specify a fixed contrast parameter. Normal contrast is given by the
        value 1.0; larger values produce images with more contrast.

  - Lux:
      type: float
      description: |
        Report an estimate of the current illuminance level in lux. The Lux
        control can only be returned in metadata.

  - AwbEnable:
      type: bool
      description: |
        Enable or disable the AWB.

        \sa ColourGains

  # AwbMode needs further attention:
  # - Auto-generate max enum value.
  # - Better handling of custom types.
  - AwbMode:
      type: int32_t
      description: |
        Specify the range of illuminants to use for the AWB algorithm. The modes
        supported are platform specific, and not all modes may be supported.
      enum:
        - name: AwbAuto
          value: 0
          description: Search over the whole colour temperature range.
        - name: AwbIncandescent
          value: 1
          description: Incandescent AWB lamp mode.
        - name: AwbTungsten
          value: 2
          description: Tungsten AWB lamp mode.
        - name: AwbFluorescent
          value: 3
          description: Fluorescent AWB lamp mode.
        - name: AwbIndoor
          value: 4
          description: Indoor AWB lighting mode.
        - name: AwbDaylight
          value: 5
          description: Daylight AWB lighting mode.
        - name: AwbCloudy
          value: 6
          description: Cloudy AWB lighting mode.
        - name: AwbCustom
          value: 7
          description: Custom AWB mode.

  - AwbLocked:
      type: bool
      description: |
        Report the lock status of a running AWB algorithm.

        If the AWB algorithm is locked the value shall be set to true, if it's
        converging it shall be set to false. If the AWB algorithm is not
        running the control shall not be present in the metadata control list.

        \sa AwbEnable

  - ColourGains:
      type: float
      description: |
        Pair of gain values for the Red and Blue colour channels, in that
        order. ColourGains can only be applied in a Request when the AWB is
        disabled.

        \sa AwbEnable
      size: [2]

  - ColourTemperature:
      type: int32_t
      description: Report the current estimate of the colour temperature, in
        kelvin, for this frame. The ColourTemperature control can only be
        returned in metadata.

  - Saturation:
      type: float
      description:  |
        Specify a fixed saturation parameter. Normal saturation is given by
        the value 1.0; larger values produce more saturated colours; 0.0
        produces a greyscale image.

  - SensorBlackLevels:
      type: int32_t
      description: |
        Reports the sensor black levels used for processing a frame, in the
        order R, Gr, Gb, B. These values are returned as numbers out of a 16-bit
        pixel range (as if pixels ranged from 0 to 65535). The SensorBlackLevels
        control can only be returned in metadata.
      size: [4]

  - Sharpness:
      type: float
      description:  |
        A value of 0.0 means no sharpening. The minimum value means
        minimal sharpening, and shall be 0.0 unless the camera can't
        disable sharpening completely. The default value shall give a
        "reasonable" level of sharpening, suitable for most use cases.
        The maximum value may apply extremely high levels of sharpening,
        higher than anyone could reasonably want. Negative values are
        not allowed. Note also that sharpening is not applied to raw
        streams.

  - FocusFoM:
      type: int32_t
      description: |
        Reports a Figure of Merit (FoM) to indicate how in-focus the frame is.
        A larger FocusFoM value indicates a more in-focus frame. This control
        depends on the IPA to gather ISP statistics from the defined focus
        region, and combine them in a suitable way to generate a FocusFoM value.
        In this respect, it is not necessarily aimed at providing a way to
        implement a focus algorithm by the application, rather an indication of
        how in-focus a frame is.

  - ColourCorrectionMatrix:
      type: float
      description: |
        The 3x3 matrix that converts camera RGB to sRGB within the
        imaging pipeline. This should describe the matrix that is used
        after pixels have been white-balanced, but before any gamma
        transformation. The 3x3 matrix is stored in conventional reading
        order in an array of 9 floating point values.

      size: [3x3]

  - ScalerCrop:
      type: Rectangle
      description: |
        Sets the image portion that will be scaled to form the whole of
        the final output image. The (x,y) location of this rectangle is
        relative to the PixelArrayActiveAreas that is being used. The units
        remain native sensor pixels, even if the sensor is being used in
        a binning or skipping mode.

        This control is only present when the pipeline supports scaling. Its
        maximum valid value is given by the properties::ScalerCropMaximum
        property, and the two can be used to implement digital zoom.

  - DigitalGain:
      type: float
      description: |
        Digital gain value applied during the processing steps applied
        to the image as captured from the sensor.

        The global digital gain factor is applied to all the colour channels
        of the RAW image. Different pipeline models are free to
        specify how the global gain factor applies to each separate
        channel.

        If an imaging pipeline applies digital gain in distinct
        processing steps, this value indicates their total sum.
        Pipelines are free to decide how to adjust each processing
        step to respect the received gain factor and shall report
        their total value in the request metadata.

  - FrameDuration:
      type: int64_t
      description: |
        The instantaneous frame duration from start of frame exposure to start
        of next exposure, expressed in microseconds. This control is meant to
        be returned in metadata.

  - FrameDurationLimits:
      type: int64_t
      description: |
        The minimum and maximum (in that order) frame duration,
        expressed in microseconds.

        When provided by applications, the control specifies the sensor frame
        duration interval the pipeline has to use. This limits the largest
        exposure time the sensor can use. For example, if a maximum frame
        duration of 33ms is requested (corresponding to 30 frames per second),
        the sensor will not be able to raise the exposure time above 33ms.
        A fixed frame duration is achieved by setting the minimum and maximum
        values to be the same. Setting both values to 0 reverts to using the
        IPA provided defaults.

        The maximum frame duration provides the absolute limit to the shutter
        speed computed by the AE algorithm and it overrides any exposure mode
        setting specified with controls::AeExposureMode. Similarly, when a
        manual exposure time is set through controls::ExposureTime, it also
        gets clipped to the limits set by this control. When reported in
        metadata, the control expresses the minimum and maximum frame
        durations used after being clipped to the sensor provided frame
        duration limits.

        \sa AeExposureMode
        \sa ExposureTime

        \todo Define how to calculate the capture frame rate by
        defining controls to report additional delays introduced by
        the capture pipeline or post-processing stages (ie JPEG
        conversion, frame scaling).

        \todo Provide an explicit definition of default control values, for
        this and all other controls.

      size: [2]

  - SensorTimestamp:
      type: int64_t
      description: |
        The time when the first row of the image sensor active array is exposed.

        The timestamp, expressed in nanoseconds, represents a monotonically
        increasing counter since the system boot time, as defined by the
        Linux-specific CLOCK_BOOTTIME clock id.

        The SensorTimestamp control can only be returned in metadata.

        \todo Define how the sensor timestamp has to be used in the reprocessing
        use case.

  - AfMode:
      type: int32_t
      description: |
        Control to set the mode of the AF (autofocus) algorithm.

        An implementation may choose not to implement all the modes.

      enum:
        - name: AfModeManual
          value: 0
          description: |
            The AF algorithm is in manual mode. In this mode it will never
            perform any action nor move the lens of its own accord, but an
            application can specify the desired lens position using the
            LensPosition control.

            In this mode the AfState will always report AfStateIdle.
        - name: AfModeAuto
          value: 1
          description: |
            The AF algorithm is in auto mode. This means that the algorithm
            will never move the lens or change state unless the AfTrigger
            control is used. The AfTrigger control can be used to initiate a
            focus scan, the results of which will be reported by AfState.

            If the autofocus algorithm is moved from AfModeAuto to another
            mode while a scan is in progress, the scan is cancelled
            immediately, without waiting for the scan to finish.

            When first entering this mode the AfState will report
            AfStateIdle. When a trigger control is sent, AfState will
            report AfStateScanning for a period before spontaneously
            changing to AfStateFocused or AfStateFailed, depending on
            the outcome of the scan. It will remain in this state until
            another scan is initiated by the AfTrigger control. If a scan is
            cancelled (without changing to another mode), AfState will return
            to AfStateIdle.
        - name: AfModeContinuous
          value: 2
          description: |
            The AF algorithm is in continuous mode. This means that the lens can
            re-start a scan spontaneously at any moment, without any user
            intervention. The AfState still reports whether the algorithm is
            currently scanning or not, though the application has no ability to
            initiate or cancel scans, nor to move the lens for itself.

            However, applications can pause the AF algorithm from continuously
            scanning by using the AfPause control. This allows video or still
            images to be captured whilst guaranteeing that the focus is fixed.

            When set to AfModeContinuous, the system will immediately initiate a
            scan so AfState will report AfStateScanning, and will settle on one
            of AfStateFocused or AfStateFailed, depending on the scan result.

  - AfRange:
      type: int32_t
      description: |
        Control to set the range of focus distances that is scanned. An
        implementation may choose not to implement all the options here.
      enum:
        - name: AfRangeNormal
          value: 0
          description: |
            A wide range of focus distances is scanned, all the way from
            infinity down to close distances, though depending on the
            implementation, possibly not including the very closest macro
            positions.
        - name: AfRangeMacro
          value: 1
          description: Only close distances are scanned.
        - name: AfRangeFull
          value: 2
          description: |
            The full range of focus distances is scanned just as with
            AfRangeNormal but this time including the very closest macro
            positions.

  - AfSpeed:
      type: int32_t
      description: |
        Control that determines whether the AF algorithm is to move the lens
        as quickly as possible or more steadily. For example, during video
        recording it may be desirable not to move the lens too abruptly, but
        when in a preview mode (waiting for a still capture) it may be
        helpful to move the lens as quickly as is reasonably possible.
      enum:
        - name: AfSpeedNormal
          value: 0
          description: Move the lens at its usual speed.
        - name: AfSpeedFast
          value: 1
          description: Move the lens more quickly.

  - AfMetering:
      type: int32_t
      description: |
        Instruct the AF algorithm how it should decide which parts of the image
        should be used to measure focus.
      enum:
        - name: AfMeteringAuto
          value: 0
          description: The AF algorithm should decide for itself where it will
            measure focus.
        - name: AfMeteringWindows
          value: 1
          description: The AF algorithm should use the rectangles defined by
            the AfWindows control to measure focus. If no windows are specified
            the behaviour is platform dependent.

  - AfWindows:
      type: Rectangle
      description: |
        Sets the focus windows used by the AF algorithm when AfMetering is set
        to AfMeteringWindows. The units used are pixels within the rectangle
        returned by the ScalerCropMaximum property.

        In order to be activated, a rectangle must be programmed with non-zero
        width and height. Internally, these rectangles are intersected with the
        ScalerCropMaximum rectangle. If the window becomes empty after this
        operation, then the window is ignored. If all the windows end up being
        ignored, then the behaviour is platform dependent.

        On platforms that support the ScalerCrop control (for implementing
        digital zoom, for example), no automatic recalculation or adjustment of
        AF windows is performed internally if the ScalerCrop is changed. If any
        window lies outside the output image after the scaler crop has been
        applied, it is up to the application to recalculate them.

        The details of how the windows are used are platform dependent. We note
        that when there is more than one AF window, a typical implementation
        might find the optimal focus position for each one and finally select
        the window where the focal distance for the objects shown in that part
        of the image are closest to the camera.

      size: [n]

  - AfTrigger:
      type: int32_t
      description: |
        This control starts an autofocus scan when AfMode is set to AfModeAuto,
        and can also be used to terminate a scan early.

        It is ignored if AfMode is set to AfModeManual or AfModeContinuous.

      enum:
        - name: AfTriggerStart
          value: 0
          description: Start an AF scan. Ignored if a scan is in progress.
        - name: AfTriggerCancel
          value: 1
          description: Cancel an AF scan. This does not cause the lens to move
            anywhere else. Ignored if no scan is in progress.

  - AfPause:
      type: int32_t
      description: |
        This control has no effect except when in continuous autofocus mode
        (AfModeContinuous). It can be used to pause any lens movements while
        (for example) images are captured. The algorithm remains inactive
        until it is instructed to resume.

      enum:
        - name: AfPauseImmediate
          value: 0
          description: |
            Pause the continuous autofocus algorithm immediately, whether or not
            any kind of scan is underway. AfPauseState will subsequently report
            AfPauseStatePaused. AfState may report any of AfStateScanning,
            AfStateFocused or AfStateFailed, depending on the algorithm's state
            when it received this control.
        - name: AfPauseDeferred
          value: 1
          description: |
            This is similar to AfPauseImmediate, and if the AfState is currently
            reporting AfStateFocused or AfStateFailed it will remain in that
            state and AfPauseState will report AfPauseStatePaused.

            However, if the algorithm is scanning (AfStateScanning),
            AfPauseState will report AfPauseStatePausing until the scan is
            finished, at which point AfState will report one of AfStateFocused
            or AfStateFailed, and AfPauseState will change to
            AfPauseStatePaused.

        - name: AfPauseResume
          value: 2
          description: |
            Resume continuous autofocus operation. The algorithm starts again
            from exactly where it left off, and AfPauseState will report
            AfPauseStateRunning.

  - LensPosition:
      type: float
      description: |
        Acts as a control to instruct the lens to move to a particular position
        and also reports back the position of the lens for each frame.

        The LensPosition control is ignored unless the AfMode is set to
        AfModeManual, though the value is reported back unconditionally in all
        modes.

        The units are a reciprocal distance scale like dioptres but normalised
        for the hyperfocal distance. That is, for a lens with hyperfocal
        distance H, and setting it to a focal distance D, the lens position LP,
        which is generally a non-integer, is given by

        \f$LP = \frac{H}{D}\f$

        For example:

        0 moves the lens to infinity.
        0.5 moves the lens to twice the hyperfocal distance.
        1 moves the lens to the hyperfocal position.
        And larger values will focus the lens ever closer.

        \todo Define a property to report the Hyperforcal distance of calibrated
        lenses.

        \todo Define a property to report the maximum and minimum positions of
        this lens. The minimum value will often be zero (meaning infinity).

  - AfState:
      type: int32_t
      description: |
        Reports the current state of the AF algorithm in conjunction with the
        reported AfMode value and (in continuous AF mode) the AfPauseState
        value. The possible state changes are described below, though we note
        the following state transitions that occur when the AfMode is changed.

        If the AfMode is set to AfModeManual, then the AfState will always
        report AfStateIdle (even if the lens is subsequently moved). Changing to
        the AfModeManual state does not initiate any lens movement.

        If the AfMode is set to AfModeAuto then the AfState will report
        AfStateIdle. However, if AfModeAuto and AfTriggerStart are sent together
        then AfState will omit AfStateIdle and move straight to AfStateScanning
        (and start a scan).

        If the AfMode is set to AfModeContinuous then the AfState will initially
        report AfStateScanning.

      enum:
        - name: AfStateIdle
          value: 0
          description: |
            The AF algorithm is in manual mode (AfModeManual) or in auto mode
            (AfModeAuto) and a scan has not yet been triggered, or an
            in-progress scan was cancelled.
        - name: AfStateScanning
          value: 1
          description: |
            The AF algorithm is in auto mode (AfModeAuto), and a scan has been
            started using the AfTrigger control. The scan can be cancelled by
            sending AfTriggerCancel at which point the algorithm will either
            move back to AfStateIdle or, if the scan actually completes before
            the cancel request is processed, to one of AfStateFocused or
            AfStateFailed.

            Alternatively the AF algorithm could be in continuous mode
            (AfModeContinuous) at which point it may enter this state
            spontaneously whenever it determines that a rescan is needed.
        - name: AfStateFocused
          value: 2
          description: |
            The AF algorithm is in auto (AfModeAuto) or continuous
            (AfModeContinuous) mode and a scan has completed with the result
            that the algorithm believes the image is now in focus.
        - name: AfStateFailed
          value: 3
          description: |
            The AF algorithm is in auto (AfModeAuto) or continuous
            (AfModeContinuous) mode and a scan has completed with the result
            that the algorithm did not find a good focus position.

  - AfPauseState:
      type: int32_t
      description: |
        Only applicable in continuous (AfModeContinuous) mode, this reports
        whether the algorithm is currently running, paused or pausing (that is,
        will pause as soon as any in-progress scan completes).

        Any change to AfMode will cause AfPauseStateRunning to be reported.

      enum:
        - name: AfPauseStateRunning
          value: 0
          description: |
            Continuous AF is running and the algorithm may restart a scan
            spontaneously.
        - name: AfPauseStatePausing
          value: 1
          description: |
            Continuous AF has been sent an AfPauseDeferred control, and will
            pause as soon as any in-progress scan completes (and then report
            AfPauseStatePaused). No new scans will be start spontaneously until
            the AfPauseResume control is sent.
        - name: AfPauseStatePaused
          value: 2
          description: |
            Continuous AF is paused. No further state changes or lens movements
            will occur until the AfPauseResume control is sent.

  # ----------------------------------------------------------------------------
  # Draft controls section

  - AePrecaptureTrigger:
      type: int32_t
      draft: true
      description: |
        Control for AE metering trigger. Currently identical to