videodev2.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977
  1. #ifndef __LINUX_VIDEODEV2_H
  2. #define __LINUX_VIDEODEV2_H
  3. /*
  4. * Video for Linux Two
  5. *
  6. * Header file for v4l or V4L2 drivers and applications, for
  7. * Linux kernels 2.2.x or 2.4.x.
  8. *
  9. * See http://bytesex.org/v4l/ for API specs and other
  10. * v4l2 documentation.
  11. *
  12. * Author: Bill Dirks <bdirks@pacbell.net>
  13. * Justin Schoeman
  14. * et al.
  15. */
  16. #ifdef __KERNEL__
  17. #include <linux/time.h> /* need struct timeval */
  18. #endif
  19. #include <linux/compiler.h> /* need __user */
  20. /*
  21. * M I S C E L L A N E O U S
  22. */
  23. /* Four-character-code (FOURCC) */
  24. #define v4l2_fourcc(a,b,c,d)\
  25. (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
  26. /*
  27. * E N U M S
  28. */
  29. enum v4l2_field {
  30. V4L2_FIELD_ANY = 0, /* driver can choose from none,
  31. top, bottom, interlaced
  32. depending on whatever it thinks
  33. is approximate ... */
  34. V4L2_FIELD_NONE = 1, /* this device has no fields ... */
  35. V4L2_FIELD_TOP = 2, /* top field only */
  36. V4L2_FIELD_BOTTOM = 3, /* bottom field only */
  37. V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
  38. V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one
  39. buffer, top-bottom order */
  40. V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */
  41. V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into
  42. separate buffers */
  43. };
  44. #define V4L2_FIELD_HAS_TOP(field) \
  45. ((field) == V4L2_FIELD_TOP ||\
  46. (field) == V4L2_FIELD_INTERLACED ||\
  47. (field) == V4L2_FIELD_SEQ_TB ||\
  48. (field) == V4L2_FIELD_SEQ_BT)
  49. #define V4L2_FIELD_HAS_BOTTOM(field) \
  50. ((field) == V4L2_FIELD_BOTTOM ||\
  51. (field) == V4L2_FIELD_INTERLACED ||\
  52. (field) == V4L2_FIELD_SEQ_TB ||\
  53. (field) == V4L2_FIELD_SEQ_BT)
  54. #define V4L2_FIELD_HAS_BOTH(field) \
  55. ((field) == V4L2_FIELD_INTERLACED ||\
  56. (field) == V4L2_FIELD_SEQ_TB ||\
  57. (field) == V4L2_FIELD_SEQ_BT)
  58. enum v4l2_buf_type {
  59. V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
  60. V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
  61. V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
  62. V4L2_BUF_TYPE_VBI_CAPTURE = 4,
  63. V4L2_BUF_TYPE_VBI_OUTPUT = 5,
  64. V4L2_BUF_TYPE_PRIVATE = 0x80,
  65. };
  66. enum v4l2_ctrl_type {
  67. V4L2_CTRL_TYPE_INTEGER = 1,
  68. V4L2_CTRL_TYPE_BOOLEAN = 2,
  69. V4L2_CTRL_TYPE_MENU = 3,
  70. V4L2_CTRL_TYPE_BUTTON = 4,
  71. };
  72. enum v4l2_tuner_type {
  73. V4L2_TUNER_RADIO = 1,
  74. V4L2_TUNER_ANALOG_TV = 2,
  75. V4L2_TUNER_DIGITAL_TV = 3,
  76. };
  77. enum v4l2_memory {
  78. V4L2_MEMORY_MMAP = 1,
  79. V4L2_MEMORY_USERPTR = 2,
  80. V4L2_MEMORY_OVERLAY = 3,
  81. };
  82. /* see also http://vektor.theorem.ca/graphics/ycbcr/ */
  83. enum v4l2_colorspace {
  84. /* ITU-R 601 -- broadcast NTSC/PAL */
  85. V4L2_COLORSPACE_SMPTE170M = 1,
  86. /* 1125-Line (US) HDTV */
  87. V4L2_COLORSPACE_SMPTE240M = 2,
  88. /* HD and modern captures. */
  89. V4L2_COLORSPACE_REC709 = 3,
  90. /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
  91. V4L2_COLORSPACE_BT878 = 4,
  92. /* These should be useful. Assume 601 extents. */
  93. V4L2_COLORSPACE_470_SYSTEM_M = 5,
  94. V4L2_COLORSPACE_470_SYSTEM_BG = 6,
  95. /* I know there will be cameras that send this. So, this is
  96. * unspecified chromaticities and full 0-255 on each of the
  97. * Y'CbCr components
  98. */
  99. V4L2_COLORSPACE_JPEG = 7,
  100. /* For RGB colourspaces, this is probably a good start. */
  101. V4L2_COLORSPACE_SRGB = 8,
  102. };
  103. enum v4l2_priority {
  104. V4L2_PRIORITY_UNSET = 0, /* not initialized */
  105. V4L2_PRIORITY_BACKGROUND = 1,
  106. V4L2_PRIORITY_INTERACTIVE = 2,
  107. V4L2_PRIORITY_RECORD = 3,
  108. V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE,
  109. };
  110. struct v4l2_rect {
  111. __s32 left;
  112. __s32 top;
  113. __s32 width;
  114. __s32 height;
  115. };
  116. struct v4l2_fract {
  117. __u32 numerator;
  118. __u32 denominator;
  119. };
  120. /*
  121. * D R I V E R C A P A B I L I T I E S
  122. */
  123. struct v4l2_capability
  124. {
  125. __u8 driver[16]; /* i.e. "bttv" */
  126. __u8 card[32]; /* i.e. "Hauppauge WinTV" */
  127. __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
  128. __u32 version; /* should use KERNEL_VERSION() */
  129. __u32 capabilities; /* Device capabilities */
  130. __u32 reserved[4];
  131. };
  132. /* Values for 'capabilities' field */
  133. #define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */
  134. #define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */
  135. #define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */
  136. #define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a VBI capture device */
  137. #define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a VBI output device */
  138. #define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
  139. #define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
  140. #define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
  141. #define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
  142. #define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
  143. #define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
  144. #define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
  145. /*
  146. * V I D E O I M A G E F O R M A T
  147. */
  148. struct v4l2_pix_format
  149. {
  150. __u32 width;
  151. __u32 height;
  152. __u32 pixelformat;
  153. enum v4l2_field field;
  154. __u32 bytesperline; /* for padding, zero if unused */
  155. __u32 sizeimage;
  156. enum v4l2_colorspace colorspace;
  157. __u32 priv; /* private data, depends on pixelformat */
  158. };
  159. /* Pixel format FOURCC depth Description */
  160. #define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */
  161. #define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */
  162. #define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */
  163. #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */
  164. #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */
  165. #define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */
  166. #define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */
  167. #define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */
  168. #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */
  169. #define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */
  170. #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */
  171. #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */
  172. #define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */
  173. #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */
  174. #define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */
  175. #define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */
  176. #define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */
  177. /* two planes -- one Y, one Cr + Cb interleaved */
  178. #define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */
  179. #define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */
  180. /* The following formats are not defined in the V4L2 specification */
  181. #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */
  182. #define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */
  183. #define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */
  184. #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */
  185. /* see http://www.siliconimaging.com/RGB%20Bayer.htm */
  186. #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */
  187. /* compressed formats */
  188. #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */
  189. #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */
  190. #define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */
  191. #define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG */
  192. /* Vendor-specific formats */
  193. #define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */
  194. #define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */
  195. /*
  196. * F O R M A T E N U M E R A T I O N
  197. */
  198. struct v4l2_fmtdesc
  199. {
  200. __u32 index; /* Format number */
  201. enum v4l2_buf_type type; /* buffer type */
  202. __u32 flags;
  203. __u8 description[32]; /* Description string */
  204. __u32 pixelformat; /* Format fourcc */
  205. __u32 reserved[4];
  206. };
  207. #define V4L2_FMT_FLAG_COMPRESSED 0x0001
  208. /*
  209. * T I M E C O D E
  210. */
  211. struct v4l2_timecode
  212. {
  213. __u32 type;
  214. __u32 flags;
  215. __u8 frames;
  216. __u8 seconds;
  217. __u8 minutes;
  218. __u8 hours;
  219. __u8 userbits[4];
  220. };
  221. /* Type */
  222. #define V4L2_TC_TYPE_24FPS 1
  223. #define V4L2_TC_TYPE_25FPS 2
  224. #define V4L2_TC_TYPE_30FPS 3
  225. #define V4L2_TC_TYPE_50FPS 4
  226. #define V4L2_TC_TYPE_60FPS 5
  227. /* Flags */
  228. #define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */
  229. #define V4L2_TC_FLAG_COLORFRAME 0x0002
  230. #define V4L2_TC_USERBITS_field 0x000C
  231. #define V4L2_TC_USERBITS_USERDEFINED 0x0000
  232. #define V4L2_TC_USERBITS_8BITCHARS 0x0008
  233. /* The above is based on SMPTE timecodes */
  234. #if 1
  235. /*
  236. * M P E G C O M P R E S S I O N P A R A M E T E R S
  237. *
  238. * ### WARNING: this is still work-in-progress right now, most likely
  239. * ### there will be some incompatible changes.
  240. *
  241. */
  242. enum v4l2_bitrate_mode {
  243. V4L2_BITRATE_NONE = 0, /* not specified */
  244. V4L2_BITRATE_CBR, /* constant bitrate */
  245. V4L2_BITRATE_VBR, /* variable bitrate */
  246. };
  247. struct v4l2_bitrate {
  248. /* rates are specified in kbit/sec */
  249. enum v4l2_bitrate_mode mode;
  250. __u32 min;
  251. __u32 target; /* use this one for CBR */
  252. __u32 max;
  253. };
  254. enum v4l2_mpeg_streamtype {
  255. V4L2_MPEG_SS_1, /* MPEG-1 system stream */
  256. V4L2_MPEG_PS_2, /* MPEG-2 program stream */
  257. V4L2_MPEG_TS_2, /* MPEG-2 transport stream */
  258. V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */
  259. };
  260. enum v4l2_mpeg_audiotype {
  261. V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */
  262. V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */
  263. V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */
  264. V4L2_MPEG_AC3, /* AC3 */
  265. V4L2_MPEG_LPCM, /* LPCM */
  266. };
  267. enum v4l2_mpeg_videotype {
  268. V4L2_MPEG_VI_1, /* MPEG-1 */
  269. V4L2_MPEG_VI_2, /* MPEG-2 */
  270. };
  271. enum v4l2_mpeg_aspectratio {
  272. V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */
  273. V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */
  274. V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */
  275. V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */
  276. };
  277. struct v4l2_mpeg_compression {
  278. /* general */
  279. enum v4l2_mpeg_streamtype st_type;
  280. struct v4l2_bitrate st_bitrate;
  281. /* transport streams */
  282. __u16 ts_pid_pmt;
  283. __u16 ts_pid_audio;
  284. __u16 ts_pid_video;
  285. __u16 ts_pid_pcr;
  286. /* program stream */
  287. __u16 ps_size;
  288. __u16 reserved_1; /* align */
  289. /* audio */
  290. enum v4l2_mpeg_audiotype au_type;
  291. struct v4l2_bitrate au_bitrate;
  292. __u32 au_sample_rate;
  293. __u8 au_pesid;
  294. __u8 reserved_2[3]; /* align */
  295. /* video */
  296. enum v4l2_mpeg_videotype vi_type;
  297. enum v4l2_mpeg_aspectratio vi_aspect_ratio;
  298. struct v4l2_bitrate vi_bitrate;
  299. __u32 vi_frame_rate;
  300. __u16 vi_frames_per_gop;
  301. __u16 vi_bframes_count;
  302. __u8 vi_pesid;
  303. __u8 reserved_3[3]; /* align */
  304. /* misc flags */
  305. __u32 closed_gops:1;
  306. __u32 pulldown:1;
  307. __u32 reserved_4:30; /* align */
  308. /* I don't expect the above being perfect yet ;) */
  309. __u32 reserved_5[8];
  310. };
  311. #endif
  312. struct v4l2_jpegcompression
  313. {
  314. int quality;
  315. int APPn; /* Number of APP segment to be written,
  316. * must be 0..15 */
  317. int APP_len; /* Length of data in JPEG APPn segment */
  318. char APP_data[60]; /* Data in the JPEG APPn segment. */
  319. int COM_len; /* Length of data in JPEG COM segment */
  320. char COM_data[60]; /* Data in JPEG COM segment */
  321. __u32 jpeg_markers; /* Which markers should go into the JPEG
  322. * output. Unless you exactly know what
  323. * you do, leave them untouched.
  324. * Inluding less markers will make the
  325. * resulting code smaller, but there will
  326. * be fewer aplications which can read it.
  327. * The presence of the APP and COM marker
  328. * is influenced by APP_len and COM_len
  329. * ONLY, not by this property! */
  330. #define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
  331. #define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
  332. #define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
  333. #define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */
  334. #define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will
  335. * allways use APP0 */
  336. };
  337. /*
  338. * M E M O R Y - M A P P I N G B U F F E R S
  339. */
  340. struct v4l2_requestbuffers
  341. {
  342. __u32 count;
  343. enum v4l2_buf_type type;
  344. enum v4l2_memory memory;
  345. __u32 reserved[2];
  346. };
  347. struct v4l2_buffer
  348. {
  349. __u32 index;
  350. enum v4l2_buf_type type;
  351. __u32 bytesused;
  352. __u32 flags;
  353. enum v4l2_field field;
  354. struct timeval timestamp;
  355. struct v4l2_timecode timecode;
  356. __u32 sequence;
  357. /* memory location */
  358. enum v4l2_memory memory;
  359. union {
  360. __u32 offset;
  361. unsigned long userptr;
  362. } m;
  363. __u32 length;
  364. __u32 input;
  365. __u32 reserved;
  366. };
  367. /* Flags for 'flags' field */
  368. #define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
  369. #define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
  370. #define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
  371. #define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
  372. #define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
  373. #define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
  374. #define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
  375. #define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */
  376. /*
  377. * O V E R L A Y P R E V I E W
  378. */
  379. struct v4l2_framebuffer
  380. {
  381. __u32 capability;
  382. __u32 flags;
  383. /* FIXME: in theory we should pass something like PCI device + memory
  384. * region + offset instead of some physical address */
  385. void* base;
  386. struct v4l2_pix_format fmt;
  387. };
  388. /* Flags for the 'capability' field. Read only */
  389. #define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
  390. #define V4L2_FBUF_CAP_CHROMAKEY 0x0002
  391. #define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
  392. #define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
  393. /* Flags for the 'flags' field. */
  394. #define V4L2_FBUF_FLAG_PRIMARY 0x0001
  395. #define V4L2_FBUF_FLAG_OVERLAY 0x0002
  396. #define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
  397. struct v4l2_clip
  398. {
  399. struct v4l2_rect c;
  400. struct v4l2_clip *next;
  401. };
  402. struct v4l2_window
  403. {
  404. struct v4l2_rect w;
  405. enum v4l2_field field;
  406. __u32 chromakey;
  407. struct v4l2_clip __user *clips;
  408. __u32 clipcount;
  409. void __user *bitmap;
  410. };
  411. /*
  412. * C A P T U R E P A R A M E T E R S
  413. */
  414. struct v4l2_captureparm
  415. {
  416. __u32 capability; /* Supported modes */
  417. __u32 capturemode; /* Current mode */
  418. struct v4l2_fract timeperframe; /* Time per frame in .1us units */
  419. __u32 extendedmode; /* Driver-specific extensions */
  420. __u32 readbuffers; /* # of buffers for read */
  421. __u32 reserved[4];
  422. };
  423. /* Flags for 'capability' and 'capturemode' fields */
  424. #define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
  425. #define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
  426. struct v4l2_outputparm
  427. {
  428. __u32 capability; /* Supported modes */
  429. __u32 outputmode; /* Current mode */
  430. struct v4l2_fract timeperframe; /* Time per frame in seconds */
  431. __u32 extendedmode; /* Driver-specific extensions */
  432. __u32 writebuffers; /* # of buffers for write */
  433. __u32 reserved[4];
  434. };
  435. /*
  436. * I N P U T I M A G E C R O P P I N G
  437. */
  438. struct v4l2_cropcap {
  439. enum v4l2_buf_type type;
  440. struct v4l2_rect bounds;
  441. struct v4l2_rect defrect;
  442. struct v4l2_fract pixelaspect;
  443. };
  444. struct v4l2_crop {
  445. enum v4l2_buf_type type;
  446. struct v4l2_rect c;
  447. };
  448. /*
  449. * A N A L O G V I D E O S T A N D A R D
  450. */
  451. typedef __u64 v4l2_std_id;
  452. /* one bit for each */
  453. #define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001)
  454. #define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002)
  455. #define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004)
  456. #define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008)
  457. #define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010)
  458. #define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020)
  459. #define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040)
  460. #define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080)
  461. #define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100)
  462. #define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200)
  463. #define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
  464. #define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
  465. #define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
  466. #define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
  467. #define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
  468. #define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
  469. #define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
  470. #define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000)
  471. #define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
  472. #define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
  473. #define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
  474. /* ATSC/HDTV */
  475. #define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
  476. #define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)
  477. /* some common needed stuff */
  478. #define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\
  479. V4L2_STD_PAL_B1 |\
  480. V4L2_STD_PAL_G)
  481. #define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\
  482. V4L2_STD_PAL_D1 |\
  483. V4L2_STD_PAL_K)
  484. #define V4L2_STD_PAL (V4L2_STD_PAL_BG |\
  485. V4L2_STD_PAL_DK |\
  486. V4L2_STD_PAL_H |\
  487. V4L2_STD_PAL_I)
  488. #define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\
  489. V4L2_STD_NTSC_M_JP)
  490. #define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\
  491. V4L2_STD_SECAM_K |\
  492. V4L2_STD_SECAM_K1)
  493. #define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\
  494. V4L2_STD_SECAM_G |\
  495. V4L2_STD_SECAM_H |\
  496. V4L2_STD_SECAM_DK |\
  497. V4L2_STD_SECAM_L)
  498. #define V4L2_STD_525_60 (V4L2_STD_PAL_M |\
  499. V4L2_STD_PAL_60 |\
  500. V4L2_STD_NTSC)
  501. #define V4L2_STD_625_50 (V4L2_STD_PAL |\
  502. V4L2_STD_PAL_N |\
  503. V4L2_STD_PAL_Nc |\
  504. V4L2_STD_SECAM)
  505. #define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\
  506. V4L2_STD_ATSC_16_VSB)
  507. #define V4L2_STD_UNKNOWN 0
  508. #define V4L2_STD_ALL (V4L2_STD_525_60 |\
  509. V4L2_STD_625_50)
  510. struct v4l2_standard
  511. {
  512. __u32 index;
  513. v4l2_std_id id;
  514. __u8 name[24];
  515. struct v4l2_fract frameperiod; /* Frames, not fields */
  516. __u32 framelines;
  517. __u32 reserved[4];
  518. };
  519. /*
  520. * V I D E O I N P U T S
  521. */
  522. struct v4l2_input
  523. {
  524. __u32 index; /* Which input */
  525. __u8 name[32]; /* Label */
  526. __u32 type; /* Type of input */
  527. __u32 audioset; /* Associated audios (bitfield) */
  528. __u32 tuner; /* Associated tuner */
  529. v4l2_std_id std;
  530. __u32 status;
  531. __u32 reserved[4];
  532. };
  533. /* Values for the 'type' field */
  534. #define V4L2_INPUT_TYPE_TUNER 1
  535. #define V4L2_INPUT_TYPE_CAMERA 2
  536. /* field 'status' - general */
  537. #define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */
  538. #define V4L2_IN_ST_NO_SIGNAL 0x00000002
  539. #define V4L2_IN_ST_NO_COLOR 0x00000004
  540. /* field 'status' - analog */
  541. #define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */
  542. #define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */
  543. /* field 'status' - digital */
  544. #define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */
  545. #define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */
  546. #define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */
  547. /* field 'status' - VCR and set-top box */
  548. #define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */
  549. #define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */
  550. #define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */
  551. /*
  552. * V I D E O O U T P U T S
  553. */
  554. struct v4l2_output
  555. {
  556. __u32 index; /* Which output */
  557. __u8 name[32]; /* Label */
  558. __u32 type; /* Type of output */
  559. __u32 audioset; /* Associated audios (bitfield) */
  560. __u32 modulator; /* Associated modulator */
  561. v4l2_std_id std;
  562. __u32 reserved[4];
  563. };
  564. /* Values for the 'type' field */
  565. #define V4L2_OUTPUT_TYPE_MODULATOR 1
  566. #define V4L2_OUTPUT_TYPE_ANALOG 2
  567. #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
  568. /*
  569. * C O N T R O L S
  570. */
  571. struct v4l2_control
  572. {
  573. __u32 id;
  574. __s32 value;
  575. };
  576. /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
  577. struct v4l2_queryctrl
  578. {
  579. __u32 id;
  580. enum v4l2_ctrl_type type;
  581. __u8 name[32]; /* Whatever */
  582. __s32 minimum; /* Note signedness */
  583. __s32 maximum;
  584. __s32 step;
  585. __s32 default_value;
  586. __u32 flags;
  587. __u32 reserved[2];
  588. };
  589. /* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
  590. struct v4l2_querymenu
  591. {
  592. __u32 id;
  593. __u32 index;
  594. __u8 name[32]; /* Whatever */
  595. __u32 reserved;
  596. };
  597. /* Control flags */
  598. #define V4L2_CTRL_FLAG_DISABLED 0x0001
  599. #define V4L2_CTRL_FLAG_GRABBED 0x0002
  600. /* Control IDs defined by V4L2 */
  601. #define V4L2_CID_BASE 0x00980900
  602. /* IDs reserved for driver specific controls */
  603. #define V4L2_CID_PRIVATE_BASE 0x08000000
  604. #define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
  605. #define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
  606. #define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
  607. #define V4L2_CID_HUE (V4L2_CID_BASE+3)
  608. #define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5)
  609. #define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6)
  610. #define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7)
  611. #define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
  612. #define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
  613. #define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
  614. #define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11)
  615. #define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
  616. #define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
  617. #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
  618. #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
  619. #define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
  620. #define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */
  621. #define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
  622. #define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
  623. #define V4L2_CID_GAIN (V4L2_CID_BASE+19)
  624. #define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
  625. #define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
  626. #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
  627. #define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
  628. #define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */
  629. /*
  630. * T U N I N G
  631. */
  632. struct v4l2_tuner
  633. {
  634. __u32 index;
  635. __u8 name[32];
  636. enum v4l2_tuner_type type;
  637. __u32 capability;
  638. __u32 rangelow;
  639. __u32 rangehigh;
  640. __u32 rxsubchans;
  641. __u32 audmode;
  642. __s32 signal;
  643. __s32 afc;
  644. __u32 reserved[4];
  645. };
  646. struct v4l2_modulator
  647. {
  648. __u32 index;
  649. __u8 name[32];
  650. __u32 capability;
  651. __u32 rangelow;
  652. __u32 rangehigh;
  653. __u32 txsubchans;
  654. __u32 reserved[4];
  655. };
  656. /* Flags for the 'capability' field */
  657. #define V4L2_TUNER_CAP_LOW 0x0001
  658. #define V4L2_TUNER_CAP_NORM 0x0002
  659. #define V4L2_TUNER_CAP_STEREO 0x0010
  660. #define V4L2_TUNER_CAP_LANG2 0x0020
  661. #define V4L2_TUNER_CAP_SAP 0x0020
  662. #define V4L2_TUNER_CAP_LANG1 0x0040
  663. /* Flags for the 'rxsubchans' field */
  664. #define V4L2_TUNER_SUB_MONO 0x0001
  665. #define V4L2_TUNER_SUB_STEREO 0x0002
  666. #define V4L2_TUNER_SUB_LANG2 0x0004
  667. #define V4L2_TUNER_SUB_SAP 0x0004
  668. #define V4L2_TUNER_SUB_LANG1 0x0008
  669. /* Values for the 'audmode' field */
  670. #define V4L2_TUNER_MODE_MONO 0x0000
  671. #define V4L2_TUNER_MODE_STEREO 0x0001
  672. #define V4L2_TUNER_MODE_LANG2 0x0002
  673. #define V4L2_TUNER_MODE_SAP 0x0002
  674. #define V4L2_TUNER_MODE_LANG1 0x0003
  675. struct v4l2_frequency
  676. {
  677. __u32 tuner;
  678. enum v4l2_tuner_type type;
  679. __u32 frequency;
  680. __u32 reserved[8];
  681. };
  682. /*
  683. * A U D I O
  684. */
  685. struct v4l2_audio
  686. {
  687. __u32 index;
  688. __u8 name[32];
  689. __u32 capability;
  690. __u32 mode;
  691. __u32 reserved[2];
  692. };
  693. /* Flags for the 'capability' field */
  694. #define V4L2_AUDCAP_STEREO 0x00001
  695. #define V4L2_AUDCAP_AVL 0x00002
  696. /* Flags for the 'mode' field */
  697. #define V4L2_AUDMODE_AVL 0x00001
  698. struct v4l2_audioout
  699. {
  700. __u32 index;
  701. __u8 name[32];
  702. __u32 capability;
  703. __u32 mode;
  704. __u32 reserved[2];
  705. };
  706. /*
  707. * D A T A S E R V I C E S ( V B I )
  708. *
  709. * Data services API by Michael Schimek
  710. */
  711. struct v4l2_vbi_format
  712. {
  713. __u32 sampling_rate; /* in 1 Hz */
  714. __u32 offset;
  715. __u32 samples_per_line;
  716. __u32 sample_format; /* V4L2_PIX_FMT_* */
  717. __s32 start[2];
  718. __u32 count[2];
  719. __u32 flags; /* V4L2_VBI_* */
  720. __u32 reserved[2]; /* must be zero */
  721. };
  722. /* VBI flags */
  723. #define V4L2_VBI_UNSYNC (1<< 0)
  724. #define V4L2_VBI_INTERLACED (1<< 1)
  725. /*
  726. * A G G R E G A T E S T R U C T U R E S
  727. */
  728. /* Stream data format
  729. */
  730. struct v4l2_format
  731. {
  732. enum v4l2_buf_type type;
  733. union
  734. {
  735. struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE
  736. struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY
  737. struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE
  738. __u8 raw_data[200]; // user-defined
  739. } fmt;
  740. };
  741. /* Stream type-dependent parameters
  742. */
  743. struct v4l2_streamparm
  744. {
  745. enum v4l2_buf_type type;
  746. union
  747. {
  748. struct v4l2_captureparm capture;
  749. struct v4l2_outputparm output;
  750. __u8 raw_data[200]; /* user-defined */
  751. } parm;
  752. };
  753. /*
  754. * I O C T L C O D E S F O R V I D E O D E V I C E S
  755. *
  756. */
  757. #define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability)
  758. #define VIDIOC_RESERVED _IO ('V', 1)
  759. #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc)
  760. #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format)
  761. #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format)
  762. #if 1 /* experimental */
  763. #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression)
  764. #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression)
  765. #endif
  766. #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers)
  767. #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer)
  768. #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer)
  769. #define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer)
  770. #define VIDIOC_OVERLAY _IOW ('V', 14, int)
  771. #define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer)
  772. #define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer)
  773. #define VIDIOC_STREAMON _IOW ('V', 18, int)
  774. #define VIDIOC_STREAMOFF _IOW ('V', 19, int)
  775. #define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm)
  776. #define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm)
  777. #define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id)
  778. #define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id)
  779. #define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard)
  780. #define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input)
  781. #define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control)
  782. #define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control)
  783. #define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner)
  784. #define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner)
  785. #define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio)
  786. #define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio)
  787. #define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl)
  788. #define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu)
  789. #define VIDIOC_G_INPUT _IOR ('V', 38, int)
  790. #define VIDIOC_S_INPUT _IOWR ('V', 39, int)
  791. #define VIDIOC_G_OUTPUT _IOR ('V', 46, int)
  792. #define VIDIOC_S_OUTPUT _IOWR ('V', 47, int)
  793. #define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output)
  794. #define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout)
  795. #define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout)
  796. #define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator)
  797. #define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator)
  798. #define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency)
  799. #define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency)
  800. #define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap)
  801. #define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop)
  802. #define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop)
  803. #define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression)
  804. #define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression)
  805. #define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id)
  806. #define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format)
  807. #define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio)
  808. #define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout)
  809. #define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority)
  810. #define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority)
  811. /* for compatibility, will go away some day */
  812. #define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int)
  813. #define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm)
  814. #define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control)
  815. #define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio)
  816. #define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout)
  817. #define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap)
  818. #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
  819. #ifdef __KERNEL__
  820. /*
  821. *
  822. * V 4 L 2 D R I V E R H E L P E R A P I
  823. *
  824. * Some commonly needed functions for drivers (v4l2-common.o module)
  825. */
  826. #include <linux/fs.h>
  827. /* Video standard functions */
  828. extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
  829. extern int v4l2_video_std_construct(struct v4l2_standard *vs,
  830. int id, char *name);
  831. /* prority handling */
  832. struct v4l2_prio_state {
  833. atomic_t prios[4];
  834. };
  835. int v4l2_prio_init(struct v4l2_prio_state *global);
  836. int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
  837. enum v4l2_priority new);
  838. int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
  839. int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
  840. enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
  841. int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
  842. /* names for fancy debug output */
  843. extern char *v4l2_field_names[];
  844. extern char *v4l2_type_names[];
  845. extern char *v4l2_ioctl_names[];
  846. /* Compatibility layer interface -- v4l1-compat module */
  847. typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
  848. unsigned int cmd, void *arg);
  849. int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
  850. int cmd, void *arg, v4l2_kioctl driver_ioctl);
  851. #endif /* __KERNEL__ */
  852. #endif /* __LINUX_VIDEODEV2_H */
  853. /*
  854. * Local variables:
  855. * c-basic-offset: 8
  856. * End:
  857. */