videodev.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. #ifndef __LINUX_VIDEODEV_H
  2. #define __LINUX_VIDEODEV_H
  3. #include <linux/compiler.h>
  4. #include <linux/types.h>
  5. #include <linux/version.h>
  6. #define HAVE_V4L2 1
  7. #include <linux/videodev2.h>
  8. #ifdef __KERNEL__
  9. #include <linux/poll.h>
  10. #include <linux/mm.h>
  11. #include <linux/device.h>
  12. struct video_device
  13. {
  14. /* device info */
  15. struct device *dev;
  16. char name[32];
  17. int type; /* v4l1 */
  18. int type2; /* v4l2 */
  19. int hardware;
  20. int minor;
  21. /* device ops + callbacks */
  22. struct file_operations *fops;
  23. void (*release)(struct video_device *vfd);
  24. #if 1 /* to be removed in 2.7.x */
  25. /* obsolete -- fops->owner is used instead */
  26. struct module *owner;
  27. /* dev->driver_data will be used instead some day.
  28. * Use the video_{get|set}_drvdata() helper functions,
  29. * so the switch over will be transparent for you.
  30. * Or use {pci|usb}_{get|set}_drvdata() directly. */
  31. void *priv;
  32. #endif
  33. /* for videodev.c intenal usage -- please don't touch */
  34. int users; /* video_exclusive_{open|close} ... */
  35. struct semaphore lock; /* ... helper function uses these */
  36. char devfs_name[64]; /* devfs */
  37. struct class_device class_dev; /* sysfs */
  38. };
  39. #define VIDEO_MAJOR 81
  40. #define VFL_TYPE_GRABBER 0
  41. #define VFL_TYPE_VBI 1
  42. #define VFL_TYPE_RADIO 2
  43. #define VFL_TYPE_VTX 3
  44. extern int video_register_device(struct video_device *, int type, int nr);
  45. extern void video_unregister_device(struct video_device *);
  46. extern struct video_device* video_devdata(struct file*);
  47. #define to_video_device(cd) container_of(cd, struct video_device, class_dev)
  48. static inline void
  49. video_device_create_file(struct video_device *vfd,
  50. struct class_device_attribute *attr)
  51. {
  52. class_device_create_file(&vfd->class_dev, attr);
  53. }
  54. static inline void
  55. video_device_remove_file(struct video_device *vfd,
  56. struct class_device_attribute *attr)
  57. {
  58. class_device_remove_file(&vfd->class_dev, attr);
  59. }
  60. /* helper functions to alloc / release struct video_device, the
  61. later can be used for video_device->release() */
  62. struct video_device *video_device_alloc(void);
  63. void video_device_release(struct video_device *vfd);
  64. /* helper functions to access driver private data. */
  65. static inline void *video_get_drvdata(struct video_device *dev)
  66. {
  67. return dev->priv;
  68. }
  69. static inline void video_set_drvdata(struct video_device *dev, void *data)
  70. {
  71. dev->priv = data;
  72. }
  73. extern int video_exclusive_open(struct inode *inode, struct file *file);
  74. extern int video_exclusive_release(struct inode *inode, struct file *file);
  75. extern int video_usercopy(struct inode *inode, struct file *file,
  76. unsigned int cmd, unsigned long arg,
  77. int (*func)(struct inode *inode, struct file *file,
  78. unsigned int cmd, void *arg));
  79. #endif /* __KERNEL__ */
  80. #define VID_TYPE_CAPTURE 1 /* Can capture */
  81. #define VID_TYPE_TUNER 2 /* Can tune */
  82. #define VID_TYPE_TELETEXT 4 /* Does teletext */
  83. #define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
  84. #define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
  85. #define VID_TYPE_CLIPPING 32 /* Can clip */
  86. #define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
  87. #define VID_TYPE_SCALES 128 /* Scalable */
  88. #define VID_TYPE_MONOCHROME 256 /* Monochrome only */
  89. #define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
  90. #define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
  91. #define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
  92. #define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
  93. #define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
  94. struct video_capability
  95. {
  96. char name[32];
  97. int type;
  98. int channels; /* Num channels */
  99. int audios; /* Num audio devices */
  100. int maxwidth; /* Supported width */
  101. int maxheight; /* And height */
  102. int minwidth; /* Supported width */
  103. int minheight; /* And height */
  104. };
  105. struct video_channel
  106. {
  107. int channel;
  108. char name[32];
  109. int tuners;
  110. __u32 flags;
  111. #define VIDEO_VC_TUNER 1 /* Channel has a tuner */
  112. #define VIDEO_VC_AUDIO 2 /* Channel has audio */
  113. __u16 type;
  114. #define VIDEO_TYPE_TV 1
  115. #define VIDEO_TYPE_CAMERA 2
  116. __u16 norm; /* Norm set by channel */
  117. };
  118. struct video_tuner
  119. {
  120. int tuner;
  121. char name[32];
  122. unsigned long rangelow, rangehigh; /* Tuner range */
  123. __u32 flags;
  124. #define VIDEO_TUNER_PAL 1
  125. #define VIDEO_TUNER_NTSC 2
  126. #define VIDEO_TUNER_SECAM 4
  127. #define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
  128. #define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
  129. #define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
  130. #define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */
  131. #define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */
  132. __u16 mode; /* PAL/NTSC/SECAM/OTHER */
  133. #define VIDEO_MODE_PAL 0
  134. #define VIDEO_MODE_NTSC 1
  135. #define VIDEO_MODE_SECAM 2
  136. #define VIDEO_MODE_AUTO 3
  137. __u16 signal; /* Signal strength 16bit scale */
  138. };
  139. struct video_picture
  140. {
  141. __u16 brightness;
  142. __u16 hue;
  143. __u16 colour;
  144. __u16 contrast;
  145. __u16 whiteness; /* Black and white only */
  146. __u16 depth; /* Capture depth */
  147. __u16 palette; /* Palette in use */
  148. #define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
  149. #define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
  150. #define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
  151. #define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
  152. #define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
  153. #define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
  154. #define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
  155. #define VIDEO_PALETTE_YUYV 8
  156. #define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
  157. #define VIDEO_PALETTE_YUV420 10
  158. #define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
  159. #define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
  160. #define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
  161. #define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
  162. #define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
  163. #define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
  164. #define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
  165. #define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
  166. };
  167. struct video_audio
  168. {
  169. int audio; /* Audio channel */
  170. __u16 volume; /* If settable */
  171. __u16 bass, treble;
  172. __u32 flags;
  173. #define VIDEO_AUDIO_MUTE 1
  174. #define VIDEO_AUDIO_MUTABLE 2
  175. #define VIDEO_AUDIO_VOLUME 4
  176. #define VIDEO_AUDIO_BASS 8
  177. #define VIDEO_AUDIO_TREBLE 16
  178. #define VIDEO_AUDIO_BALANCE 32
  179. char name[16];
  180. #define VIDEO_SOUND_MONO 1
  181. #define VIDEO_SOUND_STEREO 2
  182. #define VIDEO_SOUND_LANG1 4
  183. #define VIDEO_SOUND_LANG2 8
  184. __u16 mode;
  185. __u16 balance; /* Stereo balance */
  186. __u16 step; /* Step actual volume uses */
  187. };
  188. struct video_clip
  189. {
  190. __s32 x,y;
  191. __s32 width, height;
  192. struct video_clip *next; /* For user use/driver use only */
  193. };
  194. struct video_window
  195. {
  196. __u32 x,y; /* Position of window */
  197. __u32 width,height; /* Its size */
  198. __u32 chromakey;
  199. __u32 flags;
  200. struct video_clip __user *clips; /* Set only */
  201. int clipcount;
  202. #define VIDEO_WINDOW_INTERLACE 1
  203. #define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */
  204. #define VIDEO_CLIP_BITMAP -1
  205. /* bitmap is 1024x625, a '1' bit represents a clipped pixel */
  206. #define VIDEO_CLIPMAP_SIZE (128 * 625)
  207. };
  208. struct video_capture
  209. {
  210. __u32 x,y; /* Offsets into image */
  211. __u32 width, height; /* Area to capture */
  212. __u16 decimation; /* Decimation divider */
  213. __u16 flags; /* Flags for capture */
  214. #define VIDEO_CAPTURE_ODD 0 /* Temporal */
  215. #define VIDEO_CAPTURE_EVEN 1
  216. };
  217. struct video_buffer
  218. {
  219. void *base;
  220. int height,width;
  221. int depth;
  222. int bytesperline;
  223. };
  224. struct video_mmap
  225. {
  226. unsigned int frame; /* Frame (0 - n) for double buffer */
  227. int height,width;
  228. unsigned int format; /* should be VIDEO_PALETTE_* */
  229. };
  230. struct video_key
  231. {
  232. __u8 key[8];
  233. __u32 flags;
  234. };
  235. #define VIDEO_MAX_FRAME 32
  236. struct video_mbuf
  237. {
  238. int size; /* Total memory to map */
  239. int frames; /* Frames */
  240. int offsets[VIDEO_MAX_FRAME];
  241. };
  242. #define VIDEO_NO_UNIT (-1)
  243. struct video_unit
  244. {
  245. int video; /* Video minor */
  246. int vbi; /* VBI minor */
  247. int radio; /* Radio minor */
  248. int audio; /* Audio minor */
  249. int teletext; /* Teletext minor */
  250. };
  251. struct vbi_format {
  252. __u32 sampling_rate; /* in Hz */
  253. __u32 samples_per_line;
  254. __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */
  255. __s32 start[2]; /* starting line for each frame */
  256. __u32 count[2]; /* count of lines for each frame */
  257. __u32 flags;
  258. #define VBI_UNSYNC 1 /* can distingues between top/bottom field */
  259. #define VBI_INTERLACED 2 /* lines are interlaced */
  260. };
  261. /* video_info is biased towards hardware mpeg encode/decode */
  262. /* but it could apply generically to any hardware compressor/decompressor */
  263. struct video_info
  264. {
  265. __u32 frame_count; /* frames output since decode/encode began */
  266. __u32 h_size; /* current unscaled horizontal size */
  267. __u32 v_size; /* current unscaled veritcal size */
  268. __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */
  269. __u32 picture_type; /* current picture type */
  270. __u32 temporal_reference; /* current temporal reference */
  271. __u8 user_data[256]; /* user data last found in compressed stream */
  272. /* user_data[0] contains user data flags, user_data[1] has count */
  273. };
  274. /* generic structure for setting playback modes */
  275. struct video_play_mode
  276. {
  277. int mode;
  278. int p1;
  279. int p2;
  280. };
  281. /* for loading microcode / fpga programming */
  282. struct video_code
  283. {
  284. char loadwhat[16]; /* name or tag of file being passed */
  285. int datasize;
  286. __u8 *data;
  287. };
  288. #define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
  289. #define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
  290. #define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
  291. #define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
  292. #define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
  293. #define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
  294. #define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
  295. #define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
  296. #define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */
  297. #define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
  298. #define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
  299. #define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
  300. #define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
  301. #define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
  302. #define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
  303. #define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
  304. #define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
  305. #define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
  306. #define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
  307. #define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */
  308. #define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */
  309. #define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */
  310. #define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */
  311. #define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */
  312. #define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */
  313. #define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */
  314. #define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */
  315. #define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */
  316. #define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */
  317. #define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
  318. /* VIDIOCSWRITEMODE */
  319. #define VID_WRITE_MPEG_AUD 0
  320. #define VID_WRITE_MPEG_VID 1
  321. #define VID_WRITE_OSD 2
  322. #define VID_WRITE_TTX 3
  323. #define VID_WRITE_CC 4
  324. #define VID_WRITE_MJPEG 5
  325. /* VIDIOCSPLAYMODE */
  326. #define VID_PLAY_VID_OUT_MODE 0
  327. /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */
  328. #define VID_PLAY_GENLOCK 1
  329. /* p1: 0 = OFF, 1 = ON */
  330. /* p2: GENLOCK FINE DELAY value */
  331. #define VID_PLAY_NORMAL 2
  332. #define VID_PLAY_PAUSE 3
  333. #define VID_PLAY_SINGLE_FRAME 4
  334. #define VID_PLAY_FAST_FORWARD 5
  335. #define VID_PLAY_SLOW_MOTION 6
  336. #define VID_PLAY_IMMEDIATE_NORMAL 7
  337. #define VID_PLAY_SWITCH_CHANNELS 8
  338. #define VID_PLAY_FREEZE_FRAME 9
  339. #define VID_PLAY_STILL_MODE 10
  340. #define VID_PLAY_MASTER_MODE 11
  341. /* p1: see below */
  342. #define VID_PLAY_MASTER_NONE 1
  343. #define VID_PLAY_MASTER_VIDEO 2
  344. #define VID_PLAY_MASTER_AUDIO 3
  345. #define VID_PLAY_ACTIVE_SCANLINES 12
  346. /* p1 = first active; p2 = last active */
  347. #define VID_PLAY_RESET 13
  348. #define VID_PLAY_END_MARK 14
  349. #define VID_HARDWARE_BT848 1
  350. #define VID_HARDWARE_QCAM_BW 2
  351. #define VID_HARDWARE_PMS 3
  352. #define VID_HARDWARE_QCAM_C 4
  353. #define VID_HARDWARE_PSEUDO 5
  354. #define VID_HARDWARE_SAA5249 6
  355. #define VID_HARDWARE_AZTECH 7
  356. #define VID_HARDWARE_SF16MI 8
  357. #define VID_HARDWARE_RTRACK 9
  358. #define VID_HARDWARE_ZOLTRIX 10
  359. #define VID_HARDWARE_SAA7146 11
  360. #define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */
  361. #define VID_HARDWARE_RTRACK2 13
  362. #define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */
  363. #define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */
  364. #define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */
  365. #define VID_HARDWARE_BROADWAY 17 /* Broadway project */
  366. #define VID_HARDWARE_GEMTEK 18
  367. #define VID_HARDWARE_TYPHOON 19
  368. #define VID_HARDWARE_VINO 20 /* SGI Indy Vino */
  369. #define VID_HARDWARE_CADET 21 /* Cadet radio */
  370. #define VID_HARDWARE_TRUST 22 /* Trust FM Radio */
  371. #define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */
  372. #define VID_HARDWARE_CPIA 24
  373. #define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */
  374. #define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */
  375. #define VID_HARDWARE_OV511 27
  376. #define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */
  377. #define VID_HARDWARE_W9966 29
  378. #define VID_HARDWARE_SE401 30 /* SE401 USB webcams */
  379. #define VID_HARDWARE_PWC 31 /* Philips webcams */
  380. #define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */
  381. #define VID_HARDWARE_CPIA2 33
  382. #define VID_HARDWARE_VICAM 34
  383. #define VID_HARDWARE_SF16FMR2 35
  384. #define VID_HARDWARE_W9968CF 36
  385. #define VID_HARDWARE_SAA7114H 37
  386. #define VID_HARDWARE_SN9C102 38
  387. #define VID_HARDWARE_ARV 39
  388. #endif /* __LINUX_VIDEODEV_H */
  389. /*
  390. * Local variables:
  391. * c-basic-offset: 8
  392. * End:
  393. */