Merged VRT work-in-progress from eb/vrt2 (11518:11598) into trunk.
[debian/gnuradio] / vrt / include / vrt / bits.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef INCLUDED_VRT_BITS_H
23 #define INCLUDED_VRT_BITS_H
24
25 #include <stdint.h>
26
27
28 /* VRT Header bits */
29
30 #define VRTH_PT_MASK              (0xf << 28)
31 #define VRTH_PT_IF_DATA_NO_SID    (0x0 << 28)   // IF-Data, no stream id
32 #define VRTH_PT_IF_DATA_WITH_SID  (0x1 << 28)   // IF-Data, w/ stream id
33 #define VRTH_PT_EXT_DATA_NO_SID   (0x2 << 28)
34 #define VRTH_PT_EXT_DATA_WITH_SID (0x3 << 28)
35 #define VRTH_PT_IF_CONTEXT        (0x4 << 28)
36 #define VRTH_PT_EXT_CONTEXT       (0x5 << 28)
37
38 #define VRTH_HAS_CLASSID          (1 << 27)
39 #define VRTH_HAS_TRAILER          (1 << 26)     // Data pkts only
40 #define VRTH_START_OF_BURST       (1 << 25)     // Data (Tx) pkts only
41 #define VRTH_END_OF_BURST         (1 << 24)     // Data (Tx) pkts only
42 #define VRTH_TSM                  (1 << 24)     // Context pkts only
43
44 #define VRTH_TSI_MASK             (0x3 << 22)
45 #define VRTH_TSI_NONE             (0x0 << 22)
46 #define VRTH_TSI_UTC              (0x1 << 22)
47 #define VRTH_TSI_GPS              (0x2 << 22)
48 #define VRTH_TSI_OTHER            (0x3 << 22)
49
50 #define VRTH_TSF_MASK             (0x3 << 20)
51 #define VRTH_TSF_NONE             (0x0 << 20)
52 #define VRTH_TSF_SAMPLE_CNT       (0x1 << 20)
53 #define VRTH_TSF_REAL_TIME_PS     (0x2 << 20)
54 #define VRTH_TSF_FREE_RUNNING     (0x3 << 20)
55
56 #define VRTH_PKT_CNT_MASK         (0xf << 16)
57 #define VRTH_PKT_SIZE_MASK        0xffff                    
58
59
60 static inline int
61 vrth_pkt_cnt(uint32_t h)
62 {
63   return (h & VRTH_PKT_CNT_MASK) >> 16;
64 }
65
66 static inline int
67 vrth_pkt_size(uint32_t h)
68 {
69   return h & VRTH_PKT_SIZE_MASK;
70 }
71
72 #endif /* INCLUDED_VRT_BITS_H */