Skip to content

Commit 211b938

Browse files
kakuleszaslawblauciak
authored andcommitted
format: add align up/down macros
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>
1 parent 757f2c9 commit 211b938

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/include/sof/audio/format.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
#define MINUS_80DB_Q1_31 214748 /* 10^(-80/20) */
5454
#define MINUS_90DB_Q1_31 67909 /* 10^(-90/20) */
5555

56+
/* Align the number to the nearest alignment value */
57+
#define ALIGN_UP(size, alignment) \
58+
(((size) % (alignment) == 0) ? (size) : \
59+
((size) - ((size) % (alignment)) + (alignment)))
60+
#define ALIGN_DOWN(size, alignment) \
61+
((size) - ((size) % (alignment)))
62+
5663
/* Compute the number of shifts
5764
* This will result in a compiler overflow error if shift bits are out of
5865
* range as INT64_MAX/MIN is greater than 32 bit Q shift parameter

0 commit comments

Comments
 (0)