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