3 * Shared header file for the Linux user-space API for
4 * Linear Systems Ltd. DVB Master ASI interface boards.
6 * Copyright (C) 1999 Tony Bolger <d7v@indigo.ie>
7 * Copyright (C) 2000-2010 Linear Systems Ltd.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of Linear Systems Ltd. nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY LINEAR SYSTEMS LTD. "AS IS" AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL LINEAR SYSTEMS LTD. OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Linear Systems can be contacted at <http://www.linsys.ca/>.
43 #define ASI_DRIVER_NAME "asi"
45 #define ASI_MAJOR 61 /* Set to 0 for dynamic allocation.
46 * Otherwise, 61 is available.
47 * See /usr/src/linux/Documentation/devices.txt */
49 #define ASI_TX_BUFFERS_MIN 2 /* This must be at least 2 */
50 /* The minimum transmit buffer size must be positive, divisible by 8,
51 * and large enough that the buffers aren't transferred to the onboard FIFOs
52 * too quickly for the machine to handle the interrupts.
53 * This is especially a problem at startup, when the FIFOs are empty.
54 * Relevant factors include onboard FIFO size, PCI bus throughput,
55 * processor speed, and interrupt latency. */
56 #define ASI_TX_BUFSIZE_MIN 1024
57 #define ASI_RX_BUFFERS_MIN 2 /* This must be at least 2 */
58 #define ASI_RX_BUFSIZE_MIN 8 /* This must be positive and divisible by 8 */
60 #define ASI_TX_BUFFERS 54 /* This must be at least 2 */
61 #define ASI_TX_BUFSIZE 38352 /* This must be positive and divisible by 8 */
62 #define ASI_RX_BUFFERS 54 /* This must be at least 2 */
63 #define ASI_RX_BUFSIZE 38352 /* This must be positive and divisible by 8 */
65 /* Ioctl () definitions */
66 #define ASI_IOC_MAGIC '?' /* This ioctl magic number is currently free. See
67 * /usr/src/linux/Documentation/ioctl-number.txt */
69 #define ASI_IOC_TXGETCAP _IOR(ASI_IOC_MAGIC, 1, unsigned int)
70 #define ASI_IOC_TXGETEVENTS _IOR(ASI_IOC_MAGIC, 2, unsigned int)
71 #define ASI_IOC_TXGETBUFLEVEL _IOR(ASI_IOC_MAGIC, 3, unsigned int)
72 #define ASI_IOC_TXSETSTUFFING _IOW(ASI_IOC_MAGIC, 4, struct asi_txstuffing)
73 #define ASI_IOC_TXGETBYTECOUNT _IOR(ASI_IOC_MAGIC, 5, unsigned int)
74 /* #define ASI_IOC_TXGETFIFO _IOR(ASI_IOC_MAGIC, 6, int) */
75 #define ASI_IOC_TXGETTXD _IOR(ASI_IOC_MAGIC, 7, int)
76 #define ASI_IOC_TXGET27COUNT _IOR(ASI_IOC_MAGIC, 8, unsigned int)
77 /* Provide compatibility with applications compiled for older API */
78 #define ASI_IOC_TXSETPID_DEPRECATED _IOR(ASI_IOC_MAGIC, 9, unsigned int)
79 #define ASI_IOC_TXSETPID _IOW(ASI_IOC_MAGIC, 9, unsigned int)
80 #define ASI_IOC_TXGETPCRSTAMP _IOR(ASI_IOC_MAGIC, 10, struct asi_pcrstamp)
81 /* Provide compatibility with applications compiled for older API */
82 #define ASI_IOC_TXCHANGENEXTIP_DEPRECATED _IOR(ASI_IOC_MAGIC, 11, int)
83 #define ASI_IOC_TXCHANGENEXTIP _IOW(ASI_IOC_MAGIC, 11, int)
85 #define ASI_IOC_RXGETCAP _IOR(ASI_IOC_MAGIC, 65, unsigned int)
86 #define ASI_IOC_RXGETEVENTS _IOR(ASI_IOC_MAGIC, 66, unsigned int)
87 #define ASI_IOC_RXGETBUFLEVEL _IOR(ASI_IOC_MAGIC, 67, unsigned int)
88 /* #define ASI_IOC_RXSETREFRAME _IOW(ASI_IOC_MAGIC, 68, int) */
89 #define ASI_IOC_RXGETSTATUS _IOR(ASI_IOC_MAGIC, 69, int)
90 #define ASI_IOC_RXGETBYTECOUNT _IOR(ASI_IOC_MAGIC, 70, unsigned int)
91 /* #define ASI_IOC_RXGETFIFO _IOR(ASI_IOC_MAGIC, 71, int) */
92 #define ASI_IOC_RXSETINVSYNC _IOW(ASI_IOC_MAGIC, 72, int)
93 #define ASI_IOC_RXGETCARRIER _IOR(ASI_IOC_MAGIC, 73, int)
94 #define ASI_IOC_RXSETDSYNC _IOW(ASI_IOC_MAGIC, 74, int)
95 #define ASI_IOC_RXGETRXD _IOR(ASI_IOC_MAGIC, 75, int)
96 #define ASI_IOC_RXSETPF _IOW(ASI_IOC_MAGIC, 76, unsigned int [256])
97 /* #define ASI_IOC_RXSETPFE _IOW(ASI_IOC_MAGIC, 77, int) */
98 #define ASI_IOC_RXSETPID0 _IOW(ASI_IOC_MAGIC, 78, int)
99 #define ASI_IOC_RXGETPID0COUNT _IOR(ASI_IOC_MAGIC, 79, unsigned int)
100 #define ASI_IOC_RXSETPID1 _IOW(ASI_IOC_MAGIC, 80, int)
101 #define ASI_IOC_RXGETPID1COUNT _IOR(ASI_IOC_MAGIC, 81, unsigned int)
102 #define ASI_IOC_RXSETPID2 _IOW(ASI_IOC_MAGIC, 82, int)
103 #define ASI_IOC_RXGETPID2COUNT _IOR(ASI_IOC_MAGIC, 83, unsigned int)
104 #define ASI_IOC_RXSETPID3 _IOW(ASI_IOC_MAGIC, 84, int)
105 #define ASI_IOC_RXGETPID3COUNT _IOR(ASI_IOC_MAGIC, 85, unsigned int)
106 /* #define ASI_IOC_RXGETSTAMP _IOR(ASI_IOC_MAGIC, 86, unsigned int) */
107 #define ASI_IOC_RXGET27COUNT _IOR(ASI_IOC_MAGIC, 87, unsigned int)
108 #define ASI_IOC_RXGETSTATUS2 _IOR(ASI_IOC_MAGIC, 88, int)
109 /* Provide compatibility with applications compiled for older API */
110 #define ASI_IOC_RXSETINPUT_DEPRECATED _IOR(ASI_IOC_MAGIC, 89, int)
111 #define ASI_IOC_RXSETINPUT _IOW(ASI_IOC_MAGIC, 89, int)
112 #define ASI_IOC_RXGETRXD2 _IOR(ASI_IOC_MAGIC, 90, int)
114 #define ASI_IOC_GETID _IOR(ASI_IOC_MAGIC, 129, unsigned int)
115 #define ASI_IOC_GETVERSION _IOR(ASI_IOC_MAGIC, 130, unsigned int)
117 /* Transmitter event flag bit locations */
118 #define ASI_EVENT_TX_BUFFER_ORDER 0
119 #define ASI_EVENT_TX_BUFFER (1 << ASI_EVENT_TX_BUFFER_ORDER)
120 #define ASI_EVENT_TX_FIFO_ORDER 1
121 #define ASI_EVENT_TX_FIFO (1 << ASI_EVENT_TX_FIFO_ORDER)
122 #define ASI_EVENT_TX_DATA_ORDER 2
123 #define ASI_EVENT_TX_DATA (1 << ASI_EVENT_TX_DATA_ORDER)
125 /* Receiver event flag bit locations */
126 #define ASI_EVENT_RX_BUFFER_ORDER 0
127 #define ASI_EVENT_RX_BUFFER (1 << ASI_EVENT_RX_BUFFER_ORDER)
128 #define ASI_EVENT_RX_FIFO_ORDER 1
129 #define ASI_EVENT_RX_FIFO (1 << ASI_EVENT_RX_FIFO_ORDER)
130 #define ASI_EVENT_RX_CARRIER_ORDER 2
131 #define ASI_EVENT_RX_CARRIER (1 << ASI_EVENT_RX_CARRIER_ORDER)
132 #define ASI_EVENT_RX_AOS_ORDER 3
133 #define ASI_EVENT_RX_AOS (1 << ASI_EVENT_RX_AOS_ORDER)
134 #define ASI_EVENT_RX_LOS_ORDER 4
135 #define ASI_EVENT_RX_LOS (1 << ASI_EVENT_RX_LOS_ORDER)
136 #define ASI_EVENT_RX_DATA_ORDER 5
137 #define ASI_EVENT_RX_DATA (1 << ASI_EVENT_RX_DATA_ORDER)
140 * asi_txstuffing - Transmitter stuffing parameters
141 * @ib: interbyte stuffing
142 * @ip: interpacket stuffing
148 struct asi_txstuffing
{
149 /* Number of K28.5 characters to insert between packet bytes */
152 /* Base number of K28.5 characters to insert between packets,
153 * not including the two required by ASI */
156 /* Number of packets with (ip) bytes of interpacket stuffing
157 * per finetuning cycle */
158 unsigned int normal_ip
;
160 /* Number of packets with (ip + 1) bytes of interpacket stuffing
161 * per finetuning cycle */
164 /* Number of packets with (ip) bytes of interpacket stuffing
165 * per interleaved finetuning cycle */
166 unsigned int il_normal
;
168 /* Number of packets with (ip + 1) bytes of interpacket stuffing
169 * per interleaved finetuning cycle */
174 * asi_pcrstamp - PCR - departure time pair
175 * @adaptation_field_length: adaptation field length
176 * @adaptation_field_flags: adaptation field flags
177 * @PCR: a program clock reference
178 * @count: departure time of this PCR, in 1 / 27 MHz
180 struct asi_pcrstamp
{
181 unsigned char adaptation_field_length
;
182 unsigned char adaptation_field_flags
;
183 unsigned char PCR
[6];
187 /* Interface capabilities */
188 #define ASI_CAP_TX_MAKE204 0x00000004
189 #define ASI_CAP_TX_FINETUNING 0x00000008
190 #define ASI_CAP_TX_BYTECOUNTER 0x00000010
191 #define ASI_CAP_TX_SETCLKSRC 0x00000020
192 #define ASI_CAP_TX_FIFOUNDERRUN 0x00000040
193 #define ASI_CAP_TX_LARGEIB 0x00000080
194 #define ASI_CAP_TX_INTERLEAVING 0x00000100
195 #define ASI_CAP_TX_DATA 0x00000200
196 #define ASI_CAP_TX_RXCLKSRC 0x00000400
197 /* #define ASI_CAP_TX_COMPOSITEREF 0x00000800 */
198 #define ASI_CAP_TX_PCRSTAMP 0x00001000
199 #define ASI_CAP_TX_CHANGENEXTIP 0x00002000
200 #define ASI_CAP_TX_27COUNTER 0x00004000
201 #define ASI_CAP_TX_BYTESOR27 0x00008000
202 #define ASI_CAP_TX_TIMESTAMPS 0x00010000
203 #define ASI_CAP_TX_PTIMESTAMPS 0x00020000
204 #define ASI_CAP_TX_NULLPACKETS 0x00040000
205 #define ASI_CAP_TX_EXTCLKSRC2 0x00080000
207 #define ASI_CAP_RX_SYNC 0x00000004
208 #define ASI_CAP_RX_MAKE188 0x00000008
209 #define ASI_CAP_RX_BYTECOUNTER 0x00000010
210 /* #define ASI_CAP_RX_FIFOSTATUS 0x00000020 */
211 #define ASI_CAP_RX_INVSYNC 0x00000040
212 #define ASI_CAP_RX_CD 0x00000080
213 #define ASI_CAP_RX_DSYNC 0x00000100
214 #define ASI_CAP_RX_DATA 0x00000200
215 #define ASI_CAP_RX_PIDFILTER 0x00000400
216 #define ASI_CAP_RX_PIDCOUNTER 0x00000800
217 #define ASI_CAP_RX_4PIDCOUNTER 0x00001000
218 #define ASI_CAP_RX_FORCEDMA 0x00002000
219 #define ASI_CAP_RX_27COUNTER 0x00004000
220 #define ASI_CAP_RX_BYTESOR27 0x00008000
221 #define ASI_CAP_RX_TIMESTAMPS 0x00010000
222 #define ASI_CAP_RX_PTIMESTAMPS 0x00020000
223 #define ASI_CAP_RX_NULLPACKETS 0x00040000
224 #define ASI_CAP_RX_REDUNDANT 0x00080000
225 #define ASI_CAP_RX_DATA2 0x00100000
227 /* Transmitter clock source settings */
228 #define ASI_CTL_TX_CLKSRC_ONBOARD 0
229 #define ASI_CTL_TX_CLKSRC_EXT 1
230 #define ASI_CTL_TX_CLKSRC_RX 2
231 #define ASI_CTL_TX_CLKSRC_EXT2 3
233 /* Transmitter mode settings */
234 #define ASI_CTL_TX_MODE_188 0
235 #define ASI_CTL_TX_MODE_204 1
236 #define ASI_CTL_TX_MODE_MAKE204 2
238 /* Receiver mode settings */
239 #define ASI_CTL_RX_MODE_RAW 0
240 #define ASI_CTL_RX_MODE_188 1
241 #define ASI_CTL_RX_MODE_204 2
242 #define ASI_CTL_RX_MODE_AUTO 3
243 #define ASI_CTL_RX_MODE_AUTOMAKE188 4
244 #define ASI_CTL_RX_MODE_204MAKE188 5
246 /* Timestamping settings */
247 #define ASI_CTL_TSTAMP_NONE 0
248 #define ASI_CTL_TSTAMP_APPEND 1
249 #define ASI_CTL_TSTAMP_PREPEND 2
251 /* Transport settings */
252 #define ASI_CTL_TRANSPORT_DVB_ASI 0
253 #define ASI_CTL_TRANSPORT_SMPTE_310M 1