spca505.c

来自「trident tm5600的linux驱动」· C语言 代码 · 共 944 行 · 第 1/2 页

C
944
字号
/* * SPCA505 chip based cameras initialization data * * V4L2 by Jean-Francis Moine <http://moinejf.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 * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#define MODULE_NAME "spca505"#include "gspca.h"MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver");MODULE_LICENSE("GPL");/* specific webcam descriptor */struct sd {	struct gspca_dev gspca_dev;		/* !! must be the first item */	unsigned char brightness;	char subtype;#define IntelPCCameraPro 0#define Nxultra 1};/* V4L2 controls supported by the driver */static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);static struct ctrl sd_ctrls[] = {#define SD_BRIGHTNESS 0	{	    {		.id      = V4L2_CID_BRIGHTNESS,		.type    = V4L2_CTRL_TYPE_INTEGER,		.name    = "Brightness",		.minimum = 0,		.maximum = 255,		.step    = 1,		.default_value = 127,	    },	    .set = sd_setbrightness,	    .get = sd_getbrightness,	},};static struct v4l2_pix_format vga_mode[] = {	{160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,		.bytesperline = 160,		.sizeimage = 160 * 120 * 3 / 2,		.colorspace = V4L2_COLORSPACE_SRGB,		.priv = 5},	{176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,		.bytesperline = 176,		.sizeimage = 176 * 144 * 3 / 2,		.colorspace = V4L2_COLORSPACE_SRGB,		.priv = 4},	{320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,		.bytesperline = 320,		.sizeimage = 320 * 240 * 3 / 2,		.colorspace = V4L2_COLORSPACE_SRGB,		.priv = 2},	{352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,		.bytesperline = 352,		.sizeimage = 352 * 288 * 3 / 2,		.colorspace = V4L2_COLORSPACE_SRGB,		.priv = 1},	{640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,		.bytesperline = 640,		.sizeimage = 640 * 480 * 3 / 2,		.colorspace = V4L2_COLORSPACE_SRGB,		.priv = 0},};#define SPCA50X_OFFSET_DATA 10#define SPCA50X_REG_USB 0x02	/* spca505 501 */#define SPCA50X_USB_CTRL 0x00	/* spca505 */#define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */#define SPCA50X_REG_GLOBAL 0x03	/* spca505 */#define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */#define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */#define SPCA50X_GLOBAL_MISC1 0x01 /* 505 */#define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */#define SPCA50X_GMISC3_SAA7113RST 0x20	/* Not sure about this one spca505 *//* * Data to initialize a SPCA505. Common to the CCD and external modes */static const __u16 spca505_init_data[][3] = {	/* line	   bmRequest,value,index */	/* 1819 */	{SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3},	/* Sensor reset */	/* 1822 */ {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3},	/* 1825 */ {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1},	/* Block USB reset */	/* 1828 */ {SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL,		SPCA50X_GLOBAL_MISC0},	/* 1831 */ {0x5, 0x01, 0x10},					/* Maybe power down some stuff */	/* 1834 */ {0x5, 0x0f, 0x11},	/* Setup internal CCD  ? */	/* 1837 */ {0x6, 0x10, 0x08},	/* 1840 */ {0x6, 0x00, 0x09},	/* 1843 */ {0x6, 0x00, 0x0a},	/* 1846 */ {0x6, 0x00, 0x0b},	/* 1849 */ {0x6, 0x10, 0x0c},	/* 1852 */ {0x6, 0x00, 0x0d},	/* 1855 */ {0x6, 0x00, 0x0e},	/* 1858 */ {0x6, 0x00, 0x0f},	/* 1861 */ {0x6, 0x10, 0x10},	/* 1864 */ {0x6, 0x02, 0x11},	/* 1867 */ {0x6, 0x00, 0x12},	/* 1870 */ {0x6, 0x04, 0x13},	/* 1873 */ {0x6, 0x02, 0x14},	/* 1876 */ {0x6, 0x8a, 0x51},	/* 1879 */ {0x6, 0x40, 0x52},	/* 1882 */ {0x6, 0xb6, 0x53},	/* 1885 */ {0x6, 0x3d, 0x54},	{}};/* * Data to initialize the camera using the internal CCD */static const __u16 spca505_open_data_ccd[][3] = {	/* line	   bmRequest,value,index */	/* Internal CCD data set */	/* 1891 */ {0x3, 0x04, 0x01},	/* This could be a reset */	/* 1894 */ {0x3, 0x00, 0x01},	/* Setup compression and image registers. 0x6 and 0x7 seem to be	   related to H&V hold, and are resolution mode specific */		/* 1897 */ {0x4, 0x10, 0x01},		/* DIFF(0x50), was (0x10) */	/* 1900 */ {0x4, 0x00, 0x04},	/* 1903 */ {0x4, 0x00, 0x05},	/* 1906 */ {0x4, 0x20, 0x06},	/* 1909 */ {0x4, 0x20, 0x07},	/* 1912 */ {0x8, 0x0a, 0x00},	/* DIFF (0x4a), was (0xa) */	/* 1915 */ {0x5, 0x00, 0x10},	/* 1918 */ {0x5, 0x00, 0x11},	/* 1921 */ {0x5, 0x00, 0x00},	/* DIFF not written */	/* 1924 */ {0x5, 0x00, 0x01},	/* DIFF not written */	/* 1927 */ {0x5, 0x00, 0x02},	/* DIFF not written */	/* 1930 */ {0x5, 0x00, 0x03},	/* DIFF not written */	/* 1933 */ {0x5, 0x00, 0x04},	/* DIFF not written */		/* 1936 */ {0x5, 0x80, 0x05},		/* DIFF not written */		/* 1939 */ {0x5, 0xe0, 0x06},		/* DIFF not written */		/* 1942 */ {0x5, 0x20, 0x07},		/* DIFF not written */		/* 1945 */ {0x5, 0xa0, 0x08},		/* DIFF not written */		/* 1948 */ {0x5, 0x0, 0x12},		/* DIFF not written */	/* 1951 */ {0x5, 0x02, 0x0f},	/* DIFF not written */		/* 1954 */ {0x5, 0x10, 0x46},		/* DIFF not written */		/* 1957 */ {0x5, 0x8, 0x4a},		/* DIFF not written */	/* 1960 */ {0x3, 0x08, 0x03},	/* DIFF (0x3,0x28,0x3) */	/* 1963 */ {0x3, 0x08, 0x01},	/* 1966 */ {0x3, 0x0c, 0x03},	/* DIFF not written */		/* 1969 */ {0x3, 0x21, 0x00},		/* DIFF (0x39) *//* Extra block copied from init to hopefully ensure CCD is in a sane state */	/* 1837 */ {0x6, 0x10, 0x08},	/* 1840 */ {0x6, 0x00, 0x09},	/* 1843 */ {0x6, 0x00, 0x0a},	/* 1846 */ {0x6, 0x00, 0x0b},	/* 1849 */ {0x6, 0x10, 0x0c},	/* 1852 */ {0x6, 0x00, 0x0d},	/* 1855 */ {0x6, 0x00, 0x0e},	/* 1858 */ {0x6, 0x00, 0x0f},	/* 1861 */ {0x6, 0x10, 0x10},	/* 1864 */ {0x6, 0x02, 0x11},	/* 1867 */ {0x6, 0x00, 0x12},	/* 1870 */ {0x6, 0x04, 0x13},	/* 1873 */ {0x6, 0x02, 0x14},	/* 1876 */ {0x6, 0x8a, 0x51},	/* 1879 */ {0x6, 0x40, 0x52},	/* 1882 */ {0x6, 0xb6, 0x53},	/* 1885 */ {0x6, 0x3d, 0x54},	/* End of extra block */		/* 1972 */ {0x6, 0x3f, 0x1},		/* Block skipped */	/* 1975 */ {0x6, 0x10, 0x02},	/* 1978 */ {0x6, 0x64, 0x07},	/* 1981 */ {0x6, 0x10, 0x08},	/* 1984 */ {0x6, 0x00, 0x09},	/* 1987 */ {0x6, 0x00, 0x0a},	/* 1990 */ {0x6, 0x00, 0x0b},	/* 1993 */ {0x6, 0x10, 0x0c},	/* 1996 */ {0x6, 0x00, 0x0d},	/* 1999 */ {0x6, 0x00, 0x0e},	/* 2002 */ {0x6, 0x00, 0x0f},	/* 2005 */ {0x6, 0x10, 0x10},	/* 2008 */ {0x6, 0x02, 0x11},	/* 2011 */ {0x6, 0x00, 0x12},	/* 2014 */ {0x6, 0x04, 0x13},	/* 2017 */ {0x6, 0x02, 0x14},	/* 2020 */ {0x6, 0x8a, 0x51},	/* 2023 */ {0x6, 0x40, 0x52},	/* 2026 */ {0x6, 0xb6, 0x53},	/* 2029 */ {0x6, 0x3d, 0x54},	/* 2032 */ {0x6, 0x60, 0x57},	/* 2035 */ {0x6, 0x20, 0x58},	/* 2038 */ {0x6, 0x15, 0x59},	/* 2041 */ {0x6, 0x05, 0x5a},	/* 2044 */ {0x5, 0x01, 0xc0},	/* 2047 */ {0x5, 0x10, 0xcb},		/* 2050 */ {0x5, 0x80, 0xc1},		/* */		/* 2053 */ {0x5, 0x0, 0xc2},		/* 4 was 0 */	/* 2056 */ {0x5, 0x00, 0xca},		/* 2059 */ {0x5, 0x80, 0xc1},		/*  */	/* 2062 */ {0x5, 0x04, 0xc2},	/* 2065 */ {0x5, 0x00, 0xca},		/* 2068 */ {0x5, 0x0, 0xc1},		/*  */	/* 2071 */ {0x5, 0x00, 0xc2},	/* 2074 */ {0x5, 0x00, 0xca},		/* 2077 */ {0x5, 0x40, 0xc1},		/* */	/* 2080 */ {0x5, 0x17, 0xc2},	/* 2083 */ {0x5, 0x00, 0xca},		/* 2086 */ {0x5, 0x80, 0xc1},		/* */	/* 2089 */ {0x5, 0x06, 0xc2},	/* 2092 */ {0x5, 0x00, 0xca},		/* 2095 */ {0x5, 0x80, 0xc1},		/* */	/* 2098 */ {0x5, 0x04, 0xc2},	/* 2101 */ {0x5, 0x00, 0xca},	/* 2104 */ {0x3, 0x4c, 0x3},	/* 2107 */ {0x3, 0x18, 0x1},	/* 2110 */ {0x6, 0x70, 0x51},	/* 2113 */ {0x6, 0xbe, 0x53},	/* 2116 */ {0x6, 0x71, 0x57},	/* 2119 */ {0x6, 0x20, 0x58},	/* 2122 */ {0x6, 0x05, 0x59},	/* 2125 */ {0x6, 0x15, 0x5a},	/* 2128 */ {0x4, 0x00, 0x08},	/* Compress = OFF (0x1 to turn on) */	/* 2131 */ {0x4, 0x12, 0x09},	/* 2134 */ {0x4, 0x21, 0x0a},	/* 2137 */ {0x4, 0x10, 0x0b},	/* 2140 */ {0x4, 0x21, 0x0c},	/* 2143 */ {0x4, 0x05, 0x00},	/* was 5 (Image Type ? ) */	/* 2146 */ {0x4, 0x00, 0x01},	/* 2149 */ {0x6, 0x3f, 0x01},	/* 2152 */ {0x4, 0x00, 0x04},	/* 2155 */ {0x4, 0x00, 0x05},	/* 2158 */ {0x4, 0x40, 0x06},	/* 2161 */ {0x4, 0x40, 0x07},	/* 2164 */ {0x6, 0x1c, 0x17},	/* 2167 */ {0x6, 0xe2, 0x19},	/* 2170 */ {0x6, 0x1c, 0x1b},	/* 2173 */ {0x6, 0xe2, 0x1d},	/* 2176 */ {0x6, 0xaa, 0x1f},	/* 2179 */ {0x6, 0x70, 0x20},	/* 2182 */ {0x5, 0x01, 0x10},	/* 2185 */ {0x5, 0x00, 0x11},	/* 2188 */ {0x5, 0x01, 0x00},	/* 2191 */ {0x5, 0x05, 0x01},		/* 2194 */ {0x5, 0x00, 0xc1},		/* */	/* 2197 */ {0x5, 0x00, 0xc2},	/* 2200 */ {0x5, 0x00, 0xca},	/* 2203 */ {0x6, 0x70, 0x51},	/* 2206 */ {0x6, 0xbe, 0x53},	{}};#if 0/* * Data to initialize the camera in external video mode */static const __u16 spca505_open_data_ext[][3] = {	/* line	   bmRequest,value,index */	/* External video input dataset */	/* 0808 */ {0x3, 0x04, 0x01},	/* 0809 */ {0x3, 0x00, 0x01},	/* 0810 */ {0x4, 0x50, 0x01},	/* 0811 */ {0x4, 0x00, 0x04},	/* 0812 */ {0x4, 0x0a, 0x05},	/* 0813 */ {0x4, 0x20, 0x06},	/* 0814 */ {0x4, 0x20, 0x07},	/* 0815 */ {0x8, 0x4a, 0x00},	/* 0816 */ {0x5, 0x00, 0x10},	/* 0817 */ {0x5, 0x00, 0x11},	/* 0818 */ {0x3, 0x08, 0x03},	/* 0819 */ {0x3, 0x28, 0x03},	/* 0820 */ {0x3, 0x08, 0x01},	/* 0821 */ {0x3, 0x39, 0x00},	/* 0822 */ {0x5, 0x01, 0xc0},	/* 0823 */ {0x5, 0x10, 0xcb},	/* 0824 */ {0x5, 0x80, 0xc1},	/* 0825 */ {0x5, 0x05, 0xc2},	/* 0826 */ {0x5, 0x00, 0xca},	/* 0827 */ {0x5, 0x00, 0xc1},	/* 0828 */ {0x5, 0x01, 0xc2},	/* 0829 */ {0x5, 0x00, 0xca},	/* 0830 */ {0x5, 0x01, 0x10},	/* 0831 */ {0x5, 0x0f, 0x11},	{}};/* * Additional data needed to initialze the camera in external mode */static const __u16 spca505_open_data2[][3] = {	/* line	   bmRequest,value,index */	/* 1384 */ {0x3, 0x68, 0x03},	/* 1385 */ {0x3, 0x10, 0x01},	/* 1386 */ {0x8, 0x4a, 0x00},	/* 1387 */ {0x4, 0x00, 0x08},	/* was 1 COMPRESSION ENABLE ! */		/* 1388 */ {0x4, 0x12, 0x09},		/* Think these are the compression registers */	/* 1389 */ {0x4, 0x21, 0x0a},	/* 1390 */ {0x4, 0x10, 0x0b},	/* 1391 */ {0x4, 0x21, 0x0c},	/* 1392 */ {0x4, 0x05, 0x00},	/* This may be the picture type code (5=160x120 as YUV4:2:0) */	/* 1393 */ {0x4, 0x00, 0x01},	/* 1394 */ {0x6, 0x3f, 0x01},	/* 1395 */ {0x4, 0x00, 0x04},	/* 1396 */ {0x4, 0x0a, 0x05},		/* 1397 */ {0x4, 0x40, 0x06},		/* was 40 */		/* 1398 */ {0x4, 0x40, 0x07},		/* was 50 */	/* 1399 */ {0x4, 0x02, 0x05},	/* 1400 */ {0x4, 0x00, 0x04},	{}};#endif/*   Made by Tomasz Zablocki (skalamandra@poczta.onet.pl) * SPCA505b chip based cameras initialization data * *//* jfm */#define initial_brightness 0x7f	/* 0x0(white)-0xff(black) *//* #define initial_brightness 0x0	//0x0(white)-0xff(black) *//* * Data to initialize a SPCA505. Common to the CCD and external modes */static const __u16 spca505b_init_data[][3] = {/* start */	{0x02, 0x00, 0x00},		/* init */	{0x02, 0x00, 0x01},	{0x02, 0x00, 0x02},	{0x02, 0x00, 0x03},	{0x02, 0x00, 0x04},	{0x02, 0x00, 0x05},	{0x02, 0x00, 0x06},	{0x02, 0x00, 0x07},	{0x02, 0x00, 0x08},	{0x02, 0x00, 0x09},	{0x03, 0x00, 0x00},	{0x03, 0x00, 0x01},	{0x03, 0x00, 0x02},	{0x03, 0x00, 0x03},	{0x03, 0x00, 0x04},	{0x03, 0x00, 0x05},	{0x03, 0x00, 0x06},	{0x04, 0x00, 0x00},	{0x04, 0x00, 0x02},	{0x04, 0x00, 0x04},	{0x04, 0x00, 0x05},	{0x04, 0x00, 0x06},	{0x04, 0x00, 0x07},	{0x04, 0x00, 0x08},	{0x04, 0x00, 0x09},	{0x04, 0x00, 0x0a},	{0x04, 0x00, 0x0b},	{0x04, 0x00, 0x0c},	{0x07, 0x00, 0x00},	{0x07, 0x00, 0x03},	{0x08, 0x00, 0x00},	{0x08, 0x00, 0x01},	{0x08, 0x00, 0x02},	{0x00, 0x01, 0x00},	{0x00, 0x01, 0x01},	{0x00, 0x01, 0x34},	{0x00, 0x01, 0x35},	{0x06, 0x18, 0x08},	{0x06, 0xfc, 0x09},	{0x06, 0xfc, 0x0a},	{0x06, 0xfc, 0x0b},	{0x06, 0x18, 0x0c},	{0x06, 0xfc, 0x0d},	{0x06, 0xfc, 0x0e},	{0x06, 0xfc, 0x0f},	{0x06, 0x18, 0x10},	{0x06, 0xfe, 0x12},	{0x06, 0x00, 0x11},	{0x06, 0x00, 0x14},	{0x06, 0x00, 0x13},	{0x06, 0x28, 0x51},	{0x06, 0xff, 0x53},	{0x02, 0x00, 0x08},	{0x03, 0x00, 0x03},	{0x03, 0x10, 0x03},	{}};/* * Data to initialize the camera using the internal CCD */static const __u16 spca505b_open_data_ccd[][3] = {/* {0x02,0x00,0x00}, */	{0x03, 0x04, 0x01},		/* rst */	{0x03, 0x00, 0x01},

⌨️ 快捷键说明

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