#ifndef PWC_IOCTL_H1#define PWC_IOCTL_H23/* (C) 2001-2004 Nemosoft Unv.4(C) 2004-2006 Luc Saillard ([email protected])56NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx7driver and thus may have bugs that are not present in the original version.8Please send bug reports and support requests to <[email protected]>.9The decompression routines have been implemented by reverse-engineering the10Nemosoft binary pwcx module. Caveat emptor.1112This program is free software; you can redistribute it and/or modify13it under the terms of the GNU General Public License as published by14the Free Software Foundation; either version 2 of the License, or15(at your option) any later version.1617This program is distributed in the hope that it will be useful,18but WITHOUT ANY WARRANTY; without even the implied warranty of19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20GNU General Public License for more details.2122You should have received a copy of the GNU General Public License23along with this program; if not, write to the Free Software24Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA25*/2627/* This is pwc-ioctl.h belonging to PWC 10.0.1028It contains structures and defines to communicate from user space29directly to the driver.30*/3132/*33Changes342001/08/03 Alvarado Added ioctl constants to access methods for35changing white balance and red/blue gains362002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE372003/12/13 Nemosft Unv. Some modifications to make interfacing to38PWCX easier392006/01/01 Luc Saillard Add raw format definition40*/4142/* These are private ioctl() commands, specific for the Philips webcams.43They contain functions not found in other webcams, and settings not44specified in the Video4Linux API.4546The #define names are built up like follows:47VIDIOC VIDeo IOCtl prefix48PWC Philps WebCam49G optional: Get50S optional: Set51... the function52*/5354#include <linux/types.h>55#include <linux/version.h>5657/* Enumeration of image sizes */58#define PSZ_SQCIF 0x0059#define PSZ_QSIF 0x0160#define PSZ_QCIF 0x0261#define PSZ_SIF 0x0362#define PSZ_CIF 0x0463#define PSZ_VGA 0x0564#define PSZ_MAX 6656667/* The frame rate is encoded in the video_window.flags parameter using68the upper 16 bits, since some flags are defined nowadays. The following69defines provide a mask and shift to filter out this value.70This value can also be passing using the private flag when using v4l2 and71VIDIOC_S_FMT ioctl.7273In 'Snapshot' mode the camera freezes its automatic exposure and colour74balance controls.75*/76#define PWC_FPS_SHIFT 1677#define PWC_FPS_MASK 0x00FF000078#define PWC_FPS_FRMASK 0x003F000079#define PWC_FPS_SNAPSHOT 0x0040000080#define PWC_QLT_MASK 0x0300000081#define PWC_QLT_SHIFT 24828384/* structure for transferring x & y coordinates */85struct pwc_coord86{87int x, y; /* guess what */88int size; /* size, or offset */89};909192/* Used with VIDIOCPWCPROBE */93struct pwc_probe94{95char name[32];96int type;97};9899struct pwc_serial100{101char serial[30]; /* String with serial number. Contains terminating 0 */102};103104/* pwc_whitebalance.mode values */105#define PWC_WB_INDOOR 0106#define PWC_WB_OUTDOOR 1107#define PWC_WB_FL 2108#define PWC_WB_MANUAL 3109#define PWC_WB_AUTO 4110111/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).112Set mode to one of the PWC_WB_* values above.113*red and *blue are the respective gains of these colour components inside114the camera; range 0..65535115When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;116otherwise undefined.117'read_red' and 'read_blue' are read-only.118*/119struct pwc_whitebalance120{121int mode;122int manual_red, manual_blue; /* R/W */123int read_red, read_blue; /* R/O */124};125126/*127'control_speed' and 'control_delay' are used in automatic whitebalance mode,128and tell the camera how fast it should react to changes in lighting, and129with how much delay. Valid values are 0..65535.130*/131struct pwc_wb_speed132{133int control_speed;134int control_delay;135136};137138/* Used with VIDIOCPWC[SG]LED */139struct pwc_leds140{141int led_on; /* Led on-time; range = 0..25000 */142int led_off; /* Led off-time; range = 0..25000 */143};144145/* Image size (used with GREALSIZE) */146struct pwc_imagesize147{148int width;149int height;150};151152/* Defines and structures for Motorized Pan & Tilt */153#define PWC_MPT_PAN 0x01154#define PWC_MPT_TILT 0x02155#define PWC_MPT_TIMEOUT 0x04 /* for status */156157/* Set angles; when absolute != 0, the angle is absolute and the158driver calculates the relative offset for you. This can only159be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns160absolute angles.161*/162struct pwc_mpt_angles163{164int absolute; /* write-only */165int pan; /* degrees * 100 */166int tilt; /* degress * 100 */167};168169/* Range of angles of the camera, both horizontally and vertically.170*/171struct pwc_mpt_range172{173int pan_min, pan_max; /* degrees * 100 */174int tilt_min, tilt_max;175};176177struct pwc_mpt_status178{179int status;180int time_pan;181int time_tilt;182};183184185/* This is used for out-of-kernel decompression. With it, you can get186all the necessary information to initialize and use the decompressor187routines in standalone applications.188*/189struct pwc_video_command190{191int type; /* camera type (645, 675, 730, etc.) */192int release; /* release number */193194int size; /* one of PSZ_* */195int alternate;196int command_len; /* length of USB video command */197unsigned char command_buf[13]; /* Actual USB video command */198int bandlength; /* >0 = compressed */199int frame_size; /* Size of one (un)compressed frame */200};201202/* Flags for PWCX subroutines. Not all modules honour all flags. */203#define PWCX_FLAG_PLANAR 0x0001204#define PWCX_FLAG_BAYER 0x0008205206207/* IOCTL definitions */208209/* Restore user settings */210#define VIDIOCPWCRUSER _IO('v', 192)211/* Save user settings */212#define VIDIOCPWCSUSER _IO('v', 193)213/* Restore factory settings */214#define VIDIOCPWCFACTORY _IO('v', 194)215216/* You can manipulate the compression factor. A compression preference of 0217means use uncompressed modes when available; 1 is low compression, 2 is218medium and 3 is high compression preferred. Of course, the higher the219compression, the lower the bandwidth used but more chance of artefacts220in the image. The driver automatically chooses a higher compression when221the preferred mode is not available.222*/223/* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */224#define VIDIOCPWCSCQUAL _IOW('v', 195, int)225/* Get preferred compression quality */226#define VIDIOCPWCGCQUAL _IOR('v', 195, int)227228229/* Retrieve serial number of camera */230#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial)231232/* This is a probe function; since so many devices are supported, it233becomes difficult to include all the names in programs that want to234check for the enhanced Philips stuff. So in stead, try this PROBE;235it returns a structure with the original name, and the corresponding236Philips type.237To use, fill the structure with zeroes, call PROBE and if that succeeds,238compare the name with that returned from VIDIOCGCAP; they should be the239same. If so, you can be assured it is a Philips (OEM) cam and the type240is valid.241*/242#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)243244/* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */245#define VIDIOCPWCSAGC _IOW('v', 200, int)246/* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */247#define VIDIOCPWCGAGC _IOR('v', 200, int)248/* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */249#define VIDIOCPWCSSHUTTER _IOW('v', 201, int)250251/* Color compensation (Auto White Balance) */252#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance)253#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance)254255/* Auto WB speed */256#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed)257#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed)258259/* LEDs on/off/blink; int range 0..65535 */260#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds)261#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds)262263/* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */264#define VIDIOCPWCSCONTOUR _IOW('v', 206, int)265#define VIDIOCPWCGCONTOUR _IOR('v', 206, int)266267/* Backlight compensation; 0 = off, otherwise on */268#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int)269#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int)270271/* Flickerless mode; = 0 off, otherwise on */272#define VIDIOCPWCSFLICKER _IOW('v', 208, int)273#define VIDIOCPWCGFLICKER _IOR('v', 208, int)274275/* Dynamic noise reduction; 0 off, 3 = high noise reduction */276#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)277#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int)278279/* Real image size as used by the camera; tells you whether or not there's a gray border around the image */280#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)281282/* Motorized pan & tilt functions */283#define VIDIOCPWCMPTRESET _IOW('v', 211, int)284#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)285#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)286#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)287#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)288289/* Get the USB set-video command; needed for initializing libpwcx */290#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)291struct pwc_table_init_buffer {292int len;293char *buffer;294295};296#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer)297298/*299* This is private command used when communicating with v4l2.300* In the future all private ioctl will be remove/replace to301* use interface offer by v4l2.302*/303304#define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0)305#define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1)306#define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2)307#define V4L2_CID_PRIVATE_COLOUR_MODE (V4L2_CID_PRIVATE_BASE + 3)308#define V4L2_CID_PRIVATE_AUTOCONTOUR (V4L2_CID_PRIVATE_BASE + 4)309#define V4L2_CID_PRIVATE_CONTOUR (V4L2_CID_PRIVATE_BASE + 5)310#define V4L2_CID_PRIVATE_BACKLIGHT (V4L2_CID_PRIVATE_BASE + 6)311#define V4L2_CID_PRIVATE_FLICKERLESS (V4L2_CID_PRIVATE_BASE + 7)312#define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8)313314struct pwc_raw_frame {315__le16 type; /* type of the webcam */316__le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */317__u8 cmd[4]; /* the four byte of the command (in case of nala,318only the first 3 bytes is filled) */319__u8 rawframe[0]; /* frame_size = H/4*vbandlength */320} __attribute__ ((packed));321322323#endif324325326