⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbvideo.h

📁 基于S3CEB2410平台LINUX操作系统下 USB驱动源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
	int user_size;			/* Size of that camera-dependent data */	int debug;			/* Debug level for usbvideo */	unsigned char iface;		/* Video interface number */	unsigned char video_endp;	unsigned char ifaceAltActive;	unsigned char ifaceAltInactive; /* Alt settings */	unsigned long flags;		/* FLAGS_USBVIDEO_xxx */	unsigned long paletteBits;	/* Which palettes we accept? */	unsigned short defaultPalette;	/* What palette to use for read() */	struct semaphore lock;	int user;		/* user count for exclusive use */	videosize_t videosize;	/* Current setting */	videosize_t canvas;	/* This is the width,height of the V4L canvas */	int max_frame_size;	/* Bytes in one video frame */	int uvd_used;        	/* Is this structure in use? */	int streaming;		/* Are we streaming Isochronous? */	int grabbing;		/* Are we grabbing? */	int settingsAdjusted;	/* Have we adjusted contrast etc.? */	int last_error;		/* What calamity struck us? */	char *fbuf;		/* Videodev buffer area */	int fbuf_size;		/* Videodev buffer size */	int curframe;	int iso_packet_len;	/* Videomode-dependent, saves bus bandwidth */	RingQueue_t dp;		/* Isoc data pump */	usbvideo_frame_t frame[USBVIDEO_NUMFRAMES];	usbvideo_sbuf_t sbuf[USBVIDEO_NUMSBUF];	volatile int remove_pending;	/* If set then about to exit */	struct video_picture vpic, vpic_old;	/* Picture settings */	struct video_capability vcap;		/* Video capabilities */	struct video_channel vchan;	/* May be used for tuner support */	usbvideo_statistics_t stats;	struct proc_dir_entry *procfs_vEntry;	/* /proc/video/MYDRIVER/video2 */	char videoName[32];		/* Holds name like "video7" */} uvd_t;/* * usbvideo callbacks (virtual methods). They are set when usbvideo * services are registered. All of these default to NULL, except those * that default to usbvideo-provided methods. */typedef struct {	void *(*probe)(struct usb_device *, unsigned int,const struct usb_device_id *);	void (*userFree)(uvd_t *);	void (*disconnect)(struct usb_device *, void *);	int (*setupOnOpen)(uvd_t *);	void (*videoStart)(uvd_t *);	void (*videoStop)(uvd_t *);	void (*processData)(uvd_t *, usbvideo_frame_t *);	void (*postProcess)(uvd_t *, usbvideo_frame_t *);	void (*adjustPicture)(uvd_t *);	int (*getFPS)(uvd_t *);	int (*overlayHook)(uvd_t *, usbvideo_frame_t *);	int (*getFrame)(uvd_t *, int);	int (*procfs_read)(char *page,char **start,off_t off,int count,int *eof,void *data);	int (*procfs_write)(struct file *file,const char *buffer,unsigned long count,void *data);} usbvideo_cb_t;struct s_usbvideo_t {	int num_cameras;		/* As allocated */	struct usb_driver usbdrv;	/* Interface to the USB stack */	char drvName[80];		/* Driver name */	struct semaphore lock;		/* Mutex protecting camera structures */	usbvideo_cb_t cb;		/* Table of callbacks (virtual methods) */	struct video_device vdt;	/* Video device template */	uvd_t *cam;			/* Array of camera structures */	int uses_procfs;		/* Non-zero if we create /proc entries */	struct proc_dir_entry *procfs_dEntry;	/* /proc/video/MYDRIVER */	struct module *md_module;	/* Minidriver module */};typedef struct s_usbvideo_t usbvideo_t;/* * This macro retrieves callback address from the uvd_t object. * No validity checks are done here, so be sure to check the * callback beforehand with VALID_CALLBACK. */#define	GET_CALLBACK(uvd,cbName) ((uvd)->handle->cb.cbName)/* * This macro returns either callback pointer or NULL. This is safe * macro, meaning that most of components of data structures involved * may be NULL - this only results in NULL being returned. You may * wish to use this macro to make sure that the callback is callable. * However keep in mind that those checks take time. */#define	VALID_CALLBACK(uvd,cbName) ((((uvd) != NULL) && \		((uvd)->handle != NULL)) ? GET_CALLBACK(uvd,cbName) : NULL)void RingQueue_Initialize(RingQueue_t *rq);void RingQueue_Allocate(RingQueue_t *rq, int rqLen);int  RingQueue_IsAllocated(const RingQueue_t *rq);void RingQueue_Free(RingQueue_t *rq);int  RingQueue_Dequeue(RingQueue_t *rq, unsigned char *dst, int len);int  RingQueue_Enqueue(RingQueue_t *rq, const unsigned char *cdata, int n);int  RingQueue_GetLength(const RingQueue_t *rq);void RingQueue_InterruptibleSleepOn(RingQueue_t *rq);void RingQueue_WakeUpInterruptible(RingQueue_t *rq);void usbvideo_CollectRawData(uvd_t *uvd, usbvideo_frame_t *frame);void usbvideo_DrawLine(	usbvideo_frame_t *frame,	int x1, int y1,	int x2, int y2,	unsigned char cr, unsigned char cg, unsigned char cb);void usbvideo_HexDump(const unsigned char *data, int len);void usbvideo_OverlayChar(uvd_t *uvd, usbvideo_frame_t *frame, int x, int y, int ch);void usbvideo_OverlayString(uvd_t *uvd, usbvideo_frame_t *frame, int x, int y, const char *str);void usbvideo_OverlayStats(uvd_t *uvd, usbvideo_frame_t *frame);void usbvideo_ReportStatistics(const uvd_t *uvd);void usbvideo_SayAndWait(const char *what);void usbvideo_TestPattern(uvd_t *uvd, int fullframe, int pmode);void usbvideo_VideosizeToString(char *buf, int bufLen, videosize_t vs);/* Memory allocation routines */unsigned long usbvideo_uvirt_to_kva(pgd_t *pgd, unsigned long adr);unsigned long usbvideo_kvirt_to_pa(unsigned long adr);void *usbvideo_rvmalloc(unsigned long size);void usbvideo_rvfree(void *mem, unsigned long size);int usbvideo_register(	usbvideo_t **pCams,	const int num_cams,	const int num_extra,	const char *driverName,	const usbvideo_cb_t *cbTable,	struct module *md);uvd_t *usbvideo_AllocateDevice(usbvideo_t *cams);int usbvideo_RegisterVideoDevice(uvd_t *uvd);void usbvideo_Deregister(usbvideo_t **uvt);void usbvideo_Disconnect(struct usb_device *dev, void *ptr);void usbvideo_CameraRelease(uvd_t *uvd);void usbvideo_v4l_close(struct video_device *dev);int usbvideo_v4l_initialize(struct video_device *dev);int usbvideo_v4l_ioctl(struct video_device *dev, unsigned int cmd, void *arg);int usbvideo_v4l_mmap(struct video_device *dev, const char *adr, unsigned long size);int usbvideo_v4l_open(struct video_device *dev, int flags);long usbvideo_v4l_read(struct video_device *dev, char *buf,			unsigned long count, int noblock);long usbvideo_v4l_write(struct video_device *dev, const char *buf,			unsigned long count, int noblock);int usbvideo_GetFrame(uvd_t *uvd, int frameNum);int usbvideo_NewFrame(uvd_t *uvd, int framenum);int usbvideo_StartDataPump(uvd_t *uvd);void usbvideo_StopDataPump(uvd_t *uvd);void usbvideo_DeinterlaceFrame(uvd_t *uvd, usbvideo_frame_t *frame);void usbvideo_SoftwareContrastAdjustment(uvd_t *uvd, usbvideo_frame_t *frame);/* * This code performs bounds checking - use it when working with * new formats, or else you may get oopses all over the place. * If pixel falls out of bounds then it gets shoved back (as close * to place of offence as possible) and is painted bright red. * * There are two important concepts: frame width, height and * V4L canvas width, height. The former is the area requested by * the application -for this very frame-. The latter is the largest * possible frame that we can serve (we advertise that via V4L ioctl). * The frame data is expected to be formatted as lines of length * VIDEOSIZE_X(fr->request), total VIDEOSIZE_Y(frame->request) lines. */static inline void RGB24_PUTPIXEL(	usbvideo_frame_t *fr,	int ix, int iy,	unsigned char vr,	unsigned char vg,	unsigned char vb){	register unsigned char *pf;	int limiter = 0, mx, my;	mx = ix;	my = iy;	if (mx < 0) {		mx=0;		limiter++;	} else if (mx >= VIDEOSIZE_X((fr)->request)) {		mx= VIDEOSIZE_X((fr)->request) - 1;		limiter++;	}	if (my < 0) {		my = 0;		limiter++;	} else if (my >= VIDEOSIZE_Y((fr)->request)) {		my = VIDEOSIZE_Y((fr)->request) - 1;		limiter++;	}	pf = (fr)->data + V4L_BYTES_PER_PIXEL*((iy)*VIDEOSIZE_X((fr)->request) + (ix));	if (limiter) {		*pf++ = 0;		*pf++ = 0;		*pf++ = 0xFF;	} else {		*pf++ = (vb);		*pf++ = (vg);		*pf++ = (vr);	}}#endif /* usbvideo_h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -