Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/include/sof/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@
#ifndef __SOF_BIT_H__
#define __SOF_BIT_H__

/* Zephyr defines this - remove local copy once Zephyr integration complete */
#ifdef BIT
#undef BIT
#endif
#ifdef __ZEPHYR__
#include <zephyr/sys/util_macro.h>
#else

#if ASSEMBLY
#define BIT(b) (1 << (b))
#else
#define BIT(b) (1UL << (b))
#endif

#define MASK(b_hi, b_lo) \
(((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo))
#define SET_BIT(b, x) (((x) & 1) << (b))
#define SET_BITS(b_hi, b_lo, x) \
(((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo))
#define GET_BIT(b, x) \
(((x) & (1ULL << (b))) >> (b))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR - I see GET_BIT() and SET_BITS() defined in Zephyr in DMIC and DAI driver headers with the latter being defined in two headers, maybe they could be moved to a common shared header


#endif /* __ZEPHYR__ */

#define GET_BITS(b_hi, b_lo, x) \
(((x) & MASK(b_hi, b_lo)) >> (b_lo))

#define MASK(b_hi, b_lo) \
(((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo))
#define SET_BIT(b, x) (((x) & 1) << (b))

#endif /* __SOF_BIT_H__ */