1 | #ifndef PWC_IOCTL_H |
---|
2 | #define PWC_IOCTL_H |
---|
3 | |
---|
4 | /* (C) 2001-2004 Nemosoft Unv. |
---|
5 | (C) 2004-2006 Luc Saillard (luc@saillard.org) |
---|
6 | |
---|
7 | NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx |
---|
8 | driver and thus may have bugs that are not present in the original version. |
---|
9 | Please send bug reports and support requests to <luc@saillard.org>. |
---|
10 | The decompression routines have been implemented by reverse-engineering the |
---|
11 | Nemosoft binary pwcx module. Caveat emptor. |
---|
12 | |
---|
13 | This program is free software; you can redistribute it and/or modify |
---|
14 | it under the terms of the GNU General Public License as published by |
---|
15 | the Free Software Foundation; either version 2 of the License, or |
---|
16 | (at your option) any later version. |
---|
17 | |
---|
18 | This program is distributed in the hope that it will be useful, |
---|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | GNU General Public License for more details. |
---|
22 | |
---|
23 | You should have received a copy of the GNU General Public License |
---|
24 | along with this program; if not, write to the Free Software |
---|
25 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
26 | |
---|
27 | */ |
---|
28 | |
---|
29 | /* This is pwc-ioctl.h belonging to PWC 10.0.10 |
---|
30 | It contains structures and defines to communicate from user space |
---|
31 | directly to the driver. |
---|
32 | */ |
---|
33 | |
---|
34 | /* |
---|
35 | Changes |
---|
36 | 2001/08/03 Alvarado Added ioctl constants to access methods for |
---|
37 | changing white balance and red/blue gains |
---|
38 | 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE |
---|
39 | 2003/12/13 Nemosft Unv. Some modifications to make interfacing to |
---|
40 | PWCX easier |
---|
41 | 2006/01/01 Luc Saillard Add raw format definition |
---|
42 | */ |
---|
43 | |
---|
44 | /* These are private ioctl() commands, specific for the Philips webcams. |
---|
45 | They contain functions not found in other webcams, and settings not |
---|
46 | specified in the Video4Linux API. |
---|
47 | |
---|
48 | The #define names are built up like follows: |
---|
49 | VIDIOC VIDeo IOCtl prefix |
---|
50 | PWC Philps WebCam |
---|
51 | G optional: Get |
---|
52 | S optional: Set |
---|
53 | ... the function |
---|
54 | */ |
---|
55 | |
---|
56 | #include <linux/types.h> |
---|
57 | |
---|
58 | /* Enumeration of image sizes */ |
---|
59 | #define PSZ_SQCIF 0x00 |
---|
60 | #define PSZ_QSIF 0x01 |
---|
61 | #define PSZ_QCIF 0x02 |
---|
62 | #define PSZ_SIF 0x03 |
---|
63 | #define PSZ_CIF 0x04 |
---|
64 | #define PSZ_VGA 0x05 |
---|
65 | #define PSZ_MAX 6 |
---|
66 | |
---|
67 | |
---|
68 | /* The frame rate is encoded in the video_window.flags parameter using |
---|
69 | the upper 16 bits, since some flags are defined nowadays. The following |
---|
70 | defines provide a mask and shift to filter out this value. |
---|
71 | This value can also be passing using the private flag when using v4l2 and |
---|
72 | VIDIOC_S_FMT ioctl. |
---|
73 | |
---|
74 | In 'Snapshot' mode the camera freezes its automatic exposure and colour |
---|
75 | balance controls. |
---|
76 | */ |
---|
77 | #define PWC_FPS_SHIFT 16 |
---|
78 | #define PWC_FPS_MASK 0x00FF0000 |
---|
79 | #define PWC_FPS_FRMASK 0x003F0000 |
---|
80 | #define PWC_FPS_SNAPSHOT 0x00400000 |
---|
81 | #define PWC_QLT_MASK 0x03000000 |
---|
82 | #define PWC_QLT_SHIFT 24 |
---|
83 | |
---|
84 | |
---|
85 | /* structure for transferring x & y coordinates */ |
---|
86 | struct pwc_coord |
---|
87 | { |
---|
88 | int x, y; /* guess what */ |
---|
89 | int size; /* size, or offset */ |
---|
90 | }; |
---|
91 | |
---|
92 | |
---|
93 | /* Used with VIDIOCPWCPROBE */ |
---|
94 | struct pwc_probe |
---|
95 | { |
---|
96 | char name[32]; |
---|
97 | int type; |
---|
98 | }; |
---|
99 | |
---|
100 | struct pwc_serial |
---|
101 | { |
---|
102 | char serial[30]; /* String with serial number. Contains terminating 0 */ |
---|
103 | }; |
---|
104 | |
---|
105 | /* pwc_whitebalance.mode values */ |
---|
106 | #define PWC_WB_INDOOR 0 |
---|
107 | #define PWC_WB_OUTDOOR 1 |
---|
108 | #define PWC_WB_FL 2 |
---|
109 | #define PWC_WB_MANUAL 3 |
---|
110 | #define PWC_WB_AUTO 4 |
---|
111 | |
---|
112 | /* Used with VIDIOCPWC[SG]AWB (Auto White Balance). |
---|
113 | Set mode to one of the PWC_WB_* values above. |
---|
114 | *red and *blue are the respective gains of these colour components inside |
---|
115 | the camera; range 0..65535 |
---|
116 | When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; |
---|
117 | otherwise undefined. |
---|
118 | 'read_red' and 'read_blue' are read-only. |
---|
119 | */ |
---|
120 | struct pwc_whitebalance |
---|
121 | { |
---|
122 | int mode; |
---|
123 | int manual_red, manual_blue; /* R/W */ |
---|
124 | int read_red, read_blue; /* R/O */ |
---|
125 | }; |
---|
126 | |
---|
127 | /* |
---|
128 | 'control_speed' and 'control_delay' are used in automatic whitebalance mode, |
---|
129 | and tell the camera how fast it should react to changes in lighting, and |
---|
130 | with how much delay. Valid values are 0..65535. |
---|
131 | */ |
---|
132 | struct pwc_wb_speed |
---|
133 | { |
---|
134 | int control_speed; |
---|
135 | int control_delay; |
---|
136 | |
---|
137 | }; |
---|
138 | |
---|
139 | /* Used with VIDIOCPWC[SG]LED */ |
---|
140 | struct pwc_leds |
---|
141 | { |
---|
142 | int led_on; /* Led on-time; range = 0..25000 */ |
---|
143 | int led_off; /* Led off-time; range = 0..25000 */ |
---|
144 | }; |
---|
145 | |
---|
146 | /* Image size (used with GREALSIZE) */ |
---|
147 | struct pwc_imagesize |
---|
148 | { |
---|
149 | int width; |
---|
150 | int height; |
---|
151 | }; |
---|
152 | |
---|
153 | /* Defines and structures for Motorized Pan & Tilt */ |
---|
154 | #define PWC_MPT_PAN 0x01 |
---|
155 | #define PWC_MPT_TILT 0x02 |
---|
156 | #define PWC_MPT_TIMEOUT 0x04 /* for status */ |
---|
157 | |
---|
158 | /* Set angles; when absolute != 0, the angle is absolute and the |
---|
159 | driver calculates the relative offset for you. This can only |
---|
160 | be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns |
---|
161 | absolute angles. |
---|
162 | */ |
---|
163 | struct pwc_mpt_angles |
---|
164 | { |
---|
165 | int absolute; /* write-only */ |
---|
166 | int pan; /* degrees * 100 */ |
---|
167 | int tilt; /* degress * 100 */ |
---|
168 | }; |
---|
169 | |
---|
170 | /* Range of angles of the camera, both horizontally and vertically. |
---|
171 | */ |
---|
172 | struct pwc_mpt_range |
---|
173 | { |
---|
174 | int pan_min, pan_max; /* degrees * 100 */ |
---|
175 | int tilt_min, tilt_max; |
---|
176 | }; |
---|
177 | |
---|
178 | struct pwc_mpt_status |
---|
179 | { |
---|
180 | int status; |
---|
181 | int time_pan; |
---|
182 | int time_tilt; |
---|
183 | }; |
---|
184 | |
---|
185 | |
---|
186 | /* This is used for out-of-kernel decompression. With it, you can get |
---|
187 | all the necessary information to initialize and use the decompressor |
---|
188 | routines in standalone applications. |
---|
189 | */ |
---|
190 | struct pwc_video_command |
---|
191 | { |
---|
192 | int type; /* camera type (645, 675, 730, etc.) */ |
---|
193 | int release; /* release number */ |
---|
194 | |
---|
195 | int size; /* one of PSZ_* */ |
---|
196 | int alternate; |
---|
197 | int command_len; /* length of USB video command */ |
---|
198 | unsigned char command_buf[13]; /* Actual USB video command */ |
---|
199 | int bandlength; /* >0 = compressed */ |
---|
200 | int frame_size; /* Size of one (un)compressed frame */ |
---|
201 | }; |
---|
202 | |
---|
203 | /* Flags for PWCX subroutines. Not all modules honor all flags. */ |
---|
204 | #define PWCX_FLAG_PLANAR 0x0001 |
---|
205 | #define PWCX_FLAG_BAYER 0x0008 |
---|
206 | |
---|
207 | |
---|
208 | /* IOCTL definitions */ |
---|
209 | |
---|
210 | /* Restore user settings */ |
---|
211 | #define VIDIOCPWCRUSER _IO('v', 192) |
---|
212 | /* Save user settings */ |
---|
213 | #define VIDIOCPWCSUSER _IO('v', 193) |
---|
214 | /* Restore factory settings */ |
---|
215 | #define VIDIOCPWCFACTORY _IO('v', 194) |
---|
216 | |
---|
217 | /* You can manipulate the compression factor. A compression preference of 0 |
---|
218 | means use uncompressed modes when available; 1 is low compression, 2 is |
---|
219 | medium and 3 is high compression preferred. Of course, the higher the |
---|
220 | compression, the lower the bandwidth used but more chance of artefacts |
---|
221 | in the image. The driver automatically chooses a higher compression when |
---|
222 | the preferred mode is not available. |
---|
223 | */ |
---|
224 | /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ |
---|
225 | #define VIDIOCPWCSCQUAL _IOW('v', 195, int) |
---|
226 | /* Get preferred compression quality */ |
---|
227 | #define VIDIOCPWCGCQUAL _IOR('v', 195, int) |
---|
228 | |
---|
229 | |
---|
230 | /* Retrieve serial number of camera */ |
---|
231 | #define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) |
---|
232 | |
---|
233 | /* This is a probe function; since so many devices are supported, it |
---|
234 | becomes difficult to include all the names in programs that want to |
---|
235 | check for the enhanced Philips stuff. So in stead, try this PROBE; |
---|
236 | it returns a structure with the original name, and the corresponding |
---|
237 | Philips type. |
---|
238 | To use, fill the structure with zeroes, call PROBE and if that succeeds, |
---|
239 | compare the name with that returned from VIDIOCGCAP; they should be the |
---|
240 | same. If so, you can be assured it is a Philips (OEM) cam and the type |
---|
241 | is valid. |
---|
242 | */ |
---|
243 | #define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) |
---|
244 | |
---|
245 | /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ |
---|
246 | #define VIDIOCPWCSAGC _IOW('v', 200, int) |
---|
247 | /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ |
---|
248 | #define VIDIOCPWCGAGC _IOR('v', 200, int) |
---|
249 | /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ |
---|
250 | #define VIDIOCPWCSSHUTTER _IOW('v', 201, int) |
---|
251 | |
---|
252 | /* Color compensation (Auto White Balance) */ |
---|
253 | #define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) |
---|
254 | #define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) |
---|
255 | |
---|
256 | /* Auto WB speed */ |
---|
257 | #define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) |
---|
258 | #define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) |
---|
259 | |
---|
260 | /* LEDs on/off/blink; int range 0..65535 */ |
---|
261 | #define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) |
---|
262 | #define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) |
---|
263 | |
---|
264 | /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ |
---|
265 | #define VIDIOCPWCSCONTOUR _IOW('v', 206, int) |
---|
266 | #define VIDIOCPWCGCONTOUR _IOR('v', 206, int) |
---|
267 | |
---|
268 | /* Backlight compensation; 0 = off, otherwise on */ |
---|
269 | #define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) |
---|
270 | #define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) |
---|
271 | |
---|
272 | /* Flickerless mode; = 0 off, otherwise on */ |
---|
273 | #define VIDIOCPWCSFLICKER _IOW('v', 208, int) |
---|
274 | #define VIDIOCPWCGFLICKER _IOR('v', 208, int) |
---|
275 | |
---|
276 | /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ |
---|
277 | #define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) |
---|
278 | #define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) |
---|
279 | |
---|
280 | /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ |
---|
281 | #define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) |
---|
282 | |
---|
283 | /* Motorized pan & tilt functions */ |
---|
284 | #define VIDIOCPWCMPTRESET _IOW('v', 211, int) |
---|
285 | #define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) |
---|
286 | #define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) |
---|
287 | #define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) |
---|
288 | #define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) |
---|
289 | |
---|
290 | /* Get the USB set-video command; needed for initializing libpwcx */ |
---|
291 | #define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) |
---|
292 | struct pwc_table_init_buffer { |
---|
293 | int len; |
---|
294 | char *buffer; |
---|
295 | |
---|
296 | }; |
---|
297 | #define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) |
---|
298 | |
---|
299 | /* |
---|
300 | * This is private command used when communicating with v4l2. |
---|
301 | * In the future all private ioctl will be remove/replace to |
---|
302 | * use interface offer by v4l2. |
---|
303 | */ |
---|
304 | |
---|
305 | #define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0) |
---|
306 | #define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1) |
---|
307 | #define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2) |
---|
308 | #define V4L2_CID_PRIVATE_COLOUR_MODE (V4L2_CID_PRIVATE_BASE + 3) |
---|
309 | #define V4L2_CID_PRIVATE_AUTOCONTOUR (V4L2_CID_PRIVATE_BASE + 4) |
---|
310 | #define V4L2_CID_PRIVATE_CONTOUR (V4L2_CID_PRIVATE_BASE + 5) |
---|
311 | #define V4L2_CID_PRIVATE_BACKLIGHT (V4L2_CID_PRIVATE_BASE + 6) |
---|
312 | #define V4L2_CID_PRIVATE_FLICKERLESS (V4L2_CID_PRIVATE_BASE + 7) |
---|
313 | #define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8) |
---|
314 | |
---|
315 | struct pwc_raw_frame { |
---|
316 | unsigned short type; /* type of the webcam */ |
---|
317 | unsigned short vbandlength; /* Size of 4lines compressed (used by the decompressor) */ |
---|
318 | unsigned char cmd[4]; /* the four byte of the command (in case of nala version, only the first 3 bytes is filled) */ |
---|
319 | #ifndef __cplusplus |
---|
320 | unsigned char rawframe[0]; /* frame_size = H/4*vbandlength */ |
---|
321 | #endif |
---|
322 | } __attribute__ ((packed)); |
---|
323 | |
---|
324 | |
---|
325 | #endif |
---|