pwc-ioctl.h
1 #ifndef PWC_IOCTL_H
2 #define PWC_IOCTL_H
3 
4 /* Copyright (C) 2001-2004 Nemosoft Unv.
5  Copyright (C) 2004 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 /* This is pwc-ioctl.h belonging to PWC 8.12.1
29  It contains structures and defines to communicate from user space
30  directly to the driver.
31  */
32 
33 /*
34  Changes
35  2001/08/03 Alvarado Added ioctl constants to access methods for
36  changing white balance and red/blue gains
37  2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
38  2003/12/13 Nemosft Unv. Some modifications to make interfacing to
39  PWCX easier
40  */
41 
42 /* These are private ioctl() commands, specific for the Philips webcams.
43  They contain functions not found in other webcams, and settings not
44  specified in the Video4Linux API.
45 
46  The #define names are built up like follows:
47  VIDIOC VIDeo IOCtl prefix
48  PWC Philps WebCam
49  G optional: Get
50  S optional: Set
51  ... the function
52  */
53 
54 
55  /* Enumeration of image sizes */
56 #define PSZ_SQCIF 0x00
57 #define PSZ_QSIF 0x01
58 #define PSZ_QCIF 0x02
59 #define PSZ_SIF 0x03
60 #define PSZ_CIF 0x04
61 #define PSZ_VGA 0x05
62 #define PSZ_MAX 6
63 
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 
69  In 'Snapshot' mode the camera freezes its automatic exposure and colour
70  balance controls.
71  */
72 #define PWC_FPS_SHIFT 16
73 #define PWC_FPS_MASK 0x00FF0000
74 #define PWC_FPS_FRMASK 0x003F0000
75 #define PWC_FPS_SNAPSHOT 0x00400000
76 
77 
78 /* structure for transfering x & y coordinates */
79 struct pwc_coord
80 {
81  int x, y; /* guess what */
82  int size; /* size, or offset */
83 };
84 
85 
86 /* Used with VIDIOCPWCPROBE */
87 struct pwc_probe
88 {
89  char name[32];
90  int type;
91 };
92 
93 struct pwc_serial
94 {
95  char serial[30]; /* String with serial number. Contains terminating 0 */
96 };
97 
98 /* pwc_whitebalance.mode values */
99 #define PWC_WB_INDOOR 0
100 #define PWC_WB_OUTDOOR 1
101 #define PWC_WB_FL 2
102 #define PWC_WB_MANUAL 3
103 #define PWC_WB_AUTO 4
104 
105 /* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
106  Set mode to one of the PWC_WB_* values above.
107  *red and *blue are the respective gains of these colour components inside
108  the camera; range 0..65535
109  When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
110  otherwise undefined.
111  'read_red' and 'read_blue' are read-only.
112 */
114 {
115  int mode;
116  int manual_red, manual_blue; /* R/W */
117  int read_red, read_blue; /* R/O */
118 };
119 
120 /*
121  'control_speed' and 'control_delay' are used in automatic whitebalance mode,
122  and tell the camera how fast it should react to changes in lighting, and
123  with how much delay. Valid values are 0..65535.
124 */
126 {
127  int control_speed;
128  int control_delay;
129 
130 };
131 
132 /* Used with VIDIOCPWC[SG]LED */
133 struct pwc_leds
134 {
135  int led_on; /* Led on-time; range = 0..25000 */
136  int led_off; /* Led off-time; range = 0..25000 */
137 };
138 
139 /* Image size (used with GREALSIZE) */
141 {
142  int width;
143  int height;
144 };
145 
146 /* Defines and structures for Motorized Pan & Tilt */
147 #define PWC_MPT_PAN 0x01
148 #define PWC_MPT_TILT 0x02
149 #define PWC_MPT_TIMEOUT 0x04 /* for status */
150 
151 /* Set angles; when absolute != 0, the angle is absolute and the
152  driver calculates the relative offset for you. This can only
153  be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
154  absolute angles.
155  */
157 {
158  int absolute; /* write-only */
159  int pan; /* degrees * 100 */
160  int tilt; /* degress * 100 */
161 };
162 
163 /* Range of angles of the camera, both horizontally and vertically.
164  */
166 {
167  int pan_min, pan_max; /* degrees * 100 */
168  int tilt_min, tilt_max;
169 };
170 
172 {
173  int status;
174  int time_pan;
175  int time_tilt;
176 };
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_* */
189  int alternate;
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 
201 /* IOCTL definitions */
202 
203  /* Restore user settings */
204 #define VIDIOCPWCRUSER _IO('v', 192)
205  /* Save user settings */
206 #define VIDIOCPWCSUSER _IO('v', 193)
207  /* Restore factory settings */
208 #define VIDIOCPWCFACTORY _IO('v', 194)
209 
210  /* You can manipulate the compression factor. A compression preference of 0
211  means use uncompressed modes when available; 1 is low compression, 2 is
212  medium and 3 is high compression preferred. Of course, the higher the
213  compression, the lower the bandwidth used but more chance of artefacts
214  in the image. The driver automatically chooses a higher compression when
215  the preferred mode is not available.
216  */
217  /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */
218 #define VIDIOCPWCSCQUAL _IOW('v', 195, int)
219  /* Get preferred compression quality */
220 #define VIDIOCPWCGCQUAL _IOR('v', 195, int)
221 
222 
223 /* Retrieve serial number of camera */
224 #define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial)
225 
226  /* This is a probe function; since so many devices are supported, it
227  becomes difficult to include all the names in programs that want to
228  check for the enhanced Philips stuff. So in stead, try this PROBE;
229  it returns a structure with the original name, and the corresponding
230  Philips type.
231  To use, fill the structure with zeroes, call PROBE and if that succeeds,
232  compare the name with that returned from VIDIOCGCAP; they should be the
233  same. If so, you can be assured it is a Philips (OEM) cam and the type
234  is valid.
235  */
236 #define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)
237 
238  /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */
239 #define VIDIOCPWCSAGC _IOW('v', 200, int)
240  /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */
241 #define VIDIOCPWCGAGC _IOR('v', 200, int)
242  /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */
243 #define VIDIOCPWCSSHUTTER _IOW('v', 201, int)
244 
245  /* Color compensation (Auto White Balance) */
246 #define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance)
247 #define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance)
248 
249  /* Auto WB speed */
250 #define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed)
251 #define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed)
252 
253  /* LEDs on/off/blink; int range 0..65535 */
254 #define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds)
255 #define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds)
256 
257  /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */
258 #define VIDIOCPWCSCONTOUR _IOW('v', 206, int)
259 #define VIDIOCPWCGCONTOUR _IOR('v', 206, int)
260 
261  /* Backlight compensation; 0 = off, otherwise on */
262 #define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int)
263 #define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int)
264 
265  /* Flickerless mode; = 0 off, otherwise on */
266 #define VIDIOCPWCSFLICKER _IOW('v', 208, int)
267 #define VIDIOCPWCGFLICKER _IOR('v', 208, int)
268 
269  /* Dynamic noise reduction; 0 off, 3 = high noise reduction */
270 #define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
271 #define VIDIOCPWCGDYNNOISE _IOR('v', 209, int)
272 
273  /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
274 #define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
275 
276  /* Motorized pan & tilt functions */
277 #define VIDIOCPWCMPTRESET _IOW('v', 211, int)
278 #define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
279 #define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
280 #define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)
281 #define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)
282 
283  /* Get the USB set-video command; needed for initializing libpwcx */
284 #define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)
286  int len;
287  char *buffer;
288 
289 };
290 #define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer)
291 
292 #endif
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:158
#define PLAYER_PTZ_DATA_STATE
Data subtype: state.
Definition: player_interfaces.h:1208
float tiltspeed
Desired tilt velocity [rad/s].
Definition: player_interfaces.h:1259
Definition: pwc-ioctl.h:79
Generic message header.
Definition: player.h:160
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:657
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:663
Data: state (PLAYER_PTZ_DATA_STATE)
Definition: player_interfaces.h:1228
float tilt
Desired tilt angle [rad].
Definition: player_interfaces.h:1253
Command: state (PLAYER_PTZ_CMD_STATE)
Definition: player_interfaces.h:1248
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
float zoom
Desired field of view [rad].
Definition: player_interfaces.h:1255
#define PLAYER_PTZ_POSITION_CONTROL
Control mode, for use with PLAYER_PTZ_REQ_CONTROL_MODE.
Definition: player_interfaces.h:1221
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:167
virtual void Main(void)=0
Main method for driver thread.
Definition: pwc-ioctl.h:113
int ReadInt(int section, const char *name, int value)
Read an integer value.
#define PLAYER_PTZ_REQ_GENERIC
Request/reply subtype: generic.
Definition: player_interfaces.h:1196
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:94
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:111
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: pwc-ioctl.h:156
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:105
uint32_t mode
Mode to use: must be either PLAYER_PTZ_VELOCITY_CONTROL or PLAYER_PTZ_POSITION_CONTROL.
Definition: player_interfaces.h:1305
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:124
Request/reply: Control mode.
Definition: player_interfaces.h:1301
Definition: pwc-ioctl.h:183
float pan
Desired pan angle [rad].
Definition: player_interfaces.h:1251
Class for loading configuration file information.
Definition: configfile.h:195
Definition: pwc-ioctl.h:133
float panspeed
Desired pan velocity [rad/s].
Definition: player_interfaces.h:1257
An autopointer for the message queue.
Definition: message.h:72
#define PLAYER_PTZ_VELOCITY_CONTROL
Control mode, for use with PLAYER_PTZ_REQ_CONTROL_MODE.
Definition: player_interfaces.h:1219
Definition: pwc-ioctl.h:140
Definition: pwc-ioctl.h:87
Definition: pwc-ioctl.h:285
Base class for drivers which oeprate with a thread.
Definition: driver.h:551
Definition: pwc-ioctl.h:165
#define PLAYER_PTZ_CMD_STATE
Command subtype: state.
Definition: player_interfaces.h:1214
Definition: pwc-ioctl.h:171
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:98
Definition: pwc-ioctl.h:125
Base class for all drivers.
Definition: driver.h:107
Definition: pwc-ioctl.h:93
#define PLAYER_PTZ_REQ_CONTROL_MODE
Request/reply subtype: control mode.
Definition: player_interfaces.h:1199
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:75