usbvision.h
来自「trident tm5600的linux驱动」· C头文件 代码 · 共 525 行 · 第 1/2 页
H
525 行
/* * USBVISION.H * usbvision header file * * Copyright (c) 1999-2005 Joerg Heckenbach <joerg@heckenbach-aw.de> * Dwaine Garden <dwainegarden@rogers.com> * * * Report problems to v4l MailingList : http://www.redhat.com/mailman/listinfo/video4linux-list * * This module is part of usbvision driver project. * Updates to driver completed by Dwaine P. Garden * v4l2 conversion by Thierry Merle <thierry.merle@free.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifndef __LINUX_USBVISION_H#define __LINUX_USBVISION_H#include <linux/list.h>#include <linux/usb.h>#include <linux/i2c.h>#include <linux/mutex.h>#include <media/v4l2-common.h>#include <media/tuner.h>#include <linux/videodev2.h>#include "compat.h"#define USBVISION_DEBUG /* Turn on debug messages */#define USBVISION_PWR_REG 0x00 #define USBVISION_SSPND_EN (1 << 1) #define USBVISION_RES2 (1 << 2) #define USBVISION_PWR_VID (1 << 5) #define USBVISION_E2_EN (1 << 7)#define USBVISION_CONFIG_REG 0x01#define USBVISION_ADRS_REG 0x02#define USBVISION_ALTER_REG 0x03#define USBVISION_FORCE_ALTER_REG 0x04#define USBVISION_STATUS_REG 0x05#define USBVISION_IOPIN_REG 0x06 #define USBVISION_IO_1 (1 << 0) #define USBVISION_IO_2 (1 << 1) #define USBVISION_AUDIO_IN 0 #define USBVISION_AUDIO_TV 1 #define USBVISION_AUDIO_RADIO 2 #define USBVISION_AUDIO_MUTE 3#define USBVISION_SER_MODE 0x07#define USBVISION_SER_ADRS 0x08#define USBVISION_SER_CONT 0x09#define USBVISION_SER_DAT1 0x0A#define USBVISION_SER_DAT2 0x0B#define USBVISION_SER_DAT3 0x0C#define USBVISION_SER_DAT4 0x0D#define USBVISION_EE_DATA 0x0E#define USBVISION_EE_LSBAD 0x0F#define USBVISION_EE_CONT 0x10#define USBVISION_DRM_CONT 0x12 #define USBVISION_REF (1 << 0) #define USBVISION_RES_UR (1 << 2) #define USBVISION_RES_FDL (1 << 3) #define USBVISION_RES_VDW (1 << 4)#define USBVISION_DRM_PRM1 0x13#define USBVISION_DRM_PRM2 0x14#define USBVISION_DRM_PRM3 0x15#define USBVISION_DRM_PRM4 0x16#define USBVISION_DRM_PRM5 0x17#define USBVISION_DRM_PRM6 0x18#define USBVISION_DRM_PRM7 0x19#define USBVISION_DRM_PRM8 0x1A#define USBVISION_VIN_REG1 0x1B #define USBVISION_8_422_SYNC 0x01 #define USBVISION_16_422_SYNC 0x02 #define USBVISION_VSNC_POL (1 << 3) #define USBVISION_HSNC_POL (1 << 4) #define USBVISION_FID_POL (1 << 5) #define USBVISION_HVALID_PO (1 << 6) #define USBVISION_VCLK_POL (1 << 7)#define USBVISION_VIN_REG2 0x1C #define USBVISION_AUTO_FID (1 << 0) #define USBVISION_NONE_INTER (1 << 1) #define USBVISION_NOHVALID (1 << 2) #define USBVISION_UV_ID (1 << 3) #define USBVISION_FIX_2C (1 << 4) #define USBVISION_SEND_FID (1 << 5) #define USBVISION_KEEP_BLANK (1 << 7)#define USBVISION_LXSIZE_I 0x1D#define USBVISION_MXSIZE_I 0x1E#define USBVISION_LYSIZE_I 0x1F#define USBVISION_MYSIZE_I 0x20#define USBVISION_LX_OFFST 0x21#define USBVISION_MX_OFFST 0x22#define USBVISION_LY_OFFST 0x23#define USBVISION_MY_OFFST 0x24#define USBVISION_FRM_RATE 0x25#define USBVISION_LXSIZE_O 0x26#define USBVISION_MXSIZE_O 0x27#define USBVISION_LYSIZE_O 0x28#define USBVISION_MYSIZE_O 0x29#define USBVISION_FILT_CONT 0x2A#define USBVISION_VO_MODE 0x2B#define USBVISION_INTRA_CYC 0x2C#define USBVISION_STRIP_SZ 0x2D#define USBVISION_FORCE_INTRA 0x2E#define USBVISION_FORCE_UP 0x2F#define USBVISION_BUF_THR 0x30#define USBVISION_DVI_YUV 0x31#define USBVISION_AUDIO_CONT 0x32#define USBVISION_AUD_PK_LEN 0x33#define USBVISION_BLK_PK_LEN 0x34#define USBVISION_PCM_THR1 0x38#define USBVISION_PCM_THR2 0x39#define USBVISION_DIST_THR_L 0x3A#define USBVISION_DIST_THR_H 0x3B#define USBVISION_MAX_DIST_L 0x3C#define USBVISION_MAX_DIST_H 0x3D#define USBVISION_OP_CODE 0x33#define MAX_BYTES_PER_PIXEL 4#define MIN_FRAME_WIDTH 64#define MAX_USB_WIDTH 320 //384#define MAX_FRAME_WIDTH 320 //384 /*streching sometimes causes crashes*/#define MIN_FRAME_HEIGHT 48#define MAX_USB_HEIGHT 240 //288#define MAX_FRAME_HEIGHT 240 //288 /*Streching sometimes causes crashes*/#define MAX_FRAME_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * MAX_BYTES_PER_PIXEL)#define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) //bytesize of clipmask#define USBVISION_URB_FRAMES 32#define USBVISION_NUM_HEADERMARKER 20#define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */#define USBVISION_NUMSBUF 2 /* Dimensioning the USB S buffering */#define USBVISION_POWEROFF_TIME 3 * (HZ) // 3 seconds#define FRAMERATE_MIN 0#define FRAMERATE_MAX 31enum { ISOC_MODE_YUV422 = 0x03, ISOC_MODE_YUV420 = 0x14, ISOC_MODE_COMPRESS = 0x60,};/* This macro restricts an int variable to an inclusive range */#define RESTRICT_TO_RANGE(v,mi,ma) { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); }/* * We use macros to do YUV -> RGB conversion because this is * very important for speed and totally unimportant for size. * * YUV -> RGB Conversion * --------------------- * * B = 1.164*(Y-16) + 2.018*(V-128) * G = 1.164*(Y-16) - 0.813*(U-128) - 0.391*(V-128) * R = 1.164*(Y-16) + 1.596*(U-128) * * If you fancy integer arithmetics (as you should), hear this: * * 65536*B = 76284*(Y-16) + 132252*(V-128) * 65536*G = 76284*(Y-16) - 53281*(U-128) - 25625*(V-128) * 65536*R = 76284*(Y-16) + 104595*(U-128) * * Make sure the output values are within [0..255] range. */#define LIMIT_RGB(x) (((x) < 0) ? 0 : (((x) > 255) ? 255 : (x)))#define YUV_TO_RGB_BY_THE_BOOK(my,mu,mv,mr,mg,mb) { \ int mm_y, mm_yc, mm_u, mm_v, mm_r, mm_g, mm_b; \ mm_y = (my) - 16; \ mm_u = (mu) - 128; \ mm_v = (mv) - 128; \ mm_yc= mm_y * 76284; \ mm_b = (mm_yc + 132252*mm_v ) >> 16; \ mm_g = (mm_yc - 53281*mm_u - 25625*mm_v ) >> 16; \ mm_r = (mm_yc + 104595*mm_u ) >> 16; \ mb = LIMIT_RGB(mm_b); \ mg = LIMIT_RGB(mm_g); \ mr = LIMIT_RGB(mm_r); \}/* Debugging aid */#define USBVISION_SAY_AND_WAIT(what) { \ wait_queue_head_t wq; \ init_waitqueue_head(&wq); \ printk(KERN_INFO "Say: %s\n", what); \ interruptible_sleep_on_timeout (&wq, HZ*3); \}/* * This macro checks if usbvision is still operational. The 'usbvision' * pointer must be valid, usbvision->dev must be valid, we are not * removing the device and the device has not erred on us. */#define USBVISION_IS_OPERATIONAL(udevice) (\ (udevice != NULL) && \ ((udevice)->dev != NULL) && \ ((udevice)->last_error == 0) && \ (!(udevice)->remove_pending))#define I2C_USB_ADAP_MAX 16#define USBVISION_NORMS (V4L2_STD_PAL | V4L2_STD_NTSC | V4L2_STD_SECAM | V4L2_STD_PAL_M)/* ----------------------------------------------------------------- *//* usbvision video structures *//* ----------------------------------------------------------------- */enum ScanState { ScanState_Scanning, /* Scanning for header */ ScanState_Lines /* Parsing lines */};/* Completion states of the data parser */enum ParseState { ParseState_Continue, /* Just parse next item */ ParseState_NextFrame, /* Frame done, send it to V4L */ ParseState_Out, /* Not enough data for frame */ ParseState_EndParse /* End parsing */};enum FrameState { FrameState_Unused, /* Unused (no MCAPTURE) */ FrameState_Ready, /* Ready to start grabbing */ FrameState_Grabbing, /* In the process of being grabbed into */ FrameState_Done, /* Finished grabbing, but not been synced yet */ FrameState_DoneHold, /* Are syncing or reading */ FrameState_Error, /* Something bad happened while processing */};/* stream states */enum StreamState { Stream_Off, /* Driver streaming is completely OFF */ Stream_Idle, /* Driver streaming is ready to be put ON by the application */ Stream_Interrupt, /* Driver streaming must be interrupted */ Stream_On, /* Driver streaming is put ON by the application */};enum IsocState { IsocState_InFrame, /* Isoc packet is member of frame */ IsocState_NoFrame, /* Isoc packet is not member of any frame */};struct usb_device;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?