root/branches/libfreebob-1.0/src/libfreebobstreaming/cip.h

Revision 190, 3.5 kB (checked in by pieterpalmers, 18 years ago)

- fixed SSE-accellerated encoders/decoders
- moved SYT CIP_TRANSFER_DELAY to cip.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #ifndef _IEC61883_CIP_PRIVATE_H
2 #define _IEC61883_CIP_PRIVATE_H
3
4 #include <libraw1394/raw1394.h>
5 #include <endian.h>
6
7 #define IEC61883_FMT_DV 0x00
8 #define IEC61883_FMT_AMDTP 0x10
9 #define IEC61883_FMT_MPEG2 0x20
10
11 #define CIP_TRANSFER_DELAY 9000
12
13 #if __BYTE_ORDER == __BIG_ENDIAN
14
15 struct iec61883_packet {
16         /* First quadlet */
17         unsigned int dbs      : 8;
18         unsigned int eoh0     : 2;
19         unsigned int sid      : 6;
20
21         unsigned int dbc      : 8;
22         unsigned int fn       : 2;
23         unsigned int qpc      : 3;
24         unsigned int sph      : 1;
25         unsigned int reserved : 2;
26
27         /* Second quadlet */
28         unsigned int fdf      : 8;
29         unsigned int eoh1     : 2;
30         unsigned int fmt      : 6;
31
32         unsigned int syt      : 16;
33
34         unsigned char data[0];
35 };
36
37 #elif __BYTE_ORDER == __LITTLE_ENDIAN
38
39 struct iec61883_packet {
40         /* First quadlet */
41         unsigned int sid      : 6;
42         unsigned int eoh0     : 2;
43         unsigned int dbs      : 8;
44
45         unsigned int reserved : 2;
46         unsigned int sph      : 1;
47         unsigned int qpc      : 3;
48         unsigned int fn       : 2;
49         unsigned int dbc      : 8;
50
51         /* Second quadlet */
52         unsigned int fmt      : 6;
53         unsigned int eoh1     : 2;
54         unsigned int fdf      : 8;
55
56         unsigned int syt      : 16;
57
58         unsigned char data[0];
59 };
60
61 #else
62
63 #error Unknown bitfield type
64
65 #endif
66
67 /*
68  * The TAG value is present in the isochronous header (first quadlet). It
69  * provides a high level label for the format of data carried by the
70  * isochronous packet.
71  */
72
73 #define IEC61883_TAG_WITHOUT_CIP 0 /* CIP header NOT included */
74 #define IEC61883_TAG_WITH_CIP    1 /* CIP header included. */
75 #define IEC61883_TAG_RESERVED1   2 /* Reserved */
76 #define IEC61883_TAG_RESERVED2   3 /* Reserved */
77
78 #define IEC61883_FDF_NODATA   0xFF
79                
80 /* AM824 format definitions. */
81 #define IEC61883_FDF_AM824 0x00
82 #define IEC61883_FDF_AM824_CONTROLLED 0x04
83 #define IEC61883_FDF_SFC_MASK 0x03
84
85 #define IEC61883_AM824_LABEL              0x40
86 #define IEC61883_AM824_LABEL_RAW_24BITS   0x40
87 #define IEC61883_AM824_LABEL_RAW_20BITS   0x41
88 #define IEC61883_AM824_LABEL_RAW_16BITS   0x42
89 #define IEC61883_AM824_LABEL_RAW_RESERVED 0x43
90
91 #define IEC61883_AM824_VBL_24BITS   0x0
92 #define IEC61883_AM824_VBL_20BITS   0x1
93 #define IEC61883_AM824_VBL_16BITS   0x2
94 #define IEC61883_AM824_VBL_RESERVED 0x3
95
96 /* IEC-60958 format definitions. */
97 #define IEC60958_LABEL   0x0
98 #define IEC60958_PAC_B   0x3 /* Preamble Code 'B': Start of channel 1, at
99                               * the start of a data block. */
100 #define IEC60958_PAC_RSV 0x2 /* Preamble Code 'RESERVED' */
101 #define IEC60958_PAC_M   0x1 /* Preamble Code 'M': Start of channel 1 that
102                               * is not at the start of a data block. */
103 #define IEC60958_PAC_W   0x0 /* Preamble Code 'W': start of channel 2. */
104 #define IEC60958_DATA_VALID   0 /* When cleared means data is valid. */
105 #define IEC60958_DATA_INVALID 1 /* When set means data is not suitable for an ADC. */
106
107 struct iec61883_fraction {
108         int integer;
109         int numerator;
110         int denominator;
111 };
112
113 struct iec61883_cip {
114         struct iec61883_fraction cycle_offset;
115         struct iec61883_fraction ticks_per_syt_offset;
116         struct iec61883_fraction ready_samples;
117         struct iec61883_fraction samples_per_cycle;
118         int dbc, dbs;
119         int cycle_count;
120         int cycle_count2;
121         int mode;
122         int syt_interval;
123         int dimension;
124         int rate;
125         int fdf;
126         int format;
127 };
128
129 void
130 iec61883_cip_init(struct iec61883_cip *cip, int format, int fdf,
131                 int rate, int dbs, int syt_interval);
132 void
133 iec61883_cip_set_transmission_mode(struct iec61883_cip *ptz, int mode);
134
135 int
136 iec61883_cip_get_max_packet_size(struct iec61883_cip *ptz);
137
138 int
139 iec61883_cip_fill_header(raw1394handle_t handle, struct iec61883_cip *cip,
140                 struct iec61883_packet *packet);
141
142
143 #endif
Note: See TracBrowser for help on using the browser.