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

📄 dma.c

📁 ARM9摄象头驱动程序
💻 C
字号:
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 stopCMOScapture(){#if 0	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);#endif}//------------------------------------////      Capture image data with DMA////      Unified function for all //      supported image size capture////      Return TRUE if success//      Return FALSE if FIFO is overrun////------------------------------------static U32 SFCM_capture_DMA(U32 nPixel){	dma_data_size = nPixel;	readSeqNum = capSeqNum = SOFseqNum = 0;	stopCapture = 0;	*(U32 *) CSI_STS_REG = 0x10000;	//clear last SOF irq	*(U32 *) CSI_CTRL_REG1 |= 0x60;	//prepare for sync clear FIFOs	*(U32 *) CSI_CTRL_REG1 |= 0x10000;	//enable SOF intr	return TRUE;}static void dma_complete_handler(){	DMA_channel_disable(dma_channel);	*((U32 *) DMA_ISR) = (1 << dma_channel);	// clear DMA complete interrupt flag	wake_up_interruptible(&dma_wait);	DMA_channel_enable(dma_channel);	/*	   if (*(U32 *) CSI_STS_REG & 1) {	   printk("!!! Data in FIFO !!!\n");	   return;	   }	 */}static void dma_error_handler(int error_type){	printk("*** CSI DMA error, type = 0x%08x ! ***\n", error_type);}static void csi_intr_handler(int irq, void *dev_id, struct pt_regs *regs){	if (*(U32 *) CSI_STS_REG & 0x10000)	// SOF intr ?	{		*(U32 *) CSI_STS_REG = 0x10000;	// clear SOF intr		if (SOFseqNum == 0) {			DMA_channel_enable(dma_channel);			*(U32 *) CSI_CTRL_REG1 &= ~0x10000;	//disable SOF intr			//printk("dma data size:%d\n", dma_data_size);		} else {			return;		}	}	return;}

⌨️ 快捷键说明

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