[libcamera-devel] [PATCH v1 7/9] ipa: raspberrypi: Add line length calculations helper functions
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Oct 4 19:11:40 CEST 2022
Hi Naush,
Thank you for the patch.
On Mon, Oct 03, 2022 at 09:39:33AM +0100, Naushir Patuck via libcamera-devel wrote:
> Add CamHelper::hblankToLineLength() to calculate the line length duration
> from the horizontal blanking (in pixels) value.
>
> Add CamHelper::LineLengthToHblank() to calculate the horizontal blanking (in
s/Line/line/
> pixels) value from the line length duration.
>
> Add CamHelper::lineLengthPckToDuration() to calculate the line length duration
> from the line length in pixels.
>
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> ---
> src/ipa/raspberrypi/cam_helper.cpp | 16 ++++++++++++++++
> src/ipa/raspberrypi/cam_helper.h | 3 +++
> 2 files changed, 19 insertions(+)
>
> diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp
> index 916632f83037..c255ab0cb53f 100644
> --- a/src/ipa/raspberrypi/cam_helper.cpp
> +++ b/src/ipa/raspberrypi/cam_helper.cpp
> @@ -19,6 +19,7 @@
> using namespace RPiController;
> using namespace libcamera;
> using libcamera::utils::Duration;
> +using namespace std::literals::chrono_literals;
>
> namespace libcamera {
> LOG_DECLARE_CATEGORY(IPARPI)
> @@ -102,6 +103,21 @@ uint32_t CamHelper::getVBlanking(Duration &exposure,
> return vblank;
> }
>
> +Duration CamHelper::hblankToLineLength(uint32_t hblank) const
> +{
> + return (mode_.width + hblank) * (1.0s / mode_.pixelRate);
The previous patch performs the exact same calculation in
IPARPi::fillDeviceStatus(). The next patch then replaces that code with
this function. Could this patch be moved before 6/9, and this function
be used there already ?
> +}
> +
> +uint32_t CamHelper::lineLengthToHblank(const Duration &lineLength) const
> +{
> + return (lineLength * mode_.pixelRate / 1.0s) - mode_.width;
> +}
> +
> +Duration CamHelper::lineLengthPckToDuration(uint32_t lineLengthPck) const
> +{
> + return hblankToLineLength(lineLengthPck - mode_.width);
I would have written
return lineLengthPck * (1.0s / mode_.pixelRate);
to avoid subtracting mode_.width to add it back in hblankToLineLength().
I don't mind much either way.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> +}
> +
> void CamHelper::setCameraMode(const CameraMode &mode)
> {
> mode_ = mode;
> diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h
> index 1bbdd715d2b1..b5c0726ff00e 100644
> --- a/src/ipa/raspberrypi/cam_helper.h
> +++ b/src/ipa/raspberrypi/cam_helper.h
> @@ -85,6 +85,9 @@ public:
> virtual uint32_t getVBlanking(libcamera::utils::Duration &exposure,
> libcamera::utils::Duration minFrameDuration,
> libcamera::utils::Duration maxFrameDuration) const;
> + libcamera::utils::Duration hblankToLineLength(uint32_t hblank) const;
> + uint32_t lineLengthToHblank(const libcamera::utils::Duration &duration) const;
> + libcamera::utils::Duration lineLengthPckToDuration(uint32_t lineLengthPck) const;
> virtual uint32_t gainCode(double gain) const = 0;
> virtual double gain(uint32_t gainCode) const = 0;
> virtual void getDelays(int &exposureDelay, int &gainDelay,
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list