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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dma-sa1100.c

?? microwindows移植到S3C44B0的源碼
?? C
字號:
/* * arch/arm/kernel/dma-sa1100.c * * Support functions for the SA11x0 internal DMA channels. * (see also Documentation/arm/SA1100/DMA) * * Copyright (C) 2000 Nicolas Pitre * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */#include <linux/module.h>#include <linux/init.h>#include <linux/sched.h>#include <linux/spinlock.h>#include <linux/slab.h>#include <linux/errno.h>#include <asm/system.h>#include <asm/irq.h>#include <asm/hardware.h>#include <asm/io.h>#include <asm/dma.h>#include <asm/mach/dma.h>#undef DEBUG#ifdef DEBUG#define DPRINTK( s, arg... )  printk( "dma<%s>: " s, dma->device_id , ##arg )#else#define DPRINTK( x... )#endif/* * DMA control register structure */typedef struct {	volatile u_long DDAR;	volatile u_long SetDCSR;	volatile u_long ClrDCSR;	volatile u_long RdDCSR;	volatile dma_addr_t DBSA;	volatile u_long DBTA;	volatile dma_addr_t DBSB;	volatile u_long DBTB;} dma_regs_t;#include "dma.h"sa1100_dma_t dma_chan[MAX_SA1100_DMA_CHANNELS];/* * Maximum physical DMA buffer size */#define MAX_DMA_SIZE		0x1fff#define MAX_DMA_ORDER		12/* * DMA processing... */static inline int start_sa1100_dma(sa1100_dma_t * dma, dma_addr_t dma_ptr, int size){	dma_regs_t *regs = dma->regs;	int status;	status = regs->RdDCSR;	/* If both DMA buffers are started, there's nothing else we can do. */	if ((status & (DCSR_STRTA | DCSR_STRTB)) == (DCSR_STRTA | DCSR_STRTB)) {		DPRINTK("start: st %#x busy\n", status);		return -EBUSY;	}	if (((status & DCSR_BIU) && (status & DCSR_STRTB)) ||	    (!(status & DCSR_BIU) && !(status & DCSR_STRTA))) {		if (status & DCSR_DONEA) {			/* give a chance for the interrupt to be processed */			goto irq_pending;		}		regs->DBSA = dma_ptr;		regs->DBTA = size;		regs->SetDCSR = DCSR_STRTA | DCSR_IE | DCSR_RUN;		DPRINTK("start a=%#x s=%d on A\n", dma_ptr, size);	} else {		if (status & DCSR_DONEB) {			/* give a chance for the interrupt to be processed */			goto irq_pending;		}		regs->DBSB = dma_ptr;		regs->DBTB = size;		regs->SetDCSR = DCSR_STRTB | DCSR_IE | DCSR_RUN;		DPRINTK("start a=%#x s=%d on B\n", dma_ptr, size);	}	return 0;irq_pending:	return -EAGAIN;}static int start_dma(sa1100_dma_t *dma, dma_addr_t dma_ptr, int size){	if (channel_is_sa1111_sac(dma - dma_chan))		return start_sa1111_sac_dma(dma, dma_ptr, size);	return start_sa1100_dma(dma, dma_ptr, size);}/* This must be called with IRQ disabled */static void process_dma(sa1100_dma_t * dma){	dma_buf_t *buf;	int chunksize;	for (;;) {		buf = dma->tail;		if (!buf || dma->stopped) {			/* no more data available */			DPRINTK("process: no more buf (dma %s)\n",				dma->curr ? "active" : "inactive");			/*			 * Some devices may require DMA still sending data			 * at any time for clock reference, etc.			 * Note: if there is still a data buffer being			 * processed then the ref count is negative.  This			 * allows for the DMA termination to be accounted in			 * the proper order.			 */			if (dma->spin_size && dma->spin_ref >= 0) {				chunksize = dma->spin_size;				if (chunksize > MAX_DMA_SIZE)					chunksize = (1 << MAX_DMA_ORDER);				while (start_dma(dma, dma->spin_addr, chunksize) == 0)					dma->spin_ref++;				if (dma->curr != NULL)					dma->spin_ref = -dma->spin_ref;			}			break;		}		/*		 * This improves latency if there are some active spinning		 * buffers.  We kill them altogether.		 */		if (dma->spin_ref > 0) {			if (channel_is_sa1111_sac(dma - dma_chan))				sa1111_reset_sac_dma(dma - dma_chan);			else				dma->regs->ClrDCSR =				    DCSR_STRTA|DCSR_STRTB|DCSR_DONEA|DCSR_DONEB;			dma->spin_ref = 0;		}		/*		 * Let's try to start DMA on the current buffer.		 * If DMA is busy then we break here.		 */		chunksize = buf->size;		if (chunksize > MAX_DMA_SIZE)			chunksize = (1 << MAX_DMA_ORDER);		DPRINTK("process: b=%#x s=%d\n", (int) buf->id, buf->size);		if (start_dma(dma, buf->dma_ptr, chunksize) != 0)			break;		if (!dma->curr)			dma->curr = buf;		buf->ref++;		buf->dma_ptr += chunksize;		buf->size -= chunksize;		if (buf->size == 0) {			/* current buffer is done: move tail to the next one */			dma->tail = buf->next;			DPRINTK("process: next b=%#x\n", (int) dma->tail);		}	}}/* This must be called with IRQ disabled */void sa1100_dma_done (sa1100_dma_t *dma){	dma_buf_t *buf = dma->curr;	if (dma->spin_ref > 0) {		dma->spin_ref--;	} else if (buf) {		buf->ref--;		if (buf->ref == 0 && buf->size == 0) {			/*			 * Current buffer is done.			 * Move current reference to the next one and send			 * the processed buffer to the callback function,			 * then discard it.			 */			DPRINTK("IRQ: buf done\n");			dma->curr = buf->next;			dma->spin_ref = -dma->spin_ref;			if (dma->head == buf)				dma->head = NULL;			if (dma->callback) {				int size = buf->dma_ptr - buf->dma_start;				dma->callback(buf->id, size);			}			kfree(buf);		}	}	process_dma(dma);}static void dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs){	sa1100_dma_t *dma = (sa1100_dma_t *) dev_id;	int status = dma->regs->RdDCSR;	DPRINTK("IRQ: b=%#x st=%#x\n", (int) dma->curr->id, status);	if (status & (DCSR_ERROR)) {		printk(KERN_ERR "DMA on \"%s\" caused an error\n", dma->device_id);		dma->regs->ClrDCSR = DCSR_ERROR;	}	dma->regs->ClrDCSR = status & (DCSR_DONEA | DCSR_DONEB);	if (status & DCSR_DONEA)		sa1100_dma_done (dma);	if (status & DCSR_DONEB)		sa1100_dma_done (dma);}/* * DMA interface functions */static spinlock_t dma_list_lock;int sa1100_request_dma (dmach_t * channel, const char *device_id,			dma_device_t device){	sa1100_dma_t *dma = NULL;	dma_regs_t *regs;	int i, err;	*channel = -1;		/* to be sure we catch the freeing of a misregistered channel */	err = 0;	spin_lock(&dma_list_lock);	for (i = 0; i < SA1100_DMA_CHANNELS; i++) {		if (dma_chan[i].in_use) {			if (dma_chan[i].device == device) {				err = -EBUSY;				break;			}		} else if (!dma) {			dma = &dma_chan[i];		}	}	if (!err) {	       if (dma)		       dma->in_use = 1;	       else		       err = -ENOSR;	}	spin_unlock(&dma_list_lock);	if (err)		return err;	err = request_irq(dma->irq, dma_irq_handler, SA_INTERRUPT,			  device_id, (void *) dma);	if (err) {		printk(KERN_ERR		       "%s: unable to request IRQ %d for DMA channel\n",		       device_id, dma->irq);		return err;	}	*channel = dma - dma_chan;	dma->device_id = device_id;	dma->device = device;	dma->callback = NULL;	dma->spin_size = 0;	regs = dma->regs;	regs->ClrDCSR =		(DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB |		 DCSR_IE | DCSR_ERROR | DCSR_RUN);	regs->DDAR = device;	DPRINTK("requested\n");	return 0;}int sa1100_dma_set_callback(dmach_t channel, dma_callback_t cb){	sa1100_dma_t *dma = &dma_chan[channel];	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	dma->callback = cb;	DPRINTK("cb = %p\n", cb);	return 0;}int sa1100_dma_set_spin(dmach_t channel, dma_addr_t addr, int size){	sa1100_dma_t *dma = &dma_chan[channel];	int flags;	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	DPRINTK("set spin %d at %#x\n", size, addr);	local_irq_save(flags);	dma->spin_addr = addr;	dma->spin_size = size;	if (size)		process_dma(dma);	local_irq_restore(flags);	return 0;}int sa1100_dma_queue_buffer(dmach_t channel, void *buf_id,			    dma_addr_t data, int size){	sa1100_dma_t *dma;	dma_buf_t *buf;	int flags;	dma = &dma_chan[channel];	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	buf = kmalloc(sizeof(*buf), GFP_ATOMIC);	if (!buf)		return -ENOMEM;	buf->next = NULL;	buf->ref = 0;	buf->dma_ptr = buf->dma_start = data;	buf->size = size;	buf->id = buf_id;	DPRINTK("queueing b=%#x a=%#x s=%d\n", (int) buf_id, data, size);	local_irq_save(flags);	if (dma->head)		dma->head->next = buf;	dma->head = buf;	if (!dma->tail)		dma->tail = buf;	process_dma(dma);	local_irq_restore(flags);	return 0;}int sa1100_dma_get_current(dmach_t channel, void **buf_id, dma_addr_t *addr){	sa1100_dma_t *dma = &dma_chan[channel];	dma_regs_t *regs;	int flags, ret;	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	if (channel_is_sa1111_sac(channel))		return sa1111_dma_get_current(channel, buf_id, addr);	regs = dma->regs;	local_irq_save(flags);	if (dma->curr && dma->spin_ref <= 0) {		dma_buf_t *buf = dma->curr;		int status, using_bufa;		status = regs->RdDCSR;		/*		 * If we got here, that's because there is, or recently was, a		 * buffer being processed.  We must determine whether buffer		 * A or B is active.  Two possibilities: either we are		 * in the middle of a buffer, or the DMA controller just		 * switched to the next toggle but the interrupt hasn't been		 * serviced yet.  The former case is straight forward.  In		 * the later case, we'll do like if DMA is just at the end		 * of the previous toggle since all registers haven't been		 * reset yet.  This goes around the edge case and since we're		 * always a little behind anyways it shouldn't make a big		 * difference.  If DMA has been stopped prior calling this		 * then the position is always exact.		 */		using_bufa = ((!(status & DCSR_BIU) &&  (status & DCSR_STRTA)) ||			      ( (status & DCSR_BIU) && !(status & DCSR_STRTB)));		if (buf_id)			*buf_id = buf->id;		*addr = (using_bufa) ? regs->DBSA : regs->DBSB;		/*		 * Clamp funky pointers sometimes returned by the hardware		 * on completed DMA transfers		 */		if (*addr < buf->dma_start ||		    *addr > buf->dma_ptr)			*addr = buf->dma_ptr;		DPRINTK("curr_pos: b=%#x a=%#x\n", (int)dma->curr->id, *addr);		ret = 0;	} else if (dma->tail && dma->stopped) {		dma_buf_t *buf = dma->tail;		if (buf_id)			*buf_id = buf->id;		*addr = buf->dma_ptr;		ret = 0;	} else {		if (buf_id)			*buf_id = NULL;		*addr = 0;		ret = -ENXIO;	}	local_irq_restore(flags);	return ret;}int sa1100_dma_stop(dmach_t channel){	sa1100_dma_t *dma = &dma_chan[channel];	int flags;	if (channel_is_sa1111_sac(channel))		return sa1111_dma_stop(channel);	if (dma->stopped)		return 0;	local_irq_save(flags);	dma->stopped = 1;	/*	 * Stop DMA and tweak state variables so everything could restart	 * from there when resume/wakeup occurs.	 */	dma->regs->ClrDCSR = DCSR_RUN | DCSR_IE;	if (dma->curr) {		dma_buf_t *buf = dma->curr;		if (dma->spin_ref <= 0) {			dma_addr_t curpos;			sa1100_dma_get_current(channel, NULL, &curpos);			buf->size += buf->dma_ptr - curpos;			buf->dma_ptr = curpos;		}		buf->ref = 0;		dma->tail = buf;		dma->curr = NULL;	}	dma->spin_ref = 0;	dma->regs->ClrDCSR = DCSR_STRTA|DCSR_STRTB|DCSR_DONEA|DCSR_DONEB;	process_dma(dma);	local_irq_restore(flags);	return 0;}int sa1100_dma_resume(dmach_t channel){	sa1100_dma_t *dma = &dma_chan[channel];	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	if (channel_is_sa1111_sac(channel))		return sa1111_dma_resume(channel);	if (dma->stopped) {		int flags;		save_flags_cli(flags);		dma->stopped = 0;		process_dma(dma);		restore_flags(flags);	}	return 0;}int sa1100_dma_flush_all(dmach_t channel){	sa1100_dma_t *dma = &dma_chan[channel];	dma_buf_t *buf, *next_buf;	int flags;	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	local_irq_save(flags);	if (channel_is_sa1111_sac(channel))		sa1111_reset_sac_dma(channel);	else		dma->regs->ClrDCSR = DCSR_STRTA|DCSR_STRTB|DCSR_DONEA|DCSR_DONEB|DCSR_RUN|DCSR_IE;	buf = dma->curr;	if (!buf)		buf = dma->tail;	dma->head = dma->tail = dma->curr = NULL;	dma->stopped = 0;	dma->spin_ref = 0;	process_dma(dma);	local_irq_restore(flags);	while (buf) {		next_buf = buf->next;		kfree(buf);		buf = next_buf;	}	DPRINTK("flushed\n");	return 0;}void sa1100_free_dma(dmach_t channel){	sa1100_dma_t *dma;	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS)		return;	dma = &dma_chan[channel];	if (!dma->in_use) {		printk(KERN_ERR "Trying to free free DMA%d\n", channel);		return;	}	sa1100_dma_set_spin(channel, 0, 0);	sa1100_dma_flush_all(channel);	if (channel_is_sa1111_sac(channel)) {		sa1111_cleanup_sac_dma(channel);	} else {		free_irq(IRQ_DMA0 + channel, (void *) dma);	}	dma->in_use = 0;	DPRINTK("freed\n");}EXPORT_SYMBOL(sa1100_request_dma);EXPORT_SYMBOL(sa1100_dma_set_callback);EXPORT_SYMBOL(sa1100_dma_set_spin);EXPORT_SYMBOL(sa1100_dma_queue_buffer);EXPORT_SYMBOL(sa1100_dma_get_current);EXPORT_SYMBOL(sa1100_dma_stop);EXPORT_SYMBOL(sa1100_dma_resume);EXPORT_SYMBOL(sa1100_dma_flush_all);EXPORT_SYMBOL(sa1100_free_dma);#ifdef CONFIG_PM/* Drivers should call this from their PM callback function */int sa1100_dma_sleep(dmach_t channel){        sa1100_dma_t *dma = &dma_chan[channel];	int orig_state;	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	if (channel_is_sa1111_sac(channel)) {		/* We'll cheat a little until someone actually		 * write the real thing.		 */		sa1111_reset_sac_dma(channel);		return 0;	}	orig_state = dma->stopped;	sa1100_dma_stop(channel);	dma->regs->ClrDCSR = DCSR_RUN | DCSR_IE | DCSR_STRTA | DCSR_STRTB;	dma->stopped = orig_state;	dma->spin_ref = 0;	return 0;}int sa1100_dma_wakeup(dmach_t channel){        sa1100_dma_t *dma = &dma_chan[channel];	dma_regs_t *regs;	int flags;	if ((unsigned)channel >= MAX_SA1100_DMA_CHANNELS || !dma->in_use)		return -EINVAL;	if (channel_is_sa1111_sac(channel)) {		/* We'll cheat a little until someone actually		 * write the real thing.		 */		return 0;	}	regs = dma->regs;	regs->ClrDCSR =		(DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB |		 DCSR_IE | DCSR_ERROR | DCSR_RUN);	regs->DDAR = dma->device;	local_irq_save(flags);	process_dma(dma);	local_irq_restore(flags);	return 0;}EXPORT_SYMBOL(sa1100_dma_sleep);EXPORT_SYMBOL(sa1100_dma_wakeup);#endifstatic int __init sa1100_init_dma(void){	int channel;	for (channel = 0; channel < SA1100_DMA_CHANNELS; channel++) {		dma_chan[channel].regs =		    (dma_regs_t *) &DDAR(channel);		dma_chan[channel].irq = IRQ_DMA0 + channel;	}	return 0;}__initcall(sa1100_init_dma);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产拍欧美日韩视频二区| 99在线精品一区二区三区| 在线成人免费观看| 亚洲第一狼人社区| 欧美精品粉嫩高潮一区二区| 日韩精品一二区| 777a∨成人精品桃花网| 日本在线不卡一区| 2017欧美狠狠色| 成人一区二区三区视频在线观看| 国产精品久久久久9999吃药| 成人免费视频国产在线观看| 亚洲欧美激情一区二区| 欧美日韩精品一区二区三区蜜桃 | 5566中文字幕一区二区电影| 视频在线观看一区二区三区| 精品福利视频一区二区三区| 成人小视频在线观看| 一区二区三区电影在线播| 欧美日韩国产小视频| 久久不见久久见免费视频1| 国产亚洲短视频| 欧洲一区二区三区免费视频| 黄色成人免费在线| 亚洲三级理论片| 日韩西西人体444www| 成人伦理片在线| 日韩国产精品久久久| 欧美国产精品一区二区| 欧美三级视频在线播放| 国产乱国产乱300精品| 亚洲精品中文在线| 亚洲精品在线电影| 色综合天天综合狠狠| 久久se这里有精品| 亚洲免费观看高清完整版在线| 日韩欧美区一区二| 99re热这里只有精品视频| 美女网站视频久久| 亚洲情趣在线观看| 久久久影院官网| 日韩一区二区视频| 97精品国产露脸对白| 精品在线一区二区三区| 亚洲一区视频在线观看视频| 国产婷婷色一区二区三区四区| 欧美群妇大交群中文字幕| 成人精品在线视频观看| 久久99国产精品成人| 亚洲综合999| 国产精品理伦片| 久久新电视剧免费观看| 欧美老人xxxx18| 91蝌蚪国产九色| 99久久久久久| 成人动漫视频在线| 国产一区二区导航在线播放| 日韩国产一二三区| 一区二区成人在线| 亚洲男同性视频| 国产精品夫妻自拍| 久久久久久久久97黄色工厂| 日韩欧美色综合网站| 欧美精品一级二级三级| 色婷婷av一区二区三区软件| 成人永久免费视频| 国产一区二区三区四区五区入口| 天堂成人免费av电影一区| 亚洲三级免费观看| 亚洲欧美日韩中文播放 | 欧美精品第1页| 欧美视频在线观看一区二区| 色婷婷综合久久久中文字幕| youjizz久久| av电影在线观看完整版一区二区| 懂色av一区二区三区蜜臀| 国产一区二区按摩在线观看| 久久99国产精品免费| 激情六月婷婷久久| 国产一区二区女| 国产乱国产乱300精品| 国产成人av电影免费在线观看| 国产精品99久久久| 国产一区二区三区观看| 国产高清不卡一区| 高潮精品一区videoshd| 国产高清不卡二三区| 成av人片一区二区| 色综合久久99| 欧美片在线播放| 8x8x8国产精品| 欧美成人在线直播| 国产三级精品视频| 国产精品国产三级国产aⅴ中文| 中文字幕五月欧美| 一二三区精品福利视频| 亚洲成人在线网站| 看电视剧不卡顿的网站| 国产精品一二三| 不卡的看片网站| 91激情在线视频| 7777女厕盗摄久久久| 久久综合资源网| 亚洲日穴在线视频| 性做久久久久久久免费看| 久久99精品国产91久久来源| 成人18精品视频| 欧美男生操女生| 国产丝袜美腿一区二区三区| 亚洲人妖av一区二区| 亚洲电影一区二区三区| 久草精品在线观看| 99视频精品全部免费在线| 欧美日韩一区二区三区四区 | 精品在线观看视频| 成人av动漫在线| 欧美群妇大交群的观看方式| 国产视频911| 亚洲444eee在线观看| 国产一区二区三区黄视频| 色综合久久综合| 精品国产不卡一区二区三区| 自拍av一区二区三区| 九九国产精品视频| 91免费观看国产| 欧美成人激情免费网| 日韩美女精品在线| 久久国内精品视频| 色哟哟在线观看一区二区三区| 欧美videos中文字幕| 亚洲激情在线激情| 精品系列免费在线观看| 欧美中文一区二区三区| 久久久久97国产精华液好用吗| 亚洲国产精品天堂| 成人激情视频网站| 精品日韩一区二区三区| 亚洲一二三四区不卡| 成人亚洲精品久久久久软件| 日韩精品最新网址| 亚洲高清在线视频| hitomi一区二区三区精品| 精品日韩在线一区| 午夜av区久久| 色婷婷国产精品| 成人欧美一区二区三区黑人麻豆 | 国产成人精品一区二区三区四区| 欧美电影一区二区| 亚洲精品日韩一| 风间由美一区二区av101 | 蓝色福利精品导航| 欧美午夜寂寞影院| 日韩毛片视频在线看| 国产成人免费网站| 久久综合精品国产一区二区三区| 日韩电影一区二区三区| 欧美日精品一区视频| 夜夜亚洲天天久久| 91官网在线观看| 亚洲日本va在线观看| 99久久精品免费| 中文字幕在线一区| 成人免费高清在线| 中文字幕一区二区视频| 成人av综合在线| 中文字幕日韩av资源站| www.久久精品| 亚洲丝袜美腿综合| 91免费国产视频网站| 亚洲老司机在线| 在线免费不卡视频| 亚洲国产va精品久久久不卡综合| 欧美三级一区二区| 日韩精品一卡二卡三卡四卡无卡| 3atv在线一区二区三区| 日韩电影在线观看电影| 精品乱人伦小说| 国产一区二区三区不卡在线观看| 国产亚洲欧美日韩日本| www.亚洲在线| 一区二区三区四区不卡在线| 欧美在线综合视频| 亚洲成国产人片在线观看| 91精品国产综合久久精品app | 欧美日韩免费一区二区三区 | 亚洲欧洲成人自拍| 在线视频观看一区| 亚洲成av人**亚洲成av**| 欧美肥妇free| 精品亚洲成a人| 国产精品美女久久福利网站| 91久久久免费一区二区| 五月婷婷激情综合| 欧美精品一区二区精品网| 国产精品中文字幕一区二区三区| 国产精品久久久久永久免费观看| 一本在线高清不卡dvd| 日韩av二区在线播放| 久久久久久97三级| 色婷婷激情久久|