GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / media / usb / pvrusb2 / pvrusb2-util.h
1 /*
2  *
3  *
4  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  */
16 #ifndef __PVRUSB2_UTIL_H
17 #define __PVRUSB2_UTIL_H
18
19 #define PVR2_DECOMPOSE_LE(t,i,d) \
20     do {    \
21         (t)[i] = (d) & 0xff;\
22         (t)[i+1] = ((d) >> 8) & 0xff;\
23         (t)[i+2] = ((d) >> 16) & 0xff;\
24         (t)[i+3] = ((d) >> 24) & 0xff;\
25     } while(0)
26
27 #define PVR2_DECOMPOSE_BE(t,i,d) \
28     do {    \
29         (t)[i+3] = (d) & 0xff;\
30         (t)[i+2] = ((d) >> 8) & 0xff;\
31         (t)[i+1] = ((d) >> 16) & 0xff;\
32         (t)[i] = ((d) >> 24) & 0xff;\
33     } while(0)
34
35 #define PVR2_COMPOSE_LE(t,i) \
36     ((((u32)((t)[i+3])) << 24) | \
37      (((u32)((t)[i+2])) << 16) | \
38      (((u32)((t)[i+1])) << 8) | \
39      ((u32)((t)[i])))
40
41 #define PVR2_COMPOSE_BE(t,i) \
42     ((((u32)((t)[i])) << 24) | \
43      (((u32)((t)[i+1])) << 16) | \
44      (((u32)((t)[i+2])) << 8) | \
45      ((u32)((t)[i+3])))
46
47
48 #endif /* __PVRUSB2_UTIL_H */