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

📄 conex.c

📁 trident tm5600的linux驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *		Connexant Cx11646 library *		Copyright (C) 2004 Michel Xhaard mxhaard@magic.fr * * V4L2 by Jean-Francois 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 "conex"#include "gspca.h"#define CONEX_CAM 1		/* special JPEG header */#include "jpeg.h"MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver");MODULE_LICENSE("GPL");/* specific webcam descriptor */struct sd {	struct gspca_dev gspca_dev;	/* !! must be the first item */	unsigned char brightness;	unsigned char contrast;	unsigned char colors;	unsigned char qindex;};/* 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 int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);static struct ctrl sd_ctrls[] = {	{	    {		.id	 = V4L2_CID_BRIGHTNESS,		.type	 = V4L2_CTRL_TYPE_INTEGER,		.name	 = "Brightness",		.minimum = 0,		.maximum = 255,		.step	 = 1,#define BRIGHTNESS_DEF 0xd4		.default_value = BRIGHTNESS_DEF,	    },	    .set = sd_setbrightness,	    .get = sd_getbrightness,	},	{	    {		.id      = V4L2_CID_CONTRAST,		.type    = V4L2_CTRL_TYPE_INTEGER,		.name    = "Contrast",		.minimum = 0x0a,		.maximum = 0x1f,		.step    = 1,#define CONTRAST_DEF 0x0c		.default_value = CONTRAST_DEF,	    },	    .set = sd_setcontrast,	    .get = sd_getcontrast,	},	{	    {		.id      = V4L2_CID_SATURATION,		.type    = V4L2_CTRL_TYPE_INTEGER,		.name    = "Color",		.minimum = 0,		.maximum = 7,		.step    = 1,#define COLOR_DEF 3		.default_value = COLOR_DEF,	    },	    .set = sd_setcolors,	    .get = sd_getcolors,	},};static struct v4l2_pix_format vga_mode[] = {	{176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,		.bytesperline = 176,		.sizeimage = 176 * 144 * 3 / 8 + 590,		.colorspace = V4L2_COLORSPACE_JPEG,		.priv = 3},	{320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,		.bytesperline = 320,		.sizeimage = 320 * 240 * 3 / 8 + 590,		.colorspace = V4L2_COLORSPACE_JPEG,		.priv = 2},	{352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,		.bytesperline = 352,		.sizeimage = 352 * 288 * 3 / 8 + 590,		.colorspace = V4L2_COLORSPACE_JPEG,		.priv = 1},	{640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,		.bytesperline = 640,		.sizeimage = 640 * 480 * 3 / 8 + 590,		.colorspace = V4L2_COLORSPACE_JPEG,		.priv = 0},};/* the read bytes are found in gspca_dev->usb_buf */static void reg_r(struct gspca_dev *gspca_dev,		  __u16 index,		  __u16 len){	struct usb_device *dev = gspca_dev->dev;#ifdef GSPCA_DEBUG	if (len > USB_BUF_SZ) {		err("reg_r: buffer overflow");		return;	}#endif	usb_control_msg(dev,			usb_rcvctrlpipe(dev, 0),			0,			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,			0,			index, gspca_dev->usb_buf, len,			500);	PDEBUG(D_USBI, "reg read [%02x] -> %02x ..",			index, gspca_dev->usb_buf[0]);}/* the bytes to write are in gspca_dev->usb_buf */static void reg_w_val(struct gspca_dev *gspca_dev,			__u16 index,			__u8 val){	struct usb_device *dev = gspca_dev->dev;	gspca_dev->usb_buf[0] = val;	usb_control_msg(dev,			usb_sndctrlpipe(dev, 0),			0,			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,			0,			index, gspca_dev->usb_buf, 1, 500);}static void reg_w(struct gspca_dev *gspca_dev,		  __u16 index,		  const __u8 *buffer,		  __u16 len){	struct usb_device *dev = gspca_dev->dev;#ifdef GSPCA_DEBUG	if (len > USB_BUF_SZ) {		err("reg_w: buffer overflow");		return;	}	PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);#endif	memcpy(gspca_dev->usb_buf, buffer, len);	usb_control_msg(dev,			usb_sndctrlpipe(dev, 0),			0,			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,			0,			index, gspca_dev->usb_buf, len, 500);}static const __u8 cx_sensor_init[][4] = {	{0x88, 0x11, 0x01, 0x01},	{0x88, 0x12, 0x70, 0x01},	{0x88, 0x0f, 0x00, 0x01},	{0x88, 0x05, 0x01, 0x01},	{}};static const __u8 cx11646_fw1[][3] = {	{0x00, 0x02, 0x00},	{0x01, 0x43, 0x00},	{0x02, 0xA7, 0x00},	{0x03, 0x8B, 0x01},	{0x04, 0xE9, 0x02},	{0x05, 0x08, 0x04},	{0x06, 0x08, 0x05},	{0x07, 0x07, 0x06},	{0x08, 0xE7, 0x06},	{0x09, 0xC6, 0x07},	{0x0A, 0x86, 0x08},	{0x0B, 0x46, 0x09},	{0x0C, 0x05, 0x0A},	{0x0D, 0xA5, 0x0A},	{0x0E, 0x45, 0x0B},	{0x0F, 0xE5, 0x0B},	{0x10, 0x85, 0x0C},	{0x11, 0x25, 0x0D},	{0x12, 0xC4, 0x0D},	{0x13, 0x45, 0x0E},	{0x14, 0xE4, 0x0E},	{0x15, 0x64, 0x0F},	{0x16, 0xE4, 0x0F},	{0x17, 0x64, 0x10},	{0x18, 0xE4, 0x10},	{0x19, 0x64, 0x11},	{0x1A, 0xE4, 0x11},	{0x1B, 0x64, 0x12},	{0x1C, 0xE3, 0x12},	{0x1D, 0x44, 0x13},	{0x1E, 0xC3, 0x13},	{0x1F, 0x24, 0x14},	{0x20, 0xA3, 0x14},	{0x21, 0x04, 0x15},	{0x22, 0x83, 0x15},	{0x23, 0xE3, 0x15},	{0x24, 0x43, 0x16},	{0x25, 0xA4, 0x16},	{0x26, 0x23, 0x17},	{0x27, 0x83, 0x17},	{0x28, 0xE3, 0x17},	{0x29, 0x43, 0x18},	{0x2A, 0xA3, 0x18},	{0x2B, 0x03, 0x19},	{0x2C, 0x63, 0x19},	{0x2D, 0xC3, 0x19},	{0x2E, 0x22, 0x1A},	{0x2F, 0x63, 0x1A},	{0x30, 0xC3, 0x1A},	{0x31, 0x23, 0x1B},	{0x32, 0x83, 0x1B},	{0x33, 0xE2, 0x1B},	{0x34, 0x23, 0x1C},	{0x35, 0x83, 0x1C},	{0x36, 0xE2, 0x1C},	{0x37, 0x23, 0x1D},	{0x38, 0x83, 0x1D},	{0x39, 0xE2, 0x1D},	{0x3A, 0x23, 0x1E},	{0x3B, 0x82, 0x1E},	{0x3C, 0xC3, 0x1E},	{0x3D, 0x22, 0x1F},	{0x3E, 0x63, 0x1F},	{0x3F, 0xC1, 0x1F},	{}};static void cx11646_fw(struct gspca_dev*gspca_dev){	int i = 0;	reg_w_val(gspca_dev, 0x006a, 0x02);	while (cx11646_fw1[i][1]) {		reg_w(gspca_dev, 0x006b, cx11646_fw1[i], 3);		i++;	}	reg_w_val(gspca_dev, 0x006a, 0x00);}static const __u8 cxsensor[] = {	0x88, 0x12, 0x70, 0x01,	0x88, 0x0d, 0x02, 0x01,	0x88, 0x0f, 0x00, 0x01,	0x88, 0x03, 0x71, 0x01, 0x88, 0x04, 0x00, 0x01,	/* 3 */	0x88, 0x02, 0x10, 0x01,	0x88, 0x00, 0xD4, 0x01, 0x88, 0x01, 0x01, 0x01,	/* 5 */	0x88, 0x0B, 0x00, 0x01,	0x88, 0x0A, 0x0A, 0x01,	0x88, 0x00, 0x08, 0x01, 0x88, 0x01, 0x00, 0x01,	/* 8 */	0x88, 0x05, 0x01, 0x01,	0xA1, 0x18, 0x00, 0x01,	0x00};static const __u8 reg20[] = { 0x10, 0x42, 0x81, 0x19, 0xd3, 0xff, 0xa7, 0xff };static const __u8 reg28[] = { 0x87, 0x00, 0x87, 0x00, 0x8f, 0xff, 0xea, 0xff };static const __u8 reg10[] = { 0xb1, 0xb1 };static const __u8 reg71a[] = { 0x08, 0x18, 0x0a, 0x1e };	/* 640 */static const __u8 reg71b[] = { 0x04, 0x0c, 0x05, 0x0f };	/* 352{0x04,0x0a,0x06,0x12}; //352{0x05,0x0e,0x06,0x11}; //352 */static const __u8 reg71c[] = { 0x02, 0x07, 0x03, 0x09 };					/* 320{0x04,0x0c,0x05,0x0f}; //320 */static const __u8 reg71d[] = { 0x02, 0x07, 0x03, 0x09 };	/* 176 */static const __u8 reg7b[] = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff };static void cx_sensor(struct gspca_dev*gspca_dev){	int i = 0;	int length;	const __u8 *ptsensor = cxsensor;	reg_w(gspca_dev, 0x0020, reg20, 8);	reg_w(gspca_dev, 0x0028, reg28, 8);	reg_w(gspca_dev, 0x0010, reg10, 8);	reg_w_val(gspca_dev, 0x0092, 0x03);	switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {	case 0:		reg_w(gspca_dev, 0x0071, reg71a, 4);		break;	case 1:		reg_w(gspca_dev, 0x0071, reg71b, 4);		break;	default:/*	case 2: */		reg_w(gspca_dev, 0x0071, reg71c, 4);		break;	case 3:		reg_w(gspca_dev, 0x0071, reg71d, 4);		break;	}	reg_w(gspca_dev, 0x007b, reg7b, 6);	reg_w_val(gspca_dev, 0x00f8, 0x00);	reg_w(gspca_dev, 0x0010, reg10, 8);	reg_w_val(gspca_dev, 0x0098, 0x41);	for (i = 0; i < 11; i++) {		if (i == 3 || i == 5 || i == 8)			length = 8;		else			length = 4;		reg_w(gspca_dev, 0x00e5, ptsensor, length);		if (length == 4)			reg_r(gspca_dev, 0x00e8, 1);		else			reg_r(gspca_dev, 0x00e8, length);		ptsensor += length;	}	reg_r(gspca_dev, 0x00e7, 8);}static const __u8 cx_inits_176[] = {	0x33, 0x81, 0xB0, 0x00, 0x90, 0x00, 0x0A, 0x03,	/* 176x144 */	0x00, 0x03, 0x03, 0x03, 0x1B, 0x05, 0x30, 0x03,	0x65, 0x15, 0x18, 0x25, 0x03, 0x25, 0x08, 0x30,	0x3B, 0x25, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,	0xDC, 0xFF, 0xEE, 0xFF, 0xC5, 0xFF, 0xBF, 0xFF,	0xF7, 0xFF, 0x88, 0xFF, 0x66, 0x02, 0x28, 0x02,	0x1E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

⌨️ 快捷键说明

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