xref: /titanic_41/usr/src/uts/common/sys/dcam/dcam1394_io.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DCAM_DCAM1394_IO_H
28 #define	_SYS_DCAM_DCAM1394_IO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/time.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /* macros for manipulating dcam1394_param_list_t structure */
39 #define	PARAM_LIST_INIT(list)			bzero(list, sizeof (list))
40 #define	PARAM_LIST_ADD(list, param, subparam)	list[param][subparam].flag = 1
41 #define	PARAM_LIST_REMOVE(list, param, subparam)  list[param][subparam].flag = 0
42 #define	PARAM_LIST_IS_ENTRY(list, param, subparam) list[param][subparam].flag
43 #define	PARAM_VAL(list, param, subparam)	list[param][subparam].val
44 #define	PARAM_ERR(list, param, subparam)	list[param][subparam].err
45 
46 #define	DCAM1394_NUM_PARAM	30
47 #define	DCAM1394_NUM_SUBPARAM	24
48 
49 /* parameters */
50 #define	DCAM1394_PARAM_CAP_POWER_CTRL			0x0
51 #define	DCAM1394_PARAM_CAP_VID_MODE			0x1
52 #define	DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_0	0x2
53 #define	DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_1	0x3
54 #define	DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_2	0x4
55 #define	DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_3	0x5
56 #define	DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_4	0x6
57 #define	DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_5	0x7
58 #define	DCAM1394_PARAM_POWER				0x8
59 #define	DCAM1394_PARAM_VID_MODE				0x9
60 #define	DCAM1394_PARAM_FRAME_RATE			0xA
61 #define	DCAM1394_PARAM_RING_BUFF_CAPACITY		0xB
62 #define	DCAM1394_PARAM_RING_BUFF_NUM_FRAMES_READY	0xC
63 #define	DCAM1394_PARAM_RING_BUFF_READ_PTR_INCR		0xD
64 #define	DCAM1394_PARAM_FRAME_NUM_BYTES			0xE
65 #define	DCAM1394_PARAM_STATUS				0xF
66 #define	DCAM1394_PARAM_BRIGHTNESS			0x10
67 #define	DCAM1394_PARAM_EXPOSURE				0x11
68 #define	DCAM1394_PARAM_SHARPNESS			0x12
69 #define	DCAM1394_PARAM_WHITE_BALANCE			0x13
70 #define	DCAM1394_PARAM_HUE				0x14
71 #define	DCAM1394_PARAM_SATURATION			0x15
72 #define	DCAM1394_PARAM_GAMMA				0x16
73 #define	DCAM1394_PARAM_SHUTTER				0x17
74 #define	DCAM1394_PARAM_GAIN				0x18
75 #define	DCAM1394_PARAM_IRIS				0x19
76 #define	DCAM1394_PARAM_FOCUS				0x1A
77 #define	DCAM1394_PARAM_ZOOM				0x1B
78 #define	DCAM1394_PARAM_PAN				0x1C
79 #define	DCAM1394_PARAM_TILT				0x1D
80 
81 /* subparameters */
82 
83 /* for DCAM1394_PARAM_CAP_VID_MODE */
84 #define	DCAM1394_SUBPARAM_VID_MODE_0			0x0
85 #define	DCAM1394_SUBPARAM_VID_MODE_YUV_444_160_120	0x0
86 #define	DCAM1394_SUBPARAM_VID_MODE_1			0x1
87 #define	DCAM1394_SUBPARAM_VID_MODE_YUV_422_320_240	0x1
88 #define	DCAM1394_SUBPARAM_VID_MODE_2			0x2
89 #define	DCAM1394_SUBPARAM_VID_MODE_YUV_411_640_480	0x2
90 #define	DCAM1394_SUBPARAM_VID_MODE_3			0x3
91 #define	DCAM1394_SUBPARAM_VID_MODE_YUV_422_640_480	0x3
92 #define	DCAM1394_SUBPARAM_VID_MODE_4			0x4
93 #define	DCAM1394_SUBPARAM_VID_MODE_RGB_640_480		0x4
94 #define	DCAM1394_SUBPARAM_VID_MODE_5			0x5
95 #define	DCAM1394_SUBPARAM_VID_MODE_Y_640_480		0x5
96 
97 /* for DCAM1394_PARAM_CAP_FRAME_RATE_VID_MODE_0 */
98 #define	DCAM1394_SUBPARAM_FRAME_RATE_0			0x6
99 #define	DCAM1394_SUBPARAM_FRAME_RATE_3_75_FPS		0x6
100 #define	DCAM1394_SUBPARAM_FRAME_RATE_1			0x7
101 #define	DCAM1394_SUBPARAM_FRAME_RATE_7_5_FPS		0x7
102 #define	DCAM1394_SUBPARAM_FRAME_RATE_2			0x8
103 #define	DCAM1394_SUBPARAM_FRAME_RATE_15_FPS		0x8
104 #define	DCAM1394_SUBPARAM_FRAME_RATE_3			0x9
105 #define	DCAM1394_SUBPARAM_FRAME_RATE_30_FPS		0x9
106 #define	DCAM1394_SUBPARAM_FRAME_RATE_4			0xA
107 #define	DCAM1394_SUBPARAM_FRAME_RATE_60_FPS		0xA
108 
109 /* for features */
110 #define	DCAM1394_SUBPARAM_PRESENCE			0xB
111 #define	DCAM1394_SUBPARAM_CAP_READ			0xC
112 #define	DCAM1394_SUBPARAM_CAP_ON_OFF			0xD
113 #define	DCAM1394_SUBPARAM_CAP_CTRL_AUTO			0xE
114 #define	DCAM1394_SUBPARAM_CAP_CTRL_MANUAL		0xF
115 #define	DCAM1394_SUBPARAM_MIN_VAL			0x10
116 #define	DCAM1394_SUBPARAM_MAX_VAL			0x11
117 #define	DCAM1394_SUBPARAM_ON_OFF			0x12
118 #define	DCAM1394_SUBPARAM_CTRL_MODE			0x13
119 #define	DCAM1394_SUBPARAM_VALUE				0x14
120 
121 /* for white balance feature */
122 #define	DCAM1394_SUBPARAM_U_VALUE			0x15
123 #define	DCAM1394_SUBPARAM_V_VALUE			0x16
124 
125 #define	DCAM1394_SUBPARAM_NONE				0x17
126 
127 /* parameter values */
128 
129 /* for video mode param */
130 
131 #define	DCAM1394_VID_MODE_0			0x0
132 #define	DCAM1394_VID_MODE_YUV_444_160_120	0x0
133 
134 #define	DCAM1394_VID_MODE_1			0x1
135 #define	DCAM1394_VID_MODE_YUV_422_320_240	0x1
136 
137 #define	DCAM1394_VID_MODE_2			0x2
138 #define	DCAM1394_VID_MODE_YUV_411_640_480	0x2
139 
140 #define	DCAM1394_VID_MODE_3			0x3
141 #define	DCAM1394_VID_MODE_YUV_422_640_480	0x3
142 
143 #define	DCAM1394_VID_MODE_4			0x4
144 #define	DCAM1394_VID_MODE_RGB_640_480		0x4
145 
146 #define	DCAM1394_VID_MODE_5			0x5
147 #define	DCAM1394_VID_MODE_Y_640_480		0x5
148 
149 /* for frame rate param */
150 
151 #define	DCAM1394_FRAME_RATE_0			0x6
152 #define	DCAM1394_3_75_FPS			0x6
153 
154 #define	DCAM1394_FRAME_RATE_1			0x7
155 #define	DCAM1394_7_5_FPS			0x7
156 
157 #define	DCAM1394_FRAME_RATE_2			0x8
158 #define	DCAM1394_15_FPS				0x8
159 
160 #define	DCAM1394_FRAME_RATE_3			0x9
161 #define	DCAM1394_30_FPS				0x9
162 
163 #define	DCAM1394_FRAME_RATE_4			0xA
164 #define	DCAM1394_60_FPS				0xA
165 
166 /* for feature control mode subparam */
167 
168 #define	DCAM1394_CTRL_AUTO			0x1
169 #define	DCAM1394_CTRL_MANUAL			0x0
170 
171 /* for power control subparam */
172 
173 #define	DCAM1394_POWER_OFF			0x0
174 #define	DCAM1394_POWER_ON			0x1
175 
176 /* ioctl() commands */
177 
178 #define	DCAM1394_IOC				('d' << 8)
179 
180 #define	DCAM1394_CMD_REG_READ			(DCAM1394_IOC | 0)
181 #define	DCAM1394_CMD_REG_WRITE			(DCAM1394_IOC | 1)
182 
183 #define	DCAM1394_CMD_CAM_RESET			(DCAM1394_IOC | 2)
184 #define	DCAM1394_CMD_PARAM_GET			(DCAM1394_IOC | 3)
185 #define	DCAM1394_CMD_PARAM_SET			(DCAM1394_IOC | 4)
186 #define	DCAM1394_CMD_FRAME_RCV_START		(DCAM1394_IOC | 5)
187 #define	DCAM1394_CMD_FRAME_RCV_STOP		(DCAM1394_IOC | 6)
188 #define	DCAM1394_CMD_RING_BUFF_FLUSH		(DCAM1394_IOC | 7)
189 #define	DCAM1394_CMD_FRAME_SEQ_NUM_COUNT_RESET	(DCAM1394_IOC | 8)
190 
191 #define	DCAM1394_RING_BUFF_OFFS		0x1
192 
193 /* for DCAM1394_PARAM_STATUS */
194 
195 #define	DCAM1394_STATUS_FRAME_RCV_DONE			0x1
196 #define	DCAM1394_STATUS_RING_BUFF_LOST_FRAME		0x2
197 #define	DCAM1394_STATUS_PARAM_CHANGE			0x4
198 #define	DCAM1394_STATUS_FRAME_SEQ_NUM_COUNT_OVERFLOW	0x8
199 #define	DCAM1394_STATUS_CAM_UNPLUG			0x10
200 
201 typedef struct dcam1394_param_list_entry_s {
202 	int 		flag;
203 	int 		err;
204 	unsigned int 	val;
205 
206 } dcam1394_param_list_entry_t;
207 
208 typedef dcam1394_param_list_entry_t
209 	dcam1394_param_list_t[DCAM1394_NUM_PARAM][DCAM1394_NUM_SUBPARAM];
210 
211 typedef dcam1394_param_list_entry_t
212 	(*dcam1394_param_list_p_t)[DCAM1394_NUM_PARAM][DCAM1394_NUM_SUBPARAM];
213 
214 typedef struct dcam1394_frame_s {
215 	unsigned int	 vid_mode;
216 	unsigned int	 seq_num;
217 	hrtime_t	 timestamp;
218 	unsigned char	*buff;
219 } dcam1394_frame_t;
220 
221 typedef struct dcam1394_reg_io_s {
222 	unsigned int	offs;
223 	unsigned int 	val;
224 
225 } dcam1394_reg_io_t;
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif	/* _SYS_DCAM_DCAM1394_IO_H */
232