Skip to content

Commit

Permalink
format: add align up/down macros
Browse files Browse the repository at this point in the history
ALGIN_UP/ALIGN_DOWN macros allows to align the number to the nearest alignment
value. E.g. upward value aligment is required for DGMBS register.

Signed-off-by: Kamil Kulesza <kamil.kulesza@linux.intel.com>
  • Loading branch information
kakulesza authored and slawblauciak committed Aug 3, 2018
1 parent 757f2c9 commit 211b938
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/include/sof/audio/format.h
Expand Up @@ -53,6 +53,13 @@
#define MINUS_80DB_Q1_31 214748 /* 10^(-80/20) */
#define MINUS_90DB_Q1_31 67909 /* 10^(-90/20) */

/* Align the number to the nearest alignment value */
#define ALIGN_UP(size, alignment) \
(((size) % (alignment) == 0) ? (size) : \
((size) - ((size) % (alignment)) + (alignment)))
#define ALIGN_DOWN(size, alignment) \
((size) - ((size) % (alignment)))

/* Compute the number of shifts
* This will result in a compiler overflow error if shift bits are out of
* range as INT64_MAX/MIN is greater than 32 bit Q shift parameter
Expand Down

0 comments on commit 211b938

Please sign in to comment.