root/trunk/libffado/src/libstreaming/util/cip.h

Revision 864, 4.6 kB (checked in by ppalmers, 15 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

Line 
1 /*
2  * libiec61883 - Linux IEEE 1394 streaming media library.
3  * Copyright (C) 2004 Kristian Hogsberg, Dan Dennedy, and Dan Maas.
4  * This file written by Kristian Hogsberg.
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, or
9  * (at your option) version 3 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #ifndef _IEC61883_CIP_PRIVATE_H
22 #define _IEC61883_CIP_PRIVATE_H
23
24 #include <libraw1394/raw1394.h>
25 #include <endian.h>
26 #include <stdint.h>
27
28 #define IEC61883_FMT_DV 0x00
29 #define IEC61883_FMT_AMDTP 0x10
30 #define IEC61883_FMT_MPEG2 0x20
31
32 #define CIP_TRANSFER_DELAY 9000
33
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #if __BYTE_ORDER == __BIG_ENDIAN
40
41
42 struct iec61883_packet {
43     /* First quadlet */
44     uint8_t dbs      : 8;
45     uint8_t eoh0     : 2;
46     uint8_t sid      : 6;
47
48     uint8_t dbc      : 8;
49     uint8_t fn       : 2;
50     uint8_t qpc      : 3;
51     uint8_t sph      : 1;
52     uint8_t reserved : 2;
53
54     /* Second quadlet */
55     uint8_t fdf      : 8;
56     uint8_t eoh1     : 2;
57     uint8_t fmt      : 6;
58
59     uint16_t syt      : 16;
60
61     unsigned char data[0];
62 };
63
64 #elif __BYTE_ORDER == __LITTLE_ENDIAN
65
66 struct iec61883_packet {
67     /* First quadlet */
68     uint8_t sid      : 6;
69     uint8_t eoh0     : 2;
70     uint8_t dbs      : 8;
71
72     uint8_t reserved : 2;
73     uint8_t sph      : 1;
74     uint8_t qpc      : 3;
75     uint8_t fn       : 2;
76     uint8_t dbc      : 8;
77
78     /* Second quadlet */
79     uint8_t fmt      : 6;
80     uint8_t eoh1     : 2;
81     uint8_t fdf      : 8;
82
83     uint16_t syt      : 16;
84
85     unsigned char data[0];
86 };
87
88 #else
89
90 #error Unknown bitfield type
91
92 #endif
93
94 /*
95  * The TAG value is present in the isochronous header (first quadlet). It
96  * provides a high level label for the format of data carried by the
97  * isochronous packet.
98  */
99
100 #define IEC61883_TAG_WITHOUT_CIP 0 /* CIP header NOT included */
101 #define IEC61883_TAG_WITH_CIP    1 /* CIP header included. */
102 #define IEC61883_TAG_RESERVED1   2 /* Reserved */
103 #define IEC61883_TAG_RESERVED2   3 /* Reserved */
104
105 #define IEC61883_FDF_NODATA   0xFF
106
107 /* AM824 format definitions. */
108 #define IEC61883_FDF_AM824 0x00
109 #define IEC61883_FDF_AM824_CONTROLLED 0x04
110 #define IEC61883_FDF_SFC_MASK 0x03
111
112 #define IEC61883_AM824_LABEL              0x40
113 #define IEC61883_AM824_LABEL_RAW_24BITS   0x40
114 #define IEC61883_AM824_LABEL_RAW_20BITS   0x41
115 #define IEC61883_AM824_LABEL_RAW_16BITS   0x42
116 #define IEC61883_AM824_LABEL_RAW_RESERVED 0x43
117
118 #define IEC61883_AM824_VBL_24BITS   0x0
119 #define IEC61883_AM824_VBL_20BITS   0x1
120 #define IEC61883_AM824_VBL_16BITS   0x2
121 #define IEC61883_AM824_VBL_RESERVED 0x3
122
123 /* IEC-60958 format definitions. */
124 #define IEC60958_LABEL   0x0
125 #define IEC60958_PAC_B   0x3 /* Preamble Code 'B': Start of channel 1, at
126                   * the start of a data block. */
127 #define IEC60958_PAC_RSV 0x2 /* Preamble Code 'RESERVED' */
128 #define IEC60958_PAC_M   0x1 /* Preamble Code 'M': Start of channel 1 that
129                   *    is not at the start of a data block. */
130 #define IEC60958_PAC_W   0x0 /* Preamble Code 'W': start of channel 2. */
131 #define IEC60958_DATA_VALID   0 /* When cleared means data is valid. */
132 #define IEC60958_DATA_INVALID 1 /* When set means data is not suitable for an ADC. */
133
134 struct iec61883_fraction {
135     int integer;
136     int numerator;
137     int denominator;
138 };
139
140 struct iec61883_cip {
141     struct iec61883_fraction cycle_offset;
142     struct iec61883_fraction ticks_per_syt_offset;
143     struct iec61883_fraction ready_samples;
144     struct iec61883_fraction samples_per_cycle;
145     int dbc, dbs;
146     int cycle_count;
147     int cycle_count2;
148     int mode;
149     int syt_interval;
150     int dimension;
151     int rate;
152     int fdf;
153     int format;
154 };
155
156 void
157 iec61883_cip_init(struct iec61883_cip *cip, int format, int fdf,
158         int rate, int dbs, int syt_interval);
159 void
160 iec61883_cip_set_transmission_mode(struct iec61883_cip *ptz, int mode);
161
162 int
163 iec61883_cip_get_max_packet_size(struct iec61883_cip *ptz);
164
165 int
166 iec61883_cip_fill_header(int node_id, struct iec61883_cip *cip,
167         struct iec61883_packet *packet);
168
169 int
170 iec61883_cip_fill_header_nodata(int node_id, struct iec61883_cip *cip,
171         struct iec61883_packet *packet);
172
173 #ifdef __cplusplus
174 }
175 #endif
176
177 #endif
Note: See TracBrowser for help on using the browser.