资源简介
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
评论
共有 条评论