Home | History | Annotate | Line # | Download | only in lib
      1  1.1  riastrad /*	$NetBSD: drm_random.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /* SPDX-License-Identifier: GPL-2.0 */
      4  1.1  riastrad #ifndef __DRM_RANDOM_H__
      5  1.1  riastrad #define __DRM_RANDOM_H__
      6  1.1  riastrad 
      7  1.1  riastrad /* This is a temporary home for a couple of utility functions that should
      8  1.1  riastrad  * be transposed to lib/ at the earliest convenience.
      9  1.1  riastrad  */
     10  1.1  riastrad 
     11  1.1  riastrad #include <linux/random.h>
     12  1.1  riastrad 
     13  1.1  riastrad #define DRM_RND_STATE_INITIALIZER(seed__) ({				\
     14  1.1  riastrad 	struct rnd_state state__;					\
     15  1.1  riastrad 	prandom_seed_state(&state__, (seed__));				\
     16  1.1  riastrad 	state__;							\
     17  1.1  riastrad })
     18  1.1  riastrad 
     19  1.1  riastrad #define DRM_RND_STATE(name__, seed__) \
     20  1.1  riastrad 	struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
     21  1.1  riastrad 
     22  1.1  riastrad unsigned int *drm_random_order(unsigned int count,
     23  1.1  riastrad 			       struct rnd_state *state);
     24  1.1  riastrad void drm_random_reorder(unsigned int *order,
     25  1.1  riastrad 			unsigned int count,
     26  1.1  riastrad 			struct rnd_state *state);
     27  1.1  riastrad 
     28  1.1  riastrad #endif /* !__DRM_RANDOM_H__ */
     29