From d405d1fd5e791b3ebc45dc980be2fce9ac0f3529 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Mon, 13 Jul 2020 15:05:23 +0200 Subject: libcamera: utils: Add alignUp and alignDown functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add to libcamera utils library two functions to round up or down a value to an alignment and add a test in test/utils.cpp for the two new functions. Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/utils.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libcamera') diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 0567328f..615df46a 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -444,6 +444,22 @@ std::string libcameraSourcePath() return path + "/"; } +/** + * \fn alignDown(unsigned int value, unsigned int alignment) + * \brief Align \a value down to \a alignment + * \param[in] value The value to align + * \param[in] alignment The alignment + * \return The value rounded down to the nearest multiple of \a alignment + */ + +/** + * \fn alignUp(unsigned int value, unsigned int alignment) + * \brief Align \a value up to \a alignment + * \param[in] value The value to align + * \param[in] alignment The alignment + * \return The value rounded up to the nearest multiple of \a alignment + */ + } /* namespace utils */ } /* namespace libcamera */ -- cgit v1.2.1