資源簡介
memory to memory sdma copy demo,飛思卡爾的imx6 sdma驅動mem to mem的例子
imx6 sdma內存復制驅動, linux內核3.0.35版本! SDMA例子,親測可用
飛思卡爾的i.mx6驅動,飛思卡爾的i.mx6驅動內存到內存的sdma驅動例子,測試通過;
聚散內容到聚散內存的復制,編譯方法是寫一個makefile 然后設定內核編譯環境的環境變量,然后 make, Makefile 內容:
obj-m += imx6_sdma_test_sg_to_sg_demo.o
all:
make -C /home/xxx/你的內核目錄 SUBDIRS=$(PWD) modules
clean:
make -C /home/xxx/你的內核目錄 SUBDIRS=$(PWD) clean

代碼片段和文件信息
/*
?*?The?code?contained?herein?is?licensed?under?the?GNU?General?Public
?*?License.?You?may?obtain?a?copy?of?the?GNU?General?Public?License
?*?Version?2?or?later?at?the?following?locations:
?*
?*?http://www.opensource.org/licenses/gpl-license.html
?*?http://www.gnu.org/copyleft/gpl.html
?*/
/*
?*?Copyright?2006-2012?Freescale?Semiconductor?Inc.?All?rights?reserved.
?*/
/*
?*?The?code?contained?herein?is?licensed?under?the?GNU?General?Public
?*?License.?You?may?obtain?a?copy?of?the?GNU?General?Public?License
?*?Version?2?or?later?at?the?following?locations:
?*
?*?http://www.opensource.org/licenses/gpl-license.html
?*?http://www.gnu.org/copyleft/gpl.html
?*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
//#include?
#define?DEBUG
#define?DEF_SG_QTY?3
#ifdef?DEBUG
/*?If?you?are?writing?a?driver?please?use?dev_dbg?instead?*/
#define?dev_printk(fmt?args...)??printk(KERN_DEBUG?fmt?##?args)
#else
static?/*inline*/?int?__attribute__?((format?(printf?1?2)))?dev_printk(const?char?*?fmt?...)
{
return?0;
}
#endif
static?int?gMajor;?/*?major?number?of?device?*/
static?struct?class?*dma_tm_class;
u32?*wbuf[DEF_SG_QTY];
u32?*rbuf[DEF_SG_QTY];
struct?dma_chan?*dma_m2m_chan;
struct?completion?dma_m2m_ok;
struct?scatterlist?sg[DEF_SG_QTY]?sg2[DEF_SG_QTY];
#define?SDMA_BUF_SIZE??40960
static?bool?dma_m2m_filter(struct?dma_chan?*chan?void?*param)
{
if?(!imx_dma_is_general_purpose(chan))
return?false;
chan->private?=?param;
return?true;
}
int?sdma_open(struct?inode?*?inode?struct?file?*?filp)
{
int?i;
dma_cap_mask_t?dma_m2m_mask;
struct?imx_dma_data?m2m_dma_data?=?{0};
init_completion(&dma_m2m_ok);
dma_cap_zero(dma_m2m_mask);
dma_cap_set(DMA_SLAVE?dma_m2m_mask);
m2m_dma_data.peripheral_type?=?IMX_DMATYPE_MEMORY;
m2m_dma_data.priority?=?DMA_PRIO_HIGH;
dma_m2m_chan?=?dma_request_channel(dma_m2m_mask?dma_m2m_filter?&m2m_dma_data);
if?(!dma_m2m_chan)?{
dev_printk(“Error?opening?the?SDMA?memory?to?memory?channel\n“);
return?-EINVAL;
}
for(i=0;?i wbuf[i]?=?kzalloc(SDMA_BUF_SIZE?GFP_DMA);
if(!wbuf[i])?{
dev_printk(“error?wbuf[%d]?!!!!!!!!!!!\n“?i);
return?-1;
}
}
dev_printk(“kzalloc?%d?wbuf?succeed\n“?DEF_SG_QTY);
for(i=0;?i rbuf[i]?=?kzalloc(SDMA_BUF_SIZE?GFP_DMA);
if(!rbuf[i])?{
dev_printk(“error?rbuf[%d]?!!!!!!!!!!!\n“?i);
return?-1;
}
}
dev_printk(“kzalloc?%d?rbuf?succeed\n“?DEF_SG_QTY);
return?0;
}
int?sdma_release(struct?inode?*?inode?struct?file?*?filp)
{
int?i;
dma_release_channel(dma_m2m_cha
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????8385??2017-01-19?14:37??mem_to_mem_cpy_imx6q_sdma.c
評論
共有 條評論