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