亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? csi2c.c

?? 飛思卡爾的imx1的csi的驅動參考
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*Special notes for CMOS sensor data capture.There are two capture modes: continuous mode (also called rolling-shutter) andsingle frame mode.The single frame mode is to be used only when there is flash.So we pick the continuous mode. And under such mode there are two different streaming modes: continuous streaming and single-frame streaming. While single-frame streaming mode functions more-or-less the same way as the singel-framecapture mode (which is not suitable for us), we have to choose the continuousstreaming mode.When continuous capture mode + continuous streaming mode is used, the CMOS sensor keeps dumping out data through the CSI interface. Every frame of datais marked by a Start Of Frame (hereafter called "SOF") signal. The simple way is to use the SOF interrupt to setup the DMA transfer for a particularframe and keep on for the following frames.However, the first bit of image data will be sent out from the CMOS sensor 32CMOS sensor clocks (which may be several times slower than MX1's systemclock) after the rising edge of the SOF signal. So for a non-realtime OS suchas Linux, it is possible that the setup of the DMA channel will be later thanthe first bit of image data (which keep on rolling out). In such case, dataloss will occur, which will result in lost-sync of image data (shifting of image data on the display).To solve this problem, we have chosen the following scheme:- use SOF interrupt to setup the DMA channel for the first time- number every SOF interrupt and DMA complete interrupt with consecutive number- in every SOF interrupt, check whether there is missing DMA complete interrupt  by comparing the SOF sequence number with the DMA complete sequence number.  - if there is missing DMA complete interrupt, stop the current DMA transfer    and start a new one- in every DMA complete interrupt, check whether there is still data in the   CSI receive FIFO (this is to ensure that the DMA complete interrupt is not  a "shifted one"*)  - if the receive FIFO is not empty, discard the interrupt and treat it as lost  - if there is no data in the receive FIFO, it is counted as a normal DMA    complete interrupt. It will then setup the next DMA transfer  *REMARK:When a SOF interrupt find a lost DMA complete interrupt, it will stop the currenttransfer. However, it is possible that the DMA transfer is completed just before it is terminated in the SOF interrupt. So there will be a DMA complete interruptjust right after completion of the SOF interrupt. We have to identify such "shifted" DMA interrupt, instead of treating it as a normal DMA complete interrupt.  Figure 1: two kinds of normal DMA complete interrupt  SOF                                            SOF       <---------- image data ---------->       ^-- DMA transfer started here                                         ^-- DMA transfer ended here   ^-- DMA channel setup here  SOF                                            SOF       <---------- image data ---------->               <---------- image data ---------->              DMA transfer ended here --^              and setup next DMA transfer                                                        ^-- DMA channel setup here                                                               DMA transfer ended here --^Figure 2: a shifted DMA complete interrupt  SOF                                            SOF       <---------- image data ---------->              <---------- image data ---------->         ^-- DMA transfer started here                                                          ^-- DMA transfer ended here   ^-- DMA channel setup here                                (not terminated by the SOF interrupt)                                                 */#include <linux/kernel.h>#include <linux/module.h>#include <linux/compatmac.h>#include <linux/hdreg.h>#include <linux/vmalloc.h>#include <linux/fs.h>#include <linux/module.h>#include <linux/blkpg.h>//#include <asm/arch/hardware.h>#include <linux/i2c.h>#include <linux/i2c-algo-bit.h>#include <linux/i2c-id.h>#include <linux/slab.h>#include <asm/io.h>//#include <asm/proc-armv/cache.h>#include <linux/mm.h>#include <linux/wrapper.h>#include <asm/dma.h>#include <linux/miscdevice.h>#include "type.h"#include "mx1hw.h"//#define DEBUG_CSI2C#ifdef DEBUG_CSI2C#define dprintcsi2c(str...) printk("<"__FUNCTION__"> "str)#else#define dprintcsi2c(str...)	// nothing#endif#define IOCTL_CSI_INIT			1#define IOCTL_I2C_WRITE			2#define IOCTL_I2C_READ			3#define IOCTL_SUBSAMPLE			4#define IOCTL_SET_GAIN			5#define IOCTL_SET_VF_WIDTH		6#define IOCTL_SET_INT_TIME		7#define IOCTL_DMA_CAPTURE		8//#define IOCTL_RESET_ASSERT		11//#define IOCTL_RESET_RELEASE	12#define IOCTL_STOP_CAPTURE		13#define IOCTL_INC_FRM			20		// increment frame rate meter#define CSI_IRQ					6#define I2C_DRIVERID_I2CCSI	0x1001/* Define of Massage Flag */#define EMBEDDED_REGISTER		0x01#define I2C_M_READ				0x02#define I2C_M_WRITE					0x04//	I2C clock divider//#define I2C_CLKDIV		0x17		// 0x17 => /960 => 100k I2C clock for 96 MHz system clock#define I2C_CLKDIV		0x13		// 0x13 => /480 => 100k I2C clock for 48 MHz system clock////	SENSOR read/write command//#define SCM20014_ADDR_W (U32) 0x66	//01100110b, last bit 0 => WRITE#define SCM20014_ADDR_R (U32) 0x67	//01100111b, last bit 1 => READ// functions and interfacestatic int csi2c_open(struct inode *inode, struct file *filp);static int csi2c_release(struct inode *inode, struct file *filp);static ssize_t csi2c_read(struct file *filp, char *buf, size_t size, loff_t *l);static ssize_t csi2c_write(struct file *filp, const char *buf, size_t size, loff_t *l);static int csi2c_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);static void I2C_init(void);static U32 CSI_init(U32 systemClock, U32 sensorClock);static void I2C_read(U32 reg, U32 * _data);static void I2C_write(U32 reg, U32 data);static void port_init_SENSOR(void);static U32 SFCM_capture_DMA(U32 nPixel);static int i2c_csi_attach_adapter (struct i2c_adapter * adap);static void dma_complete_handler(void);static void dma_error_handler(int error_type);static int	gMajor=0;static U32 *csi_data_buf=0;static U32 gSensorClock;int sensorFrameCount=0;static dmach_t dma_channel;static U32 readSeqNum;static U32 capSeqNum;static U32 SOFseqNum;static U8 stopCapture;static U8 badFrame;static U32 dma_buf_phy_addr;static U32 dma_data_size;static U8 dmaStopped;static U8 SOFintrStopped;static DECLARE_WAIT_QUEUE_HEAD(dma_wait);static DECLARE_WAIT_QUEUE_HEAD(stop_capture_wait);static struct i2c_driver i2c_csi_driver = {	name:					"i2c-csi client driver",	id:					I2C_DRIVERID_I2CCSI,	flags:				I2C_DF_DUMMY | I2C_DF_NOTIFY,	attach_adapter:	i2c_csi_attach_adapter,	detach_client:		NULL,	/*i2c_csi_detach_client,*/	command:				NULL};static struct i2c_client i2c_csi_client = {	name:		"i2c-csi client",	id:		1,	flags:	0,	addr:		-1,	adapter:	NULL,	driver:	&i2c_csi_driver,	data:		NULL};struct file_operations csi2c_fops = {	open:          csi2c_open,	release:       csi2c_release,	read:          csi2c_read,	write:			csi2c_write,	ioctl:			csi2c_ioctl,};static int csi2c_open(struct inode *inode, struct file *filp){	dprintcsi2c("*** open ***\n");   MOD_INC_USE_COUNT;	/* request DMA channel for RxFIFO data */	for(dma_channel = 0; dma_channel < 11; dma_channel++)	{		if ( (request_dma(dma_channel, "CMOS Sensor")) == 0)		{			printk("dma channel %d granted\n", dma_channel);			*((U32 *)(DMA_SAR0+dma_channel*0x40)) = 0x00224010;	// CSI RxFIFO register			*((U32 *)(DMA_RSSR0+dma_channel*0x40)) = 7;					// CSI data			*((U32 *)(DMA_BLR0+dma_channel*0x40)) = 64;					// burst length : 16 words = 64 bytes			*((U32 *)(DMA_RTOR0+dma_channel*0x40)) = 0;					// burst timeout, not used			*((U32 *)(DMA_BUCR0+dma_channel*0x40)) = 0;					// bus utilization, not used			request_dma_intr( dma_channel, (callback_t)dma_complete_handler, (err_callback_t)dma_error_handler ); 			break;		}	}   if (dma_channel > 11)   	printk("*** ERROR: no dma channel is available ! ***\n");	return 0;}static int csi2c_release(struct inode *inode, struct file *filp){	dprintcsi2c("*** close ***\n");	MOD_DEC_USE_COUNT;	free_dma_intr(dma_channel);	free_dma(dma_channel);	return 0;}static ssize_t csi2c_read(struct file *filp, char *buf, size_t size, loff_t *l){	U32 flags;	U32 captureDone;		dprintcsi2c("*** read ***\n");	do	{		captureDone = 0;		save_flags(flags);		cli();		if (capSeqNum > readSeqNum)			captureDone = 1;		restore_flags(flags);		if (!captureDone)			interruptible_sleep_on(&dma_wait);		if (badFrame)			captureDone = 1;				} while (!captureDone);			if (badFrame)	{//		printk("--- bad frame ---\n");		return 0;	// a zero size frame implies bad frame	}	else	{		readSeqNum++;		copy_to_user(buf, csi_data_buf, size);		return size;	}		}static ssize_t csi2c_write(struct file *filp, const char *buf, size_t size, loff_t *l){	dprintcsi2c("*** write ***\n");	return 0;}static int malloc_buffer() {	if ((csi_data_buf = (U32 *)__get_free_pages(GFP_KERNEL, 7)))	// 128 pages = 128x4K = 512K	{		dma_buf_phy_addr = virt_to_phys((void *)csi_data_buf);		dprintcsi2c("Buffer start: 0x%08x, DMA addr: 0x%08x\n", (int)csi_data_buf, (int)dma_buf_phy_addr);	}	else	{		printk("*** ERROR: cannot allocate buffer memory for driver ! ***\n");		return -1;	}	return 0;}static void free_buffer(){	dprintcsi2c("free buffer\n");	if (csi_data_buf)		__free_pages((void *)csi_data_buf,7);		// 512K}static void	setSubsample(int subsample){	U32 value;		switch (subsample)	{		case 2:		// divide by 2			value = 0x25;			break;		case 4:		// divide by 4			value = 0x2A;			break;		case 8:		// divide by 8			value = 0x2F;			break;		default:		// i.e. full subsampling			value = 0;		// REMARK: "cm" bit must be cleared for full-sampling	}	I2C_write(0x41, value);}			static void setGlobalGain(int gain){	I2C_write(0x10, gain);}static void setVFwidth(int width){	I2C_write(0x52, width >> 8);	I2C_write(0x53, width & 0xFF);}			static void	setIntegrationTime(int value){	I2C_write(0x4E, value >> 8);	I2C_write(0x4F, value & 0xFF);}static void stopCMOScapture(){	U32 flags;	U8 allStopped;		save_flags(flags);	cli();	stopCapture = 1;	dmaStopped = 0;	SOFintrStopped = 0;	allStopped = 0;	restore_flags(flags);		do	{		save_flags(flags);		cli();		if ((dmaStopped) && (SOFintrStopped))		{			allStopped = 1;			restore_flags(flags);		}		else		{			interruptible_sleep_on(&stop_capture_wait);					restore_flags(flags);		}	} while (!allStopped);}static int csi2c_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){	dprintcsi2c("cmd: 0x%08x, arg: 0x%08x\n", cmd, (int)arg);	switch(cmd)	{		case IOCTL_CSI_INIT:			dprintcsi2c("Init CSI, bus clock: %d MHz, sensor clock: %d MHz\n", (int)(arg >> 8), (int)(arg & 0xFF));			{				return (CSI_init(arg >> 8, arg & 0xFF));			}			break;		case IOCTL_I2C_WRITE:			dprintcsi2c("I2C write - reg: 0x%02x, data: 0x%02x\n", arg >> 8, arg&0xFF);			I2C_write(arg>>8, arg&0xFF);			break;		case IOCTL_I2C_READ:			{				int	rv;						dprintcsi2c("I2C read\n");				I2C_read(arg, &rv);				return(rv);					}			break;		case IOCTL_SUBSAMPLE:			dprintcsi2c("Set subsample: %d\n", (int)arg);			setSubsample(arg);			break;		case IOCTL_SET_GAIN:			dprintcsi2c("Set global gain to %d\n", (int)arg);			setGlobalGain(arg);			break;		case IOCTL_SET_VF_WIDTH:			dprintcsi2c("Set virtual frame width to 0x%04x\n", (int)arg);			setVFwidth(arg);			break;		case IOCTL_SET_INT_TIME:			dprintcsi2c("Set integration time to 0x%04x\n", (int)arg);			setIntegrationTime(arg);			break;		case IOCTL_DMA_CAPTURE:			dprintcsi2c("DMA capture for %d bytes\n", (int)arg);			return SFCM_capture_DMA((U32)arg);			break;/*		case IOCTL_RESET_ASSERT:        * (U32 *)PTB_DR   |= (0x1 << 18); 	// RESET asserted			break;		case IOCTL_RESET_RELEASE:        * (U32 *)PTB_DR   &= ~(0x1 << 18); 	// RESET released			break;*/					case IOCTL_STOP_CAPTURE:			stopCMOScapture();			break;		case IOCTL_INC_FRM:			{				U32 flags = 0;				save_flags(flags);				cli();				sensorFrameCount++;				restore_flags(flags);			}			break;	}	return 0;}static int i2c_csi_attach_adapter (struct i2c_adapter * adap){	/* find out the adapter for the I2C module in the DBMX1*/	if (memcmp(adap->name, "DBMX I2C Adapter", 16) != 0 )		return -ENODEV;	/* store the adapter to the client driver */	i2c_csi_client.adapter = adap;	return 0;}static void I2C_init(void){	// init port	//	PA15 : I2C_DATA	//	PA16 : I2C_CLK	* (U32 *)PTA_DDIR |=  0x00018000;	* (U32 *)PTA_GIUS &= ~0x00018000;		/* 	 * set the address of the CMOS sensor to the client	 */	i2c_csi_client.addr = SCM20014_ADDR_W;	/* 	 * call the i2c_add_driver() to register the driver 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
波多野结衣在线一区| 免费人成网站在线观看欧美高清| 狠狠狠色丁香婷婷综合激情| 2023国产精品自拍| 国产精品一卡二| 中文在线资源观看网站视频免费不卡| 成人夜色视频网站在线观看| 最好看的中文字幕久久| 色伊人久久综合中文字幕| 亚洲在线观看免费视频| 91精品在线一区二区| 狠狠色丁香久久婷婷综| 亚洲欧美在线高清| 欧美丝袜丝交足nylons图片| 免费在线成人网| 日本一区二区三区国色天香| 色综合色狠狠天天综合色| 视频一区视频二区中文字幕| 久久天天做天天爱综合色| 99九九99九九九视频精品| 亚洲444eee在线观看| 精品国产区一区| 色综合久久综合网| 精品一区二区三区免费观看| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 欧洲视频一区二区| 国产一区二区三区观看| 一区二区三区电影在线播| 欧美一区二区在线免费观看| 粉嫩嫩av羞羞动漫久久久| 亚洲一区二区不卡免费| 久久久综合激的五月天| 欧美三级三级三级| 国产a精品视频| 亚洲va欧美va人人爽午夜| 久久看人人爽人人| 欧美久久久一区| 成人av高清在线| 精品一区二区日韩| 亚洲综合色视频| 中文字幕国产一区二区| 91.麻豆视频| 色狠狠av一区二区三区| 国产精品影视在线观看| 五月婷婷色综合| 亚洲欧美日韩国产中文在线| 久久免费精品国产久精品久久久久| 欧美性三三影院| av网站免费线看精品| 久国产精品韩国三级视频| 亚洲综合免费观看高清完整版| 国产午夜精品久久久久久久| 91精品国产一区二区三区蜜臀| 91亚洲永久精品| 福利电影一区二区三区| 精品无码三级在线观看视频| 亚洲国产cao| 日韩伦理免费电影| 久久精品视频免费观看| 日韩欧美一区在线| 在线播放国产精品二区一二区四区 | 亚洲大片精品永久免费| ●精品国产综合乱码久久久久| 久久九九影视网| 精品久久久久久久久久久院品网 | 亚洲日本乱码在线观看| 亚洲国产成人私人影院tom| 久久亚洲精品小早川怜子| 91精品国产全国免费观看| 欧美日韩国产成人在线免费| 91黄色在线观看| 一本到不卡免费一区二区| 成人黄色av电影| 成人小视频免费观看| 国产宾馆实践打屁股91| 高清av一区二区| 成人av免费在线| 一本色道亚洲精品aⅴ| 91在线免费看| 欧美综合亚洲图片综合区| 日本福利一区二区| 欧美日本视频在线| 欧美一级片在线看| 欧美一区二区美女| 久久亚洲精精品中文字幕早川悠里| 精品欧美乱码久久久久久1区2区| 日韩精品中文字幕在线一区| 久久免费视频一区| 国产精品美女久久久久av爽李琼| 国产精品毛片久久久久久| 中文字幕中文字幕在线一区| 亚洲老司机在线| 视频一区视频二区中文字幕| 久久精品国产999大香线蕉| 国产在线精品一区二区| 大白屁股一区二区视频| 91丨九色丨黑人外教| 欧美亚洲高清一区二区三区不卡| 欧美精品 日韩| 久久久久国产精品免费免费搜索| 国产精品卡一卡二卡三| 亚洲精品日韩综合观看成人91| 午夜不卡av在线| 国产成人亚洲综合a∨婷婷| 色综合中文综合网| 欧美日韩在线精品一区二区三区激情 | 图片区小说区国产精品视频| 老司机午夜精品99久久| 成人综合婷婷国产精品久久蜜臀| 日本道精品一区二区三区| 欧美欧美欧美欧美首页| 久久久久成人黄色影片| 一区二区三区丝袜| 激情综合色综合久久| 成人激情免费电影网址| 欧美日韩五月天| 久久精品夜夜夜夜久久| 伊人色综合久久天天人手人婷| 免费视频最近日韩| 99天天综合性| 日韩亚洲欧美一区二区三区| 国产精品国产精品国产专区不片| 天堂蜜桃一区二区三区| 成人黄色av网站在线| 91精品国产91久久综合桃花| 欧美激情一区三区| 人人爽香蕉精品| 色综合一区二区三区| 久久久久国产精品厨房| 午夜视频在线观看一区二区| 成人免费看黄yyy456| 5566中文字幕一区二区电影| 国产精品传媒视频| 久久99精品一区二区三区三区| 一本一本大道香蕉久在线精品| 337p粉嫩大胆噜噜噜噜噜91av | 另类的小说在线视频另类成人小视频在线 | 一区二区激情视频| 国产aⅴ综合色| 欧美电影免费观看高清完整版在| 亚洲一区av在线| av亚洲精华国产精华精华| 久久久久久影视| 日本成人中文字幕在线视频| 色婷婷综合久色| 国产精品天干天干在观线| 狠狠v欧美v日韩v亚洲ⅴ| 欧美电影一区二区三区| 一个色妞综合视频在线观看| 丁香另类激情小说| 国产亚洲女人久久久久毛片| 黄色日韩网站视频| 欧美成va人片在线观看| 日本一不卡视频| 5858s免费视频成人| 亚洲福利视频一区二区| 91九色02白丝porn| 亚洲欧美另类图片小说| 91网页版在线| 亚洲天堂精品在线观看| 国产精品1区2区| 久久夜色精品国产噜噜av| 精品在线一区二区| 久久这里只有精品6| 狠狠色丁香久久婷婷综| 久久蜜桃香蕉精品一区二区三区| 激情国产一区二区| 久久综合精品国产一区二区三区| 美日韩一区二区| 日韩欧美不卡一区| 久久国产精品一区二区| 久久夜色精品国产欧美乱极品| 国产在线不卡一区| 国产欧美日韩精品a在线观看| 粉嫩av一区二区三区在线播放 | 亚洲免费观看在线视频| 色丁香久综合在线久综合在线观看| 亚洲乱码日产精品bd| 在线亚洲精品福利网址导航| 一区二区成人在线视频 | 欧美亚洲日本一区| 亚洲国产综合人成综合网站| 6080午夜不卡| 久久99精品久久久久久国产越南| 日韩欧美一二区| 懂色av中文字幕一区二区三区| 中文字幕亚洲欧美在线不卡| 欧美亚洲日本国产| 美女www一区二区| 欧美激情资源网| 色狠狠av一区二区三区| 日韩va亚洲va欧美va久久| 日韩精品一区二| 波多野结衣精品在线| 亚洲精品视频免费观看| 91精品国产黑色紧身裤美女| 国产高清久久久久| 亚洲精品免费一二三区| 日韩午夜电影在线观看| 福利视频网站一区二区三区|