diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2012-06-27 14:48:47 +0200 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2012-07-05 19:58:39 +0200 |
commit | 9eac8021f3d33a63156f9f5d43a220e88bb3f8db (patch) | |
tree | f7061124c079b8c48c8832278b33d97bdde39899 /src/radeon.h | |
parent | 060c7836e7f7777bacca4e23f57c5985beab33bc (diff) |
EXA: Factor out pixmap BO allocation into a helper function.
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Diffstat (limited to 'src/radeon.h')
-rw-r--r-- | src/radeon.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/radeon.h b/src/radeon.h index 742a6f85..d357dc13 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -665,4 +665,24 @@ enum { RADEON_CREATE_PIXMAP_SZBUFFER = 0x80000000, /* for eg */ }; + +/* Compute log base 2 of val. */ +static __inline__ int +RADEONLog2(int val) +{ + int bits; +#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__) + __asm volatile("bsrl %1, %0" + : "=r" (bits) + : "c" (val) + ); + return bits; +#else + for (bits = 0; val != 0; val >>= 1, ++bits) + ; + return bits - 1; +#endif +} + + #endif /* _RADEON_H_ */ |