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