歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

DMA應具備的操作函數

/* arch/arm/plat-samsung/include/plat/dma.h
*
* Copyright (C) 2003-2006 Simtec Electronics
* Ben Dooks <[email protected]>
*
* Samsung S3C DMA support
*
* 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.
*/


enum s3c2410_dma_buffresult {//表示buf傳送的結果
S3C2410_RES_OK,
S3C2410_RES_ERR,
S3C2410_RES_ABORT
};


enum s3c2410_dmasrc {
S3C2410_DMASRC_HW, /* source is memory */
S3C2410_DMASRC_MEM, /* source is hardware */
S3C_DMA_MEM2MEM, /* source is memory - READ/WRITE */
S3C_DMA_MEM2MEM_SET, /* source is memory - READ/WRITE for MEMSET*/
S3C_DMA_MEM2MEM_P, /* source is hardware - READ/WRITE */
S3C_DMA_PER2PER /* source is hardware - READ/WRITE */
};


/* enum s3c2410_chan_op
*
* operation codes passed to the DMA code by the user, and also used
* to inform the current channel owner of any changes to the system state
*/
enum s3c2410_chan_op {
S3C2410_DMAOP_START,
S3C2410_DMAOP_STOP,
S3C2410_DMAOP_PAUSE,
S3C2410_DMAOP_RESUME,
S3C2410_DMAOP_FLUSH,
S3C2410_DMAOP_TIMEOUT, /* internal signal to handler */
S3C2410_DMAOP_STARTED, /* indicate channel started */
S3C2410_DMAOP_ABORT, /* abnormal stop */
};


struct s3c2410_dma_client {
char *name;
};


struct s3c2410_dma_chan;

 


/* s3c2410_dma_cbfn_t
*
* buffer callback routine type /回調函數
*定義函數指針
*/
typedef void (*s3c2410_dma_cbfn_t)(struct s3c2410_dma_chan *, void *buf, int size, enum s3c2410_dma_buffresult result);
typedef int (*s3c2410_dma_opfn_t)(struct s3c2410_dma_chan *, enum s3c2410_chan_op );


extern int s3c2410_dma_set_opfn(unsigned int, s3c2410_dma_opfn_t rtn);
extern int s3c2410_dma_set_buffdone_fn(unsigned int, s3c2410_dma_cbfn_t rtn);//設置傳輸buf後的回調函數

 

 


/* s3c2410_dma_request
*
* request a dma channel exclusivley 請求 DMA通道
*/
extern int s3c2410_dma_request(unsigned int channel, struct s3c2410_dma_client *, void *dev);

 


/* s3c2410_dma_ctrl
*
* change the state of the dma channel 改變通道狀態
*/
extern int s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op);

 


/* s3c2410_dma_setflags
*
* set the channel's flags to a given state
*/
extern int s3c2410_dma_setflags(unsigned int channel, unsigned int flags);

 


/* s3c2410_dma_free
*
* free the dma channel (will also abort any outstanding operations) 釋放通道
*/
extern int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *);

 


/* s3c2410_dma_enqueue
*
* place the given buffer onto the queue of operations for the channel.
* The buffer must be allocated from dma coherent memory, or the Dcache/WB
* drained before the buffer is given to the DMA system. 入隊列函數
*/
extern int s3c2410_dma_enqueue(unsigned int channel, void *id, dma_addr_t data, int size);

 


/* s3c2410_dma_config
*
* configure the dma channel 配置通道
*/
extern int s3c2410_dma_config(unsigned int channel, int xferunit);

 


/* s3c2410_dma_setswap
*
* configure the swap capability of xfer
*/
extern int s3c2410_dma_setswap(unsigned int channel, unsigned int bytes_swap);

 


/* s3c2410_dma_devconfig
*
* configure the device we're talking to 配置設備
*/
extern int s3c2410_dma_devconfig(unsigned int channel, enum s3c2410_dmasrc source, unsigned long devaddr);

 


/* s3c2410_dma_getposition
*
* get the position that the dma transfer is currently at 當前位置
*/
extern int s3c2410_dma_getposition(unsigned int channel, dma_addr_t *src, dma_addr_t *dest);

Copyright © Linux教程網 All Rights Reserved