2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/device.h>
24 #include <linux/dmaengine.h>
25 #include <linux/delay.h>
30 static volatile u8 *buffer1;
31 static volatile u8 *buffer2;
33 struct dma_client *test_dma_client;
34 struct dma_chan *test_dma_chan;
35 static dma_cookie_t cookie;
42 printk("buffer1 = %p\n", buffer1);
43 printk("buffer2 = %p\n", buffer2);
44 for (i = 0; i < 20; i+=4)
45 printk("%u %u %u %u\n", buffer2[i], buffer2[i+1], buffer2[i+2], buffer2[i+3]);
47 // for (i = 0; i < 10; i++) {
48 cookie = dma_async_memcpy_buf_to_buf(test_dma_chan,
52 dma_async_memcpy_issue_pending(test_dma_chan);
54 // printk("dma cookie = %i\n", cookie);
55 if (dma_async_memcpy_complete(test_dma_chan, cookie, NULL, NULL) == DMA_IN_PROGRESS)
56 printk("DMA cookie == IN PROGRESS\n");
58 printk("DMA cookie == SUCCESS\n");
60 for (i = 0; i < 1000; i++) {
65 printk("i = %d\n", i);
66 for (i = 0; i < 20; i+=4)
67 printk("%u %u %u %u\n", buffer2[i], buffer2[i+1], buffer2[i+2], buffer2[i+3]);
68 for (i = 0; i < 20; i+=4)
69 printk("%u %u %u %u\n", buffer1[i], buffer1[i+1], buffer1[i+2], buffer1[i+3]);
73 void test_dma_event(struct dma_client *client, struct dma_chan *chan, enum dma_event event)
76 case DMA_RESOURCE_ADDED:
80 case DMA_RESOURCE_REMOVED:
89 testclient_init_module(void)
93 buffer1 = kmalloc(sizeof(u8) * 2000, SLAB_KERNEL);
94 buffer2 = kmalloc(sizeof(u8) * 2000, SLAB_KERNEL);
96 memset((void *)buffer2, 0, 2000);
97 for (i = 0; i < 2000; i++)
100 test_dma_client = dma_async_client_register(test_dma_event);
101 if (!test_dma_client) {
102 printk(KERN_ERR "Could not register dma client!\n");
106 dma_async_client_chan_request(test_dma_client, 1);
111 module_init(testclient_init_module);
114 testclient_exit_module(void)
117 for (i = 0; i < 20; i+=4)
118 printk("%u %u %u %u\n", buffer2[i], buffer2[i+1], buffer2[i+2], buffer2[i+3]);
121 if (dma_async_memcpy_complete(test_dma_chan, cookie, NULL, NULL) == DMA_SUCCESS)
122 printk("DMA cookie == SUCCESS\n");
124 printk("DMA cookie == IN PROGRESS\n");
127 dma_async_client_unregister(test_dma_client);
129 kfree ((void*)buffer1);
130 kfree ((void*)buffer2);
133 module_exit(testclient_exit_module);
135 MODULE_LICENSE("GPL");