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