xref: /titanic_41/usr/src/uts/common/sys/av/iec61883.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_AV_IEC61883_H
28 #define	_SYS_AV_IEC61883_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * IEC 61883 interfaces
34  */
35 
36 #include <sys/types.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /* current interface version */
43 #define	IEC61883_IMPL_MKVER(major, minor) (((major) << 8) | (minor))
44 #define	IEC61883_IMPL_VER_MAJOR(ver)	(((ver) >> 8) & 0xff)
45 #define	IEC61883_IMPL_VER_MINOR(ver)	((ver) & 0xff)
46 #define	IEC61883_V1_0			IEC61883_IMPL_MKVER(1, 0)
47 
48 /*
49  * asyncronous request (ARQ)
50  */
51 typedef struct iec61883_arq {
52 	int		arq_type;	/* type */
53 	int		arq_len;	/* length */
54 	union {
55 		uint32_t	quadlet;
56 		uint64_t	octlet;
57 		uint8_t		buf[8];
58 	} arq_data;			/* data */
59 } iec61883_arq_t;
60 
61 /* ARQ types (arq_type) */
62 enum {
63 	IEC61883_ARQ_FCP_CMD,
64 	IEC61883_ARQ_FCP_RESP,
65 	IEC61883_ARQ_BUS_RESET
66 };
67 
68 /*
69  * IEC61883_ISOCH_INIT argument
70  */
71 typedef struct iec61883_isoch_init {
72 	int		ii_version;	/* interface version */
73 	int		ii_pkt_size;	/* packet size */
74 	int		ii_frame_size;	/* packets/frame */
75 	int		ii_frame_cnt;	/* # of frames */
76 	int		ii_direction;	/* xfer direction */
77 	int		ii_bus_speed;	/* bus speed */
78 	uint64_t	ii_channel;	/* channel mask */
79 	int		ii_dbs;		/* DBS */
80 	int		ii_fn;		/* FN */
81 	int		ii_rate_n;	/* rate numerator */
82 	int		ii_rate_d;	/* rate denominator */
83 	int		ii_ts_mode;	/* timestamp mode */
84 	int		ii_flags;	/* flags */
85 	int		ii_handle;	/* isoch handle */
86 	int		ii_frame_rcnt;	/* # of frames */
87 	off_t		ii_mmap_off;	/* mmap offset */
88 	int		ii_rchannel;	/* channel */
89 	int		ii_error;	/* error code */
90 } iec61883_isoch_init_t;
91 
92 /* xfer directions (ii_direction) */
93 enum {
94 	IEC61883_DIR_RECV,
95 	IEC61883_DIR_XMIT
96 };
97 
98 /* bus speeds (ii_bus_speed) */
99 enum {
100 	IEC61883_S100,
101 	IEC61883_S200,
102 	IEC61883_S400
103 };
104 
105 /* special rate coefficients (ii_rate_n, ii_rate_d) */
106 #define	IEC61883_RATE_N_DV_NTSC		1
107 #define	IEC61883_RATE_D_DV_NTSC		0
108 #define	IEC61883_RATE_N_DV_PAL		2
109 #define	IEC61883_RATE_D_DV_PAL		0
110 
111 /* timestamp modes (ii_ts_mode) */
112 enum {
113 	IEC61883_TS_NONE	= 0,
114 	IEC61883_TS_SYT		= 0x0206
115 };
116 
117 /* error codes (ii_error) */
118 enum {
119 	IEC61883_ERR_NOMEM	= 1,
120 	IEC61883_ERR_NOCHANNEL,
121 	IEC61883_ERR_PKT_SIZE,
122 	IEC61883_ERR_VERSION,
123 	IEC61883_ERR_INVAL,
124 	IEC61883_ERR_OTHER
125 };
126 
127 /*
128  * data transfer strusture
129  */
130 typedef struct iec61883_xfer {
131 	int	xf_empty_idx;	/* first empty frame */
132 	int	xf_empty_cnt;	/* empty frame count */
133 	int	xf_full_idx;	/* first full frame */
134 	int	xf_full_cnt;	/* full frame count */
135 	int	xf_error;	/* error */
136 } iec61883_xfer_t;
137 
138 /*
139  * IEC61883_RECV argument
140  */
141 typedef struct iec61883_recv {
142 	int		rx_handle;	/* isoch handle */
143 	int		rx_flags;	/* flags */
144 	iec61883_xfer_t	rx_xfer;	/* xfer params */
145 } iec61883_recv_t;
146 
147 /*
148  * IEC61883_XMIT argument
149  */
150 typedef struct iec61883_xmit {
151 	int		tx_handle;	/* isoch handle */
152 	int		tx_flags;	/* flags */
153 	iec61883_xfer_t	tx_xfer;	/* xfer params */
154 	int		tx_miss_cnt;	/* missed cycles */
155 } iec61883_xmit_t;
156 
157 /*
158  * IEC61883_PLUG_INIT argument
159  */
160 typedef struct iec61883_plug_init {
161 	int		pi_ver;		/* interface version */
162 	int		pi_loc;		/* plug location */
163 	int		pi_type;	/* plug type */
164 	int		pi_num;		/* plug number */
165 	int		pi_flags;	/* flags */
166 	int		pi_handle;	/* plug handle */
167 	int		pi_rnum;	/* plug number */
168 } iec61883_plug_init_t;
169 
170 /* plug locations (pi_loc) */
171 enum {
172 	IEC61883_LOC_LOCAL,
173 	IEC61883_LOC_REMOTE
174 };
175 
176 /* plug types (pi_type) */
177 enum {
178 	IEC61883_PLUG_IN,
179 	IEC61883_PLUG_OUT,
180 	IEC61883_PLUG_MASTER_IN,
181 	IEC61883_PLUG_MASTER_OUT
182 };
183 
184 /* special plug number (pi_num) */
185 enum {
186 	IEC61883_PLUG_ANY	= -1
187 };
188 
189 /*
190  * IEC61883_PLUG_REG_READ argument
191  */
192 typedef struct iec61883_plug_reg_val {
193 	int		pr_handle;	/* plug handle */
194 	uint32_t	pr_val;		/* register value */
195 } iec61883_plug_reg_val_t;
196 
197 /*
198  * IEC61883_PLUG_REG_CAS argument
199  */
200 typedef struct iec61883_plug_reg_lock {
201 	int		pl_handle;	/* plug handle */
202 	uint32_t	pl_arg;		/* compare arg */
203 	uint32_t	pl_data;	/* write value */
204 	uint32_t	pl_old;		/* original value */
205 } iec61883_plug_reg_lock_t;
206 
207 /*
208  * IEC61883_NODE_GET_TEXT_LEAF argument
209  */
210 typedef struct iec61883_node_text_leaf {
211 	int		tl_parent;	/* ROM parent */
212 	int		tl_num;		/* leaf number */
213 	int		tl_len;		/* buffer length */
214 	uint32_t	*tl_data;	/* data buffer */
215 	int		tl_cnt;		/* leaf count */
216 	int		tl_rlen;	/* real length */
217 	uint32_t	tl_spec;	/* specifier */
218 	uint32_t	tl_lang_id;	/* language id */
219 	uint32_t	tl_desc_entry;	/* entry described by this leaf */
220 } iec61883_node_text_leaf_t;
221 
222 /* ROM parent types (tl_parent) */
223 enum {
224 	IEC61883_ROM_ROOT,	/* leaf in the root directory */
225 	IEC61883_ROM_UNIT	/* leaf in the unit directory */
226 };
227 
228 /* ioctl codes */
229 #define	IEC61883_IMPL_IOC		('i' << 8)
230 #define	IEC61883_IMPL_MKIOC(c)		(c | IEC61883_IMPL_IOC)
231 
232 #define	IEC61883_ISOCH_INIT		IEC61883_IMPL_MKIOC(0x01)
233 #define	IEC61883_ISOCH_FINI		IEC61883_IMPL_MKIOC(0x02)
234 #define	IEC61883_START			IEC61883_IMPL_MKIOC(0x03)
235 #define	IEC61883_STOP			IEC61883_IMPL_MKIOC(0x04)
236 #define	IEC61883_RECV			IEC61883_IMPL_MKIOC(0x05)
237 #define	IEC61883_XMIT			IEC61883_IMPL_MKIOC(0x06)
238 #define	IEC61883_PLUG_INIT		IEC61883_IMPL_MKIOC(0x07)
239 #define	IEC61883_PLUG_FINI		IEC61883_IMPL_MKIOC(0x08)
240 #define	IEC61883_PLUG_REG_READ		IEC61883_IMPL_MKIOC(0x09)
241 #define	IEC61883_PLUG_REG_CAS		IEC61883_IMPL_MKIOC(0x0A)
242 #define	IEC61883_ARQ_GET_IBUF_SIZE	IEC61883_IMPL_MKIOC(0x0B)
243 #define	IEC61883_ARQ_SET_IBUF_SIZE	IEC61883_IMPL_MKIOC(0x0C)
244 #define	IEC61883_NODE_GET_BUS_NAME	IEC61883_IMPL_MKIOC(0x0D)
245 #define	IEC61883_NODE_GET_UID		IEC61883_IMPL_MKIOC(0x0E)
246 #define	IEC61883_NODE_GET_TEXT_LEAF	IEC61883_IMPL_MKIOC(0x0F)
247 
248 
249 /* 32-bit structures for the drivers */
250 #ifdef _KERNEL
251 typedef struct iec61883_isoch_init32 {
252 	int		ii_version;	/* interface version */
253 	int		ii_pkt_size;	/* packet size */
254 	int		ii_frame_size;	/* packets/frame */
255 	int		ii_frame_cnt;	/* # of frames */
256 	int		ii_direction;	/* xfer direction */
257 	int		ii_bus_speed;	/* bus speed */
258 	uint64_t	ii_channel;	/* channel mask */
259 	int		ii_dbs;		/* DBS */
260 	int		ii_fn;		/* FN */
261 	int		ii_rate_n;	/* rate numerator */
262 	int		ii_rate_d;	/* rate denominator */
263 	int		ii_ts_mode;	/* timestamp mode */
264 	int		ii_flags;	/* flags */
265 	int		ii_handle;	/* isoch handle */
266 	int		ii_frame_rcnt;	/* # of frames */
267 	int32_t		ii_mmap_off;	/* mmap offset */
268 	int		ii_rchannel;	/* channel */
269 	int		ii_error;	/* error code */
270 } iec61883_isoch_init32_t;
271 
272 typedef struct iec61883_node_text_leaf32 {
273 	int		tl_parent;	/* ROM parent */
274 	int		tl_num;		/* leaf number */
275 	int		tl_len;		/* buffer length */
276 	caddr32_t	tl_data;	/* data buffer */
277 	int		tl_cnt;		/* leaf count */
278 	int		tl_rlen;	/* real length */
279 	uint32_t	tl_spec;	/* specifier */
280 	uint32_t	tl_lang_id;	/* language id */
281 	uint32_t	tl_desc_entry;	/* entry described by this leaf */
282 } iec61883_node_text_leaf32_t;
283 #endif /* _KERNEL */
284 
285 #ifdef __cplusplus
286 }
287 #endif
288 
289 #endif /* _SYS_AV_IEC61883_H */
290