Instrument Neutral Distributed Interface INDI  1.9.2
pwc-ioctl.h
Go to the documentation of this file.
1 /* (C) 2001-2004 Nemosoft Unv.
2  (C) 2004-2006 Luc Saillard (luc@saillard.org)
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 <luc@saillard.org>.
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 #ifndef __FreeBSD__
55 #include <linux/types.h>
56 #else
57 #include <stdint.h>
58 typedef uint16_t __le16;
59 typedef uint8_t __u8;
60 #endif
61 
62 /* Enumeration of image sizes */
63 #define PSZ_SQCIF 0x00
64 #define PSZ_QSIF 0x01
65 #define PSZ_QCIF 0x02
66 #define PSZ_SIF 0x03
67 #define PSZ_CIF 0x04
68 #define PSZ_VGA 0x05
69 #define PSZ_MAX 6
70 
71 /* The frame rate is encoded in the video_window.flags parameter using
72  the upper 16 bits, since some flags are defined nowadays. The following
73  defines provide a mask and shift to filter out this value.
74  This value can also be passing using the private flag when using v4l2 and
75  VIDIOC_S_FMT ioctl.
76 
77  In 'Snapshot' mode the camera freezes its automatic exposure and colour
78  balance controls.
79  */
80 #define PWC_FPS_SHIFT 16
81 #define PWC_FPS_MASK 0x00FF0000
82 #define PWC_FPS_FRMASK 0x003F0000
83 #define PWC_FPS_SNAPSHOT 0x00400000
84 #define PWC_QLT_MASK 0x03000000
85 #define PWC_QLT_SHIFT 24
86 
87 /* structure for transferring x & y coordinates */
88 struct pwc_coord
89 {
90  int x, y; /* guess what */
91  int size; /* size, or offset */
92 };
93 
94 /* Used with VIDIOCPWCPROBE */
95 struct pwc_probe
96 {
97  char name[32];
98  int type;
99 };
100 
102 {
103  char serial[30]; /* String with serial number. Contains terminating 0 */
104 };
105 
106 /* pwc_whitebalance.mode values */
107 #define PWC_WB_INDOOR 0
108 #define PWC_WB_OUTDOOR 1
109 #define PWC_WB_FL 2
110 #define PWC_WB_MANUAL 3
111 #define PWC_WB_AUTO 4
112 
113 /* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
114  Set mode to one of the PWC_WB_* values above.
115  *red and *blue are the respective gains of these colour components inside
116  the camera; range 0..65535
117  When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
118  otherwise undefined.
119  'read_red' and 'read_blue' are read-only.
120 */
122 {
123  int mode;
124  int manual_red, manual_blue; /* R/W */
125  int read_red, read_blue; /* R/O */
126 };
127 
128 /*
129  'control_speed' and 'control_delay' are used in automatic whitebalance mode,
130  and tell the camera how fast it should react to changes in lighting, and
131  with how much delay. Valid values are 0..65535.
132 */
134 {
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) */
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  */
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  */
173 {
174  int pan_min, pan_max; /* degrees * 100 */
176 };
177 
179 {
180  int status;
181  int time_pan;
183 };
184 
185 /* This is used for out-of-kernel decompression. With it, you can get
186  all the necessary information to initialize and use the decompressor
187  routines in standalone applications.
188  */
190 {
191  int type; /* camera type (645, 675, 730, etc.) */
192  int release; /* release number */
193 
194  int size; /* one of PSZ_* */
196  int command_len; /* length of USB video command */
197  unsigned char command_buf[13]; /* Actual USB video command */
198  int bandlength; /* >0 = compressed */
199  int frame_size; /* Size of one (un)compressed frame */
200 };
201 
202 /* Flags for PWCX subroutines. Not all modules honour all flags. */
203 #define PWCX_FLAG_PLANAR 0x0001
204 #define PWCX_FLAG_BAYER 0x0008
205 
206 /* IOCTL definitions */
207 
208 /* Restore user settings */
209 #define VIDIOCPWCRUSER _IO('v', 192)
210 /* Save user settings */
211 #define VIDIOCPWCSUSER _IO('v', 193)
212 /* Restore factory settings */
213 #define VIDIOCPWCFACTORY _IO('v', 194)
214 
215 /* You can manipulate the compression factor. A compression preference of 0
216  means use uncompressed modes when available; 1 is low compression, 2 is
217  medium and 3 is high compression preferred. Of course, the higher the
218  compression, the lower the bandwidth used but more chance of artefacts
219  in the image. The driver automatically chooses a higher compression when
220  the preferred mode is not available.
221  */
222 /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */
223 #define VIDIOCPWCSCQUAL _IOW('v', 195, int)
224 /* Get preferred compression quality */
225 #define VIDIOCPWCGCQUAL _IOR('v', 195, int)
226 
227 /* Retrieve serial number of camera */
228 #define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial)
229 
230 /* This is a probe function; since so many devices are supported, it
231  becomes difficult to include all the names in programs that want to
232  check for the enhanced Philips stuff. So in stead, try this PROBE;
233  it returns a structure with the original name, and the corresponding
234  Philips type.
235  To use, fill the structure with zeroes, call PROBE and if that succeeds,
236  compare the name with that returned from VIDIOCGCAP; they should be the
237  same. If so, you can be assured it is a Philips (OEM) cam and the type
238  is valid.
239 */
240 #define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)
241 
242 /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */
243 #define VIDIOCPWCSAGC _IOW('v', 200, int)
244 /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */
245 #define VIDIOCPWCGAGC _IOR('v', 200, int)
246 /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */
247 #define VIDIOCPWCSSHUTTER _IOW('v', 201, int)
248 
249 /* Color compensation (Auto White Balance) */
250 #define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance)
251 #define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance)
252 
253 /* Auto WB speed */
254 #define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed)
255 #define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed)
256 
257 /* LEDs on/off/blink; int range 0..65535 */
258 #define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds)
259 #define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds)
260 
261 /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */
262 #define VIDIOCPWCSCONTOUR _IOW('v', 206, int)
263 #define VIDIOCPWCGCONTOUR _IOR('v', 206, int)
264 
265 /* Backlight compensation; 0 = off, otherwise on */
266 #define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int)
267 #define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int)
268 
269 /* Flickerless mode; = 0 off, otherwise on */
270 #define VIDIOCPWCSFLICKER _IOW('v', 208, int)
271 #define VIDIOCPWCGFLICKER _IOR('v', 208, int)
272 
273 /* Dynamic noise reduction; 0 off, 3 = high noise reduction */
274 #define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
275 #define VIDIOCPWCGDYNNOISE _IOR('v', 209, int)
276 
277 /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
278 #define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
279 
280 /* Motorized pan & tilt functions */
281 #define VIDIOCPWCMPTRESET _IOW('v', 211, int)
282 #define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
283 #define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
284 #define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)
285 #define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)
286 
287 /* Get the USB set-video command; needed for initializing libpwcx */
288 #define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)
290 {
291  int len;
292  char *buffer;
293 };
294 #define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer)
295 
296 /*
297  * This is private command used when communicating with v4l2.
298  * In the future all private ioctl will be remove/replace to
299  * use interface offer by v4l2.
300  */
301 
302 #define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0)
303 #define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1)
304 #define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2)
305 #define V4L2_CID_PRIVATE_COLOUR_MODE (V4L2_CID_PRIVATE_BASE + 3)
306 #define V4L2_CID_PRIVATE_AUTOCONTOUR (V4L2_CID_PRIVATE_BASE + 4)
307 #define V4L2_CID_PRIVATE_CONTOUR (V4L2_CID_PRIVATE_BASE + 5)
308 #define V4L2_CID_PRIVATE_BACKLIGHT (V4L2_CID_PRIVATE_BASE + 6)
309 #define V4L2_CID_PRIVATE_FLICKERLESS (V4L2_CID_PRIVATE_BASE + 7)
310 #define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8)
311 
313 {
314  __le16 type; /* type of the webcam */
315  __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */
316  __u8 cmd[4]; /* the four byte of the command (in case of nala,
317  only the first 3 bytes is filled) */
318  __u8 rawframe[0]; /* frame_size = H/4*vbandlength */
319 } __attribute__((packed));
pwc_imagesize::width
int width
Definition: pwc-ioctl.h:149
pwc_table_init_buffer::len
int len
Definition: pwc-ioctl.h:291
pwc_mpt_range::tilt_min
int tilt_min
Definition: pwc-ioctl.h:175
pwc_table_init_buffer::buffer
char * buffer
Definition: pwc-ioctl.h:292
pwc_video_command::release
int release
Definition: pwc-ioctl.h:192
pwc_video_command::bandlength
int bandlength
Definition: pwc-ioctl.h:198
pwc_whitebalance::mode
int mode
Definition: pwc-ioctl.h:123
pwc_video_command::command_buf
unsigned char command_buf[13]
Definition: pwc-ioctl.h:197
pwc_raw_frame::rawframe
__u8 rawframe[0]
Definition: pwc-ioctl.h:318
pwc_whitebalance::manual_red
int manual_red
Definition: pwc-ioctl.h:124
pwc_mpt_range::pan_max
int pan_max
Definition: pwc-ioctl.h:174
pwc_whitebalance::read_blue
int read_blue
Definition: pwc-ioctl.h:125
pwc_coord
Definition: pwc-ioctl.h:88
pwc_wb_speed::control_delay
int control_delay
Definition: pwc-ioctl.h:136
pwc_coord::y
int y
Definition: pwc-ioctl.h:90
pwc_mpt_status::status
int status
Definition: pwc-ioctl.h:180
pwc_raw_frame
Definition: pwc-ioctl.h:312
pwc_whitebalance
Definition: pwc-ioctl.h:121
pwc_probe::name
char name[32]
Definition: pwc-ioctl.h:97
pwc_whitebalance::manual_blue
int manual_blue
Definition: pwc-ioctl.h:124
pwc_coord::x
int x
Definition: pwc-ioctl.h:90
pwc_mpt_status::time_pan
int time_pan
Definition: pwc-ioctl.h:181
pwc_mpt_range::tilt_max
int tilt_max
Definition: pwc-ioctl.h:175
pwc_video_command::type
int type
Definition: pwc-ioctl.h:191
pwc_probe::type
int type
Definition: pwc-ioctl.h:98
__attribute__
struct pwc_raw_frame __attribute__((packed))
pwc_mpt_angles
Definition: pwc-ioctl.h:163
pwc_coord::size
int size
Definition: pwc-ioctl.h:91
pwc_imagesize::height
int height
Definition: pwc-ioctl.h:150
pwc_raw_frame::vbandlength
__le16 vbandlength
Definition: pwc-ioctl.h:315
pwc_video_command
Definition: pwc-ioctl.h:189
pwc_video_command::alternate
int alternate
Definition: pwc-ioctl.h:195
pwc_mpt_range::pan_min
int pan_min
Definition: pwc-ioctl.h:174
pwc_video_command::command_len
int command_len
Definition: pwc-ioctl.h:196
pwc_leds::led_on
int led_on
Definition: pwc-ioctl.h:142
pwc_leds
Definition: pwc-ioctl.h:140
pwc_serial::serial
char serial[30]
Definition: pwc-ioctl.h:103
pwc_raw_frame::type
__le16 type
Definition: pwc-ioctl.h:314
pwc_imagesize
Definition: pwc-ioctl.h:147
pwc_video_command::frame_size
int frame_size
Definition: pwc-ioctl.h:199
pwc_probe
Definition: pwc-ioctl.h:95
pwc_table_init_buffer
Definition: pwc-ioctl.h:289
pwc_video_command::size
int size
Definition: pwc-ioctl.h:194
pwc_mpt_angles::tilt
int tilt
Definition: pwc-ioctl.h:167
pwc_mpt_range
Definition: pwc-ioctl.h:172
pwc_mpt_angles::pan
int pan
Definition: pwc-ioctl.h:166
pwc_mpt_status
Definition: pwc-ioctl.h:178
pwc_leds::led_off
int led_off
Definition: pwc-ioctl.h:143
pwc_wb_speed
Definition: pwc-ioctl.h:133
pwc_whitebalance::read_red
int read_red
Definition: pwc-ioctl.h:125
pwc_raw_frame::cmd
__u8 cmd[4]
Definition: pwc-ioctl.h:316
pwc_wb_speed::control_speed
int control_speed
Definition: pwc-ioctl.h:135
pwc_serial
Definition: pwc-ioctl.h:101
pwc_mpt_angles::absolute
int absolute
Definition: pwc-ioctl.h:165
pwc_mpt_status::time_tilt
int time_tilt
Definition: pwc-ioctl.h:182