📄 spca5xx.c
字号:
/* * SPCA5xx based usb camera driver (currently supports * yuv native stream spca501a, spca501c, spca505, spca508, spca506 * jpeg native stream spca500, spca551, spca504a, spca504b, spca533a, spca536a, zc0301, zc0302, cx11646, sn9c102p * bayer native stream spca561a, sn9c101, sn9c102, tv8532 ). * Z-star Vimicro chips zc0301 zc0301P zc0302 * Sunplus spca501a, spca501c, spca505, spca508, spca506, spca500, spca551, spca504a, spca504b, spca533a, spca536a * Sonix sn9c101, sn9c102, sn9c102p sn9c105 sn9c120 * Conexant cx11646 * Transvision tv_8532 * Etoms Et61x151 Et61x251 * Pixat Pac207-BCA-32 * SPCA5xx version by Michel Xhaard <mxhaard@users.sourceforge.net> * Based on : * SPCA50x version by Joel Crisp <cydergoth@users.sourceforge.net> * OmniVision OV511 Camera-to-USB Bridge Driver * Copyright (c) 1999-2000 Mark W. McClelland * Kernel 2.6.x port Michel Xhaard && Reza Jelveh (feb 2004) * Based on the Linux CPiA driver written by Peter Pregler, * Scott J. Bertin and Johannes Erdfelt. * 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. */static const char version[] = SPCA5XX_VERSION;#include <linux/config.h>#include <linux/module.h>#include <linux/version.h>#include <linux/init.h>#include <linux/fs.h>#include <linux/vmalloc.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/string.h>#include <linux/kernel.h>#include <linux/proc_fs.h>#include <linux/ctype.h>#include <linux/pagemap.h>#include <linux/usb.h>#include <asm/io.h>#include <asm/semaphore.h>#include <asm/page.h>#include <asm/uaccess.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)/* only on 2.6.x */#include <linux/jiffies.h>#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)#include <linux/wrapper.h>#endif#include <linux/param.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)#include <linux/moduleparam.h>#endif#include "spca5xx.h"#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)# undef CONFIG_VIDEO_PROC_FS# undef CONFIG_PROC_FS#endif//#define RH9_REMAP 1#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)#include "spcaCompat.h"#ifndef pte_offset_kernel# define pte_offset_kernel(dir, address) pte_offset(dir, address)#endif#endif#include "spcadecoder.h"#include "jpeg_qtables.h"#define PROC_NAME_LEN 10 //length of the proc name/* Video Size 640 x 480 x 4 bytes for RGB */#define MAX_FRAME_SIZE (640 * 480 * 4)#define MAX_DATA_SIZE (MAX_FRAME_SIZE + sizeof(struct timeval))/* Hardware auto exposure / whiteness (PC-CAM 600) */static int autoexpo = 1;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)/* Video device number (-1 is first available) */static int video_nr = -1;#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5) *//* 0=no debug messages * 1=init/detection/unload and other significant messages, * 2=some warning messages * 3=config/control function calls * 4=most function calls and data parsing messages * 5=highly repetitive mesgs * NOTE: This should be changed to 0, 1, or 2 for production kernels */static int debug = 0;/* Force image to be read in RGB instead of BGR. This option allow * programs that expect RGB data (e.g. gqcam) to work with this driver. */static int force_rgb = 0;static int gamma = 3;static int OffRed = 0;static int OffBlue = 0;static int OffGreen = 0;static int GRed = 256;static int GBlue = 256;static int GGreen = 256;static int usbgrabber = 0;#ifdef SPCA50X_ENABLE_COMPRESSION/* Enable compression. This is for experimentation only; compressed images * still cannot be decoded yet. */static int compress = 0;#endif /* SPCA50X_ENABLE_COMPRESSION */#ifdef SPCA5XX_ENABLE_REGISTERPLAYstatic int RegAddress = 0;static int RegValue = 0;static int RegStrobe = 0;#endif /* SPCA5XX_ENABLE_REGISTERPLAY *//* Initial brightness & contrast (for debug purposes) */static int bright = 0x80;static int contrast = 0x60;/* Parameter that enables you to set the minimal suitable bpp */static int min_bpp = 0;/* Parameter defines the average luminance that should be kept */static int lum_level = 0x2d;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)module_param(autoexpo, int, 0644);module_param(debug, int, 0644);module_param(force_rgb, int, 0644);module_param(gamma, int, 0644);module_param(OffRed, int, 0644);module_param(OffBlue, int, 0644);module_param(OffGreen, int, 0644);module_param(GRed, int, 0644);module_param(GBlue, int, 0644);module_param(GGreen, int, 0644);#ifdef SPCA50X_ENABLE_COMPRESSIONmodule_param(compress, int, 0644);#endif /* SPCA50X_ENABLE_COMPRESSION */module_param(bright, int, 0444);module_param(contrast, int, 0444);module_param(min_bpp, int, 0444);module_param(lum_level, int, 0444);module_param(usbgrabber, int, 0444);#ifdef SPCA5XX_ENABLE_REGISTERPLAYmodule_param(RegAddress, int, 0644);module_param(RegValue, int, 0644);module_param(RegStrobe, int, 0644);#endif /* SPCA5XX_ENABLE_REGISTERPLAY */#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) */MODULE_PARM(autoexpo, "i");MODULE_PARM(debug, "i");MODULE_PARM(force_rgb, "i");MODULE_PARM(gamma, "i");MODULE_PARM(OffRed, "i");MODULE_PARM(OffBlue, "i");MODULE_PARM(OffGreen, "i");MODULE_PARM(GRed, "i");MODULE_PARM(GBlue, "i");MODULE_PARM(GGreen, "i");#ifdef SPCA50X_ENABLE_COMPRESSIONMODULE_PARM(compress, "i");#endif /* SPCA50X_ENABLE_COMPRESSION */MODULE_PARM(bright, "i");MODULE_PARM(contrast, "i");MODULE_PARM(min_bpp, "i");MODULE_PARM(lum_level, "0-255i");MODULE_PARM(usbgrabber, "i");#endif/***************/MODULE_PARM_DESC(autoexpo, "Enable/Disable auto exposure (default=1: enabled) (PC-CAM 600/Zc03xx/spca561a/Etoms Only !!!)");MODULE_PARM_DESC(debug, "Debug level: 0=none, 1=init/detection, 2=warning, 3=config/control, 4=function call, 5=max");MODULE_PARM_DESC(force_rgb, "Read RGB instead of BGR");MODULE_PARM_DESC(gamma, "gamma setting range 0 to 7 3-> gamma=1");MODULE_PARM_DESC(OffRed, "OffRed setting range -128 to 128");MODULE_PARM_DESC(OffBlue, "OffBlue setting range -128 to 128");MODULE_PARM_DESC(OffGreen, "OffGreen setting range -128 to 128");MODULE_PARM_DESC(GRed, "Gain Red setting range 0 to 512 /256 ");MODULE_PARM_DESC(GBlue, "Gain Blue setting range 0 to 512 /256 ");MODULE_PARM_DESC(GGreen, "Gain Green setting range 0 to 512 /256 ");#ifdef SPCA50X_ENABLE_COMPRESSIONMODULE_PARM_DESC(compress, "Turn on/off compression (not functional yet)");#endif /* SPCA50X_ENABLE_COMPRESSION */MODULE_PARM_DESC(bright, "Initial brightness factor (0-255) not know by all webcams !!");MODULE_PARM_DESC(contrast, "Initial contrast factor (0-255) not know by all webcams !!");MODULE_PARM_DESC(min_bpp, "The minimal color depth that may be set (default 0)");MODULE_PARM_DESC(lum_level, "Luminance level for brightness autoadjustment (default 32)");MODULE_PARM_DESC(usbgrabber, "Is a usb grabber 0x0733:0x0430 ? (default 1) ");#ifdef SPCA5XX_ENABLE_REGISTERPLAYMODULE_PARM_DESC(RegAddress, "Register Address of PAC207");MODULE_PARM_DESC(RegValue, "Register Value for PAC207");MODULE_PARM_DESC(RegStrobe, "Strobe to read or write a register 1=write, 2=read");#endif /* SPCA5XX_ENABLE_REGISTERPLAY *//****************/MODULE_AUTHOR ("Michel Xhaard <mxhaard@users.sourceforge.net> based on spca50x driver by Joel Crisp <cydergoth@users.sourceforge.net>,ov511 driver by Mark McClelland <mwm@i.am>");MODULE_DESCRIPTION("SPCA5XX USB Camera Driver");MODULE_LICENSE("GPL");static int spca50x_move_data(struct usb_spca50x *spca50x, struct urb *urb);static struct usb_driver spca5xx_driver;#ifndef maxstatic inline int max(int a, int b){ return (a > b) ? a : b;}#endif /* max *//********************************************************************** * List of known SPCA50X-based cameras **********************************************************************//* Camera type jpeg yuvy yyuv yuyv grey gbrg*/static struct palette_list Plist[] = { {JPEG, "JPEG"}, {JPGH, "JPEG"}, {JPGC, "JPEG"}, {JPGS, "JPEG"}, {JPGM, "JPEG"}, {YUVY, "YUVY"}, {YYUV, "YYUV"}, {YUYV, "YUYV"}, {GREY, "GREY"}, {GBRG, "GBRG"}, {SN9C, "SN9C"}, {GBGR, "GBGR"}, {S561, "S561"}, {PGBRG, "GBRG"}, {-1, NULL}};static struct bridge_list Blist[] = { {BRIDGE_SPCA505, "SPCA505"}, {BRIDGE_SPCA506, "SPCA506"}, {BRIDGE_SPCA501, "SPCA501"}, {BRIDGE_SPCA508, "SPCA508"}, {BRIDGE_SPCA504, "SPCA504"}, {BRIDGE_SPCA500, "SPCA500"}, {BRIDGE_SPCA504B, "SPCA504B"}, {BRIDGE_SPCA533, "SPCA533"}, {BRIDGE_SPCA504C, "SPCA504C"}, {BRIDGE_SPCA561, "SPCA561"}, {BRIDGE_SPCA536, "SPCA536"}, {BRIDGE_SONIX, "SN9C102"}, {BRIDGE_ZC3XX, "ZC301-2"}, {BRIDGE_CX11646, "CX11646"}, {BRIDGE_TV8532, "TV8532"}, {BRIDGE_ETOMS, "ET61XX51"}, {BRIDGE_SN9CXXX, "SN9CXXX"}, {BRIDGE_MR97311, "MR97311"}, {BRIDGE_PAC207, "PAC207BCA"}, {-1, NULL}};enum { UnknownCamera = 0, // 0 IntelPCCameraPro, IntelCreateAndShare, GrandtecVcap, ViewQuestM318B, ViewQuestVQ110, KodakDVC325, MustekGsmartMini2, MustekGsmartMini3, CreativePCCam300, DLinkDSC350, // 10 CreativePCCam600, IntelPocketPCCamera, IntelEasyPCCamera, ThreeComHomeConnectLite, KodakEZ200, MaxellMaxPocket, AiptekMiniPenCam2, AiptekPocketDVII, AiptekPenCamSD, AiptekMiniPenCam13, // 20 MustekGsmartLCD3, MustekMDC5500Z, MegapixV4, AiptekPocketDV, HamaUSBSightcam, Arowana300KCMOSCamera, MystFromOriUnknownCamera, AiptekPocketDV3100, AiptekPocketCam3M, GeniusVideoCAMExpressV2, // 30 Flexcam100Camera, MustekGsmartLCD2, PureDigitalDakota, PetCam, BenqDC1500, LogitechClickSmart420, LogitechClickSmart510, BenqDC1300, HamaUSBSightcam2, MustekDV3000, // 40 CreativePccam750, MaxellCompactPM3, BenqDC3410, BenqDC1016, MicroInnovationIC200, LogitechTraveler, Flycam100Camera, UsbGrabberPV321c, ADSInstantVCD, Gsmartmini, // 50 Jenoptikjdc21lcd, LogitechClickSmart310, Terratec2move13, MustekDV4000, AiptekDV3500, LogitechClickSmart820, Enigma13, Sonix6025, Epsilon13, Nxultra, //60 AiptekPocketCam2M, DeMonUSBCapture, CreativeVista, PolaroidPDC2030, CreativeNotebook, CreativeMobile, LabtecPro, MustekWcam300A, GeniusVideoCamV2, GeniusVideoCamV3, GeniusVideoCamExpressV2b, CreativeNxPro, Sonix6029, //73 74 75 Vimicro, Digitrex2110, GsmartD30, CreativeNxPro2, Bs888e, Zc302, CreativeNoteBook2, AiptekSlim3200, /* 83 84 85 */ LabtecWebcam, QCExpress, ICM532cam, MustekGsmart300, CreativeLive, //90 MercuryDigital, Wcam300A, CreativeVista3b, VeoStingray1, VeoStingray2, TyphoonWebshotIIUSB300k, //96 PolaroidPDC3070, QCExpressEtch2, QCforNotebook, QCim, //100 WebCam320,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -