pwc-ioctl.h 11 KB

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