[libcamera-devel] [IPU3-IPA PATCH] ipu3: Initialise controls in the IPA

Umang Jain umang.jain at ideasonboard.com
Tue Aug 17 10:27:53 CEST 2021


Hi Kieran,

Looks like I missed this email :(

On 8/13/21 7:52 PM, Kieran Bingham wrote:
> In commit 11fe4333c54d ("libcamera: ipu3: Initialize controls in the
> IPA") the interface for the IPA was updated and the creation of exposure
> and frame duration controls are now the responsibility of the IPA.
>
> In libcamera, the code that creates these controls was moved to the
> integrated IPA for the IPU3.
>
> Duplicate the implementation here.
>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Acked-by: Umang Jain <umang.jain at ideasonboard.com>

> ---
>   ipu3.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/ipu3.cpp b/ipu3.cpp
> index b8015af20454..3e89e6dd4e02 100644
> --- a/ipu3.cpp
> +++ b/ipu3.cpp
> @@ -36,7 +36,10 @@ namespace ipa::ipu3 {
>   class IPAIPU3 : public IPAIPU3Interface
>   {
>   public:
> -	int init(const IPASettings &settings) override;
> +	int init(const IPASettings &settings,
> +		 const IPACameraSensorInfo &sensorInfo,
> +		 const ControlInfoMap &sensorControls,
> +		 ControlInfoMap *ipaControls) override;
>   
>   	int start() override;
>   	void stop() override {}
> @@ -83,7 +86,10 @@ private:
>   	BinaryData aiqd_;
>   };
>   
> -int IPAIPU3::init(const IPASettings &settings)
> +int IPAIPU3::init(const IPASettings &settings,
> +		  const IPACameraSensorInfo &sensorInfo,
> +		  const ControlInfoMap &sensorControls,
> +		  ControlInfoMap *ipaControls)
>   {
>   	int ret;
>   
> @@ -135,6 +141,54 @@ int IPAIPU3::init(const IPASettings &settings)
>   
>   	aiqInputParams_.init();
>   
> +	/* Initialize Controls. */
> +	ControlInfoMap::Map controls{};
> +
> +	/*
> +	 * Compute exposure time limits.
> +	 *
> +	 * Initialize the control using the line length and pixel rate of the
> +	 * current configuration converted to microseconds. Use the
> +	 * V4L2_CID_EXPOSURE control to get exposure min, max and default and
> +	 * convert it from lines to microseconds.
> +	 */
> +	double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);
> +	const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
> +	int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;
> +	int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;
> +	int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;
> +	controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,
> +							defExposure);
> +
> +	/*
> +	 * Compute the frame duration limits.
> +	 *
> +	 * The frame length is computed assuming a fixed line length combined
> +	 * with the vertical frame sizes.
> +	 */
> +	const ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second;
> +	uint32_t hblank = v4l2HBlank.def().get<int32_t>();
> +	uint32_t lineLength = sensorInfo.outputSize.width + hblank;
> +
> +	const ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second;
> +	std::array<uint32_t, 3> frameHeights{
> +		v4l2VBlank.min().get<int32_t>() + sensorInfo.outputSize.height,
> +		v4l2VBlank.max().get<int32_t>() + sensorInfo.outputSize.height,
> +		v4l2VBlank.def().get<int32_t>() + sensorInfo.outputSize.height,
> +	};
> +
> +	std::array<int64_t, 3> frameDurations;
> +	for (unsigned int i = 0; i < frameHeights.size(); ++i) {
> +		uint64_t frameSize = lineLength * frameHeights[i];
> +		frameDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);
> +	}
> +
> +	controls[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],
> +							       frameDurations[1],
> +							       frameDurations[2]);
> +
> +	*ipaControls = ControlInfoMap(std::move(controls), controls::controls);
> +
>   	return 0;
>   }
>   


More information about the libcamera-devel mailing list