xref: /openbmc/linux/drivers/gpu/drm/lib/drm_random.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a33d42ddSChris Wilson #ifndef __DRM_RANDOM_H__
3a33d42ddSChris Wilson #define __DRM_RANDOM_H__
4a33d42ddSChris Wilson 
5a33d42ddSChris Wilson /* This is a temporary home for a couple of utility functions that should
6a33d42ddSChris Wilson  * be transposed to lib/ at the earliest convenience.
7a33d42ddSChris Wilson  */
8a33d42ddSChris Wilson 
9a33d42ddSChris Wilson #include <linux/random.h>
10a33d42ddSChris Wilson 
11a33d42ddSChris Wilson #define DRM_RND_STATE_INITIALIZER(seed__) ({				\
12a33d42ddSChris Wilson 	struct rnd_state state__;					\
13a33d42ddSChris Wilson 	prandom_seed_state(&state__, (seed__));				\
14a33d42ddSChris Wilson 	state__;							\
15a33d42ddSChris Wilson })
16a33d42ddSChris Wilson 
17a33d42ddSChris Wilson #define DRM_RND_STATE(name__, seed__) \
18a33d42ddSChris Wilson 	struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
19a33d42ddSChris Wilson 
20a33d42ddSChris Wilson unsigned int *drm_random_order(unsigned int count,
21a33d42ddSChris Wilson 			       struct rnd_state *state);
22a33d42ddSChris Wilson void drm_random_reorder(unsigned int *order,
23a33d42ddSChris Wilson 			unsigned int count,
24a33d42ddSChris Wilson 			struct rnd_state *state);
25*92937f17SArunpravin u32 drm_prandom_u32_max_state(u32 ep_ro,
26*92937f17SArunpravin 			      struct rnd_state *state);
27a33d42ddSChris Wilson 
28a33d42ddSChris Wilson #endif /* !__DRM_RANDOM_H__ */
29